babylon.module.d.ts 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923158924158925158926158927158928158929158930158931158932158933158934158935158936158937158938158939158940158941158942158943158944158945158946158947158948158949158950158951158952158953158954158955158956158957158958158959158960158961158962158963158964158965158966158967158968158969158970158971158972158973158974158975158976158977158978158979158980158981158982158983158984158985158986158987158988158989158990158991158992158993158994158995158996158997158998158999159000159001159002159003159004159005159006159007159008159009159010159011159012159013159014159015159016159017159018159019159020159021159022159023159024159025159026159027159028159029159030159031159032159033159034159035159036159037159038159039159040159041159042159043159044159045159046159047159048159049159050159051159052159053159054159055159056159057159058159059159060159061159062159063159064159065159066159067159068159069159070159071159072159073159074159075159076159077159078159079159080159081159082159083159084159085159086159087159088159089159090159091159092159093159094159095159096159097159098159099159100159101159102159103159104159105159106159107159108159109159110159111159112159113159114159115159116159117159118159119159120159121159122159123159124159125159126159127159128159129159130159131159132159133159134159135159136159137159138159139159140159141159142159143159144159145159146159147159148159149159150159151159152159153159154159155159156159157159158159159159160159161159162159163159164159165159166159167159168159169159170159171159172159173159174159175159176159177159178159179159180159181159182159183159184159185159186159187159188159189159190159191159192159193159194159195159196159197159198159199159200159201159202159203159204159205159206159207159208159209159210159211159212159213159214159215159216159217159218159219159220159221159222159223159224159225159226159227159228159229159230159231159232159233159234159235159236159237159238159239159240159241159242159243159244159245159246159247159248159249159250159251159252159253159254159255159256159257159258159259159260159261159262159263159264159265159266159267159268159269159270159271159272159273159274159275159276159277159278159279159280159281159282159283159284159285159286159287159288159289159290159291159292159293159294159295159296159297159298159299159300159301159302159303159304159305159306159307159308159309159310159311159312159313159314159315159316159317159318159319159320159321159322159323159324159325159326159327159328159329159330159331159332159333159334159335159336159337159338159339159340159341159342159343159344159345159346159347159348159349159350159351159352159353159354159355159356159357159358159359159360159361159362159363159364159365159366159367159368159369159370159371159372159373159374159375159376159377159378159379159380159381159382159383159384159385159386159387159388159389159390159391159392159393159394159395159396159397159398159399159400159401159402159403159404159405159406159407159408159409159410159411159412159413159414159415159416159417159418159419159420159421159422159423159424159425159426159427159428159429159430159431159432159433159434159435159436159437159438159439159440159441159442159443159444159445159446159447159448159449159450159451159452159453159454159455159456159457159458159459159460159461159462159463159464159465159466159467159468159469159470159471159472159473159474159475159476159477159478159479159480159481159482159483159484159485159486159487159488159489159490159491159492159493159494159495159496159497159498159499159500159501159502159503159504159505159506159507159508159509159510159511159512159513159514159515159516
  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 readonly _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/Maths/math.size" {
  1646. /**
  1647. * Interface for the size containing width and height
  1648. */
  1649. export interface ISize {
  1650. /**
  1651. * Width
  1652. */
  1653. width: number;
  1654. /**
  1655. * Heighht
  1656. */
  1657. height: number;
  1658. }
  1659. /**
  1660. * Size containing widht and height
  1661. */
  1662. export class Size implements ISize {
  1663. /**
  1664. * Width
  1665. */
  1666. width: number;
  1667. /**
  1668. * Height
  1669. */
  1670. height: number;
  1671. /**
  1672. * Creates a Size object from the given width and height (floats).
  1673. * @param width width of the new size
  1674. * @param height height of the new size
  1675. */
  1676. constructor(width: number, height: number);
  1677. /**
  1678. * Returns a string with the Size width and height
  1679. * @returns a string with the Size width and height
  1680. */
  1681. toString(): string;
  1682. /**
  1683. * "Size"
  1684. * @returns the string "Size"
  1685. */
  1686. getClassName(): string;
  1687. /**
  1688. * Returns the Size hash code.
  1689. * @returns a hash code for a unique width and height
  1690. */
  1691. getHashCode(): number;
  1692. /**
  1693. * Updates the current size from the given one.
  1694. * @param src the given size
  1695. */
  1696. copyFrom(src: Size): void;
  1697. /**
  1698. * Updates in place the current Size from the given floats.
  1699. * @param width width of the new size
  1700. * @param height height of the new size
  1701. * @returns the updated Size.
  1702. */
  1703. copyFromFloats(width: number, height: number): Size;
  1704. /**
  1705. * Updates in place the current Size from the given floats.
  1706. * @param width width to set
  1707. * @param height height to set
  1708. * @returns the updated Size.
  1709. */
  1710. set(width: number, height: number): Size;
  1711. /**
  1712. * Multiplies the width and height by numbers
  1713. * @param w factor to multiple the width by
  1714. * @param h factor to multiple the height by
  1715. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1716. */
  1717. multiplyByFloats(w: number, h: number): Size;
  1718. /**
  1719. * Clones the size
  1720. * @returns a new Size copied from the given one.
  1721. */
  1722. clone(): Size;
  1723. /**
  1724. * True if the current Size and the given one width and height are strictly equal.
  1725. * @param other the other size to compare against
  1726. * @returns True if the current Size and the given one width and height are strictly equal.
  1727. */
  1728. equals(other: Size): boolean;
  1729. /**
  1730. * The surface of the Size : width * height (float).
  1731. */
  1732. get surface(): number;
  1733. /**
  1734. * Create a new size of zero
  1735. * @returns a new Size set to (0.0, 0.0)
  1736. */
  1737. static Zero(): Size;
  1738. /**
  1739. * Sums the width and height of two sizes
  1740. * @param otherSize size to add to this size
  1741. * @returns a new Size set as the addition result of the current Size and the given one.
  1742. */
  1743. add(otherSize: Size): Size;
  1744. /**
  1745. * Subtracts the width and height of two
  1746. * @param otherSize size to subtract to this size
  1747. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1748. */
  1749. subtract(otherSize: Size): Size;
  1750. /**
  1751. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1752. * @param start starting size to lerp between
  1753. * @param end end size to lerp between
  1754. * @param amount amount to lerp between the start and end values
  1755. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1756. */
  1757. static Lerp(start: Size, end: Size, amount: number): Size;
  1758. }
  1759. }
  1760. declare module "babylonjs/Materials/Textures/thinTexture" {
  1761. import { Nullable } from "babylonjs/types";
  1762. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1763. import { ISize } from "babylonjs/Maths/math.size";
  1764. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1765. /**
  1766. * Base class of all the textures in babylon.
  1767. * It groups all the common properties required to work with Thin Engine.
  1768. */
  1769. export class ThinTexture {
  1770. protected _wrapU: number;
  1771. /**
  1772. * | Value | Type | Description |
  1773. * | ----- | ------------------ | ----------- |
  1774. * | 0 | CLAMP_ADDRESSMODE | |
  1775. * | 1 | WRAP_ADDRESSMODE | |
  1776. * | 2 | MIRROR_ADDRESSMODE | |
  1777. */
  1778. get wrapU(): number;
  1779. set wrapU(value: number);
  1780. protected _wrapV: number;
  1781. /**
  1782. * | Value | Type | Description |
  1783. * | ----- | ------------------ | ----------- |
  1784. * | 0 | CLAMP_ADDRESSMODE | |
  1785. * | 1 | WRAP_ADDRESSMODE | |
  1786. * | 2 | MIRROR_ADDRESSMODE | |
  1787. */
  1788. get wrapV(): number;
  1789. set wrapV(value: number);
  1790. /**
  1791. * | Value | Type | Description |
  1792. * | ----- | ------------------ | ----------- |
  1793. * | 0 | CLAMP_ADDRESSMODE | |
  1794. * | 1 | WRAP_ADDRESSMODE | |
  1795. * | 2 | MIRROR_ADDRESSMODE | |
  1796. */
  1797. wrapR: number;
  1798. /**
  1799. * With compliant hardware and browser (supporting anisotropic filtering)
  1800. * this defines the level of anisotropic filtering in the texture.
  1801. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  1802. */
  1803. anisotropicFilteringLevel: number;
  1804. /**
  1805. * Define the current state of the loading sequence when in delayed load mode.
  1806. */
  1807. delayLoadState: number;
  1808. /**
  1809. * How a texture is mapped.
  1810. * Unused in thin texture mode.
  1811. */
  1812. get coordinatesMode(): number;
  1813. /**
  1814. * Define if the texture is a cube texture or if false a 2d texture.
  1815. */
  1816. get isCube(): boolean;
  1817. set isCube(value: boolean);
  1818. /**
  1819. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  1820. */
  1821. get is3D(): boolean;
  1822. set is3D(value: boolean);
  1823. /**
  1824. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  1825. */
  1826. get is2DArray(): boolean;
  1827. set is2DArray(value: boolean);
  1828. /**
  1829. * Get the class name of the texture.
  1830. * @returns "ThinTexture"
  1831. */
  1832. getClassName(): string;
  1833. /** @hidden */
  1834. _texture: Nullable<InternalTexture>;
  1835. protected _engine: Nullable<ThinEngine>;
  1836. private _cachedSize;
  1837. private _cachedBaseSize;
  1838. /**
  1839. * Instantiates a new ThinTexture.
  1840. * Base class of all the textures in babylon.
  1841. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  1842. * @param internalTexture Define the internalTexture to wrap
  1843. */
  1844. constructor(internalTexture: Nullable<InternalTexture>);
  1845. /**
  1846. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  1847. * @returns true if fully ready
  1848. */
  1849. isReady(): boolean;
  1850. /**
  1851. * Triggers the load sequence in delayed load mode.
  1852. */
  1853. delayLoad(): void;
  1854. /**
  1855. * Get the underlying lower level texture from Babylon.
  1856. * @returns the insternal texture
  1857. */
  1858. getInternalTexture(): Nullable<InternalTexture>;
  1859. /**
  1860. * Get the size of the texture.
  1861. * @returns the texture size.
  1862. */
  1863. getSize(): ISize;
  1864. /**
  1865. * Get the base size of the texture.
  1866. * It can be different from the size if the texture has been resized for POT for instance
  1867. * @returns the base size
  1868. */
  1869. getBaseSize(): ISize;
  1870. /**
  1871. * Update the sampling mode of the texture.
  1872. * Default is Trilinear mode.
  1873. *
  1874. * | Value | Type | Description |
  1875. * | ----- | ------------------ | ----------- |
  1876. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  1877. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  1878. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  1879. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  1880. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  1881. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  1882. * | 7 | NEAREST_LINEAR | |
  1883. * | 8 | NEAREST_NEAREST | |
  1884. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  1885. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  1886. * | 11 | LINEAR_LINEAR | |
  1887. * | 12 | LINEAR_NEAREST | |
  1888. *
  1889. * > _mag_: magnification filter (close to the viewer)
  1890. * > _min_: minification filter (far from the viewer)
  1891. * > _mip_: filter used between mip map levels
  1892. *@param samplingMode Define the new sampling mode of the texture
  1893. */
  1894. updateSamplingMode(samplingMode: number): void;
  1895. /**
  1896. * Release and destroy the underlying lower level texture aka internalTexture.
  1897. */
  1898. releaseInternalTexture(): void;
  1899. /**
  1900. * Dispose the texture and release its associated resources.
  1901. */
  1902. dispose(): void;
  1903. }
  1904. }
  1905. declare module "babylonjs/Misc/smartArray" {
  1906. /**
  1907. * Defines an array and its length.
  1908. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  1909. */
  1910. export interface ISmartArrayLike<T> {
  1911. /**
  1912. * The data of the array.
  1913. */
  1914. data: Array<T>;
  1915. /**
  1916. * The active length of the array.
  1917. */
  1918. length: number;
  1919. }
  1920. /**
  1921. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1922. */
  1923. export class SmartArray<T> implements ISmartArrayLike<T> {
  1924. /**
  1925. * The full set of data from the array.
  1926. */
  1927. data: Array<T>;
  1928. /**
  1929. * The active length of the array.
  1930. */
  1931. length: number;
  1932. protected _id: number;
  1933. /**
  1934. * Instantiates a Smart Array.
  1935. * @param capacity defines the default capacity of the array.
  1936. */
  1937. constructor(capacity: number);
  1938. /**
  1939. * Pushes a value at the end of the active data.
  1940. * @param value defines the object to push in the array.
  1941. */
  1942. push(value: T): void;
  1943. /**
  1944. * Iterates over the active data and apply the lambda to them.
  1945. * @param func defines the action to apply on each value.
  1946. */
  1947. forEach(func: (content: T) => void): void;
  1948. /**
  1949. * Sorts the full sets of data.
  1950. * @param compareFn defines the comparison function to apply.
  1951. */
  1952. sort(compareFn: (a: T, b: T) => number): void;
  1953. /**
  1954. * Resets the active data to an empty array.
  1955. */
  1956. reset(): void;
  1957. /**
  1958. * Releases all the data from the array as well as the array.
  1959. */
  1960. dispose(): void;
  1961. /**
  1962. * Concats the active data with a given array.
  1963. * @param array defines the data to concatenate with.
  1964. */
  1965. concat(array: any): void;
  1966. /**
  1967. * Returns the position of a value in the active data.
  1968. * @param value defines the value to find the index for
  1969. * @returns the index if found in the active data otherwise -1
  1970. */
  1971. indexOf(value: T): number;
  1972. /**
  1973. * Returns whether an element is part of the active data.
  1974. * @param value defines the value to look for
  1975. * @returns true if found in the active data otherwise false
  1976. */
  1977. contains(value: T): boolean;
  1978. private static _GlobalId;
  1979. }
  1980. /**
  1981. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1982. * The data in this array can only be present once
  1983. */
  1984. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  1985. private _duplicateId;
  1986. /**
  1987. * Pushes a value at the end of the active data.
  1988. * THIS DOES NOT PREVENT DUPPLICATE DATA
  1989. * @param value defines the object to push in the array.
  1990. */
  1991. push(value: T): void;
  1992. /**
  1993. * Pushes a value at the end of the active data.
  1994. * If the data is already present, it won t be added again
  1995. * @param value defines the object to push in the array.
  1996. * @returns true if added false if it was already present
  1997. */
  1998. pushNoDuplicate(value: T): boolean;
  1999. /**
  2000. * Resets the active data to an empty array.
  2001. */
  2002. reset(): void;
  2003. /**
  2004. * Concats the active data with a given array.
  2005. * This ensures no dupplicate will be present in the result.
  2006. * @param array defines the data to concatenate with.
  2007. */
  2008. concatWithNoDuplicate(array: any): void;
  2009. }
  2010. }
  2011. declare module "babylonjs/Misc/andOrNotEvaluator" {
  2012. /**
  2013. * Class used to evalaute queries containing `and` and `or` operators
  2014. */
  2015. export class AndOrNotEvaluator {
  2016. /**
  2017. * Evaluate a query
  2018. * @param query defines the query to evaluate
  2019. * @param evaluateCallback defines the callback used to filter result
  2020. * @returns true if the query matches
  2021. */
  2022. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2023. private static _HandleParenthesisContent;
  2024. private static _SimplifyNegation;
  2025. }
  2026. }
  2027. declare module "babylonjs/Misc/tags" {
  2028. /**
  2029. * Class used to store custom tags
  2030. */
  2031. export class Tags {
  2032. /**
  2033. * Adds support for tags on the given object
  2034. * @param obj defines the object to use
  2035. */
  2036. static EnableFor(obj: any): void;
  2037. /**
  2038. * Removes tags support
  2039. * @param obj defines the object to use
  2040. */
  2041. static DisableFor(obj: any): void;
  2042. /**
  2043. * Gets a boolean indicating if the given object has tags
  2044. * @param obj defines the object to use
  2045. * @returns a boolean
  2046. */
  2047. static HasTags(obj: any): boolean;
  2048. /**
  2049. * Gets the tags available on a given object
  2050. * @param obj defines the object to use
  2051. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2052. * @returns the tags
  2053. */
  2054. static GetTags(obj: any, asString?: boolean): any;
  2055. /**
  2056. * Adds tags to an object
  2057. * @param obj defines the object to use
  2058. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2059. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2060. */
  2061. static AddTagsTo(obj: any, tagsString: string): void;
  2062. /**
  2063. * @hidden
  2064. */
  2065. static _AddTagTo(obj: any, tag: string): void;
  2066. /**
  2067. * Removes specific tags from a specific object
  2068. * @param obj defines the object to use
  2069. * @param tagsString defines the tags to remove
  2070. */
  2071. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2072. /**
  2073. * @hidden
  2074. */
  2075. static _RemoveTagFrom(obj: any, tag: string): void;
  2076. /**
  2077. * Defines if tags hosted on an object match a given query
  2078. * @param obj defines the object to use
  2079. * @param tagsQuery defines the tag query
  2080. * @returns a boolean
  2081. */
  2082. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2083. }
  2084. }
  2085. declare module "babylonjs/Maths/math.scalar" {
  2086. /**
  2087. * Scalar computation library
  2088. */
  2089. export class Scalar {
  2090. /**
  2091. * Two pi constants convenient for computation.
  2092. */
  2093. static TwoPi: number;
  2094. /**
  2095. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2096. * @param a number
  2097. * @param b number
  2098. * @param epsilon (default = 1.401298E-45)
  2099. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2100. */
  2101. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2102. /**
  2103. * Returns a string : the upper case translation of the number i to hexadecimal.
  2104. * @param i number
  2105. * @returns the upper case translation of the number i to hexadecimal.
  2106. */
  2107. static ToHex(i: number): string;
  2108. /**
  2109. * Returns -1 if value is negative and +1 is value is positive.
  2110. * @param value the value
  2111. * @returns the value itself if it's equal to zero.
  2112. */
  2113. static Sign(value: number): number;
  2114. /**
  2115. * Returns the value itself if it's between min and max.
  2116. * Returns min if the value is lower than min.
  2117. * Returns max if the value is greater than max.
  2118. * @param value the value to clmap
  2119. * @param min the min value to clamp to (default: 0)
  2120. * @param max the max value to clamp to (default: 1)
  2121. * @returns the clamped value
  2122. */
  2123. static Clamp(value: number, min?: number, max?: number): number;
  2124. /**
  2125. * the log2 of value.
  2126. * @param value the value to compute log2 of
  2127. * @returns the log2 of value.
  2128. */
  2129. static Log2(value: number): number;
  2130. /**
  2131. * Loops the value, so that it is never larger than length and never smaller than 0.
  2132. *
  2133. * This is similar to the modulo operator but it works with floating point numbers.
  2134. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2135. * With t = 5 and length = 2.5, the result would be 0.0.
  2136. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2137. * @param value the value
  2138. * @param length the length
  2139. * @returns the looped value
  2140. */
  2141. static Repeat(value: number, length: number): number;
  2142. /**
  2143. * Normalize the value between 0.0 and 1.0 using min and max values
  2144. * @param value value to normalize
  2145. * @param min max to normalize between
  2146. * @param max min to normalize between
  2147. * @returns the normalized value
  2148. */
  2149. static Normalize(value: number, min: number, max: number): number;
  2150. /**
  2151. * Denormalize the value from 0.0 and 1.0 using min and max values
  2152. * @param normalized value to denormalize
  2153. * @param min max to denormalize between
  2154. * @param max min to denormalize between
  2155. * @returns the denormalized value
  2156. */
  2157. static Denormalize(normalized: number, min: number, max: number): number;
  2158. /**
  2159. * Calculates the shortest difference between two given angles given in degrees.
  2160. * @param current current angle in degrees
  2161. * @param target target angle in degrees
  2162. * @returns the delta
  2163. */
  2164. static DeltaAngle(current: number, target: number): number;
  2165. /**
  2166. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2167. * @param tx value
  2168. * @param length length
  2169. * @returns The returned value will move back and forth between 0 and length
  2170. */
  2171. static PingPong(tx: number, length: number): number;
  2172. /**
  2173. * Interpolates between min and max with smoothing at the limits.
  2174. *
  2175. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2176. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2177. * @param from from
  2178. * @param to to
  2179. * @param tx value
  2180. * @returns the smooth stepped value
  2181. */
  2182. static SmoothStep(from: number, to: number, tx: number): number;
  2183. /**
  2184. * Moves a value current towards target.
  2185. *
  2186. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2187. * Negative values of maxDelta pushes the value away from target.
  2188. * @param current current value
  2189. * @param target target value
  2190. * @param maxDelta max distance to move
  2191. * @returns resulting value
  2192. */
  2193. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2194. /**
  2195. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2196. *
  2197. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2198. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2199. * @param current current value
  2200. * @param target target value
  2201. * @param maxDelta max distance to move
  2202. * @returns resulting angle
  2203. */
  2204. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2205. /**
  2206. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2207. * @param start start value
  2208. * @param end target value
  2209. * @param amount amount to lerp between
  2210. * @returns the lerped value
  2211. */
  2212. static Lerp(start: number, end: number, amount: number): number;
  2213. /**
  2214. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2215. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2216. * @param start start value
  2217. * @param end target value
  2218. * @param amount amount to lerp between
  2219. * @returns the lerped value
  2220. */
  2221. static LerpAngle(start: number, end: number, amount: number): number;
  2222. /**
  2223. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2224. * @param a start value
  2225. * @param b target value
  2226. * @param value value between a and b
  2227. * @returns the inverseLerp value
  2228. */
  2229. static InverseLerp(a: number, b: number, value: number): number;
  2230. /**
  2231. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2232. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2233. * @param value1 spline value
  2234. * @param tangent1 spline value
  2235. * @param value2 spline value
  2236. * @param tangent2 spline value
  2237. * @param amount input value
  2238. * @returns hermite result
  2239. */
  2240. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2241. /**
  2242. * Returns a random float number between and min and max values
  2243. * @param min min value of random
  2244. * @param max max value of random
  2245. * @returns random value
  2246. */
  2247. static RandomRange(min: number, max: number): number;
  2248. /**
  2249. * This function returns percentage of a number in a given range.
  2250. *
  2251. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2252. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2253. * @param number to convert to percentage
  2254. * @param min min range
  2255. * @param max max range
  2256. * @returns the percentage
  2257. */
  2258. static RangeToPercent(number: number, min: number, max: number): number;
  2259. /**
  2260. * This function returns number that corresponds to the percentage in a given range.
  2261. *
  2262. * PercentToRange(0.34,0,100) will return 34.
  2263. * @param percent to convert to number
  2264. * @param min min range
  2265. * @param max max range
  2266. * @returns the number
  2267. */
  2268. static PercentToRange(percent: number, min: number, max: number): number;
  2269. /**
  2270. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2271. * @param angle The angle to normalize in radian.
  2272. * @return The converted angle.
  2273. */
  2274. static NormalizeRadians(angle: number): number;
  2275. }
  2276. }
  2277. declare module "babylonjs/Maths/math.constants" {
  2278. /**
  2279. * Constant used to convert a value to gamma space
  2280. * @ignorenaming
  2281. */
  2282. export const ToGammaSpace: number;
  2283. /**
  2284. * Constant used to convert a value to linear space
  2285. * @ignorenaming
  2286. */
  2287. export const ToLinearSpace = 2.2;
  2288. /**
  2289. * Constant used to define the minimal number value in Babylon.js
  2290. * @ignorenaming
  2291. */
  2292. let Epsilon: number;
  2293. export { Epsilon };
  2294. }
  2295. declare module "babylonjs/Maths/math.viewport" {
  2296. /**
  2297. * Class used to represent a viewport on screen
  2298. */
  2299. export class Viewport {
  2300. /** viewport left coordinate */
  2301. x: number;
  2302. /** viewport top coordinate */
  2303. y: number;
  2304. /**viewport width */
  2305. width: number;
  2306. /** viewport height */
  2307. height: number;
  2308. /**
  2309. * Creates a Viewport object located at (x, y) and sized (width, height)
  2310. * @param x defines viewport left coordinate
  2311. * @param y defines viewport top coordinate
  2312. * @param width defines the viewport width
  2313. * @param height defines the viewport height
  2314. */
  2315. constructor(
  2316. /** viewport left coordinate */
  2317. x: number,
  2318. /** viewport top coordinate */
  2319. y: number,
  2320. /**viewport width */
  2321. width: number,
  2322. /** viewport height */
  2323. height: number);
  2324. /**
  2325. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2326. * @param renderWidth defines the rendering width
  2327. * @param renderHeight defines the rendering height
  2328. * @returns a new Viewport
  2329. */
  2330. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2331. /**
  2332. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2333. * @param renderWidth defines the rendering width
  2334. * @param renderHeight defines the rendering height
  2335. * @param ref defines the target viewport
  2336. * @returns the current viewport
  2337. */
  2338. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2339. /**
  2340. * Returns a new Viewport copied from the current one
  2341. * @returns a new Viewport
  2342. */
  2343. clone(): Viewport;
  2344. }
  2345. }
  2346. declare module "babylonjs/Misc/arrayTools" {
  2347. /**
  2348. * Class containing a set of static utilities functions for arrays.
  2349. */
  2350. export class ArrayTools {
  2351. /**
  2352. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2353. * @param size the number of element to construct and put in the array
  2354. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2355. * @returns a new array filled with new objects
  2356. */
  2357. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2358. }
  2359. }
  2360. declare module "babylonjs/Maths/math.plane" {
  2361. import { DeepImmutable } from "babylonjs/types";
  2362. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  2363. /**
  2364. * Represents a plane by the equation ax + by + cz + d = 0
  2365. */
  2366. export class Plane {
  2367. private static _TmpMatrix;
  2368. /**
  2369. * Normal of the plane (a,b,c)
  2370. */
  2371. normal: Vector3;
  2372. /**
  2373. * d component of the plane
  2374. */
  2375. d: number;
  2376. /**
  2377. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2378. * @param a a component of the plane
  2379. * @param b b component of the plane
  2380. * @param c c component of the plane
  2381. * @param d d component of the plane
  2382. */
  2383. constructor(a: number, b: number, c: number, d: number);
  2384. /**
  2385. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2386. */
  2387. asArray(): number[];
  2388. /**
  2389. * @returns a new plane copied from the current Plane.
  2390. */
  2391. clone(): Plane;
  2392. /**
  2393. * @returns the string "Plane".
  2394. */
  2395. getClassName(): string;
  2396. /**
  2397. * @returns the Plane hash code.
  2398. */
  2399. getHashCode(): number;
  2400. /**
  2401. * Normalize the current Plane in place.
  2402. * @returns the updated Plane.
  2403. */
  2404. normalize(): Plane;
  2405. /**
  2406. * Applies a transformation the plane and returns the result
  2407. * @param transformation the transformation matrix to be applied to the plane
  2408. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2409. */
  2410. transform(transformation: DeepImmutable<Matrix>): Plane;
  2411. /**
  2412. * Compute the dot product between the point and the plane normal
  2413. * @param point point to calculate the dot product with
  2414. * @returns the dot product (float) of the point coordinates and the plane normal.
  2415. */
  2416. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2417. /**
  2418. * Updates the current Plane from the plane defined by the three given points.
  2419. * @param point1 one of the points used to contruct the plane
  2420. * @param point2 one of the points used to contruct the plane
  2421. * @param point3 one of the points used to contruct the plane
  2422. * @returns the updated Plane.
  2423. */
  2424. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2425. /**
  2426. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2427. * Note that for this function to work as expected you should make sure that:
  2428. * - direction and the plane normal are normalized
  2429. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2430. * @param direction the direction to check if the plane is facing
  2431. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2432. * @returns True if the plane is facing the given direction
  2433. */
  2434. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2435. /**
  2436. * Calculates the distance to a point
  2437. * @param point point to calculate distance to
  2438. * @returns the signed distance (float) from the given point to the Plane.
  2439. */
  2440. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2441. /**
  2442. * Creates a plane from an array
  2443. * @param array the array to create a plane from
  2444. * @returns a new Plane from the given array.
  2445. */
  2446. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2447. /**
  2448. * Creates a plane from three points
  2449. * @param point1 point used to create the plane
  2450. * @param point2 point used to create the plane
  2451. * @param point3 point used to create the plane
  2452. * @returns a new Plane defined by the three given points.
  2453. */
  2454. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2455. /**
  2456. * Creates a plane from an origin point and a normal
  2457. * @param origin origin of the plane to be constructed
  2458. * @param normal normal of the plane to be constructed
  2459. * @returns a new Plane the normal vector to this plane at the given origin point.
  2460. * Note : the vector "normal" is updated because normalized.
  2461. */
  2462. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2463. /**
  2464. * Calculates the distance from a plane and a point
  2465. * @param origin origin of the plane to be constructed
  2466. * @param normal normal of the plane to be constructed
  2467. * @param point point to calculate distance to
  2468. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2469. */
  2470. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2471. }
  2472. }
  2473. declare module "babylonjs/Engines/performanceConfigurator" {
  2474. /** @hidden */
  2475. export class PerformanceConfigurator {
  2476. /** @hidden */
  2477. static MatrixUse64Bits: boolean;
  2478. /** @hidden */
  2479. static MatrixTrackPrecisionChange: boolean;
  2480. /** @hidden */
  2481. static MatrixCurrentType: any;
  2482. /** @hidden */
  2483. static MatrixTrackedMatrices: Array<any> | null;
  2484. /** @hidden */
  2485. static SetMatrixPrecision(use64bits: boolean): void;
  2486. }
  2487. }
  2488. declare module "babylonjs/Maths/math.vector" {
  2489. import { Viewport } from "babylonjs/Maths/math.viewport";
  2490. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2491. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2492. import { Plane } from "babylonjs/Maths/math.plane";
  2493. /**
  2494. * Class representing a vector containing 2 coordinates
  2495. */
  2496. export class Vector2 {
  2497. /** defines the first coordinate */
  2498. x: number;
  2499. /** defines the second coordinate */
  2500. y: number;
  2501. /**
  2502. * Creates a new Vector2 from the given x and y coordinates
  2503. * @param x defines the first coordinate
  2504. * @param y defines the second coordinate
  2505. */
  2506. constructor(
  2507. /** defines the first coordinate */
  2508. x?: number,
  2509. /** defines the second coordinate */
  2510. y?: number);
  2511. /**
  2512. * Gets a string with the Vector2 coordinates
  2513. * @returns a string with the Vector2 coordinates
  2514. */
  2515. toString(): string;
  2516. /**
  2517. * Gets class name
  2518. * @returns the string "Vector2"
  2519. */
  2520. getClassName(): string;
  2521. /**
  2522. * Gets current vector hash code
  2523. * @returns the Vector2 hash code as a number
  2524. */
  2525. getHashCode(): number;
  2526. /**
  2527. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2528. * @param array defines the source array
  2529. * @param index defines the offset in source array
  2530. * @returns the current Vector2
  2531. */
  2532. toArray(array: FloatArray, index?: number): Vector2;
  2533. /**
  2534. * Update the current vector from an array
  2535. * @param array defines the destination array
  2536. * @param index defines the offset in the destination array
  2537. * @returns the current Vector3
  2538. */
  2539. fromArray(array: FloatArray, index?: number): Vector2;
  2540. /**
  2541. * Copy the current vector to an array
  2542. * @returns a new array with 2 elements: the Vector2 coordinates.
  2543. */
  2544. asArray(): number[];
  2545. /**
  2546. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2547. * @param source defines the source Vector2
  2548. * @returns the current updated Vector2
  2549. */
  2550. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2551. /**
  2552. * Sets the Vector2 coordinates with the given floats
  2553. * @param x defines the first coordinate
  2554. * @param y defines the second coordinate
  2555. * @returns the current updated Vector2
  2556. */
  2557. copyFromFloats(x: number, y: number): Vector2;
  2558. /**
  2559. * Sets the Vector2 coordinates with the given floats
  2560. * @param x defines the first coordinate
  2561. * @param y defines the second coordinate
  2562. * @returns the current updated Vector2
  2563. */
  2564. set(x: number, y: number): Vector2;
  2565. /**
  2566. * Add another vector with the current one
  2567. * @param otherVector defines the other vector
  2568. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2569. */
  2570. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2571. /**
  2572. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2573. * @param otherVector defines the other vector
  2574. * @param result defines the target vector
  2575. * @returns the unmodified current Vector2
  2576. */
  2577. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2578. /**
  2579. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2580. * @param otherVector defines the other vector
  2581. * @returns the current updated Vector2
  2582. */
  2583. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2584. /**
  2585. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2586. * @param otherVector defines the other vector
  2587. * @returns a new Vector2
  2588. */
  2589. addVector3(otherVector: Vector3): Vector2;
  2590. /**
  2591. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2592. * @param otherVector defines the other vector
  2593. * @returns a new Vector2
  2594. */
  2595. subtract(otherVector: Vector2): Vector2;
  2596. /**
  2597. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2598. * @param otherVector defines the other vector
  2599. * @param result defines the target vector
  2600. * @returns the unmodified current Vector2
  2601. */
  2602. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2603. /**
  2604. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2605. * @param otherVector defines the other vector
  2606. * @returns the current updated Vector2
  2607. */
  2608. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2609. /**
  2610. * Multiplies in place the current Vector2 coordinates by the given ones
  2611. * @param otherVector defines the other vector
  2612. * @returns the current updated Vector2
  2613. */
  2614. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2615. /**
  2616. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2617. * @param otherVector defines the other vector
  2618. * @returns a new Vector2
  2619. */
  2620. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2621. /**
  2622. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2623. * @param otherVector defines the other vector
  2624. * @param result defines the target vector
  2625. * @returns the unmodified current Vector2
  2626. */
  2627. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2628. /**
  2629. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2630. * @param x defines the first coordinate
  2631. * @param y defines the second coordinate
  2632. * @returns a new Vector2
  2633. */
  2634. multiplyByFloats(x: number, y: number): Vector2;
  2635. /**
  2636. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2637. * @param otherVector defines the other vector
  2638. * @returns a new Vector2
  2639. */
  2640. divide(otherVector: Vector2): Vector2;
  2641. /**
  2642. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2643. * @param otherVector defines the other vector
  2644. * @param result defines the target vector
  2645. * @returns the unmodified current Vector2
  2646. */
  2647. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2648. /**
  2649. * Divides the current Vector2 coordinates by the given ones
  2650. * @param otherVector defines the other vector
  2651. * @returns the current updated Vector2
  2652. */
  2653. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2654. /**
  2655. * Gets a new Vector2 with current Vector2 negated coordinates
  2656. * @returns a new Vector2
  2657. */
  2658. negate(): Vector2;
  2659. /**
  2660. * Negate this vector in place
  2661. * @returns this
  2662. */
  2663. negateInPlace(): Vector2;
  2664. /**
  2665. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2666. * @param result defines the Vector3 object where to store the result
  2667. * @returns the current Vector2
  2668. */
  2669. negateToRef(result: Vector2): Vector2;
  2670. /**
  2671. * Multiply the Vector2 coordinates by scale
  2672. * @param scale defines the scaling factor
  2673. * @returns the current updated Vector2
  2674. */
  2675. scaleInPlace(scale: number): Vector2;
  2676. /**
  2677. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2678. * @param scale defines the scaling factor
  2679. * @returns a new Vector2
  2680. */
  2681. scale(scale: number): Vector2;
  2682. /**
  2683. * Scale the current Vector2 values by a factor to a given Vector2
  2684. * @param scale defines the scale factor
  2685. * @param result defines the Vector2 object where to store the result
  2686. * @returns the unmodified current Vector2
  2687. */
  2688. scaleToRef(scale: number, result: Vector2): Vector2;
  2689. /**
  2690. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2691. * @param scale defines the scale factor
  2692. * @param result defines the Vector2 object where to store the result
  2693. * @returns the unmodified current Vector2
  2694. */
  2695. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2696. /**
  2697. * Gets a boolean if two vectors are equals
  2698. * @param otherVector defines the other vector
  2699. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2700. */
  2701. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2702. /**
  2703. * Gets a boolean if two vectors are equals (using an epsilon value)
  2704. * @param otherVector defines the other vector
  2705. * @param epsilon defines the minimal distance to consider equality
  2706. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2707. */
  2708. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2709. /**
  2710. * Gets a new Vector2 from current Vector2 floored values
  2711. * @returns a new Vector2
  2712. */
  2713. floor(): Vector2;
  2714. /**
  2715. * Gets a new Vector2 from current Vector2 floored values
  2716. * @returns a new Vector2
  2717. */
  2718. fract(): Vector2;
  2719. /**
  2720. * Gets the length of the vector
  2721. * @returns the vector length (float)
  2722. */
  2723. length(): number;
  2724. /**
  2725. * Gets the vector squared length
  2726. * @returns the vector squared length (float)
  2727. */
  2728. lengthSquared(): number;
  2729. /**
  2730. * Normalize the vector
  2731. * @returns the current updated Vector2
  2732. */
  2733. normalize(): Vector2;
  2734. /**
  2735. * Gets a new Vector2 copied from the Vector2
  2736. * @returns a new Vector2
  2737. */
  2738. clone(): Vector2;
  2739. /**
  2740. * Gets a new Vector2(0, 0)
  2741. * @returns a new Vector2
  2742. */
  2743. static Zero(): Vector2;
  2744. /**
  2745. * Gets a new Vector2(1, 1)
  2746. * @returns a new Vector2
  2747. */
  2748. static One(): Vector2;
  2749. /**
  2750. * Gets a new Vector2 set from the given index element of the given array
  2751. * @param array defines the data source
  2752. * @param offset defines the offset in the data source
  2753. * @returns a new Vector2
  2754. */
  2755. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2756. /**
  2757. * Sets "result" from the given index element of the given array
  2758. * @param array defines the data source
  2759. * @param offset defines the offset in the data source
  2760. * @param result defines the target vector
  2761. */
  2762. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2763. /**
  2764. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2765. * @param value1 defines 1st point of control
  2766. * @param value2 defines 2nd point of control
  2767. * @param value3 defines 3rd point of control
  2768. * @param value4 defines 4th point of control
  2769. * @param amount defines the interpolation factor
  2770. * @returns a new Vector2
  2771. */
  2772. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2773. /**
  2774. * 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".
  2775. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2776. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2777. * @param value defines the value to clamp
  2778. * @param min defines the lower limit
  2779. * @param max defines the upper limit
  2780. * @returns a new Vector2
  2781. */
  2782. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2783. /**
  2784. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2785. * @param value1 defines the 1st control point
  2786. * @param tangent1 defines the outgoing tangent
  2787. * @param value2 defines the 2nd control point
  2788. * @param tangent2 defines the incoming tangent
  2789. * @param amount defines the interpolation factor
  2790. * @returns a new Vector2
  2791. */
  2792. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2793. /**
  2794. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2795. * @param start defines the start vector
  2796. * @param end defines the end vector
  2797. * @param amount defines the interpolation factor
  2798. * @returns a new Vector2
  2799. */
  2800. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2801. /**
  2802. * Gets the dot product of the vector "left" and the vector "right"
  2803. * @param left defines first vector
  2804. * @param right defines second vector
  2805. * @returns the dot product (float)
  2806. */
  2807. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2808. /**
  2809. * Returns a new Vector2 equal to the normalized given vector
  2810. * @param vector defines the vector to normalize
  2811. * @returns a new Vector2
  2812. */
  2813. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2814. /**
  2815. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2816. * @param left defines 1st vector
  2817. * @param right defines 2nd vector
  2818. * @returns a new Vector2
  2819. */
  2820. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2821. /**
  2822. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2823. * @param left defines 1st vector
  2824. * @param right defines 2nd vector
  2825. * @returns a new Vector2
  2826. */
  2827. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2828. /**
  2829. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2830. * @param vector defines the vector to transform
  2831. * @param transformation defines the matrix to apply
  2832. * @returns a new Vector2
  2833. */
  2834. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2835. /**
  2836. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2837. * @param vector defines the vector to transform
  2838. * @param transformation defines the matrix to apply
  2839. * @param result defines the target vector
  2840. */
  2841. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2842. /**
  2843. * Determines if a given vector is included in a triangle
  2844. * @param p defines the vector to test
  2845. * @param p0 defines 1st triangle point
  2846. * @param p1 defines 2nd triangle point
  2847. * @param p2 defines 3rd triangle point
  2848. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2849. */
  2850. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2851. /**
  2852. * Gets the distance between the vectors "value1" and "value2"
  2853. * @param value1 defines first vector
  2854. * @param value2 defines second vector
  2855. * @returns the distance between vectors
  2856. */
  2857. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2858. /**
  2859. * Returns the squared distance between the vectors "value1" and "value2"
  2860. * @param value1 defines first vector
  2861. * @param value2 defines second vector
  2862. * @returns the squared distance between vectors
  2863. */
  2864. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2865. /**
  2866. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2867. * @param value1 defines first vector
  2868. * @param value2 defines second vector
  2869. * @returns a new Vector2
  2870. */
  2871. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2872. /**
  2873. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2874. * @param p defines the middle point
  2875. * @param segA defines one point of the segment
  2876. * @param segB defines the other point of the segment
  2877. * @returns the shortest distance
  2878. */
  2879. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2880. }
  2881. /**
  2882. * Class used to store (x,y,z) vector representation
  2883. * A Vector3 is the main object used in 3D geometry
  2884. * It can represent etiher the coordinates of a point the space, either a direction
  2885. * Reminder: js uses a left handed forward facing system
  2886. */
  2887. export class Vector3 {
  2888. private static _UpReadOnly;
  2889. private static _ZeroReadOnly;
  2890. /** @hidden */
  2891. _x: number;
  2892. /** @hidden */
  2893. _y: number;
  2894. /** @hidden */
  2895. _z: number;
  2896. /** @hidden */
  2897. _isDirty: boolean;
  2898. /** Gets or sets the x coordinate */
  2899. get x(): number;
  2900. set x(value: number);
  2901. /** Gets or sets the y coordinate */
  2902. get y(): number;
  2903. set y(value: number);
  2904. /** Gets or sets the z coordinate */
  2905. get z(): number;
  2906. set z(value: number);
  2907. /**
  2908. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2909. * @param x defines the first coordinates (on X axis)
  2910. * @param y defines the second coordinates (on Y axis)
  2911. * @param z defines the third coordinates (on Z axis)
  2912. */
  2913. constructor(x?: number, y?: number, z?: number);
  2914. /**
  2915. * Creates a string representation of the Vector3
  2916. * @returns a string with the Vector3 coordinates.
  2917. */
  2918. toString(): string;
  2919. /**
  2920. * Gets the class name
  2921. * @returns the string "Vector3"
  2922. */
  2923. getClassName(): string;
  2924. /**
  2925. * Creates the Vector3 hash code
  2926. * @returns a number which tends to be unique between Vector3 instances
  2927. */
  2928. getHashCode(): number;
  2929. /**
  2930. * Creates an array containing three elements : the coordinates of the Vector3
  2931. * @returns a new array of numbers
  2932. */
  2933. asArray(): number[];
  2934. /**
  2935. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2936. * @param array defines the destination array
  2937. * @param index defines the offset in the destination array
  2938. * @returns the current Vector3
  2939. */
  2940. toArray(array: FloatArray, index?: number): Vector3;
  2941. /**
  2942. * Update the current vector from an array
  2943. * @param array defines the destination array
  2944. * @param index defines the offset in the destination array
  2945. * @returns the current Vector3
  2946. */
  2947. fromArray(array: FloatArray, index?: number): Vector3;
  2948. /**
  2949. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2950. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2951. */
  2952. toQuaternion(): Quaternion;
  2953. /**
  2954. * Adds the given vector to the current Vector3
  2955. * @param otherVector defines the second operand
  2956. * @returns the current updated Vector3
  2957. */
  2958. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2959. /**
  2960. * Adds the given coordinates to the current Vector3
  2961. * @param x defines the x coordinate of the operand
  2962. * @param y defines the y coordinate of the operand
  2963. * @param z defines the z coordinate of the operand
  2964. * @returns the current updated Vector3
  2965. */
  2966. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2967. /**
  2968. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2969. * @param otherVector defines the second operand
  2970. * @returns the resulting Vector3
  2971. */
  2972. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2973. /**
  2974. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2975. * @param otherVector defines the second operand
  2976. * @param result defines the Vector3 object where to store the result
  2977. * @returns the current Vector3
  2978. */
  2979. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2980. /**
  2981. * Subtract the given vector from the current Vector3
  2982. * @param otherVector defines the second operand
  2983. * @returns the current updated Vector3
  2984. */
  2985. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2986. /**
  2987. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2988. * @param otherVector defines the second operand
  2989. * @returns the resulting Vector3
  2990. */
  2991. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2992. /**
  2993. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2994. * @param otherVector defines the second operand
  2995. * @param result defines the Vector3 object where to store the result
  2996. * @returns the current Vector3
  2997. */
  2998. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2999. /**
  3000. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3001. * @param x defines the x coordinate of the operand
  3002. * @param y defines the y coordinate of the operand
  3003. * @param z defines the z coordinate of the operand
  3004. * @returns the resulting Vector3
  3005. */
  3006. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3007. /**
  3008. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3009. * @param x defines the x coordinate of the operand
  3010. * @param y defines the y coordinate of the operand
  3011. * @param z defines the z coordinate of the operand
  3012. * @param result defines the Vector3 object where to store the result
  3013. * @returns the current Vector3
  3014. */
  3015. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3016. /**
  3017. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3018. * @returns a new Vector3
  3019. */
  3020. negate(): Vector3;
  3021. /**
  3022. * Negate this vector in place
  3023. * @returns this
  3024. */
  3025. negateInPlace(): Vector3;
  3026. /**
  3027. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3028. * @param result defines the Vector3 object where to store the result
  3029. * @returns the current Vector3
  3030. */
  3031. negateToRef(result: Vector3): Vector3;
  3032. /**
  3033. * Multiplies the Vector3 coordinates by the float "scale"
  3034. * @param scale defines the multiplier factor
  3035. * @returns the current updated Vector3
  3036. */
  3037. scaleInPlace(scale: number): Vector3;
  3038. /**
  3039. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3040. * @param scale defines the multiplier factor
  3041. * @returns a new Vector3
  3042. */
  3043. scale(scale: number): Vector3;
  3044. /**
  3045. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3046. * @param scale defines the multiplier factor
  3047. * @param result defines the Vector3 object where to store the result
  3048. * @returns the current Vector3
  3049. */
  3050. scaleToRef(scale: number, result: Vector3): Vector3;
  3051. /**
  3052. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3053. * @param scale defines the scale factor
  3054. * @param result defines the Vector3 object where to store the result
  3055. * @returns the unmodified current Vector3
  3056. */
  3057. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3058. /**
  3059. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3060. * @param origin defines the origin of the projection ray
  3061. * @param plane defines the plane to project to
  3062. * @returns the projected vector3
  3063. */
  3064. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3065. /**
  3066. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3067. * @param origin defines the origin of the projection ray
  3068. * @param plane defines the plane to project to
  3069. * @param result defines the Vector3 where to store the result
  3070. */
  3071. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3072. /**
  3073. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3074. * @param otherVector defines the second operand
  3075. * @returns true if both vectors are equals
  3076. */
  3077. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3078. /**
  3079. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3080. * @param otherVector defines the second operand
  3081. * @param epsilon defines the minimal distance to define values as equals
  3082. * @returns true if both vectors are distant less than epsilon
  3083. */
  3084. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3085. /**
  3086. * Returns true if the current Vector3 coordinates equals the given floats
  3087. * @param x defines the x coordinate of the operand
  3088. * @param y defines the y coordinate of the operand
  3089. * @param z defines the z coordinate of the operand
  3090. * @returns true if both vectors are equals
  3091. */
  3092. equalsToFloats(x: number, y: number, z: number): boolean;
  3093. /**
  3094. * Multiplies the current Vector3 coordinates by the given ones
  3095. * @param otherVector defines the second operand
  3096. * @returns the current updated Vector3
  3097. */
  3098. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3099. /**
  3100. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3101. * @param otherVector defines the second operand
  3102. * @returns the new Vector3
  3103. */
  3104. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3105. /**
  3106. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3107. * @param otherVector defines the second operand
  3108. * @param result defines the Vector3 object where to store the result
  3109. * @returns the current Vector3
  3110. */
  3111. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3112. /**
  3113. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3114. * @param x defines the x coordinate of the operand
  3115. * @param y defines the y coordinate of the operand
  3116. * @param z defines the z coordinate of the operand
  3117. * @returns the new Vector3
  3118. */
  3119. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3120. /**
  3121. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3122. * @param otherVector defines the second operand
  3123. * @returns the new Vector3
  3124. */
  3125. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3126. /**
  3127. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3128. * @param otherVector defines the second operand
  3129. * @param result defines the Vector3 object where to store the result
  3130. * @returns the current Vector3
  3131. */
  3132. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3133. /**
  3134. * Divides the current Vector3 coordinates by the given ones.
  3135. * @param otherVector defines the second operand
  3136. * @returns the current updated Vector3
  3137. */
  3138. divideInPlace(otherVector: Vector3): Vector3;
  3139. /**
  3140. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3141. * @param other defines the second operand
  3142. * @returns the current updated Vector3
  3143. */
  3144. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3145. /**
  3146. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3147. * @param other defines the second operand
  3148. * @returns the current updated Vector3
  3149. */
  3150. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3151. /**
  3152. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3153. * @param x defines the x coordinate of the operand
  3154. * @param y defines the y coordinate of the operand
  3155. * @param z defines the z coordinate of the operand
  3156. * @returns the current updated Vector3
  3157. */
  3158. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3159. /**
  3160. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3161. * @param x defines the x coordinate of the operand
  3162. * @param y defines the y coordinate of the operand
  3163. * @param z defines the z coordinate of the operand
  3164. * @returns the current updated Vector3
  3165. */
  3166. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3167. /**
  3168. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3169. * Check if is non uniform within a certain amount of decimal places to account for this
  3170. * @param epsilon the amount the values can differ
  3171. * @returns if the the vector is non uniform to a certain number of decimal places
  3172. */
  3173. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3174. /**
  3175. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3176. */
  3177. get isNonUniform(): boolean;
  3178. /**
  3179. * Gets a new Vector3 from current Vector3 floored values
  3180. * @returns a new Vector3
  3181. */
  3182. floor(): Vector3;
  3183. /**
  3184. * Gets a new Vector3 from current Vector3 floored values
  3185. * @returns a new Vector3
  3186. */
  3187. fract(): Vector3;
  3188. /**
  3189. * Gets the length of the Vector3
  3190. * @returns the length of the Vector3
  3191. */
  3192. length(): number;
  3193. /**
  3194. * Gets the squared length of the Vector3
  3195. * @returns squared length of the Vector3
  3196. */
  3197. lengthSquared(): number;
  3198. /**
  3199. * Normalize the current Vector3.
  3200. * Please note that this is an in place operation.
  3201. * @returns the current updated Vector3
  3202. */
  3203. normalize(): Vector3;
  3204. /**
  3205. * Reorders the x y z properties of the vector in place
  3206. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3207. * @returns the current updated vector
  3208. */
  3209. reorderInPlace(order: string): this;
  3210. /**
  3211. * Rotates the vector around 0,0,0 by a quaternion
  3212. * @param quaternion the rotation quaternion
  3213. * @param result vector to store the result
  3214. * @returns the resulting vector
  3215. */
  3216. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3217. /**
  3218. * Rotates a vector around a given point
  3219. * @param quaternion the rotation quaternion
  3220. * @param point the point to rotate around
  3221. * @param result vector to store the result
  3222. * @returns the resulting vector
  3223. */
  3224. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3225. /**
  3226. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3227. * The cross product is then orthogonal to both current and "other"
  3228. * @param other defines the right operand
  3229. * @returns the cross product
  3230. */
  3231. cross(other: Vector3): Vector3;
  3232. /**
  3233. * Normalize the current Vector3 with the given input length.
  3234. * Please note that this is an in place operation.
  3235. * @param len the length of the vector
  3236. * @returns the current updated Vector3
  3237. */
  3238. normalizeFromLength(len: number): Vector3;
  3239. /**
  3240. * Normalize the current Vector3 to a new vector
  3241. * @returns the new Vector3
  3242. */
  3243. normalizeToNew(): Vector3;
  3244. /**
  3245. * Normalize the current Vector3 to the reference
  3246. * @param reference define the Vector3 to update
  3247. * @returns the updated Vector3
  3248. */
  3249. normalizeToRef(reference: Vector3): Vector3;
  3250. /**
  3251. * Creates a new Vector3 copied from the current Vector3
  3252. * @returns the new Vector3
  3253. */
  3254. clone(): Vector3;
  3255. /**
  3256. * Copies the given vector coordinates to the current Vector3 ones
  3257. * @param source defines the source Vector3
  3258. * @returns the current updated Vector3
  3259. */
  3260. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3261. /**
  3262. * Copies the given floats to the current Vector3 coordinates
  3263. * @param x defines the x coordinate of the operand
  3264. * @param y defines the y coordinate of the operand
  3265. * @param z defines the z coordinate of the operand
  3266. * @returns the current updated Vector3
  3267. */
  3268. copyFromFloats(x: number, y: number, z: number): Vector3;
  3269. /**
  3270. * Copies the given floats to the current Vector3 coordinates
  3271. * @param x defines the x coordinate of the operand
  3272. * @param y defines the y coordinate of the operand
  3273. * @param z defines the z coordinate of the operand
  3274. * @returns the current updated Vector3
  3275. */
  3276. set(x: number, y: number, z: number): Vector3;
  3277. /**
  3278. * Copies the given float to the current Vector3 coordinates
  3279. * @param v defines the x, y and z coordinates of the operand
  3280. * @returns the current updated Vector3
  3281. */
  3282. setAll(v: number): Vector3;
  3283. /**
  3284. * Get the clip factor between two vectors
  3285. * @param vector0 defines the first operand
  3286. * @param vector1 defines the second operand
  3287. * @param axis defines the axis to use
  3288. * @param size defines the size along the axis
  3289. * @returns the clip factor
  3290. */
  3291. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3292. /**
  3293. * Get angle between two vectors
  3294. * @param vector0 angle between vector0 and vector1
  3295. * @param vector1 angle between vector0 and vector1
  3296. * @param normal direction of the normal
  3297. * @return the angle between vector0 and vector1
  3298. */
  3299. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3300. /**
  3301. * Returns a new Vector3 set from the index "offset" of the given array
  3302. * @param array defines the source array
  3303. * @param offset defines the offset in the source array
  3304. * @returns the new Vector3
  3305. */
  3306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3307. /**
  3308. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3309. * @param array defines the source array
  3310. * @param offset defines the offset in the source array
  3311. * @returns the new Vector3
  3312. * @deprecated Please use FromArray instead.
  3313. */
  3314. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3315. /**
  3316. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3317. * @param array defines the source array
  3318. * @param offset defines the offset in the source array
  3319. * @param result defines the Vector3 where to store the result
  3320. */
  3321. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3322. /**
  3323. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3324. * @param array defines the source array
  3325. * @param offset defines the offset in the source array
  3326. * @param result defines the Vector3 where to store the result
  3327. * @deprecated Please use FromArrayToRef instead.
  3328. */
  3329. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3330. /**
  3331. * Sets the given vector "result" with the given floats.
  3332. * @param x defines the x coordinate of the source
  3333. * @param y defines the y coordinate of the source
  3334. * @param z defines the z coordinate of the source
  3335. * @param result defines the Vector3 where to store the result
  3336. */
  3337. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3338. /**
  3339. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3340. * @returns a new empty Vector3
  3341. */
  3342. static Zero(): Vector3;
  3343. /**
  3344. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3345. * @returns a new unit Vector3
  3346. */
  3347. static One(): Vector3;
  3348. /**
  3349. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3350. * @returns a new up Vector3
  3351. */
  3352. static Up(): Vector3;
  3353. /**
  3354. * Gets a up Vector3 that must not be updated
  3355. */
  3356. static get UpReadOnly(): DeepImmutable<Vector3>;
  3357. /**
  3358. * Gets a zero Vector3 that must not be updated
  3359. */
  3360. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3361. /**
  3362. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3363. * @returns a new down Vector3
  3364. */
  3365. static Down(): Vector3;
  3366. /**
  3367. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3368. * @param rightHandedSystem is the scene right-handed (negative z)
  3369. * @returns a new forward Vector3
  3370. */
  3371. static Forward(rightHandedSystem?: boolean): Vector3;
  3372. /**
  3373. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3374. * @param rightHandedSystem is the scene right-handed (negative-z)
  3375. * @returns a new forward Vector3
  3376. */
  3377. static Backward(rightHandedSystem?: boolean): Vector3;
  3378. /**
  3379. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3380. * @returns a new right Vector3
  3381. */
  3382. static Right(): Vector3;
  3383. /**
  3384. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3385. * @returns a new left Vector3
  3386. */
  3387. static Left(): Vector3;
  3388. /**
  3389. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3390. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3391. * @param vector defines the Vector3 to transform
  3392. * @param transformation defines the transformation matrix
  3393. * @returns the transformed Vector3
  3394. */
  3395. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3396. /**
  3397. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3398. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3399. * @param vector defines the Vector3 to transform
  3400. * @param transformation defines the transformation matrix
  3401. * @param result defines the Vector3 where to store the result
  3402. */
  3403. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3404. /**
  3405. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3406. * This method computes tranformed coordinates only, not transformed direction vectors
  3407. * @param x define the x coordinate of the source vector
  3408. * @param y define the y coordinate of the source vector
  3409. * @param z define the z coordinate of the source vector
  3410. * @param transformation defines the transformation matrix
  3411. * @param result defines the Vector3 where to store the result
  3412. */
  3413. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3414. /**
  3415. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3416. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3417. * @param vector defines the Vector3 to transform
  3418. * @param transformation defines the transformation matrix
  3419. * @returns the new Vector3
  3420. */
  3421. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3422. /**
  3423. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3424. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3425. * @param vector defines the Vector3 to transform
  3426. * @param transformation defines the transformation matrix
  3427. * @param result defines the Vector3 where to store the result
  3428. */
  3429. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3430. /**
  3431. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3432. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3433. * @param x define the x coordinate of the source vector
  3434. * @param y define the y coordinate of the source vector
  3435. * @param z define the z coordinate of the source vector
  3436. * @param transformation defines the transformation matrix
  3437. * @param result defines the Vector3 where to store the result
  3438. */
  3439. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3440. /**
  3441. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3442. * @param value1 defines the first control point
  3443. * @param value2 defines the second control point
  3444. * @param value3 defines the third control point
  3445. * @param value4 defines the fourth control point
  3446. * @param amount defines the amount on the spline to use
  3447. * @returns the new Vector3
  3448. */
  3449. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3450. /**
  3451. * 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"
  3452. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3453. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3454. * @param value defines the current value
  3455. * @param min defines the lower range value
  3456. * @param max defines the upper range value
  3457. * @returns the new Vector3
  3458. */
  3459. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3460. /**
  3461. * 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"
  3462. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3463. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3464. * @param value defines the current value
  3465. * @param min defines the lower range value
  3466. * @param max defines the upper range value
  3467. * @param result defines the Vector3 where to store the result
  3468. */
  3469. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3470. /**
  3471. * Checks if a given vector is inside a specific range
  3472. * @param v defines the vector to test
  3473. * @param min defines the minimum range
  3474. * @param max defines the maximum range
  3475. */
  3476. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3477. /**
  3478. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3479. * @param value1 defines the first control point
  3480. * @param tangent1 defines the first tangent vector
  3481. * @param value2 defines the second control point
  3482. * @param tangent2 defines the second tangent vector
  3483. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3484. * @returns the new Vector3
  3485. */
  3486. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3487. /**
  3488. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3489. * @param start defines the start value
  3490. * @param end defines the end value
  3491. * @param amount max defines amount between both (between 0 and 1)
  3492. * @returns the new Vector3
  3493. */
  3494. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3495. /**
  3496. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3497. * @param start defines the start value
  3498. * @param end defines the end value
  3499. * @param amount max defines amount between both (between 0 and 1)
  3500. * @param result defines the Vector3 where to store the result
  3501. */
  3502. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3503. /**
  3504. * Returns the dot product (float) between the vectors "left" and "right"
  3505. * @param left defines the left operand
  3506. * @param right defines the right operand
  3507. * @returns the dot product
  3508. */
  3509. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3510. /**
  3511. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3512. * The cross product is then orthogonal to both "left" and "right"
  3513. * @param left defines the left operand
  3514. * @param right defines the right operand
  3515. * @returns the cross product
  3516. */
  3517. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3518. /**
  3519. * Sets the given vector "result" with the cross product of "left" and "right"
  3520. * The cross product is then orthogonal to both "left" and "right"
  3521. * @param left defines the left operand
  3522. * @param right defines the right operand
  3523. * @param result defines the Vector3 where to store the result
  3524. */
  3525. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3526. /**
  3527. * Returns a new Vector3 as the normalization of the given vector
  3528. * @param vector defines the Vector3 to normalize
  3529. * @returns the new Vector3
  3530. */
  3531. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3532. /**
  3533. * Sets the given vector "result" with the normalization of the given first vector
  3534. * @param vector defines the Vector3 to normalize
  3535. * @param result defines the Vector3 where to store the result
  3536. */
  3537. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3538. /**
  3539. * Project a Vector3 onto screen space
  3540. * @param vector defines the Vector3 to project
  3541. * @param world defines the world matrix to use
  3542. * @param transform defines the transform (view x projection) matrix to use
  3543. * @param viewport defines the screen viewport to use
  3544. * @returns the new Vector3
  3545. */
  3546. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3547. /**
  3548. * Project a Vector3 onto screen space to reference
  3549. * @param vector defines the Vector3 to project
  3550. * @param world defines the world matrix to use
  3551. * @param transform defines the transform (view x projection) matrix to use
  3552. * @param viewport defines the screen viewport to use
  3553. * @param result the vector in which the screen space will be stored
  3554. * @returns the new Vector3
  3555. */
  3556. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3557. /** @hidden */
  3558. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3559. /**
  3560. * Unproject from screen space to object space
  3561. * @param source defines the screen space Vector3 to use
  3562. * @param viewportWidth defines the current width of the viewport
  3563. * @param viewportHeight defines the current height of the viewport
  3564. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3565. * @param transform defines the transform (view x projection) matrix to use
  3566. * @returns the new Vector3
  3567. */
  3568. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3569. /**
  3570. * Unproject from screen space to object space
  3571. * @param source defines the screen space Vector3 to use
  3572. * @param viewportWidth defines the current width of the viewport
  3573. * @param viewportHeight defines the current height of the viewport
  3574. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3575. * @param view defines the view matrix to use
  3576. * @param projection defines the projection matrix to use
  3577. * @returns the new Vector3
  3578. */
  3579. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3580. /**
  3581. * Unproject from screen space to object space
  3582. * @param source defines the screen space Vector3 to use
  3583. * @param viewportWidth defines the current width of the viewport
  3584. * @param viewportHeight defines the current height of the viewport
  3585. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3586. * @param view defines the view matrix to use
  3587. * @param projection defines the projection matrix to use
  3588. * @param result defines the Vector3 where to store the result
  3589. */
  3590. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3591. /**
  3592. * Unproject from screen space to object space
  3593. * @param sourceX defines the screen space x coordinate to use
  3594. * @param sourceY defines the screen space y coordinate to use
  3595. * @param sourceZ defines the screen space z coordinate to use
  3596. * @param viewportWidth defines the current width of the viewport
  3597. * @param viewportHeight defines the current height of the viewport
  3598. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3599. * @param view defines the view matrix to use
  3600. * @param projection defines the projection matrix to use
  3601. * @param result defines the Vector3 where to store the result
  3602. */
  3603. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3604. /**
  3605. * Gets the minimal coordinate values between two Vector3
  3606. * @param left defines the first operand
  3607. * @param right defines the second operand
  3608. * @returns the new Vector3
  3609. */
  3610. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3611. /**
  3612. * Gets the maximal coordinate values between two Vector3
  3613. * @param left defines the first operand
  3614. * @param right defines the second operand
  3615. * @returns the new Vector3
  3616. */
  3617. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3618. /**
  3619. * Returns the distance between the vectors "value1" and "value2"
  3620. * @param value1 defines the first operand
  3621. * @param value2 defines the second operand
  3622. * @returns the distance
  3623. */
  3624. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3625. /**
  3626. * Returns the squared distance between the vectors "value1" and "value2"
  3627. * @param value1 defines the first operand
  3628. * @param value2 defines the second operand
  3629. * @returns the squared distance
  3630. */
  3631. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3632. /**
  3633. * Returns a new Vector3 located at the center between "value1" and "value2"
  3634. * @param value1 defines the first operand
  3635. * @param value2 defines the second operand
  3636. * @returns the new Vector3
  3637. */
  3638. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3639. /**
  3640. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3641. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3642. * to something in order to rotate it from its local system to the given target system
  3643. * Note: axis1, axis2 and axis3 are normalized during this operation
  3644. * @param axis1 defines the first axis
  3645. * @param axis2 defines the second axis
  3646. * @param axis3 defines the third axis
  3647. * @returns a new Vector3
  3648. */
  3649. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3650. /**
  3651. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3652. * @param axis1 defines the first axis
  3653. * @param axis2 defines the second axis
  3654. * @param axis3 defines the third axis
  3655. * @param ref defines the Vector3 where to store the result
  3656. */
  3657. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3658. }
  3659. /**
  3660. * Vector4 class created for EulerAngle class conversion to Quaternion
  3661. */
  3662. export class Vector4 {
  3663. /** x value of the vector */
  3664. x: number;
  3665. /** y value of the vector */
  3666. y: number;
  3667. /** z value of the vector */
  3668. z: number;
  3669. /** w value of the vector */
  3670. w: number;
  3671. /**
  3672. * Creates a Vector4 object from the given floats.
  3673. * @param x x value of the vector
  3674. * @param y y value of the vector
  3675. * @param z z value of the vector
  3676. * @param w w value of the vector
  3677. */
  3678. constructor(
  3679. /** x value of the vector */
  3680. x: number,
  3681. /** y value of the vector */
  3682. y: number,
  3683. /** z value of the vector */
  3684. z: number,
  3685. /** w value of the vector */
  3686. w: number);
  3687. /**
  3688. * Returns the string with the Vector4 coordinates.
  3689. * @returns a string containing all the vector values
  3690. */
  3691. toString(): string;
  3692. /**
  3693. * Returns the string "Vector4".
  3694. * @returns "Vector4"
  3695. */
  3696. getClassName(): string;
  3697. /**
  3698. * Returns the Vector4 hash code.
  3699. * @returns a unique hash code
  3700. */
  3701. getHashCode(): number;
  3702. /**
  3703. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3704. * @returns the resulting array
  3705. */
  3706. asArray(): number[];
  3707. /**
  3708. * Populates the given array from the given index with the Vector4 coordinates.
  3709. * @param array array to populate
  3710. * @param index index of the array to start at (default: 0)
  3711. * @returns the Vector4.
  3712. */
  3713. toArray(array: FloatArray, index?: number): Vector4;
  3714. /**
  3715. * Update the current vector from an array
  3716. * @param array defines the destination array
  3717. * @param index defines the offset in the destination array
  3718. * @returns the current Vector3
  3719. */
  3720. fromArray(array: FloatArray, index?: number): Vector4;
  3721. /**
  3722. * Adds the given vector to the current Vector4.
  3723. * @param otherVector the vector to add
  3724. * @returns the updated Vector4.
  3725. */
  3726. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3727. /**
  3728. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3729. * @param otherVector the vector to add
  3730. * @returns the resulting vector
  3731. */
  3732. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3733. /**
  3734. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3735. * @param otherVector the vector to add
  3736. * @param result the vector to store the result
  3737. * @returns the current Vector4.
  3738. */
  3739. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3740. /**
  3741. * Subtract in place the given vector from the current Vector4.
  3742. * @param otherVector the vector to subtract
  3743. * @returns the updated Vector4.
  3744. */
  3745. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3746. /**
  3747. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3748. * @param otherVector the vector to add
  3749. * @returns the new vector with the result
  3750. */
  3751. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3752. /**
  3753. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3754. * @param otherVector the vector to subtract
  3755. * @param result the vector to store the result
  3756. * @returns the current Vector4.
  3757. */
  3758. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3759. /**
  3760. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3761. */
  3762. /**
  3763. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3764. * @param x value to subtract
  3765. * @param y value to subtract
  3766. * @param z value to subtract
  3767. * @param w value to subtract
  3768. * @returns new vector containing the result
  3769. */
  3770. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3771. /**
  3772. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3773. * @param x value to subtract
  3774. * @param y value to subtract
  3775. * @param z value to subtract
  3776. * @param w value to subtract
  3777. * @param result the vector to store the result in
  3778. * @returns the current Vector4.
  3779. */
  3780. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3781. /**
  3782. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3783. * @returns a new vector with the negated values
  3784. */
  3785. negate(): Vector4;
  3786. /**
  3787. * Negate this vector in place
  3788. * @returns this
  3789. */
  3790. negateInPlace(): Vector4;
  3791. /**
  3792. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3793. * @param result defines the Vector3 object where to store the result
  3794. * @returns the current Vector4
  3795. */
  3796. negateToRef(result: Vector4): Vector4;
  3797. /**
  3798. * Multiplies the current Vector4 coordinates by scale (float).
  3799. * @param scale the number to scale with
  3800. * @returns the updated Vector4.
  3801. */
  3802. scaleInPlace(scale: number): Vector4;
  3803. /**
  3804. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3805. * @param scale the number to scale with
  3806. * @returns a new vector with the result
  3807. */
  3808. scale(scale: number): Vector4;
  3809. /**
  3810. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3811. * @param scale the number to scale with
  3812. * @param result a vector to store the result in
  3813. * @returns the current Vector4.
  3814. */
  3815. scaleToRef(scale: number, result: Vector4): Vector4;
  3816. /**
  3817. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3818. * @param scale defines the scale factor
  3819. * @param result defines the Vector4 object where to store the result
  3820. * @returns the unmodified current Vector4
  3821. */
  3822. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3823. /**
  3824. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3825. * @param otherVector the vector to compare against
  3826. * @returns true if they are equal
  3827. */
  3828. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3829. /**
  3830. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3831. * @param otherVector vector to compare against
  3832. * @param epsilon (Default: very small number)
  3833. * @returns true if they are equal
  3834. */
  3835. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3836. /**
  3837. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3838. * @param x x value to compare against
  3839. * @param y y value to compare against
  3840. * @param z z value to compare against
  3841. * @param w w value to compare against
  3842. * @returns true if equal
  3843. */
  3844. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3845. /**
  3846. * Multiplies in place the current Vector4 by the given one.
  3847. * @param otherVector vector to multiple with
  3848. * @returns the updated Vector4.
  3849. */
  3850. multiplyInPlace(otherVector: Vector4): Vector4;
  3851. /**
  3852. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3853. * @param otherVector vector to multiple with
  3854. * @returns resulting new vector
  3855. */
  3856. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3857. /**
  3858. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3859. * @param otherVector vector to multiple with
  3860. * @param result vector to store the result
  3861. * @returns the current Vector4.
  3862. */
  3863. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3864. /**
  3865. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3866. * @param x x value multiply with
  3867. * @param y y value multiply with
  3868. * @param z z value multiply with
  3869. * @param w w value multiply with
  3870. * @returns resulting new vector
  3871. */
  3872. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3873. /**
  3874. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3875. * @param otherVector vector to devide with
  3876. * @returns resulting new vector
  3877. */
  3878. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3879. /**
  3880. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3881. * @param otherVector vector to devide with
  3882. * @param result vector to store the result
  3883. * @returns the current Vector4.
  3884. */
  3885. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3886. /**
  3887. * Divides the current Vector3 coordinates by the given ones.
  3888. * @param otherVector vector to devide with
  3889. * @returns the updated Vector3.
  3890. */
  3891. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3892. /**
  3893. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3894. * @param other defines the second operand
  3895. * @returns the current updated Vector4
  3896. */
  3897. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3898. /**
  3899. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3900. * @param other defines the second operand
  3901. * @returns the current updated Vector4
  3902. */
  3903. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3904. /**
  3905. * Gets a new Vector4 from current Vector4 floored values
  3906. * @returns a new Vector4
  3907. */
  3908. floor(): Vector4;
  3909. /**
  3910. * Gets a new Vector4 from current Vector3 floored values
  3911. * @returns a new Vector4
  3912. */
  3913. fract(): Vector4;
  3914. /**
  3915. * Returns the Vector4 length (float).
  3916. * @returns the length
  3917. */
  3918. length(): number;
  3919. /**
  3920. * Returns the Vector4 squared length (float).
  3921. * @returns the length squared
  3922. */
  3923. lengthSquared(): number;
  3924. /**
  3925. * Normalizes in place the Vector4.
  3926. * @returns the updated Vector4.
  3927. */
  3928. normalize(): Vector4;
  3929. /**
  3930. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3931. * @returns this converted to a new vector3
  3932. */
  3933. toVector3(): Vector3;
  3934. /**
  3935. * Returns a new Vector4 copied from the current one.
  3936. * @returns the new cloned vector
  3937. */
  3938. clone(): Vector4;
  3939. /**
  3940. * Updates the current Vector4 with the given one coordinates.
  3941. * @param source the source vector to copy from
  3942. * @returns the updated Vector4.
  3943. */
  3944. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3945. /**
  3946. * Updates the current Vector4 coordinates with the given floats.
  3947. * @param x float to copy from
  3948. * @param y float to copy from
  3949. * @param z float to copy from
  3950. * @param w float to copy from
  3951. * @returns the updated Vector4.
  3952. */
  3953. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3954. /**
  3955. * Updates the current Vector4 coordinates with the given floats.
  3956. * @param x float to set from
  3957. * @param y float to set from
  3958. * @param z float to set from
  3959. * @param w float to set from
  3960. * @returns the updated Vector4.
  3961. */
  3962. set(x: number, y: number, z: number, w: number): Vector4;
  3963. /**
  3964. * Copies the given float to the current Vector3 coordinates
  3965. * @param v defines the x, y, z and w coordinates of the operand
  3966. * @returns the current updated Vector3
  3967. */
  3968. setAll(v: number): Vector4;
  3969. /**
  3970. * Returns a new Vector4 set from the starting index of the given array.
  3971. * @param array the array to pull values from
  3972. * @param offset the offset into the array to start at
  3973. * @returns the new vector
  3974. */
  3975. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3976. /**
  3977. * Updates the given vector "result" from the starting index of the given array.
  3978. * @param array the array to pull values from
  3979. * @param offset the offset into the array to start at
  3980. * @param result the vector to store the result in
  3981. */
  3982. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3983. /**
  3984. * Updates the given vector "result" from the starting index of the given Float32Array.
  3985. * @param array the array to pull values from
  3986. * @param offset the offset into the array to start at
  3987. * @param result the vector to store the result in
  3988. */
  3989. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3990. /**
  3991. * Updates the given vector "result" coordinates from the given floats.
  3992. * @param x float to set from
  3993. * @param y float to set from
  3994. * @param z float to set from
  3995. * @param w float to set from
  3996. * @param result the vector to the floats in
  3997. */
  3998. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3999. /**
  4000. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4001. * @returns the new vector
  4002. */
  4003. static Zero(): Vector4;
  4004. /**
  4005. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4006. * @returns the new vector
  4007. */
  4008. static One(): Vector4;
  4009. /**
  4010. * Returns a new normalized Vector4 from the given one.
  4011. * @param vector the vector to normalize
  4012. * @returns the vector
  4013. */
  4014. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4015. /**
  4016. * Updates the given vector "result" from the normalization of the given one.
  4017. * @param vector the vector to normalize
  4018. * @param result the vector to store the result in
  4019. */
  4020. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4021. /**
  4022. * Returns a vector with the minimum values from the left and right vectors
  4023. * @param left left vector to minimize
  4024. * @param right right vector to minimize
  4025. * @returns a new vector with the minimum of the left and right vector values
  4026. */
  4027. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4028. /**
  4029. * Returns a vector with the maximum values from the left and right vectors
  4030. * @param left left vector to maximize
  4031. * @param right right vector to maximize
  4032. * @returns a new vector with the maximum of the left and right vector values
  4033. */
  4034. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4035. /**
  4036. * Returns the distance (float) between the vectors "value1" and "value2".
  4037. * @param value1 value to calulate the distance between
  4038. * @param value2 value to calulate the distance between
  4039. * @return the distance between the two vectors
  4040. */
  4041. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4042. /**
  4043. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4044. * @param value1 value to calulate the distance between
  4045. * @param value2 value to calulate the distance between
  4046. * @return the distance between the two vectors squared
  4047. */
  4048. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4049. /**
  4050. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4051. * @param value1 value to calulate the center between
  4052. * @param value2 value to calulate the center between
  4053. * @return the center between the two vectors
  4054. */
  4055. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4056. /**
  4057. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4058. * This methods computes transformed normalized direction vectors only.
  4059. * @param vector the vector to transform
  4060. * @param transformation the transformation matrix to apply
  4061. * @returns the new vector
  4062. */
  4063. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4064. /**
  4065. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4066. * This methods computes transformed normalized direction vectors only.
  4067. * @param vector the vector to transform
  4068. * @param transformation the transformation matrix to apply
  4069. * @param result the vector to store the result in
  4070. */
  4071. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4072. /**
  4073. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4074. * This methods computes transformed normalized direction vectors only.
  4075. * @param x value to transform
  4076. * @param y value to transform
  4077. * @param z value to transform
  4078. * @param w value to transform
  4079. * @param transformation the transformation matrix to apply
  4080. * @param result the vector to store the results in
  4081. */
  4082. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4083. /**
  4084. * Creates a new Vector4 from a Vector3
  4085. * @param source defines the source data
  4086. * @param w defines the 4th component (default is 0)
  4087. * @returns a new Vector4
  4088. */
  4089. static FromVector3(source: Vector3, w?: number): Vector4;
  4090. }
  4091. /**
  4092. * Class used to store quaternion data
  4093. * @see https://en.wikipedia.org/wiki/Quaternion
  4094. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4095. */
  4096. export class Quaternion {
  4097. /** @hidden */
  4098. _x: number;
  4099. /** @hidden */
  4100. _y: number;
  4101. /** @hidden */
  4102. _z: number;
  4103. /** @hidden */
  4104. _w: number;
  4105. /** @hidden */
  4106. _isDirty: boolean;
  4107. /** Gets or sets the x coordinate */
  4108. get x(): number;
  4109. set x(value: number);
  4110. /** Gets or sets the y coordinate */
  4111. get y(): number;
  4112. set y(value: number);
  4113. /** Gets or sets the z coordinate */
  4114. get z(): number;
  4115. set z(value: number);
  4116. /** Gets or sets the w coordinate */
  4117. get w(): number;
  4118. set w(value: number);
  4119. /**
  4120. * Creates a new Quaternion from the given floats
  4121. * @param x defines the first component (0 by default)
  4122. * @param y defines the second component (0 by default)
  4123. * @param z defines the third component (0 by default)
  4124. * @param w defines the fourth component (1.0 by default)
  4125. */
  4126. constructor(x?: number, y?: number, z?: number, w?: number);
  4127. /**
  4128. * Gets a string representation for the current quaternion
  4129. * @returns a string with the Quaternion coordinates
  4130. */
  4131. toString(): string;
  4132. /**
  4133. * Gets the class name of the quaternion
  4134. * @returns the string "Quaternion"
  4135. */
  4136. getClassName(): string;
  4137. /**
  4138. * Gets a hash code for this quaternion
  4139. * @returns the quaternion hash code
  4140. */
  4141. getHashCode(): number;
  4142. /**
  4143. * Copy the quaternion to an array
  4144. * @returns a new array populated with 4 elements from the quaternion coordinates
  4145. */
  4146. asArray(): number[];
  4147. /**
  4148. * Check if two quaternions are equals
  4149. * @param otherQuaternion defines the second operand
  4150. * @return true if the current quaternion and the given one coordinates are strictly equals
  4151. */
  4152. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4153. /**
  4154. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4155. * @param otherQuaternion defines the other quaternion
  4156. * @param epsilon defines the minimal distance to consider equality
  4157. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4158. */
  4159. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4160. /**
  4161. * Clone the current quaternion
  4162. * @returns a new quaternion copied from the current one
  4163. */
  4164. clone(): Quaternion;
  4165. /**
  4166. * Copy a quaternion to the current one
  4167. * @param other defines the other quaternion
  4168. * @returns the updated current quaternion
  4169. */
  4170. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4171. /**
  4172. * Updates the current quaternion with the given float coordinates
  4173. * @param x defines the x coordinate
  4174. * @param y defines the y coordinate
  4175. * @param z defines the z coordinate
  4176. * @param w defines the w coordinate
  4177. * @returns the updated current quaternion
  4178. */
  4179. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4180. /**
  4181. * Updates the current quaternion from the given float coordinates
  4182. * @param x defines the x coordinate
  4183. * @param y defines the y coordinate
  4184. * @param z defines the z coordinate
  4185. * @param w defines the w coordinate
  4186. * @returns the updated current quaternion
  4187. */
  4188. set(x: number, y: number, z: number, w: number): Quaternion;
  4189. /**
  4190. * Adds two quaternions
  4191. * @param other defines the second operand
  4192. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4193. */
  4194. add(other: DeepImmutable<Quaternion>): Quaternion;
  4195. /**
  4196. * Add a quaternion to the current one
  4197. * @param other defines the quaternion to add
  4198. * @returns the current quaternion
  4199. */
  4200. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4201. /**
  4202. * Subtract two quaternions
  4203. * @param other defines the second operand
  4204. * @returns a new quaternion as the subtraction result of the given one from the current one
  4205. */
  4206. subtract(other: Quaternion): Quaternion;
  4207. /**
  4208. * Multiplies the current quaternion by a scale factor
  4209. * @param value defines the scale factor
  4210. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4211. */
  4212. scale(value: number): Quaternion;
  4213. /**
  4214. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4215. * @param scale defines the scale factor
  4216. * @param result defines the Quaternion object where to store the result
  4217. * @returns the unmodified current quaternion
  4218. */
  4219. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4220. /**
  4221. * Multiplies in place the current quaternion by a scale factor
  4222. * @param value defines the scale factor
  4223. * @returns the current modified quaternion
  4224. */
  4225. scaleInPlace(value: number): Quaternion;
  4226. /**
  4227. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4228. * @param scale defines the scale factor
  4229. * @param result defines the Quaternion object where to store the result
  4230. * @returns the unmodified current quaternion
  4231. */
  4232. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4233. /**
  4234. * Multiplies two quaternions
  4235. * @param q1 defines the second operand
  4236. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4237. */
  4238. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4239. /**
  4240. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4241. * @param q1 defines the second operand
  4242. * @param result defines the target quaternion
  4243. * @returns the current quaternion
  4244. */
  4245. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4246. /**
  4247. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4248. * @param q1 defines the second operand
  4249. * @returns the currentupdated quaternion
  4250. */
  4251. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4252. /**
  4253. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4254. * @param ref defines the target quaternion
  4255. * @returns the current quaternion
  4256. */
  4257. conjugateToRef(ref: Quaternion): Quaternion;
  4258. /**
  4259. * Conjugates in place (1-q) the current quaternion
  4260. * @returns the current updated quaternion
  4261. */
  4262. conjugateInPlace(): Quaternion;
  4263. /**
  4264. * Conjugates in place (1-q) the current quaternion
  4265. * @returns a new quaternion
  4266. */
  4267. conjugate(): Quaternion;
  4268. /**
  4269. * Gets length of current quaternion
  4270. * @returns the quaternion length (float)
  4271. */
  4272. length(): number;
  4273. /**
  4274. * Normalize in place the current quaternion
  4275. * @returns the current updated quaternion
  4276. */
  4277. normalize(): Quaternion;
  4278. /**
  4279. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4280. * @param order is a reserved parameter and is ignored for now
  4281. * @returns a new Vector3 containing the Euler angles
  4282. */
  4283. toEulerAngles(order?: string): Vector3;
  4284. /**
  4285. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4286. * @param result defines the vector which will be filled with the Euler angles
  4287. * @returns the current unchanged quaternion
  4288. */
  4289. toEulerAnglesToRef(result: Vector3): Quaternion;
  4290. /**
  4291. * Updates the given rotation matrix with the current quaternion values
  4292. * @param result defines the target matrix
  4293. * @returns the current unchanged quaternion
  4294. */
  4295. toRotationMatrix(result: Matrix): Quaternion;
  4296. /**
  4297. * Updates the current quaternion from the given rotation matrix values
  4298. * @param matrix defines the source matrix
  4299. * @returns the current updated quaternion
  4300. */
  4301. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4302. /**
  4303. * Creates a new quaternion from a rotation matrix
  4304. * @param matrix defines the source matrix
  4305. * @returns a new quaternion created from the given rotation matrix values
  4306. */
  4307. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4308. /**
  4309. * Updates the given quaternion with the given rotation matrix values
  4310. * @param matrix defines the source matrix
  4311. * @param result defines the target quaternion
  4312. */
  4313. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4314. /**
  4315. * Returns the dot product (float) between the quaternions "left" and "right"
  4316. * @param left defines the left operand
  4317. * @param right defines the right operand
  4318. * @returns the dot product
  4319. */
  4320. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4321. /**
  4322. * Checks if the two quaternions are close to each other
  4323. * @param quat0 defines the first quaternion to check
  4324. * @param quat1 defines the second quaternion to check
  4325. * @returns true if the two quaternions are close to each other
  4326. */
  4327. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4328. /**
  4329. * Creates an empty quaternion
  4330. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4331. */
  4332. static Zero(): Quaternion;
  4333. /**
  4334. * Inverse a given quaternion
  4335. * @param q defines the source quaternion
  4336. * @returns a new quaternion as the inverted current quaternion
  4337. */
  4338. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4339. /**
  4340. * Inverse a given quaternion
  4341. * @param q defines the source quaternion
  4342. * @param result the quaternion the result will be stored in
  4343. * @returns the result quaternion
  4344. */
  4345. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4346. /**
  4347. * Creates an identity quaternion
  4348. * @returns the identity quaternion
  4349. */
  4350. static Identity(): Quaternion;
  4351. /**
  4352. * Gets a boolean indicating if the given quaternion is identity
  4353. * @param quaternion defines the quaternion to check
  4354. * @returns true if the quaternion is identity
  4355. */
  4356. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4357. /**
  4358. * Creates a quaternion from a rotation around an axis
  4359. * @param axis defines the axis to use
  4360. * @param angle defines the angle to use
  4361. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4362. */
  4363. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4364. /**
  4365. * Creates a rotation around an axis and stores it into the given quaternion
  4366. * @param axis defines the axis to use
  4367. * @param angle defines the angle to use
  4368. * @param result defines the target quaternion
  4369. * @returns the target quaternion
  4370. */
  4371. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4372. /**
  4373. * Creates a new quaternion from data stored into an array
  4374. * @param array defines the data source
  4375. * @param offset defines the offset in the source array where the data starts
  4376. * @returns a new quaternion
  4377. */
  4378. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4379. /**
  4380. * Updates the given quaternion "result" from the starting index of the given array.
  4381. * @param array the array to pull values from
  4382. * @param offset the offset into the array to start at
  4383. * @param result the quaternion to store the result in
  4384. */
  4385. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4386. /**
  4387. * Create a quaternion from Euler rotation angles
  4388. * @param x Pitch
  4389. * @param y Yaw
  4390. * @param z Roll
  4391. * @returns the new Quaternion
  4392. */
  4393. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4394. /**
  4395. * Updates a quaternion from Euler rotation angles
  4396. * @param x Pitch
  4397. * @param y Yaw
  4398. * @param z Roll
  4399. * @param result the quaternion to store the result
  4400. * @returns the updated quaternion
  4401. */
  4402. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4403. /**
  4404. * Create a quaternion from Euler rotation vector
  4405. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4406. * @returns the new Quaternion
  4407. */
  4408. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4409. /**
  4410. * Updates a quaternion from Euler rotation vector
  4411. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4412. * @param result the quaternion to store the result
  4413. * @returns the updated quaternion
  4414. */
  4415. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4416. /**
  4417. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4418. * @param yaw defines the rotation around Y axis
  4419. * @param pitch defines the rotation around X axis
  4420. * @param roll defines the rotation around Z axis
  4421. * @returns the new quaternion
  4422. */
  4423. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4424. /**
  4425. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4426. * @param yaw defines the rotation around Y axis
  4427. * @param pitch defines the rotation around X axis
  4428. * @param roll defines the rotation around Z axis
  4429. * @param result defines the target quaternion
  4430. */
  4431. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4432. /**
  4433. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4434. * @param alpha defines the rotation around first axis
  4435. * @param beta defines the rotation around second axis
  4436. * @param gamma defines the rotation around third axis
  4437. * @returns the new quaternion
  4438. */
  4439. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4440. /**
  4441. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4442. * @param alpha defines the rotation around first axis
  4443. * @param beta defines the rotation around second axis
  4444. * @param gamma defines the rotation around third axis
  4445. * @param result defines the target quaternion
  4446. */
  4447. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4448. /**
  4449. * 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)
  4450. * @param axis1 defines the first axis
  4451. * @param axis2 defines the second axis
  4452. * @param axis3 defines the third axis
  4453. * @returns the new quaternion
  4454. */
  4455. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4456. /**
  4457. * 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
  4458. * @param axis1 defines the first axis
  4459. * @param axis2 defines the second axis
  4460. * @param axis3 defines the third axis
  4461. * @param ref defines the target quaternion
  4462. */
  4463. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4464. /**
  4465. * Interpolates between two quaternions
  4466. * @param left defines first quaternion
  4467. * @param right defines second quaternion
  4468. * @param amount defines the gradient to use
  4469. * @returns the new interpolated quaternion
  4470. */
  4471. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4472. /**
  4473. * Interpolates between two quaternions and stores it into a target quaternion
  4474. * @param left defines first quaternion
  4475. * @param right defines second quaternion
  4476. * @param amount defines the gradient to use
  4477. * @param result defines the target quaternion
  4478. */
  4479. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4480. /**
  4481. * Interpolate between two quaternions using Hermite interpolation
  4482. * @param value1 defines first quaternion
  4483. * @param tangent1 defines the incoming tangent
  4484. * @param value2 defines second quaternion
  4485. * @param tangent2 defines the outgoing tangent
  4486. * @param amount defines the target quaternion
  4487. * @returns the new interpolated quaternion
  4488. */
  4489. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4490. }
  4491. /**
  4492. * Class used to store matrix data (4x4)
  4493. */
  4494. export class Matrix {
  4495. /**
  4496. * Gets the precision of matrix computations
  4497. */
  4498. static get Use64Bits(): boolean;
  4499. private static _updateFlagSeed;
  4500. private static _identityReadOnly;
  4501. private _isIdentity;
  4502. private _isIdentityDirty;
  4503. private _isIdentity3x2;
  4504. private _isIdentity3x2Dirty;
  4505. /**
  4506. * Gets the update flag of the matrix which is an unique number for the matrix.
  4507. * It will be incremented every time the matrix data change.
  4508. * You can use it to speed the comparison between two versions of the same matrix.
  4509. */
  4510. updateFlag: number;
  4511. private readonly _m;
  4512. /**
  4513. * Gets the internal data of the matrix
  4514. */
  4515. get m(): DeepImmutable<Float32Array | Array<number>>;
  4516. /** @hidden */
  4517. _markAsUpdated(): void;
  4518. /** @hidden */
  4519. private _updateIdentityStatus;
  4520. /**
  4521. * Creates an empty matrix (filled with zeros)
  4522. */
  4523. constructor();
  4524. /**
  4525. * Check if the current matrix is identity
  4526. * @returns true is the matrix is the identity matrix
  4527. */
  4528. isIdentity(): boolean;
  4529. /**
  4530. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4531. * @returns true is the matrix is the identity matrix
  4532. */
  4533. isIdentityAs3x2(): boolean;
  4534. /**
  4535. * Gets the determinant of the matrix
  4536. * @returns the matrix determinant
  4537. */
  4538. determinant(): number;
  4539. /**
  4540. * Returns the matrix as a Float32Array or Array<number>
  4541. * @returns the matrix underlying array
  4542. */
  4543. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4544. /**
  4545. * Returns the matrix as a Float32Array or Array<number>
  4546. * @returns the matrix underlying array.
  4547. */
  4548. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4549. /**
  4550. * Inverts the current matrix in place
  4551. * @returns the current inverted matrix
  4552. */
  4553. invert(): Matrix;
  4554. /**
  4555. * Sets all the matrix elements to zero
  4556. * @returns the current matrix
  4557. */
  4558. reset(): Matrix;
  4559. /**
  4560. * Adds the current matrix with a second one
  4561. * @param other defines the matrix to add
  4562. * @returns a new matrix as the addition of the current matrix and the given one
  4563. */
  4564. add(other: DeepImmutable<Matrix>): Matrix;
  4565. /**
  4566. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4567. * @param other defines the matrix to add
  4568. * @param result defines the target matrix
  4569. * @returns the current matrix
  4570. */
  4571. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4572. /**
  4573. * Adds in place the given matrix to the current matrix
  4574. * @param other defines the second operand
  4575. * @returns the current updated matrix
  4576. */
  4577. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4578. /**
  4579. * Sets the given matrix to the current inverted Matrix
  4580. * @param other defines the target matrix
  4581. * @returns the unmodified current matrix
  4582. */
  4583. invertToRef(other: Matrix): Matrix;
  4584. /**
  4585. * add a value at the specified position in the current Matrix
  4586. * @param index the index of the value within the matrix. between 0 and 15.
  4587. * @param value the value to be added
  4588. * @returns the current updated matrix
  4589. */
  4590. addAtIndex(index: number, value: number): Matrix;
  4591. /**
  4592. * mutiply the specified position in the current Matrix by a value
  4593. * @param index the index of the value within the matrix. between 0 and 15.
  4594. * @param value the value to be added
  4595. * @returns the current updated matrix
  4596. */
  4597. multiplyAtIndex(index: number, value: number): Matrix;
  4598. /**
  4599. * Inserts the translation vector (using 3 floats) in the current matrix
  4600. * @param x defines the 1st component of the translation
  4601. * @param y defines the 2nd component of the translation
  4602. * @param z defines the 3rd component of the translation
  4603. * @returns the current updated matrix
  4604. */
  4605. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4606. /**
  4607. * Adds the translation vector (using 3 floats) in the current matrix
  4608. * @param x defines the 1st component of the translation
  4609. * @param y defines the 2nd component of the translation
  4610. * @param z defines the 3rd component of the translation
  4611. * @returns the current updated matrix
  4612. */
  4613. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4614. /**
  4615. * Inserts the translation vector in the current matrix
  4616. * @param vector3 defines the translation to insert
  4617. * @returns the current updated matrix
  4618. */
  4619. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4620. /**
  4621. * Gets the translation value of the current matrix
  4622. * @returns a new Vector3 as the extracted translation from the matrix
  4623. */
  4624. getTranslation(): Vector3;
  4625. /**
  4626. * Fill a Vector3 with the extracted translation from the matrix
  4627. * @param result defines the Vector3 where to store the translation
  4628. * @returns the current matrix
  4629. */
  4630. getTranslationToRef(result: Vector3): Matrix;
  4631. /**
  4632. * Remove rotation and scaling part from the matrix
  4633. * @returns the updated matrix
  4634. */
  4635. removeRotationAndScaling(): Matrix;
  4636. /**
  4637. * Multiply two matrices
  4638. * @param other defines the second operand
  4639. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4640. */
  4641. multiply(other: DeepImmutable<Matrix>): Matrix;
  4642. /**
  4643. * Copy the current matrix from the given one
  4644. * @param other defines the source matrix
  4645. * @returns the current updated matrix
  4646. */
  4647. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4648. /**
  4649. * Populates the given array from the starting index with the current matrix values
  4650. * @param array defines the target array
  4651. * @param offset defines the offset in the target array where to start storing values
  4652. * @returns the current matrix
  4653. */
  4654. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4655. /**
  4656. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4657. * @param other defines the second operand
  4658. * @param result defines the matrix where to store the multiplication
  4659. * @returns the current matrix
  4660. */
  4661. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4662. /**
  4663. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4664. * @param other defines the second operand
  4665. * @param result defines the array where to store the multiplication
  4666. * @param offset defines the offset in the target array where to start storing values
  4667. * @returns the current matrix
  4668. */
  4669. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4670. /**
  4671. * Check equality between this matrix and a second one
  4672. * @param value defines the second matrix to compare
  4673. * @returns true is the current matrix and the given one values are strictly equal
  4674. */
  4675. equals(value: DeepImmutable<Matrix>): boolean;
  4676. /**
  4677. * Clone the current matrix
  4678. * @returns a new matrix from the current matrix
  4679. */
  4680. clone(): Matrix;
  4681. /**
  4682. * Returns the name of the current matrix class
  4683. * @returns the string "Matrix"
  4684. */
  4685. getClassName(): string;
  4686. /**
  4687. * Gets the hash code of the current matrix
  4688. * @returns the hash code
  4689. */
  4690. getHashCode(): number;
  4691. /**
  4692. * Decomposes the current Matrix into a translation, rotation and scaling components
  4693. * @param scale defines the scale vector3 given as a reference to update
  4694. * @param rotation defines the rotation quaternion given as a reference to update
  4695. * @param translation defines the translation vector3 given as a reference to update
  4696. * @returns true if operation was successful
  4697. */
  4698. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4699. /**
  4700. * Gets specific row of the matrix
  4701. * @param index defines the number of the row to get
  4702. * @returns the index-th row of the current matrix as a new Vector4
  4703. */
  4704. getRow(index: number): Nullable<Vector4>;
  4705. /**
  4706. * Sets the index-th row of the current matrix to the vector4 values
  4707. * @param index defines the number of the row to set
  4708. * @param row defines the target vector4
  4709. * @returns the updated current matrix
  4710. */
  4711. setRow(index: number, row: Vector4): Matrix;
  4712. /**
  4713. * Compute the transpose of the matrix
  4714. * @returns the new transposed matrix
  4715. */
  4716. transpose(): Matrix;
  4717. /**
  4718. * Compute the transpose of the matrix and store it in a given matrix
  4719. * @param result defines the target matrix
  4720. * @returns the current matrix
  4721. */
  4722. transposeToRef(result: Matrix): Matrix;
  4723. /**
  4724. * Sets the index-th row of the current matrix with the given 4 x float values
  4725. * @param index defines the row index
  4726. * @param x defines the x component to set
  4727. * @param y defines the y component to set
  4728. * @param z defines the z component to set
  4729. * @param w defines the w component to set
  4730. * @returns the updated current matrix
  4731. */
  4732. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4733. /**
  4734. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4735. * @param scale defines the scale factor
  4736. * @returns a new matrix
  4737. */
  4738. scale(scale: number): Matrix;
  4739. /**
  4740. * Scale the current matrix values by a factor to a given result matrix
  4741. * @param scale defines the scale factor
  4742. * @param result defines the matrix to store the result
  4743. * @returns the current matrix
  4744. */
  4745. scaleToRef(scale: number, result: Matrix): Matrix;
  4746. /**
  4747. * Scale the current matrix values by a factor and add the result to a given matrix
  4748. * @param scale defines the scale factor
  4749. * @param result defines the Matrix to store the result
  4750. * @returns the current matrix
  4751. */
  4752. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4753. /**
  4754. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4755. * @param ref matrix to store the result
  4756. */
  4757. toNormalMatrix(ref: Matrix): void;
  4758. /**
  4759. * Gets only rotation part of the current matrix
  4760. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4761. */
  4762. getRotationMatrix(): Matrix;
  4763. /**
  4764. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4765. * @param result defines the target matrix to store data to
  4766. * @returns the current matrix
  4767. */
  4768. getRotationMatrixToRef(result: Matrix): Matrix;
  4769. /**
  4770. * Toggles model matrix from being right handed to left handed in place and vice versa
  4771. */
  4772. toggleModelMatrixHandInPlace(): void;
  4773. /**
  4774. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4775. */
  4776. toggleProjectionMatrixHandInPlace(): void;
  4777. /**
  4778. * Creates a matrix from an array
  4779. * @param array defines the source array
  4780. * @param offset defines an offset in the source array
  4781. * @returns a new Matrix set from the starting index of the given array
  4782. */
  4783. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4784. /**
  4785. * Copy the content of an array into a given matrix
  4786. * @param array defines the source array
  4787. * @param offset defines an offset in the source array
  4788. * @param result defines the target matrix
  4789. */
  4790. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4791. /**
  4792. * Stores an array into a matrix after having multiplied each component by a given factor
  4793. * @param array defines the source array
  4794. * @param offset defines the offset in the source array
  4795. * @param scale defines the scaling factor
  4796. * @param result defines the target matrix
  4797. */
  4798. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4799. /**
  4800. * Gets an identity matrix that must not be updated
  4801. */
  4802. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4803. /**
  4804. * Stores a list of values (16) inside a given matrix
  4805. * @param initialM11 defines 1st value of 1st row
  4806. * @param initialM12 defines 2nd value of 1st row
  4807. * @param initialM13 defines 3rd value of 1st row
  4808. * @param initialM14 defines 4th value of 1st row
  4809. * @param initialM21 defines 1st value of 2nd row
  4810. * @param initialM22 defines 2nd value of 2nd row
  4811. * @param initialM23 defines 3rd value of 2nd row
  4812. * @param initialM24 defines 4th value of 2nd row
  4813. * @param initialM31 defines 1st value of 3rd row
  4814. * @param initialM32 defines 2nd value of 3rd row
  4815. * @param initialM33 defines 3rd value of 3rd row
  4816. * @param initialM34 defines 4th value of 3rd row
  4817. * @param initialM41 defines 1st value of 4th row
  4818. * @param initialM42 defines 2nd value of 4th row
  4819. * @param initialM43 defines 3rd value of 4th row
  4820. * @param initialM44 defines 4th value of 4th row
  4821. * @param result defines the target matrix
  4822. */
  4823. 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;
  4824. /**
  4825. * Creates new matrix from a list of values (16)
  4826. * @param initialM11 defines 1st value of 1st row
  4827. * @param initialM12 defines 2nd value of 1st row
  4828. * @param initialM13 defines 3rd value of 1st row
  4829. * @param initialM14 defines 4th value of 1st row
  4830. * @param initialM21 defines 1st value of 2nd row
  4831. * @param initialM22 defines 2nd value of 2nd row
  4832. * @param initialM23 defines 3rd value of 2nd row
  4833. * @param initialM24 defines 4th value of 2nd row
  4834. * @param initialM31 defines 1st value of 3rd row
  4835. * @param initialM32 defines 2nd value of 3rd row
  4836. * @param initialM33 defines 3rd value of 3rd row
  4837. * @param initialM34 defines 4th value of 3rd row
  4838. * @param initialM41 defines 1st value of 4th row
  4839. * @param initialM42 defines 2nd value of 4th row
  4840. * @param initialM43 defines 3rd value of 4th row
  4841. * @param initialM44 defines 4th value of 4th row
  4842. * @returns the new matrix
  4843. */
  4844. 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;
  4845. /**
  4846. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4847. * @param scale defines the scale vector3
  4848. * @param rotation defines the rotation quaternion
  4849. * @param translation defines the translation vector3
  4850. * @returns a new matrix
  4851. */
  4852. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4853. /**
  4854. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4855. * @param scale defines the scale vector3
  4856. * @param rotation defines the rotation quaternion
  4857. * @param translation defines the translation vector3
  4858. * @param result defines the target matrix
  4859. */
  4860. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4861. /**
  4862. * Creates a new identity matrix
  4863. * @returns a new identity matrix
  4864. */
  4865. static Identity(): Matrix;
  4866. /**
  4867. * Creates a new identity matrix and stores the result in a given matrix
  4868. * @param result defines the target matrix
  4869. */
  4870. static IdentityToRef(result: Matrix): void;
  4871. /**
  4872. * Creates a new zero matrix
  4873. * @returns a new zero matrix
  4874. */
  4875. static Zero(): Matrix;
  4876. /**
  4877. * Creates a new rotation matrix for "angle" radians around the X axis
  4878. * @param angle defines the angle (in radians) to use
  4879. * @return the new matrix
  4880. */
  4881. static RotationX(angle: number): Matrix;
  4882. /**
  4883. * Creates a new matrix as the invert of a given matrix
  4884. * @param source defines the source matrix
  4885. * @returns the new matrix
  4886. */
  4887. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4888. /**
  4889. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4890. * @param angle defines the angle (in radians) to use
  4891. * @param result defines the target matrix
  4892. */
  4893. static RotationXToRef(angle: number, result: Matrix): void;
  4894. /**
  4895. * Creates a new rotation matrix for "angle" radians around the Y axis
  4896. * @param angle defines the angle (in radians) to use
  4897. * @return the new matrix
  4898. */
  4899. static RotationY(angle: number): Matrix;
  4900. /**
  4901. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4902. * @param angle defines the angle (in radians) to use
  4903. * @param result defines the target matrix
  4904. */
  4905. static RotationYToRef(angle: number, result: Matrix): void;
  4906. /**
  4907. * Creates a new rotation matrix for "angle" radians around the Z axis
  4908. * @param angle defines the angle (in radians) to use
  4909. * @return the new matrix
  4910. */
  4911. static RotationZ(angle: number): Matrix;
  4912. /**
  4913. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4914. * @param angle defines the angle (in radians) to use
  4915. * @param result defines the target matrix
  4916. */
  4917. static RotationZToRef(angle: number, result: Matrix): void;
  4918. /**
  4919. * Creates a new rotation matrix for "angle" radians around the given axis
  4920. * @param axis defines the axis to use
  4921. * @param angle defines the angle (in radians) to use
  4922. * @return the new matrix
  4923. */
  4924. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4925. /**
  4926. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4927. * @param axis defines the axis to use
  4928. * @param angle defines the angle (in radians) to use
  4929. * @param result defines the target matrix
  4930. */
  4931. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4932. /**
  4933. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4934. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4935. * @param from defines the vector to align
  4936. * @param to defines the vector to align to
  4937. * @param result defines the target matrix
  4938. */
  4939. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4940. /**
  4941. * Creates a rotation matrix
  4942. * @param yaw defines the yaw angle in radians (Y axis)
  4943. * @param pitch defines the pitch angle in radians (X axis)
  4944. * @param roll defines the roll angle in radians (Z axis)
  4945. * @returns the new rotation matrix
  4946. */
  4947. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4948. /**
  4949. * Creates a rotation matrix and stores it in a given matrix
  4950. * @param yaw defines the yaw angle in radians (Y axis)
  4951. * @param pitch defines the pitch angle in radians (X axis)
  4952. * @param roll defines the roll angle in radians (Z axis)
  4953. * @param result defines the target matrix
  4954. */
  4955. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4956. /**
  4957. * Creates a scaling matrix
  4958. * @param x defines the scale factor on X axis
  4959. * @param y defines the scale factor on Y axis
  4960. * @param z defines the scale factor on Z axis
  4961. * @returns the new matrix
  4962. */
  4963. static Scaling(x: number, y: number, z: number): Matrix;
  4964. /**
  4965. * Creates a scaling matrix and stores it in a given matrix
  4966. * @param x defines the scale factor on X axis
  4967. * @param y defines the scale factor on Y axis
  4968. * @param z defines the scale factor on Z axis
  4969. * @param result defines the target matrix
  4970. */
  4971. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4972. /**
  4973. * Creates a translation matrix
  4974. * @param x defines the translation on X axis
  4975. * @param y defines the translation on Y axis
  4976. * @param z defines the translationon Z axis
  4977. * @returns the new matrix
  4978. */
  4979. static Translation(x: number, y: number, z: number): Matrix;
  4980. /**
  4981. * Creates a translation matrix and stores it in a given matrix
  4982. * @param x defines the translation on X axis
  4983. * @param y defines the translation on Y axis
  4984. * @param z defines the translationon Z axis
  4985. * @param result defines the target matrix
  4986. */
  4987. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4988. /**
  4989. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4990. * @param startValue defines the start value
  4991. * @param endValue defines the end value
  4992. * @param gradient defines the gradient factor
  4993. * @returns the new matrix
  4994. */
  4995. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4996. /**
  4997. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4998. * @param startValue defines the start value
  4999. * @param endValue defines the end value
  5000. * @param gradient defines the gradient factor
  5001. * @param result defines the Matrix object where to store data
  5002. */
  5003. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5004. /**
  5005. * Builds a new matrix whose values are computed by:
  5006. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5007. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5008. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5009. * @param startValue defines the first matrix
  5010. * @param endValue defines the second matrix
  5011. * @param gradient defines the gradient between the two matrices
  5012. * @returns the new matrix
  5013. */
  5014. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5015. /**
  5016. * Update a matrix to values which are computed by:
  5017. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5018. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5019. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5020. * @param startValue defines the first matrix
  5021. * @param endValue defines the second matrix
  5022. * @param gradient defines the gradient between the two matrices
  5023. * @param result defines the target matrix
  5024. */
  5025. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5026. /**
  5027. * 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"
  5028. * This function works in left handed mode
  5029. * @param eye defines the final position of the entity
  5030. * @param target defines where the entity should look at
  5031. * @param up defines the up vector for the entity
  5032. * @returns the new matrix
  5033. */
  5034. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5035. /**
  5036. * 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".
  5037. * This function works in left handed mode
  5038. * @param eye defines the final position of the entity
  5039. * @param target defines where the entity should look at
  5040. * @param up defines the up vector for the entity
  5041. * @param result defines the target matrix
  5042. */
  5043. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5044. /**
  5045. * 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"
  5046. * This function works in right handed mode
  5047. * @param eye defines the final position of the entity
  5048. * @param target defines where the entity should look at
  5049. * @param up defines the up vector for the entity
  5050. * @returns the new matrix
  5051. */
  5052. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5053. /**
  5054. * 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".
  5055. * This function works in right handed mode
  5056. * @param eye defines the final position of the entity
  5057. * @param target defines where the entity should look at
  5058. * @param up defines the up vector for the entity
  5059. * @param result defines the target matrix
  5060. */
  5061. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5062. /**
  5063. * Create a left-handed orthographic projection matrix
  5064. * @param width defines the viewport width
  5065. * @param height defines the viewport height
  5066. * @param znear defines the near clip plane
  5067. * @param zfar defines the far clip plane
  5068. * @returns a new matrix as a left-handed orthographic projection matrix
  5069. */
  5070. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5071. /**
  5072. * Store a left-handed orthographic projection to a given matrix
  5073. * @param width defines the viewport width
  5074. * @param height defines the viewport height
  5075. * @param znear defines the near clip plane
  5076. * @param zfar defines the far clip plane
  5077. * @param result defines the target matrix
  5078. */
  5079. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5080. /**
  5081. * Create a left-handed orthographic projection matrix
  5082. * @param left defines the viewport left coordinate
  5083. * @param right defines the viewport right coordinate
  5084. * @param bottom defines the viewport bottom coordinate
  5085. * @param top defines the viewport top coordinate
  5086. * @param znear defines the near clip plane
  5087. * @param zfar defines the far clip plane
  5088. * @returns a new matrix as a left-handed orthographic projection matrix
  5089. */
  5090. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5091. /**
  5092. * Stores a left-handed orthographic projection into a given matrix
  5093. * @param left defines the viewport left coordinate
  5094. * @param right defines the viewport right coordinate
  5095. * @param bottom defines the viewport bottom coordinate
  5096. * @param top defines the viewport top coordinate
  5097. * @param znear defines the near clip plane
  5098. * @param zfar defines the far clip plane
  5099. * @param result defines the target matrix
  5100. */
  5101. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5102. /**
  5103. * Creates a right-handed orthographic projection matrix
  5104. * @param left defines the viewport left coordinate
  5105. * @param right defines the viewport right coordinate
  5106. * @param bottom defines the viewport bottom coordinate
  5107. * @param top defines the viewport top coordinate
  5108. * @param znear defines the near clip plane
  5109. * @param zfar defines the far clip plane
  5110. * @returns a new matrix as a right-handed orthographic projection matrix
  5111. */
  5112. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5113. /**
  5114. * Stores a right-handed orthographic projection into a given matrix
  5115. * @param left defines the viewport left coordinate
  5116. * @param right defines the viewport right coordinate
  5117. * @param bottom defines the viewport bottom coordinate
  5118. * @param top defines the viewport top coordinate
  5119. * @param znear defines the near clip plane
  5120. * @param zfar defines the far clip plane
  5121. * @param result defines the target matrix
  5122. */
  5123. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5124. /**
  5125. * Creates a left-handed perspective projection matrix
  5126. * @param width defines the viewport width
  5127. * @param height defines the viewport height
  5128. * @param znear defines the near clip plane
  5129. * @param zfar defines the far clip plane
  5130. * @returns a new matrix as a left-handed perspective projection matrix
  5131. */
  5132. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5133. /**
  5134. * Creates a left-handed perspective projection matrix
  5135. * @param fov defines the horizontal field of view
  5136. * @param aspect defines the aspect ratio
  5137. * @param znear defines the near clip plane
  5138. * @param zfar defines the far clip plane
  5139. * @returns a new matrix as a left-handed perspective projection matrix
  5140. */
  5141. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5142. /**
  5143. * Stores a left-handed perspective projection into a given matrix
  5144. * @param fov defines the horizontal field of view
  5145. * @param aspect defines the aspect ratio
  5146. * @param znear defines the near clip plane
  5147. * @param zfar defines the far clip plane
  5148. * @param result defines the target matrix
  5149. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5150. */
  5151. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5152. /**
  5153. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5154. * @param fov defines the horizontal field of view
  5155. * @param aspect defines the aspect ratio
  5156. * @param znear defines the near clip plane
  5157. * @param zfar not used as infinity is used as far clip
  5158. * @param result defines the target matrix
  5159. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5160. */
  5161. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5162. /**
  5163. * Creates a right-handed perspective projection matrix
  5164. * @param fov defines the horizontal field of view
  5165. * @param aspect defines the aspect ratio
  5166. * @param znear defines the near clip plane
  5167. * @param zfar defines the far clip plane
  5168. * @returns a new matrix as a right-handed perspective projection matrix
  5169. */
  5170. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5171. /**
  5172. * Stores a right-handed perspective projection into a given matrix
  5173. * @param fov defines the horizontal field of view
  5174. * @param aspect defines the aspect ratio
  5175. * @param znear defines the near clip plane
  5176. * @param zfar defines the far clip plane
  5177. * @param result defines the target matrix
  5178. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5179. */
  5180. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5181. /**
  5182. * Stores a right-handed perspective projection into a given matrix
  5183. * @param fov defines the horizontal field of view
  5184. * @param aspect defines the aspect ratio
  5185. * @param znear defines the near clip plane
  5186. * @param zfar not used as infinity is used as far clip
  5187. * @param result defines the target matrix
  5188. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5189. */
  5190. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5191. /**
  5192. * Stores a perspective projection for WebVR info a given matrix
  5193. * @param fov defines the field of view
  5194. * @param znear defines the near clip plane
  5195. * @param zfar defines the far clip plane
  5196. * @param result defines the target matrix
  5197. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5198. */
  5199. static PerspectiveFovWebVRToRef(fov: {
  5200. upDegrees: number;
  5201. downDegrees: number;
  5202. leftDegrees: number;
  5203. rightDegrees: number;
  5204. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5205. /**
  5206. * Computes a complete transformation matrix
  5207. * @param viewport defines the viewport to use
  5208. * @param world defines the world matrix
  5209. * @param view defines the view matrix
  5210. * @param projection defines the projection matrix
  5211. * @param zmin defines the near clip plane
  5212. * @param zmax defines the far clip plane
  5213. * @returns the transformation matrix
  5214. */
  5215. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5216. /**
  5217. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5218. * @param matrix defines the matrix to use
  5219. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5220. */
  5221. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5222. /**
  5223. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5224. * @param matrix defines the matrix to use
  5225. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5226. */
  5227. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5228. /**
  5229. * Compute the transpose of a given matrix
  5230. * @param matrix defines the matrix to transpose
  5231. * @returns the new matrix
  5232. */
  5233. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5234. /**
  5235. * Compute the transpose of a matrix and store it in a target matrix
  5236. * @param matrix defines the matrix to transpose
  5237. * @param result defines the target matrix
  5238. */
  5239. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5240. /**
  5241. * Computes a reflection matrix from a plane
  5242. * @param plane defines the reflection plane
  5243. * @returns a new matrix
  5244. */
  5245. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5246. /**
  5247. * Computes a reflection matrix from a plane
  5248. * @param plane defines the reflection plane
  5249. * @param result defines the target matrix
  5250. */
  5251. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5252. /**
  5253. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5254. * @param xaxis defines the value of the 1st axis
  5255. * @param yaxis defines the value of the 2nd axis
  5256. * @param zaxis defines the value of the 3rd axis
  5257. * @param result defines the target matrix
  5258. */
  5259. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5260. /**
  5261. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5262. * @param quat defines the quaternion to use
  5263. * @param result defines the target matrix
  5264. */
  5265. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5266. }
  5267. /**
  5268. * @hidden
  5269. */
  5270. export class TmpVectors {
  5271. static Vector2: Vector2[];
  5272. static Vector3: Vector3[];
  5273. static Vector4: Vector4[];
  5274. static Quaternion: Quaternion[];
  5275. static Matrix: Matrix[];
  5276. }
  5277. }
  5278. declare module "babylonjs/Maths/math.path" {
  5279. import { DeepImmutable, Nullable } from "babylonjs/types";
  5280. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5281. /**
  5282. * Defines potential orientation for back face culling
  5283. */
  5284. export enum Orientation {
  5285. /**
  5286. * Clockwise
  5287. */
  5288. CW = 0,
  5289. /** Counter clockwise */
  5290. CCW = 1
  5291. }
  5292. /** Class used to represent a Bezier curve */
  5293. export class BezierCurve {
  5294. /**
  5295. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5296. * @param t defines the time
  5297. * @param x1 defines the left coordinate on X axis
  5298. * @param y1 defines the left coordinate on Y axis
  5299. * @param x2 defines the right coordinate on X axis
  5300. * @param y2 defines the right coordinate on Y axis
  5301. * @returns the interpolated value
  5302. */
  5303. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5304. }
  5305. /**
  5306. * Defines angle representation
  5307. */
  5308. export class Angle {
  5309. private _radians;
  5310. /**
  5311. * Creates an Angle object of "radians" radians (float).
  5312. * @param radians the angle in radians
  5313. */
  5314. constructor(radians: number);
  5315. /**
  5316. * Get value in degrees
  5317. * @returns the Angle value in degrees (float)
  5318. */
  5319. degrees(): number;
  5320. /**
  5321. * Get value in radians
  5322. * @returns the Angle value in radians (float)
  5323. */
  5324. radians(): number;
  5325. /**
  5326. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5327. * @param a defines first point as the origin
  5328. * @param b defines point
  5329. * @returns a new Angle
  5330. */
  5331. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5332. /**
  5333. * Gets a new Angle object from the given float in radians
  5334. * @param radians defines the angle value in radians
  5335. * @returns a new Angle
  5336. */
  5337. static FromRadians(radians: number): Angle;
  5338. /**
  5339. * Gets a new Angle object from the given float in degrees
  5340. * @param degrees defines the angle value in degrees
  5341. * @returns a new Angle
  5342. */
  5343. static FromDegrees(degrees: number): Angle;
  5344. }
  5345. /**
  5346. * This represents an arc in a 2d space.
  5347. */
  5348. export class Arc2 {
  5349. /** Defines the start point of the arc */
  5350. startPoint: Vector2;
  5351. /** Defines the mid point of the arc */
  5352. midPoint: Vector2;
  5353. /** Defines the end point of the arc */
  5354. endPoint: Vector2;
  5355. /**
  5356. * Defines the center point of the arc.
  5357. */
  5358. centerPoint: Vector2;
  5359. /**
  5360. * Defines the radius of the arc.
  5361. */
  5362. radius: number;
  5363. /**
  5364. * Defines the angle of the arc (from mid point to end point).
  5365. */
  5366. angle: Angle;
  5367. /**
  5368. * Defines the start angle of the arc (from start point to middle point).
  5369. */
  5370. startAngle: Angle;
  5371. /**
  5372. * Defines the orientation of the arc (clock wise/counter clock wise).
  5373. */
  5374. orientation: Orientation;
  5375. /**
  5376. * Creates an Arc object from the three given points : start, middle and end.
  5377. * @param startPoint Defines the start point of the arc
  5378. * @param midPoint Defines the midlle point of the arc
  5379. * @param endPoint Defines the end point of the arc
  5380. */
  5381. constructor(
  5382. /** Defines the start point of the arc */
  5383. startPoint: Vector2,
  5384. /** Defines the mid point of the arc */
  5385. midPoint: Vector2,
  5386. /** Defines the end point of the arc */
  5387. endPoint: Vector2);
  5388. }
  5389. /**
  5390. * Represents a 2D path made up of multiple 2D points
  5391. */
  5392. export class Path2 {
  5393. private _points;
  5394. private _length;
  5395. /**
  5396. * If the path start and end point are the same
  5397. */
  5398. closed: boolean;
  5399. /**
  5400. * Creates a Path2 object from the starting 2D coordinates x and y.
  5401. * @param x the starting points x value
  5402. * @param y the starting points y value
  5403. */
  5404. constructor(x: number, y: number);
  5405. /**
  5406. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5407. * @param x the added points x value
  5408. * @param y the added points y value
  5409. * @returns the updated Path2.
  5410. */
  5411. addLineTo(x: number, y: number): Path2;
  5412. /**
  5413. * 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.
  5414. * @param midX middle point x value
  5415. * @param midY middle point y value
  5416. * @param endX end point x value
  5417. * @param endY end point y value
  5418. * @param numberOfSegments (default: 36)
  5419. * @returns the updated Path2.
  5420. */
  5421. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5422. /**
  5423. * Closes the Path2.
  5424. * @returns the Path2.
  5425. */
  5426. close(): Path2;
  5427. /**
  5428. * Gets the sum of the distance between each sequential point in the path
  5429. * @returns the Path2 total length (float).
  5430. */
  5431. length(): number;
  5432. /**
  5433. * Gets the points which construct the path
  5434. * @returns the Path2 internal array of points.
  5435. */
  5436. getPoints(): Vector2[];
  5437. /**
  5438. * Retreives the point at the distance aways from the starting point
  5439. * @param normalizedLengthPosition the length along the path to retreive the point from
  5440. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5441. */
  5442. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5443. /**
  5444. * Creates a new path starting from an x and y position
  5445. * @param x starting x value
  5446. * @param y starting y value
  5447. * @returns a new Path2 starting at the coordinates (x, y).
  5448. */
  5449. static StartingAt(x: number, y: number): Path2;
  5450. }
  5451. /**
  5452. * Represents a 3D path made up of multiple 3D points
  5453. */
  5454. export class Path3D {
  5455. /**
  5456. * an array of Vector3, the curve axis of the Path3D
  5457. */
  5458. path: Vector3[];
  5459. private _curve;
  5460. private _distances;
  5461. private _tangents;
  5462. private _normals;
  5463. private _binormals;
  5464. private _raw;
  5465. private _alignTangentsWithPath;
  5466. private readonly _pointAtData;
  5467. /**
  5468. * new Path3D(path, normal, raw)
  5469. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5470. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5471. * @param path an array of Vector3, the curve axis of the Path3D
  5472. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5473. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5474. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5475. */
  5476. constructor(
  5477. /**
  5478. * an array of Vector3, the curve axis of the Path3D
  5479. */
  5480. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5481. /**
  5482. * Returns the Path3D array of successive Vector3 designing its curve.
  5483. * @returns the Path3D array of successive Vector3 designing its curve.
  5484. */
  5485. getCurve(): Vector3[];
  5486. /**
  5487. * Returns the Path3D array of successive Vector3 designing its curve.
  5488. * @returns the Path3D array of successive Vector3 designing its curve.
  5489. */
  5490. getPoints(): Vector3[];
  5491. /**
  5492. * @returns the computed length (float) of the path.
  5493. */
  5494. length(): number;
  5495. /**
  5496. * Returns an array populated with tangent vectors on each Path3D curve point.
  5497. * @returns an array populated with tangent vectors on each Path3D curve point.
  5498. */
  5499. getTangents(): Vector3[];
  5500. /**
  5501. * Returns an array populated with normal vectors on each Path3D curve point.
  5502. * @returns an array populated with normal vectors on each Path3D curve point.
  5503. */
  5504. getNormals(): Vector3[];
  5505. /**
  5506. * Returns an array populated with binormal vectors on each Path3D curve point.
  5507. * @returns an array populated with binormal vectors on each Path3D curve point.
  5508. */
  5509. getBinormals(): Vector3[];
  5510. /**
  5511. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5512. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5513. */
  5514. getDistances(): number[];
  5515. /**
  5516. * Returns an interpolated point along this path
  5517. * @param position the position of the point along this path, from 0.0 to 1.0
  5518. * @returns a new Vector3 as the point
  5519. */
  5520. getPointAt(position: number): Vector3;
  5521. /**
  5522. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5523. * @param position the position of the point along this path, from 0.0 to 1.0
  5524. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5525. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5526. */
  5527. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5528. /**
  5529. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5530. * @param position the position of the point along this path, from 0.0 to 1.0
  5531. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5532. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5533. */
  5534. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5535. /**
  5536. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5537. * @param position the position of the point along this path, from 0.0 to 1.0
  5538. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5539. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5540. */
  5541. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5542. /**
  5543. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5544. * @param position the position of the point along this path, from 0.0 to 1.0
  5545. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5546. */
  5547. getDistanceAt(position: number): number;
  5548. /**
  5549. * Returns the array index of the previous point of an interpolated point along this path
  5550. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5551. * @returns the array index
  5552. */
  5553. getPreviousPointIndexAt(position: number): number;
  5554. /**
  5555. * 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)
  5556. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5557. * @returns the sub position
  5558. */
  5559. getSubPositionAt(position: number): number;
  5560. /**
  5561. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5562. * @param target the vector of which to get the closest position to
  5563. * @returns the position of the closest virtual point on this path to the target vector
  5564. */
  5565. getClosestPositionTo(target: Vector3): number;
  5566. /**
  5567. * Returns a sub path (slice) of this path
  5568. * @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
  5569. * @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
  5570. * @returns a sub path (slice) of this path
  5571. */
  5572. slice(start?: number, end?: number): Path3D;
  5573. /**
  5574. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5575. * @param path path which all values are copied into the curves points
  5576. * @param firstNormal which should be projected onto the curve
  5577. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5578. * @returns the same object updated.
  5579. */
  5580. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5581. private _compute;
  5582. private _getFirstNonNullVector;
  5583. private _getLastNonNullVector;
  5584. private _normalVector;
  5585. /**
  5586. * Updates the point at data for an interpolated point along this curve
  5587. * @param position the position of the point along this curve, from 0.0 to 1.0
  5588. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5589. * @returns the (updated) point at data
  5590. */
  5591. private _updatePointAtData;
  5592. /**
  5593. * Updates the point at data from the specified parameters
  5594. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5595. * @param point the interpolated point
  5596. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5597. */
  5598. private _setPointAtData;
  5599. /**
  5600. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5601. */
  5602. private _updateInterpolationMatrix;
  5603. }
  5604. /**
  5605. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5606. * A Curve3 is designed from a series of successive Vector3.
  5607. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5608. */
  5609. export class Curve3 {
  5610. private _points;
  5611. private _length;
  5612. /**
  5613. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5614. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5615. * @param v1 (Vector3) the control point
  5616. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5617. * @param nbPoints (integer) the wanted number of points in the curve
  5618. * @returns the created Curve3
  5619. */
  5620. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5621. /**
  5622. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5623. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5624. * @param v1 (Vector3) the first control point
  5625. * @param v2 (Vector3) the second control point
  5626. * @param v3 (Vector3) the end point of the Cubic Bezier
  5627. * @param nbPoints (integer) the wanted number of points in the curve
  5628. * @returns the created Curve3
  5629. */
  5630. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5631. /**
  5632. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5633. * @param p1 (Vector3) the origin point of the Hermite Spline
  5634. * @param t1 (Vector3) the tangent vector at the origin point
  5635. * @param p2 (Vector3) the end point of the Hermite Spline
  5636. * @param t2 (Vector3) the tangent vector at the end point
  5637. * @param nbPoints (integer) the wanted number of points in the curve
  5638. * @returns the created Curve3
  5639. */
  5640. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5641. /**
  5642. * Returns a Curve3 object along a CatmullRom Spline curve :
  5643. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5644. * @param nbPoints (integer) the wanted number of points between each curve control points
  5645. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5646. * @returns the created Curve3
  5647. */
  5648. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5649. /**
  5650. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5651. * A Curve3 is designed from a series of successive Vector3.
  5652. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5653. * @param points points which make up the curve
  5654. */
  5655. constructor(points: Vector3[]);
  5656. /**
  5657. * @returns the Curve3 stored array of successive Vector3
  5658. */
  5659. getPoints(): Vector3[];
  5660. /**
  5661. * @returns the computed length (float) of the curve.
  5662. */
  5663. length(): number;
  5664. /**
  5665. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5666. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5667. * curveA and curveB keep unchanged.
  5668. * @param curve the curve to continue from this curve
  5669. * @returns the newly constructed curve
  5670. */
  5671. continue(curve: DeepImmutable<Curve3>): Curve3;
  5672. private _computeLength;
  5673. }
  5674. }
  5675. declare module "babylonjs/Animations/easing" {
  5676. /**
  5677. * This represents the main contract an easing function should follow.
  5678. * Easing functions are used throughout the animation system.
  5679. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5680. */
  5681. export interface IEasingFunction {
  5682. /**
  5683. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5684. * of the easing function.
  5685. * The link below provides some of the most common examples of easing functions.
  5686. * @see https://easings.net/
  5687. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5688. * @returns the corresponding value on the curve defined by the easing function
  5689. */
  5690. ease(gradient: number): number;
  5691. }
  5692. /**
  5693. * Base class used for every default easing function.
  5694. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5695. */
  5696. export class EasingFunction implements IEasingFunction {
  5697. /**
  5698. * Interpolation follows the mathematical formula associated with the easing function.
  5699. */
  5700. static readonly EASINGMODE_EASEIN: number;
  5701. /**
  5702. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5703. */
  5704. static readonly EASINGMODE_EASEOUT: number;
  5705. /**
  5706. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5707. */
  5708. static readonly EASINGMODE_EASEINOUT: number;
  5709. private _easingMode;
  5710. /**
  5711. * Sets the easing mode of the current function.
  5712. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5713. */
  5714. setEasingMode(easingMode: number): void;
  5715. /**
  5716. * Gets the current easing mode.
  5717. * @returns the easing mode
  5718. */
  5719. getEasingMode(): number;
  5720. /**
  5721. * @hidden
  5722. */
  5723. easeInCore(gradient: number): number;
  5724. /**
  5725. * Given an input gradient between 0 and 1, this returns the corresponding value
  5726. * of the easing function.
  5727. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5728. * @returns the corresponding value on the curve defined by the easing function
  5729. */
  5730. ease(gradient: number): number;
  5731. }
  5732. /**
  5733. * Easing function with a circle shape (see link below).
  5734. * @see https://easings.net/#easeInCirc
  5735. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5736. */
  5737. export class CircleEase extends EasingFunction implements IEasingFunction {
  5738. /** @hidden */
  5739. easeInCore(gradient: number): number;
  5740. }
  5741. /**
  5742. * Easing function with a ease back shape (see link below).
  5743. * @see https://easings.net/#easeInBack
  5744. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5745. */
  5746. export class BackEase extends EasingFunction implements IEasingFunction {
  5747. /** Defines the amplitude of the function */
  5748. amplitude: number;
  5749. /**
  5750. * Instantiates a back ease easing
  5751. * @see https://easings.net/#easeInBack
  5752. * @param amplitude Defines the amplitude of the function
  5753. */
  5754. constructor(
  5755. /** Defines the amplitude of the function */
  5756. amplitude?: number);
  5757. /** @hidden */
  5758. easeInCore(gradient: number): number;
  5759. }
  5760. /**
  5761. * Easing function with a bouncing shape (see link below).
  5762. * @see https://easings.net/#easeInBounce
  5763. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5764. */
  5765. export class BounceEase extends EasingFunction implements IEasingFunction {
  5766. /** Defines the number of bounces */
  5767. bounces: number;
  5768. /** Defines the amplitude of the bounce */
  5769. bounciness: number;
  5770. /**
  5771. * Instantiates a bounce easing
  5772. * @see https://easings.net/#easeInBounce
  5773. * @param bounces Defines the number of bounces
  5774. * @param bounciness Defines the amplitude of the bounce
  5775. */
  5776. constructor(
  5777. /** Defines the number of bounces */
  5778. bounces?: number,
  5779. /** Defines the amplitude of the bounce */
  5780. bounciness?: number);
  5781. /** @hidden */
  5782. easeInCore(gradient: number): number;
  5783. }
  5784. /**
  5785. * Easing function with a power of 3 shape (see link below).
  5786. * @see https://easings.net/#easeInCubic
  5787. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5788. */
  5789. export class CubicEase extends EasingFunction implements IEasingFunction {
  5790. /** @hidden */
  5791. easeInCore(gradient: number): number;
  5792. }
  5793. /**
  5794. * Easing function with an elastic shape (see link below).
  5795. * @see https://easings.net/#easeInElastic
  5796. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5797. */
  5798. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5799. /** Defines the number of oscillations*/
  5800. oscillations: number;
  5801. /** Defines the amplitude of the oscillations*/
  5802. springiness: number;
  5803. /**
  5804. * Instantiates an elastic easing function
  5805. * @see https://easings.net/#easeInElastic
  5806. * @param oscillations Defines the number of oscillations
  5807. * @param springiness Defines the amplitude of the oscillations
  5808. */
  5809. constructor(
  5810. /** Defines the number of oscillations*/
  5811. oscillations?: number,
  5812. /** Defines the amplitude of the oscillations*/
  5813. springiness?: number);
  5814. /** @hidden */
  5815. easeInCore(gradient: number): number;
  5816. }
  5817. /**
  5818. * Easing function with an exponential shape (see link below).
  5819. * @see https://easings.net/#easeInExpo
  5820. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5821. */
  5822. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5823. /** Defines the exponent of the function */
  5824. exponent: number;
  5825. /**
  5826. * Instantiates an exponential easing function
  5827. * @see https://easings.net/#easeInExpo
  5828. * @param exponent Defines the exponent of the function
  5829. */
  5830. constructor(
  5831. /** Defines the exponent of the function */
  5832. exponent?: number);
  5833. /** @hidden */
  5834. easeInCore(gradient: number): number;
  5835. }
  5836. /**
  5837. * Easing function with a power shape (see link below).
  5838. * @see https://easings.net/#easeInQuad
  5839. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5840. */
  5841. export class PowerEase extends EasingFunction implements IEasingFunction {
  5842. /** Defines the power of the function */
  5843. power: number;
  5844. /**
  5845. * Instantiates an power base easing function
  5846. * @see https://easings.net/#easeInQuad
  5847. * @param power Defines the power of the function
  5848. */
  5849. constructor(
  5850. /** Defines the power of the function */
  5851. power?: number);
  5852. /** @hidden */
  5853. easeInCore(gradient: number): number;
  5854. }
  5855. /**
  5856. * Easing function with a power of 2 shape (see link below).
  5857. * @see https://easings.net/#easeInQuad
  5858. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5859. */
  5860. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5861. /** @hidden */
  5862. easeInCore(gradient: number): number;
  5863. }
  5864. /**
  5865. * Easing function with a power of 4 shape (see link below).
  5866. * @see https://easings.net/#easeInQuart
  5867. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5868. */
  5869. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5870. /** @hidden */
  5871. easeInCore(gradient: number): number;
  5872. }
  5873. /**
  5874. * Easing function with a power of 5 shape (see link below).
  5875. * @see https://easings.net/#easeInQuint
  5876. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5877. */
  5878. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5879. /** @hidden */
  5880. easeInCore(gradient: number): number;
  5881. }
  5882. /**
  5883. * Easing function with a sin shape (see link below).
  5884. * @see https://easings.net/#easeInSine
  5885. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5886. */
  5887. export class SineEase extends EasingFunction implements IEasingFunction {
  5888. /** @hidden */
  5889. easeInCore(gradient: number): number;
  5890. }
  5891. /**
  5892. * Easing function with a bezier shape (see link below).
  5893. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5894. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5895. */
  5896. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5897. /** Defines the x component of the start tangent in the bezier curve */
  5898. x1: number;
  5899. /** Defines the y component of the start tangent in the bezier curve */
  5900. y1: number;
  5901. /** Defines the x component of the end tangent in the bezier curve */
  5902. x2: number;
  5903. /** Defines the y component of the end tangent in the bezier curve */
  5904. y2: number;
  5905. /**
  5906. * Instantiates a bezier function
  5907. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5908. * @param x1 Defines the x component of the start tangent in the bezier curve
  5909. * @param y1 Defines the y component of the start tangent in the bezier curve
  5910. * @param x2 Defines the x component of the end tangent in the bezier curve
  5911. * @param y2 Defines the y component of the end tangent in the bezier curve
  5912. */
  5913. constructor(
  5914. /** Defines the x component of the start tangent in the bezier curve */
  5915. x1?: number,
  5916. /** Defines the y component of the start tangent in the bezier curve */
  5917. y1?: number,
  5918. /** Defines the x component of the end tangent in the bezier curve */
  5919. x2?: number,
  5920. /** Defines the y component of the end tangent in the bezier curve */
  5921. y2?: number);
  5922. /** @hidden */
  5923. easeInCore(gradient: number): number;
  5924. }
  5925. }
  5926. declare module "babylonjs/Maths/math.color" {
  5927. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5928. /**
  5929. * Class used to hold a RBG color
  5930. */
  5931. export class Color3 {
  5932. /**
  5933. * Defines the red component (between 0 and 1, default is 0)
  5934. */
  5935. r: number;
  5936. /**
  5937. * Defines the green component (between 0 and 1, default is 0)
  5938. */
  5939. g: number;
  5940. /**
  5941. * Defines the blue component (between 0 and 1, default is 0)
  5942. */
  5943. b: number;
  5944. /**
  5945. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5946. * @param r defines the red component (between 0 and 1, default is 0)
  5947. * @param g defines the green component (between 0 and 1, default is 0)
  5948. * @param b defines the blue component (between 0 and 1, default is 0)
  5949. */
  5950. constructor(
  5951. /**
  5952. * Defines the red component (between 0 and 1, default is 0)
  5953. */
  5954. r?: number,
  5955. /**
  5956. * Defines the green component (between 0 and 1, default is 0)
  5957. */
  5958. g?: number,
  5959. /**
  5960. * Defines the blue component (between 0 and 1, default is 0)
  5961. */
  5962. b?: number);
  5963. /**
  5964. * Creates a string with the Color3 current values
  5965. * @returns the string representation of the Color3 object
  5966. */
  5967. toString(): string;
  5968. /**
  5969. * Returns the string "Color3"
  5970. * @returns "Color3"
  5971. */
  5972. getClassName(): string;
  5973. /**
  5974. * Compute the Color3 hash code
  5975. * @returns an unique number that can be used to hash Color3 objects
  5976. */
  5977. getHashCode(): number;
  5978. /**
  5979. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5980. * @param array defines the array where to store the r,g,b components
  5981. * @param index defines an optional index in the target array to define where to start storing values
  5982. * @returns the current Color3 object
  5983. */
  5984. toArray(array: FloatArray, index?: number): Color3;
  5985. /**
  5986. * Update the current color with values stored in an array from the starting index of the given array
  5987. * @param array defines the source array
  5988. * @param offset defines an offset in the source array
  5989. * @returns the current Color3 object
  5990. */
  5991. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5992. /**
  5993. * Returns a new Color4 object from the current Color3 and the given alpha
  5994. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5995. * @returns a new Color4 object
  5996. */
  5997. toColor4(alpha?: number): Color4;
  5998. /**
  5999. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6000. * @returns the new array
  6001. */
  6002. asArray(): number[];
  6003. /**
  6004. * Returns the luminance value
  6005. * @returns a float value
  6006. */
  6007. toLuminance(): number;
  6008. /**
  6009. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6010. * @param otherColor defines the second operand
  6011. * @returns the new Color3 object
  6012. */
  6013. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6014. /**
  6015. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6016. * @param otherColor defines the second operand
  6017. * @param result defines the Color3 object where to store the result
  6018. * @returns the current Color3
  6019. */
  6020. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6021. /**
  6022. * Determines equality between Color3 objects
  6023. * @param otherColor defines the second operand
  6024. * @returns true if the rgb values are equal to the given ones
  6025. */
  6026. equals(otherColor: DeepImmutable<Color3>): boolean;
  6027. /**
  6028. * Determines equality between the current Color3 object and a set of r,b,g values
  6029. * @param r defines the red component to check
  6030. * @param g defines the green component to check
  6031. * @param b defines the blue component to check
  6032. * @returns true if the rgb values are equal to the given ones
  6033. */
  6034. equalsFloats(r: number, g: number, b: number): boolean;
  6035. /**
  6036. * Multiplies in place each rgb value by scale
  6037. * @param scale defines the scaling factor
  6038. * @returns the updated Color3
  6039. */
  6040. scale(scale: number): Color3;
  6041. /**
  6042. * Multiplies the rgb values by scale and stores the result into "result"
  6043. * @param scale defines the scaling factor
  6044. * @param result defines the Color3 object where to store the result
  6045. * @returns the unmodified current Color3
  6046. */
  6047. scaleToRef(scale: number, result: Color3): Color3;
  6048. /**
  6049. * Scale the current Color3 values by a factor and add the result to a given Color3
  6050. * @param scale defines the scale factor
  6051. * @param result defines color to store the result into
  6052. * @returns the unmodified current Color3
  6053. */
  6054. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6055. /**
  6056. * Clamps the rgb values by the min and max values and stores the result into "result"
  6057. * @param min defines minimum clamping value (default is 0)
  6058. * @param max defines maximum clamping value (default is 1)
  6059. * @param result defines color to store the result into
  6060. * @returns the original Color3
  6061. */
  6062. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6063. /**
  6064. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6065. * @param otherColor defines the second operand
  6066. * @returns the new Color3
  6067. */
  6068. add(otherColor: DeepImmutable<Color3>): Color3;
  6069. /**
  6070. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6071. * @param otherColor defines the second operand
  6072. * @param result defines Color3 object to store the result into
  6073. * @returns the unmodified current Color3
  6074. */
  6075. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6076. /**
  6077. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6078. * @param otherColor defines the second operand
  6079. * @returns the new Color3
  6080. */
  6081. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6082. /**
  6083. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6084. * @param otherColor defines the second operand
  6085. * @param result defines Color3 object to store the result into
  6086. * @returns the unmodified current Color3
  6087. */
  6088. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6089. /**
  6090. * Copy the current object
  6091. * @returns a new Color3 copied the current one
  6092. */
  6093. clone(): Color3;
  6094. /**
  6095. * Copies the rgb values from the source in the current Color3
  6096. * @param source defines the source Color3 object
  6097. * @returns the updated Color3 object
  6098. */
  6099. copyFrom(source: DeepImmutable<Color3>): Color3;
  6100. /**
  6101. * Updates the Color3 rgb values from the given floats
  6102. * @param r defines the red component to read from
  6103. * @param g defines the green component to read from
  6104. * @param b defines the blue component to read from
  6105. * @returns the current Color3 object
  6106. */
  6107. copyFromFloats(r: number, g: number, b: number): Color3;
  6108. /**
  6109. * Updates the Color3 rgb values from the given floats
  6110. * @param r defines the red component to read from
  6111. * @param g defines the green component to read from
  6112. * @param b defines the blue component to read from
  6113. * @returns the current Color3 object
  6114. */
  6115. set(r: number, g: number, b: number): Color3;
  6116. /**
  6117. * Compute the Color3 hexadecimal code as a string
  6118. * @returns a string containing the hexadecimal representation of the Color3 object
  6119. */
  6120. toHexString(): string;
  6121. /**
  6122. * Computes a new Color3 converted from the current one to linear space
  6123. * @returns a new Color3 object
  6124. */
  6125. toLinearSpace(): Color3;
  6126. /**
  6127. * Converts current color in rgb space to HSV values
  6128. * @returns a new color3 representing the HSV values
  6129. */
  6130. toHSV(): Color3;
  6131. /**
  6132. * Converts current color in rgb space to HSV values
  6133. * @param result defines the Color3 where to store the HSV values
  6134. */
  6135. toHSVToRef(result: Color3): void;
  6136. /**
  6137. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6138. * @param convertedColor defines the Color3 object where to store the linear space version
  6139. * @returns the unmodified Color3
  6140. */
  6141. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6142. /**
  6143. * Computes a new Color3 converted from the current one to gamma space
  6144. * @returns a new Color3 object
  6145. */
  6146. toGammaSpace(): Color3;
  6147. /**
  6148. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6149. * @param convertedColor defines the Color3 object where to store the gamma space version
  6150. * @returns the unmodified Color3
  6151. */
  6152. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6153. private static _BlackReadOnly;
  6154. /**
  6155. * Convert Hue, saturation and value to a Color3 (RGB)
  6156. * @param hue defines the hue
  6157. * @param saturation defines the saturation
  6158. * @param value defines the value
  6159. * @param result defines the Color3 where to store the RGB values
  6160. */
  6161. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6162. /**
  6163. * Creates a new Color3 from the string containing valid hexadecimal values
  6164. * @param hex defines a string containing valid hexadecimal values
  6165. * @returns a new Color3 object
  6166. */
  6167. static FromHexString(hex: string): Color3;
  6168. /**
  6169. * Creates a new Color3 from the starting index of the given array
  6170. * @param array defines the source array
  6171. * @param offset defines an offset in the source array
  6172. * @returns a new Color3 object
  6173. */
  6174. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6175. /**
  6176. * Creates a new Color3 from the starting index element of the given array
  6177. * @param array defines the source array to read from
  6178. * @param offset defines the offset in the source array
  6179. * @param result defines the target Color3 object
  6180. */
  6181. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6182. /**
  6183. * Creates a new Color3 from integer values (< 256)
  6184. * @param r defines the red component to read from (value between 0 and 255)
  6185. * @param g defines the green component to read from (value between 0 and 255)
  6186. * @param b defines the blue component to read from (value between 0 and 255)
  6187. * @returns a new Color3 object
  6188. */
  6189. static FromInts(r: number, g: number, b: number): Color3;
  6190. /**
  6191. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6192. * @param start defines the start Color3 value
  6193. * @param end defines the end Color3 value
  6194. * @param amount defines the gradient value between start and end
  6195. * @returns a new Color3 object
  6196. */
  6197. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6198. /**
  6199. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6200. * @param left defines the start value
  6201. * @param right defines the end value
  6202. * @param amount defines the gradient factor
  6203. * @param result defines the Color3 object where to store the result
  6204. */
  6205. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6206. /**
  6207. * Returns a Color3 value containing a red color
  6208. * @returns a new Color3 object
  6209. */
  6210. static Red(): Color3;
  6211. /**
  6212. * Returns a Color3 value containing a green color
  6213. * @returns a new Color3 object
  6214. */
  6215. static Green(): Color3;
  6216. /**
  6217. * Returns a Color3 value containing a blue color
  6218. * @returns a new Color3 object
  6219. */
  6220. static Blue(): Color3;
  6221. /**
  6222. * Returns a Color3 value containing a black color
  6223. * @returns a new Color3 object
  6224. */
  6225. static Black(): Color3;
  6226. /**
  6227. * Gets a Color3 value containing a black color that must not be updated
  6228. */
  6229. static get BlackReadOnly(): DeepImmutable<Color3>;
  6230. /**
  6231. * Returns a Color3 value containing a white color
  6232. * @returns a new Color3 object
  6233. */
  6234. static White(): Color3;
  6235. /**
  6236. * Returns a Color3 value containing a purple color
  6237. * @returns a new Color3 object
  6238. */
  6239. static Purple(): Color3;
  6240. /**
  6241. * Returns a Color3 value containing a magenta color
  6242. * @returns a new Color3 object
  6243. */
  6244. static Magenta(): Color3;
  6245. /**
  6246. * Returns a Color3 value containing a yellow color
  6247. * @returns a new Color3 object
  6248. */
  6249. static Yellow(): Color3;
  6250. /**
  6251. * Returns a Color3 value containing a gray color
  6252. * @returns a new Color3 object
  6253. */
  6254. static Gray(): Color3;
  6255. /**
  6256. * Returns a Color3 value containing a teal color
  6257. * @returns a new Color3 object
  6258. */
  6259. static Teal(): Color3;
  6260. /**
  6261. * Returns a Color3 value containing a random color
  6262. * @returns a new Color3 object
  6263. */
  6264. static Random(): Color3;
  6265. }
  6266. /**
  6267. * Class used to hold a RBGA color
  6268. */
  6269. export class Color4 {
  6270. /**
  6271. * Defines the red component (between 0 and 1, default is 0)
  6272. */
  6273. r: number;
  6274. /**
  6275. * Defines the green component (between 0 and 1, default is 0)
  6276. */
  6277. g: number;
  6278. /**
  6279. * Defines the blue component (between 0 and 1, default is 0)
  6280. */
  6281. b: number;
  6282. /**
  6283. * Defines the alpha component (between 0 and 1, default is 1)
  6284. */
  6285. a: number;
  6286. /**
  6287. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6288. * @param r defines the red component (between 0 and 1, default is 0)
  6289. * @param g defines the green component (between 0 and 1, default is 0)
  6290. * @param b defines the blue component (between 0 and 1, default is 0)
  6291. * @param a defines the alpha component (between 0 and 1, default is 1)
  6292. */
  6293. constructor(
  6294. /**
  6295. * Defines the red component (between 0 and 1, default is 0)
  6296. */
  6297. r?: number,
  6298. /**
  6299. * Defines the green component (between 0 and 1, default is 0)
  6300. */
  6301. g?: number,
  6302. /**
  6303. * Defines the blue component (between 0 and 1, default is 0)
  6304. */
  6305. b?: number,
  6306. /**
  6307. * Defines the alpha component (between 0 and 1, default is 1)
  6308. */
  6309. a?: number);
  6310. /**
  6311. * Adds in place the given Color4 values to the current Color4 object
  6312. * @param right defines the second operand
  6313. * @returns the current updated Color4 object
  6314. */
  6315. addInPlace(right: DeepImmutable<Color4>): Color4;
  6316. /**
  6317. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6318. * @returns the new array
  6319. */
  6320. asArray(): number[];
  6321. /**
  6322. * Stores from the starting index in the given array the Color4 successive values
  6323. * @param array defines the array where to store the r,g,b components
  6324. * @param index defines an optional index in the target array to define where to start storing values
  6325. * @returns the current Color4 object
  6326. */
  6327. toArray(array: number[], index?: number): Color4;
  6328. /**
  6329. * Update the current color with values stored in an array from the starting index of the given array
  6330. * @param array defines the source array
  6331. * @param offset defines an offset in the source array
  6332. * @returns the current Color4 object
  6333. */
  6334. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6335. /**
  6336. * Determines equality between Color4 objects
  6337. * @param otherColor defines the second operand
  6338. * @returns true if the rgba values are equal to the given ones
  6339. */
  6340. equals(otherColor: DeepImmutable<Color4>): boolean;
  6341. /**
  6342. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6343. * @param right defines the second operand
  6344. * @returns a new Color4 object
  6345. */
  6346. add(right: DeepImmutable<Color4>): Color4;
  6347. /**
  6348. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6349. * @param right defines the second operand
  6350. * @returns a new Color4 object
  6351. */
  6352. subtract(right: DeepImmutable<Color4>): Color4;
  6353. /**
  6354. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6355. * @param right defines the second operand
  6356. * @param result defines the Color4 object where to store the result
  6357. * @returns the current Color4 object
  6358. */
  6359. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6360. /**
  6361. * Creates a new Color4 with the current Color4 values multiplied by scale
  6362. * @param scale defines the scaling factor to apply
  6363. * @returns a new Color4 object
  6364. */
  6365. scale(scale: number): Color4;
  6366. /**
  6367. * Multiplies the current Color4 values by scale and stores the result in "result"
  6368. * @param scale defines the scaling factor to apply
  6369. * @param result defines the Color4 object where to store the result
  6370. * @returns the current unmodified Color4
  6371. */
  6372. scaleToRef(scale: number, result: Color4): Color4;
  6373. /**
  6374. * Scale the current Color4 values by a factor and add the result to a given Color4
  6375. * @param scale defines the scale factor
  6376. * @param result defines the Color4 object where to store the result
  6377. * @returns the unmodified current Color4
  6378. */
  6379. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6380. /**
  6381. * Clamps the rgb values by the min and max values and stores the result into "result"
  6382. * @param min defines minimum clamping value (default is 0)
  6383. * @param max defines maximum clamping value (default is 1)
  6384. * @param result defines color to store the result into.
  6385. * @returns the cuurent Color4
  6386. */
  6387. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6388. /**
  6389. * Multipy an Color4 value by another and return a new Color4 object
  6390. * @param color defines the Color4 value to multiply by
  6391. * @returns a new Color4 object
  6392. */
  6393. multiply(color: Color4): Color4;
  6394. /**
  6395. * Multipy a Color4 value by another and push the result in a reference value
  6396. * @param color defines the Color4 value to multiply by
  6397. * @param result defines the Color4 to fill the result in
  6398. * @returns the result Color4
  6399. */
  6400. multiplyToRef(color: Color4, result: Color4): Color4;
  6401. /**
  6402. * Creates a string with the Color4 current values
  6403. * @returns the string representation of the Color4 object
  6404. */
  6405. toString(): string;
  6406. /**
  6407. * Returns the string "Color4"
  6408. * @returns "Color4"
  6409. */
  6410. getClassName(): string;
  6411. /**
  6412. * Compute the Color4 hash code
  6413. * @returns an unique number that can be used to hash Color4 objects
  6414. */
  6415. getHashCode(): number;
  6416. /**
  6417. * Creates a new Color4 copied from the current one
  6418. * @returns a new Color4 object
  6419. */
  6420. clone(): Color4;
  6421. /**
  6422. * Copies the given Color4 values into the current one
  6423. * @param source defines the source Color4 object
  6424. * @returns the current updated Color4 object
  6425. */
  6426. copyFrom(source: Color4): Color4;
  6427. /**
  6428. * Copies the given float values into the current one
  6429. * @param r defines the red component to read from
  6430. * @param g defines the green component to read from
  6431. * @param b defines the blue component to read from
  6432. * @param a defines the alpha component to read from
  6433. * @returns the current updated Color4 object
  6434. */
  6435. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6436. /**
  6437. * Copies the given float values into the current one
  6438. * @param r defines the red component to read from
  6439. * @param g defines the green component to read from
  6440. * @param b defines the blue component to read from
  6441. * @param a defines the alpha component to read from
  6442. * @returns the current updated Color4 object
  6443. */
  6444. set(r: number, g: number, b: number, a: number): Color4;
  6445. /**
  6446. * Compute the Color4 hexadecimal code as a string
  6447. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6448. * @returns a string containing the hexadecimal representation of the Color4 object
  6449. */
  6450. toHexString(returnAsColor3?: boolean): string;
  6451. /**
  6452. * Computes a new Color4 converted from the current one to linear space
  6453. * @returns a new Color4 object
  6454. */
  6455. toLinearSpace(): Color4;
  6456. /**
  6457. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6458. * @param convertedColor defines the Color4 object where to store the linear space version
  6459. * @returns the unmodified Color4
  6460. */
  6461. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6462. /**
  6463. * Computes a new Color4 converted from the current one to gamma space
  6464. * @returns a new Color4 object
  6465. */
  6466. toGammaSpace(): Color4;
  6467. /**
  6468. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6469. * @param convertedColor defines the Color4 object where to store the gamma space version
  6470. * @returns the unmodified Color4
  6471. */
  6472. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6473. /**
  6474. * Creates a new Color4 from the string containing valid hexadecimal values
  6475. * @param hex defines a string containing valid hexadecimal values
  6476. * @returns a new Color4 object
  6477. */
  6478. static FromHexString(hex: string): Color4;
  6479. /**
  6480. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6481. * @param left defines the start value
  6482. * @param right defines the end value
  6483. * @param amount defines the gradient factor
  6484. * @returns a new Color4 object
  6485. */
  6486. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6487. /**
  6488. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6489. * @param left defines the start value
  6490. * @param right defines the end value
  6491. * @param amount defines the gradient factor
  6492. * @param result defines the Color4 object where to store data
  6493. */
  6494. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6495. /**
  6496. * Creates a new Color4 from a Color3 and an alpha value
  6497. * @param color3 defines the source Color3 to read from
  6498. * @param alpha defines the alpha component (1.0 by default)
  6499. * @returns a new Color4 object
  6500. */
  6501. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6502. /**
  6503. * Creates a new Color4 from the starting index element of the given array
  6504. * @param array defines the source array to read from
  6505. * @param offset defines the offset in the source array
  6506. * @returns a new Color4 object
  6507. */
  6508. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6509. /**
  6510. * Creates a new Color4 from the starting index element of the given array
  6511. * @param array defines the source array to read from
  6512. * @param offset defines the offset in the source array
  6513. * @param result defines the target Color4 object
  6514. */
  6515. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6516. /**
  6517. * Creates a new Color3 from integer values (< 256)
  6518. * @param r defines the red component to read from (value between 0 and 255)
  6519. * @param g defines the green component to read from (value between 0 and 255)
  6520. * @param b defines the blue component to read from (value between 0 and 255)
  6521. * @param a defines the alpha component to read from (value between 0 and 255)
  6522. * @returns a new Color3 object
  6523. */
  6524. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6525. /**
  6526. * Check the content of a given array and convert it to an array containing RGBA data
  6527. * If the original array was already containing count * 4 values then it is returned directly
  6528. * @param colors defines the array to check
  6529. * @param count defines the number of RGBA data to expect
  6530. * @returns an array containing count * 4 values (RGBA)
  6531. */
  6532. static CheckColors4(colors: number[], count: number): number[];
  6533. }
  6534. /**
  6535. * @hidden
  6536. */
  6537. export class TmpColors {
  6538. static Color3: Color3[];
  6539. static Color4: Color4[];
  6540. }
  6541. }
  6542. declare module "babylonjs/Animations/animationKey" {
  6543. /**
  6544. * Defines an interface which represents an animation key frame
  6545. */
  6546. export interface IAnimationKey {
  6547. /**
  6548. * Frame of the key frame
  6549. */
  6550. frame: number;
  6551. /**
  6552. * Value at the specifies key frame
  6553. */
  6554. value: any;
  6555. /**
  6556. * The input tangent for the cubic hermite spline
  6557. */
  6558. inTangent?: any;
  6559. /**
  6560. * The output tangent for the cubic hermite spline
  6561. */
  6562. outTangent?: any;
  6563. /**
  6564. * The animation interpolation type
  6565. */
  6566. interpolation?: AnimationKeyInterpolation;
  6567. }
  6568. /**
  6569. * Enum for the animation key frame interpolation type
  6570. */
  6571. export enum AnimationKeyInterpolation {
  6572. /**
  6573. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6574. */
  6575. STEP = 1
  6576. }
  6577. }
  6578. declare module "babylonjs/Animations/animationRange" {
  6579. /**
  6580. * Represents the range of an animation
  6581. */
  6582. export class AnimationRange {
  6583. /**The name of the animation range**/
  6584. name: string;
  6585. /**The starting frame of the animation */
  6586. from: number;
  6587. /**The ending frame of the animation*/
  6588. to: number;
  6589. /**
  6590. * Initializes the range of an animation
  6591. * @param name The name of the animation range
  6592. * @param from The starting frame of the animation
  6593. * @param to The ending frame of the animation
  6594. */
  6595. constructor(
  6596. /**The name of the animation range**/
  6597. name: string,
  6598. /**The starting frame of the animation */
  6599. from: number,
  6600. /**The ending frame of the animation*/
  6601. to: number);
  6602. /**
  6603. * Makes a copy of the animation range
  6604. * @returns A copy of the animation range
  6605. */
  6606. clone(): AnimationRange;
  6607. }
  6608. }
  6609. declare module "babylonjs/Animations/animationEvent" {
  6610. /**
  6611. * Composed of a frame, and an action function
  6612. */
  6613. export class AnimationEvent {
  6614. /** The frame for which the event is triggered **/
  6615. frame: number;
  6616. /** The event to perform when triggered **/
  6617. action: (currentFrame: number) => void;
  6618. /** Specifies if the event should be triggered only once**/
  6619. onlyOnce?: boolean | undefined;
  6620. /**
  6621. * Specifies if the animation event is done
  6622. */
  6623. isDone: boolean;
  6624. /**
  6625. * Initializes the animation event
  6626. * @param frame The frame for which the event is triggered
  6627. * @param action The event to perform when triggered
  6628. * @param onlyOnce Specifies if the event should be triggered only once
  6629. */
  6630. constructor(
  6631. /** The frame for which the event is triggered **/
  6632. frame: number,
  6633. /** The event to perform when triggered **/
  6634. action: (currentFrame: number) => void,
  6635. /** Specifies if the event should be triggered only once**/
  6636. onlyOnce?: boolean | undefined);
  6637. /** @hidden */
  6638. _clone(): AnimationEvent;
  6639. }
  6640. }
  6641. declare module "babylonjs/Behaviors/behavior" {
  6642. import { Nullable } from "babylonjs/types";
  6643. /**
  6644. * Interface used to define a behavior
  6645. */
  6646. export interface Behavior<T> {
  6647. /** gets or sets behavior's name */
  6648. name: string;
  6649. /**
  6650. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6651. */
  6652. init(): void;
  6653. /**
  6654. * Called when the behavior is attached to a target
  6655. * @param target defines the target where the behavior is attached to
  6656. */
  6657. attach(target: T): void;
  6658. /**
  6659. * Called when the behavior is detached from its target
  6660. */
  6661. detach(): void;
  6662. }
  6663. /**
  6664. * Interface implemented by classes supporting behaviors
  6665. */
  6666. export interface IBehaviorAware<T> {
  6667. /**
  6668. * Attach a behavior
  6669. * @param behavior defines the behavior to attach
  6670. * @returns the current host
  6671. */
  6672. addBehavior(behavior: Behavior<T>): T;
  6673. /**
  6674. * Remove a behavior from the current object
  6675. * @param behavior defines the behavior to detach
  6676. * @returns the current host
  6677. */
  6678. removeBehavior(behavior: Behavior<T>): T;
  6679. /**
  6680. * Gets a behavior using its name to search
  6681. * @param name defines the name to search
  6682. * @returns the behavior or null if not found
  6683. */
  6684. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6685. }
  6686. }
  6687. declare module "babylonjs/Meshes/buffer" {
  6688. import { Nullable, DataArray } from "babylonjs/types";
  6689. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6690. /**
  6691. * Class used to store data that will be store in GPU memory
  6692. */
  6693. export class Buffer {
  6694. private _engine;
  6695. private _buffer;
  6696. /** @hidden */
  6697. _data: Nullable<DataArray>;
  6698. private _updatable;
  6699. private _instanced;
  6700. private _divisor;
  6701. private _isAlreadyOwned;
  6702. /**
  6703. * Gets the byte stride.
  6704. */
  6705. readonly byteStride: number;
  6706. /**
  6707. * Constructor
  6708. * @param engine the engine
  6709. * @param data the data to use for this buffer
  6710. * @param updatable whether the data is updatable
  6711. * @param stride the stride (optional)
  6712. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6713. * @param instanced whether the buffer is instanced (optional)
  6714. * @param useBytes set to true if the stride in in bytes (optional)
  6715. * @param divisor sets an optional divisor for instances (1 by default)
  6716. */
  6717. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6718. /**
  6719. * Create a new VertexBuffer based on the current buffer
  6720. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6721. * @param offset defines offset in the buffer (0 by default)
  6722. * @param size defines the size in floats of attributes (position is 3 for instance)
  6723. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6724. * @param instanced defines if the vertex buffer contains indexed data
  6725. * @param useBytes defines if the offset and stride are in bytes *
  6726. * @param divisor sets an optional divisor for instances (1 by default)
  6727. * @returns the new vertex buffer
  6728. */
  6729. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6730. /**
  6731. * Gets a boolean indicating if the Buffer is updatable?
  6732. * @returns true if the buffer is updatable
  6733. */
  6734. isUpdatable(): boolean;
  6735. /**
  6736. * Gets current buffer's data
  6737. * @returns a DataArray or null
  6738. */
  6739. getData(): Nullable<DataArray>;
  6740. /**
  6741. * Gets underlying native buffer
  6742. * @returns underlying native buffer
  6743. */
  6744. getBuffer(): Nullable<DataBuffer>;
  6745. /**
  6746. * Gets the stride in float32 units (i.e. byte stride / 4).
  6747. * May not be an integer if the byte stride is not divisible by 4.
  6748. * @returns the stride in float32 units
  6749. * @deprecated Please use byteStride instead.
  6750. */
  6751. getStrideSize(): number;
  6752. /**
  6753. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6754. * @param data defines the data to store
  6755. */
  6756. create(data?: Nullable<DataArray>): void;
  6757. /** @hidden */
  6758. _rebuild(): void;
  6759. /**
  6760. * Update current buffer data
  6761. * @param data defines the data to store
  6762. */
  6763. update(data: DataArray): void;
  6764. /**
  6765. * Updates the data directly.
  6766. * @param data the new data
  6767. * @param offset the new offset
  6768. * @param vertexCount the vertex count (optional)
  6769. * @param useBytes set to true if the offset is in bytes
  6770. */
  6771. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6772. /** @hidden */
  6773. _increaseReferences(): void;
  6774. /**
  6775. * Release all resources
  6776. */
  6777. dispose(): void;
  6778. }
  6779. /**
  6780. * Specialized buffer used to store vertex data
  6781. */
  6782. export class VertexBuffer {
  6783. /** @hidden */
  6784. _buffer: Buffer;
  6785. private _kind;
  6786. private _size;
  6787. private _ownsBuffer;
  6788. private _instanced;
  6789. private _instanceDivisor;
  6790. /**
  6791. * The byte type.
  6792. */
  6793. static readonly BYTE: number;
  6794. /**
  6795. * The unsigned byte type.
  6796. */
  6797. static readonly UNSIGNED_BYTE: number;
  6798. /**
  6799. * The short type.
  6800. */
  6801. static readonly SHORT: number;
  6802. /**
  6803. * The unsigned short type.
  6804. */
  6805. static readonly UNSIGNED_SHORT: number;
  6806. /**
  6807. * The integer type.
  6808. */
  6809. static readonly INT: number;
  6810. /**
  6811. * The unsigned integer type.
  6812. */
  6813. static readonly UNSIGNED_INT: number;
  6814. /**
  6815. * The float type.
  6816. */
  6817. static readonly FLOAT: number;
  6818. /**
  6819. * Gets or sets the instance divisor when in instanced mode
  6820. */
  6821. get instanceDivisor(): number;
  6822. set instanceDivisor(value: number);
  6823. /**
  6824. * Gets the byte stride.
  6825. */
  6826. readonly byteStride: number;
  6827. /**
  6828. * Gets the byte offset.
  6829. */
  6830. readonly byteOffset: number;
  6831. /**
  6832. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6833. */
  6834. readonly normalized: boolean;
  6835. /**
  6836. * Gets the data type of each component in the array.
  6837. */
  6838. readonly type: number;
  6839. /**
  6840. * Constructor
  6841. * @param engine the engine
  6842. * @param data the data to use for this vertex buffer
  6843. * @param kind the vertex buffer kind
  6844. * @param updatable whether the data is updatable
  6845. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6846. * @param stride the stride (optional)
  6847. * @param instanced whether the buffer is instanced (optional)
  6848. * @param offset the offset of the data (optional)
  6849. * @param size the number of components (optional)
  6850. * @param type the type of the component (optional)
  6851. * @param normalized whether the data contains normalized data (optional)
  6852. * @param useBytes set to true if stride and offset are in bytes (optional)
  6853. * @param divisor defines the instance divisor to use (1 by default)
  6854. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  6855. */
  6856. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number, takeBufferOwnership?: boolean);
  6857. /** @hidden */
  6858. _rebuild(): void;
  6859. /**
  6860. * Returns the kind of the VertexBuffer (string)
  6861. * @returns a string
  6862. */
  6863. getKind(): string;
  6864. /**
  6865. * Gets a boolean indicating if the VertexBuffer is updatable?
  6866. * @returns true if the buffer is updatable
  6867. */
  6868. isUpdatable(): boolean;
  6869. /**
  6870. * Gets current buffer's data
  6871. * @returns a DataArray or null
  6872. */
  6873. getData(): Nullable<DataArray>;
  6874. /**
  6875. * Gets underlying native buffer
  6876. * @returns underlying native buffer
  6877. */
  6878. getBuffer(): Nullable<DataBuffer>;
  6879. /**
  6880. * Gets the stride in float32 units (i.e. byte stride / 4).
  6881. * May not be an integer if the byte stride is not divisible by 4.
  6882. * @returns the stride in float32 units
  6883. * @deprecated Please use byteStride instead.
  6884. */
  6885. getStrideSize(): number;
  6886. /**
  6887. * Returns the offset as a multiple of the type byte length.
  6888. * @returns the offset in bytes
  6889. * @deprecated Please use byteOffset instead.
  6890. */
  6891. getOffset(): number;
  6892. /**
  6893. * Returns the number of components per vertex attribute (integer)
  6894. * @returns the size in float
  6895. */
  6896. getSize(): number;
  6897. /**
  6898. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6899. * @returns true if this buffer is instanced
  6900. */
  6901. getIsInstanced(): boolean;
  6902. /**
  6903. * Returns the instancing divisor, zero for non-instanced (integer).
  6904. * @returns a number
  6905. */
  6906. getInstanceDivisor(): number;
  6907. /**
  6908. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6909. * @param data defines the data to store
  6910. */
  6911. create(data?: DataArray): void;
  6912. /**
  6913. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6914. * This function will create a new buffer if the current one is not updatable
  6915. * @param data defines the data to store
  6916. */
  6917. update(data: DataArray): void;
  6918. /**
  6919. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6920. * Returns the directly updated WebGLBuffer.
  6921. * @param data the new data
  6922. * @param offset the new offset
  6923. * @param useBytes set to true if the offset is in bytes
  6924. */
  6925. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6926. /**
  6927. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6928. */
  6929. dispose(): void;
  6930. /**
  6931. * Enumerates each value of this vertex buffer as numbers.
  6932. * @param count the number of values to enumerate
  6933. * @param callback the callback function called for each value
  6934. */
  6935. forEach(count: number, callback: (value: number, index: number) => void): void;
  6936. /**
  6937. * Positions
  6938. */
  6939. static readonly PositionKind: string;
  6940. /**
  6941. * Normals
  6942. */
  6943. static readonly NormalKind: string;
  6944. /**
  6945. * Tangents
  6946. */
  6947. static readonly TangentKind: string;
  6948. /**
  6949. * Texture coordinates
  6950. */
  6951. static readonly UVKind: string;
  6952. /**
  6953. * Texture coordinates 2
  6954. */
  6955. static readonly UV2Kind: string;
  6956. /**
  6957. * Texture coordinates 3
  6958. */
  6959. static readonly UV3Kind: string;
  6960. /**
  6961. * Texture coordinates 4
  6962. */
  6963. static readonly UV4Kind: string;
  6964. /**
  6965. * Texture coordinates 5
  6966. */
  6967. static readonly UV5Kind: string;
  6968. /**
  6969. * Texture coordinates 6
  6970. */
  6971. static readonly UV6Kind: string;
  6972. /**
  6973. * Colors
  6974. */
  6975. static readonly ColorKind: string;
  6976. /**
  6977. * Matrix indices (for bones)
  6978. */
  6979. static readonly MatricesIndicesKind: string;
  6980. /**
  6981. * Matrix weights (for bones)
  6982. */
  6983. static readonly MatricesWeightsKind: string;
  6984. /**
  6985. * Additional matrix indices (for bones)
  6986. */
  6987. static readonly MatricesIndicesExtraKind: string;
  6988. /**
  6989. * Additional matrix weights (for bones)
  6990. */
  6991. static readonly MatricesWeightsExtraKind: string;
  6992. /**
  6993. * Deduces the stride given a kind.
  6994. * @param kind The kind string to deduce
  6995. * @returns The deduced stride
  6996. */
  6997. static DeduceStride(kind: string): number;
  6998. /**
  6999. * Gets the byte length of the given type.
  7000. * @param type the type
  7001. * @returns the number of bytes
  7002. */
  7003. static GetTypeByteLength(type: number): number;
  7004. /**
  7005. * Enumerates each value of the given parameters as numbers.
  7006. * @param data the data to enumerate
  7007. * @param byteOffset the byte offset of the data
  7008. * @param byteStride the byte stride of the data
  7009. * @param componentCount the number of components per element
  7010. * @param componentType the type of the component
  7011. * @param count the number of values to enumerate
  7012. * @param normalized whether the data is normalized
  7013. * @param callback the callback function called for each value
  7014. */
  7015. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7016. private static _GetFloatValue;
  7017. }
  7018. }
  7019. declare module "babylonjs/Collisions/intersectionInfo" {
  7020. import { Nullable } from "babylonjs/types";
  7021. /**
  7022. * @hidden
  7023. */
  7024. export class IntersectionInfo {
  7025. bu: Nullable<number>;
  7026. bv: Nullable<number>;
  7027. distance: number;
  7028. faceId: number;
  7029. subMeshId: number;
  7030. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7031. }
  7032. }
  7033. declare module "babylonjs/Culling/boundingSphere" {
  7034. import { DeepImmutable } from "babylonjs/types";
  7035. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7036. import { Plane } from "babylonjs/Maths/math.plane";
  7037. /**
  7038. * Class used to store bounding sphere information
  7039. */
  7040. export class BoundingSphere {
  7041. /**
  7042. * Gets the center of the bounding sphere in local space
  7043. */
  7044. readonly center: Vector3;
  7045. /**
  7046. * Radius of the bounding sphere in local space
  7047. */
  7048. radius: number;
  7049. /**
  7050. * Gets the center of the bounding sphere in world space
  7051. */
  7052. readonly centerWorld: Vector3;
  7053. /**
  7054. * Radius of the bounding sphere in world space
  7055. */
  7056. radiusWorld: number;
  7057. /**
  7058. * Gets the minimum vector in local space
  7059. */
  7060. readonly minimum: Vector3;
  7061. /**
  7062. * Gets the maximum vector in local space
  7063. */
  7064. readonly maximum: Vector3;
  7065. private _worldMatrix;
  7066. private static readonly TmpVector3;
  7067. /**
  7068. * Creates a new bounding sphere
  7069. * @param min defines the minimum vector (in local space)
  7070. * @param max defines the maximum vector (in local space)
  7071. * @param worldMatrix defines the new world matrix
  7072. */
  7073. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7074. /**
  7075. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7076. * @param min defines the new minimum vector (in local space)
  7077. * @param max defines the new maximum vector (in local space)
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7081. /**
  7082. * Scale the current bounding sphere by applying a scale factor
  7083. * @param factor defines the scale factor to apply
  7084. * @returns the current bounding box
  7085. */
  7086. scale(factor: number): BoundingSphere;
  7087. /**
  7088. * Gets the world matrix of the bounding box
  7089. * @returns a matrix
  7090. */
  7091. getWorldMatrix(): DeepImmutable<Matrix>;
  7092. /** @hidden */
  7093. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7094. /**
  7095. * Tests if the bounding sphere is intersecting the frustum planes
  7096. * @param frustumPlanes defines the frustum planes to test
  7097. * @returns true if there is an intersection
  7098. */
  7099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7100. /**
  7101. * Tests if the bounding sphere center is in between the frustum planes.
  7102. * Used for optimistic fast inclusion.
  7103. * @param frustumPlanes defines the frustum planes to test
  7104. * @returns true if the sphere center is in between the frustum planes
  7105. */
  7106. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7107. /**
  7108. * Tests if a point is inside the bounding sphere
  7109. * @param point defines the point to test
  7110. * @returns true if the point is inside the bounding sphere
  7111. */
  7112. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7113. /**
  7114. * Checks if two sphere intersct
  7115. * @param sphere0 sphere 0
  7116. * @param sphere1 sphere 1
  7117. * @returns true if the speres intersect
  7118. */
  7119. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7120. }
  7121. }
  7122. declare module "babylonjs/Culling/boundingBox" {
  7123. import { DeepImmutable } from "babylonjs/types";
  7124. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7125. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7126. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7127. import { Plane } from "babylonjs/Maths/math.plane";
  7128. /**
  7129. * Class used to store bounding box information
  7130. */
  7131. export class BoundingBox implements ICullable {
  7132. /**
  7133. * Gets the 8 vectors representing the bounding box in local space
  7134. */
  7135. readonly vectors: Vector3[];
  7136. /**
  7137. * Gets the center of the bounding box in local space
  7138. */
  7139. readonly center: Vector3;
  7140. /**
  7141. * Gets the center of the bounding box in world space
  7142. */
  7143. readonly centerWorld: Vector3;
  7144. /**
  7145. * Gets the extend size in local space
  7146. */
  7147. readonly extendSize: Vector3;
  7148. /**
  7149. * Gets the extend size in world space
  7150. */
  7151. readonly extendSizeWorld: Vector3;
  7152. /**
  7153. * Gets the OBB (object bounding box) directions
  7154. */
  7155. readonly directions: Vector3[];
  7156. /**
  7157. * Gets the 8 vectors representing the bounding box in world space
  7158. */
  7159. readonly vectorsWorld: Vector3[];
  7160. /**
  7161. * Gets the minimum vector in world space
  7162. */
  7163. readonly minimumWorld: Vector3;
  7164. /**
  7165. * Gets the maximum vector in world space
  7166. */
  7167. readonly maximumWorld: Vector3;
  7168. /**
  7169. * Gets the minimum vector in local space
  7170. */
  7171. readonly minimum: Vector3;
  7172. /**
  7173. * Gets the maximum vector in local space
  7174. */
  7175. readonly maximum: Vector3;
  7176. private _worldMatrix;
  7177. private static readonly TmpVector3;
  7178. /**
  7179. * @hidden
  7180. */
  7181. _tag: number;
  7182. /**
  7183. * Creates a new bounding box
  7184. * @param min defines the minimum vector (in local space)
  7185. * @param max defines the maximum vector (in local space)
  7186. * @param worldMatrix defines the new world matrix
  7187. */
  7188. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7189. /**
  7190. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7191. * @param min defines the new minimum vector (in local space)
  7192. * @param max defines the new maximum vector (in local space)
  7193. * @param worldMatrix defines the new world matrix
  7194. */
  7195. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7196. /**
  7197. * Scale the current bounding box by applying a scale factor
  7198. * @param factor defines the scale factor to apply
  7199. * @returns the current bounding box
  7200. */
  7201. scale(factor: number): BoundingBox;
  7202. /**
  7203. * Gets the world matrix of the bounding box
  7204. * @returns a matrix
  7205. */
  7206. getWorldMatrix(): DeepImmutable<Matrix>;
  7207. /** @hidden */
  7208. _update(world: DeepImmutable<Matrix>): void;
  7209. /**
  7210. * Tests if the bounding box is intersecting the frustum planes
  7211. * @param frustumPlanes defines the frustum planes to test
  7212. * @returns true if there is an intersection
  7213. */
  7214. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7215. /**
  7216. * Tests if the bounding box is entirely inside the frustum planes
  7217. * @param frustumPlanes defines the frustum planes to test
  7218. * @returns true if there is an inclusion
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7221. /**
  7222. * Tests if a point is inside the bounding box
  7223. * @param point defines the point to test
  7224. * @returns true if the point is inside the bounding box
  7225. */
  7226. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7227. /**
  7228. * Tests if the bounding box intersects with a bounding sphere
  7229. * @param sphere defines the sphere to test
  7230. * @returns true if there is an intersection
  7231. */
  7232. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7233. /**
  7234. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7235. * @param min defines the min vector to use
  7236. * @param max defines the max vector to use
  7237. * @returns true if there is an intersection
  7238. */
  7239. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7240. /**
  7241. * Tests if two bounding boxes are intersections
  7242. * @param box0 defines the first box to test
  7243. * @param box1 defines the second box to test
  7244. * @returns true if there is an intersection
  7245. */
  7246. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7247. /**
  7248. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7249. * @param minPoint defines the minimum vector of the bounding box
  7250. * @param maxPoint defines the maximum vector of the bounding box
  7251. * @param sphereCenter defines the sphere center
  7252. * @param sphereRadius defines the sphere radius
  7253. * @returns true if there is an intersection
  7254. */
  7255. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7256. /**
  7257. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7258. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7259. * @param frustumPlanes defines the frustum planes to test
  7260. * @return true if there is an inclusion
  7261. */
  7262. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7263. /**
  7264. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7265. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7266. * @param frustumPlanes defines the frustum planes to test
  7267. * @return true if there is an intersection
  7268. */
  7269. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7270. }
  7271. }
  7272. declare module "babylonjs/Collisions/collider" {
  7273. import { Nullable, IndicesArray } from "babylonjs/types";
  7274. import { Vector3 } from "babylonjs/Maths/math.vector";
  7275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7276. import { Plane } from "babylonjs/Maths/math.plane";
  7277. /** @hidden */
  7278. export class Collider {
  7279. /** Define if a collision was found */
  7280. collisionFound: boolean;
  7281. /**
  7282. * Define last intersection point in local space
  7283. */
  7284. intersectionPoint: Vector3;
  7285. /**
  7286. * Define last collided mesh
  7287. */
  7288. collidedMesh: Nullable<AbstractMesh>;
  7289. private _collisionPoint;
  7290. private _planeIntersectionPoint;
  7291. private _tempVector;
  7292. private _tempVector2;
  7293. private _tempVector3;
  7294. private _tempVector4;
  7295. private _edge;
  7296. private _baseToVertex;
  7297. private _destinationPoint;
  7298. private _slidePlaneNormal;
  7299. private _displacementVector;
  7300. /** @hidden */
  7301. _radius: Vector3;
  7302. /** @hidden */
  7303. _retry: number;
  7304. private _velocity;
  7305. private _basePoint;
  7306. private _epsilon;
  7307. /** @hidden */
  7308. _velocityWorldLength: number;
  7309. /** @hidden */
  7310. _basePointWorld: Vector3;
  7311. private _velocityWorld;
  7312. private _normalizedVelocity;
  7313. /** @hidden */
  7314. _initialVelocity: Vector3;
  7315. /** @hidden */
  7316. _initialPosition: Vector3;
  7317. private _nearestDistance;
  7318. private _collisionMask;
  7319. get collisionMask(): number;
  7320. set collisionMask(mask: number);
  7321. /**
  7322. * Gets the plane normal used to compute the sliding response (in local space)
  7323. */
  7324. get slidePlaneNormal(): Vector3;
  7325. /** @hidden */
  7326. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7327. /** @hidden */
  7328. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7329. /** @hidden */
  7330. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7331. /** @hidden */
  7332. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7333. /** @hidden */
  7334. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7335. /** @hidden */
  7336. _getResponse(pos: Vector3, vel: Vector3): void;
  7337. }
  7338. }
  7339. declare module "babylonjs/Culling/boundingInfo" {
  7340. import { DeepImmutable } from "babylonjs/types";
  7341. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7342. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7343. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7344. import { Plane } from "babylonjs/Maths/math.plane";
  7345. import { Collider } from "babylonjs/Collisions/collider";
  7346. /**
  7347. * Interface for cullable objects
  7348. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7349. */
  7350. export interface ICullable {
  7351. /**
  7352. * Checks if the object or part of the object is in the frustum
  7353. * @param frustumPlanes Camera near/planes
  7354. * @returns true if the object is in frustum otherwise false
  7355. */
  7356. isInFrustum(frustumPlanes: Plane[]): boolean;
  7357. /**
  7358. * Checks if a cullable object (mesh...) is in the camera frustum
  7359. * Unlike isInFrustum this cheks the full bounding box
  7360. * @param frustumPlanes Camera near/planes
  7361. * @returns true if the object is in frustum otherwise false
  7362. */
  7363. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7364. }
  7365. /**
  7366. * Info for a bounding data of a mesh
  7367. */
  7368. export class BoundingInfo implements ICullable {
  7369. /**
  7370. * Bounding box for the mesh
  7371. */
  7372. readonly boundingBox: BoundingBox;
  7373. /**
  7374. * Bounding sphere for the mesh
  7375. */
  7376. readonly boundingSphere: BoundingSphere;
  7377. private _isLocked;
  7378. private static readonly TmpVector3;
  7379. /**
  7380. * Constructs bounding info
  7381. * @param minimum min vector of the bounding box/sphere
  7382. * @param maximum max vector of the bounding box/sphere
  7383. * @param worldMatrix defines the new world matrix
  7384. */
  7385. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7386. /**
  7387. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7388. * @param min defines the new minimum vector (in local space)
  7389. * @param max defines the new maximum vector (in local space)
  7390. * @param worldMatrix defines the new world matrix
  7391. */
  7392. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7393. /**
  7394. * min vector of the bounding box/sphere
  7395. */
  7396. get minimum(): Vector3;
  7397. /**
  7398. * max vector of the bounding box/sphere
  7399. */
  7400. get maximum(): Vector3;
  7401. /**
  7402. * If the info is locked and won't be updated to avoid perf overhead
  7403. */
  7404. get isLocked(): boolean;
  7405. set isLocked(value: boolean);
  7406. /**
  7407. * Updates the bounding sphere and box
  7408. * @param world world matrix to be used to update
  7409. */
  7410. update(world: DeepImmutable<Matrix>): void;
  7411. /**
  7412. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7413. * @param center New center of the bounding info
  7414. * @param extend New extend of the bounding info
  7415. * @returns the current bounding info
  7416. */
  7417. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7418. /**
  7419. * Scale the current bounding info by applying a scale factor
  7420. * @param factor defines the scale factor to apply
  7421. * @returns the current bounding info
  7422. */
  7423. scale(factor: number): BoundingInfo;
  7424. /**
  7425. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7426. * @param frustumPlanes defines the frustum to test
  7427. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7428. * @returns true if the bounding info is in the frustum planes
  7429. */
  7430. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7431. /**
  7432. * Gets the world distance between the min and max points of the bounding box
  7433. */
  7434. get diagonalLength(): number;
  7435. /**
  7436. * Checks if a cullable object (mesh...) is in the camera frustum
  7437. * Unlike isInFrustum this cheks the full bounding box
  7438. * @param frustumPlanes Camera near/planes
  7439. * @returns true if the object is in frustum otherwise false
  7440. */
  7441. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7442. /** @hidden */
  7443. _checkCollision(collider: Collider): boolean;
  7444. /**
  7445. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7446. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7447. * @param point the point to check intersection with
  7448. * @returns if the point intersects
  7449. */
  7450. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7451. /**
  7452. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7453. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7454. * @param boundingInfo the bounding info to check intersection with
  7455. * @param precise if the intersection should be done using OBB
  7456. * @returns if the bounding info intersects
  7457. */
  7458. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7459. }
  7460. }
  7461. declare module "babylonjs/Maths/math.functions" {
  7462. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7463. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7464. /**
  7465. * Extracts minimum and maximum values from a list of indexed positions
  7466. * @param positions defines the positions to use
  7467. * @param indices defines the indices to the positions
  7468. * @param indexStart defines the start index
  7469. * @param indexCount defines the end index
  7470. * @param bias defines bias value to add to the result
  7471. * @return minimum and maximum values
  7472. */
  7473. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7474. minimum: Vector3;
  7475. maximum: Vector3;
  7476. };
  7477. /**
  7478. * Extracts minimum and maximum values from a list of positions
  7479. * @param positions defines the positions to use
  7480. * @param start defines the start index in the positions array
  7481. * @param count defines the number of positions to handle
  7482. * @param bias defines bias value to add to the result
  7483. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7484. * @return minimum and maximum values
  7485. */
  7486. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7487. minimum: Vector3;
  7488. maximum: Vector3;
  7489. };
  7490. }
  7491. declare module "babylonjs/Misc/guid" {
  7492. /**
  7493. * Class used to manipulate GUIDs
  7494. */
  7495. export class GUID {
  7496. /**
  7497. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7498. * Be aware Math.random() could cause collisions, but:
  7499. * "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"
  7500. * @returns a pseudo random id
  7501. */
  7502. static RandomId(): string;
  7503. }
  7504. }
  7505. declare module "babylonjs/Materials/Textures/baseTexture" {
  7506. import { Observable } from "babylonjs/Misc/observable";
  7507. import { Nullable } from "babylonjs/types";
  7508. import { Scene } from "babylonjs/scene";
  7509. import { Matrix } from "babylonjs/Maths/math.vector";
  7510. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7511. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  7512. import "babylonjs/Misc/fileTools";
  7513. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7514. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  7515. /**
  7516. * Base class of all the textures in babylon.
  7517. * It groups all the common properties the materials, post process, lights... might need
  7518. * in order to make a correct use of the texture.
  7519. */
  7520. export class BaseTexture extends ThinTexture implements IAnimatable {
  7521. /**
  7522. * Default anisotropic filtering level for the application.
  7523. * It is set to 4 as a good tradeoff between perf and quality.
  7524. */
  7525. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7526. /**
  7527. * Gets or sets the unique id of the texture
  7528. */
  7529. uniqueId: number;
  7530. /**
  7531. * Define the name of the texture.
  7532. */
  7533. name: string;
  7534. /**
  7535. * Gets or sets an object used to store user defined information.
  7536. */
  7537. metadata: any;
  7538. /**
  7539. * For internal use only. Please do not use.
  7540. */
  7541. reservedDataStore: any;
  7542. private _hasAlpha;
  7543. /**
  7544. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7545. */
  7546. set hasAlpha(value: boolean);
  7547. get hasAlpha(): boolean;
  7548. /**
  7549. * Defines if the alpha value should be determined via the rgb values.
  7550. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7551. */
  7552. getAlphaFromRGB: boolean;
  7553. /**
  7554. * Intensity or strength of the texture.
  7555. * It is commonly used by materials to fine tune the intensity of the texture
  7556. */
  7557. level: number;
  7558. /**
  7559. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7560. * This is part of the texture as textures usually maps to one uv set.
  7561. */
  7562. coordinatesIndex: number;
  7563. protected _coordinatesMode: number;
  7564. /**
  7565. * How a texture is mapped.
  7566. *
  7567. * | Value | Type | Description |
  7568. * | ----- | ----------------------------------- | ----------- |
  7569. * | 0 | EXPLICIT_MODE | |
  7570. * | 1 | SPHERICAL_MODE | |
  7571. * | 2 | PLANAR_MODE | |
  7572. * | 3 | CUBIC_MODE | |
  7573. * | 4 | PROJECTION_MODE | |
  7574. * | 5 | SKYBOX_MODE | |
  7575. * | 6 | INVCUBIC_MODE | |
  7576. * | 7 | EQUIRECTANGULAR_MODE | |
  7577. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7578. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7579. */
  7580. set coordinatesMode(value: number);
  7581. get coordinatesMode(): number;
  7582. /**
  7583. * | Value | Type | Description |
  7584. * | ----- | ------------------ | ----------- |
  7585. * | 0 | CLAMP_ADDRESSMODE | |
  7586. * | 1 | WRAP_ADDRESSMODE | |
  7587. * | 2 | MIRROR_ADDRESSMODE | |
  7588. */
  7589. get wrapU(): number;
  7590. set wrapU(value: number);
  7591. /**
  7592. * | Value | Type | Description |
  7593. * | ----- | ------------------ | ----------- |
  7594. * | 0 | CLAMP_ADDRESSMODE | |
  7595. * | 1 | WRAP_ADDRESSMODE | |
  7596. * | 2 | MIRROR_ADDRESSMODE | |
  7597. */
  7598. get wrapV(): number;
  7599. set wrapV(value: number);
  7600. /**
  7601. * | Value | Type | Description |
  7602. * | ----- | ------------------ | ----------- |
  7603. * | 0 | CLAMP_ADDRESSMODE | |
  7604. * | 1 | WRAP_ADDRESSMODE | |
  7605. * | 2 | MIRROR_ADDRESSMODE | |
  7606. */
  7607. wrapR: number;
  7608. /**
  7609. * With compliant hardware and browser (supporting anisotropic filtering)
  7610. * this defines the level of anisotropic filtering in the texture.
  7611. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7612. */
  7613. anisotropicFilteringLevel: number;
  7614. private _isCube;
  7615. /**
  7616. * Define if the texture is a cube texture or if false a 2d texture.
  7617. */
  7618. get isCube(): boolean;
  7619. set isCube(value: boolean);
  7620. /**
  7621. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7622. */
  7623. get is3D(): boolean;
  7624. set is3D(value: boolean);
  7625. /**
  7626. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7627. */
  7628. get is2DArray(): boolean;
  7629. set is2DArray(value: boolean);
  7630. private _gammaSpace;
  7631. /**
  7632. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7633. * HDR texture are usually stored in linear space.
  7634. * This only impacts the PBR and Background materials
  7635. */
  7636. get gammaSpace(): boolean;
  7637. set gammaSpace(gamma: boolean);
  7638. /**
  7639. * Gets or sets whether or not the texture contains RGBD data.
  7640. */
  7641. get isRGBD(): boolean;
  7642. set isRGBD(value: boolean);
  7643. /**
  7644. * Is Z inverted in the texture (useful in a cube texture).
  7645. */
  7646. invertZ: boolean;
  7647. /**
  7648. * Are mip maps generated for this texture or not.
  7649. */
  7650. get noMipmap(): boolean;
  7651. /**
  7652. * @hidden
  7653. */
  7654. lodLevelInAlpha: boolean;
  7655. /**
  7656. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7657. */
  7658. get lodGenerationOffset(): number;
  7659. set lodGenerationOffset(value: number);
  7660. /**
  7661. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7662. */
  7663. get lodGenerationScale(): number;
  7664. set lodGenerationScale(value: number);
  7665. /**
  7666. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7667. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7668. * average roughness values.
  7669. */
  7670. get linearSpecularLOD(): boolean;
  7671. set linearSpecularLOD(value: boolean);
  7672. /**
  7673. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7674. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7675. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7676. */
  7677. get irradianceTexture(): Nullable<BaseTexture>;
  7678. set irradianceTexture(value: Nullable<BaseTexture>);
  7679. /**
  7680. * Define if the texture is a render target.
  7681. */
  7682. isRenderTarget: boolean;
  7683. /**
  7684. * Define the unique id of the texture in the scene.
  7685. */
  7686. get uid(): string;
  7687. /** @hidden */
  7688. _prefiltered: boolean;
  7689. /**
  7690. * Return a string representation of the texture.
  7691. * @returns the texture as a string
  7692. */
  7693. toString(): string;
  7694. /**
  7695. * Get the class name of the texture.
  7696. * @returns "BaseTexture"
  7697. */
  7698. getClassName(): string;
  7699. /**
  7700. * Define the list of animation attached to the texture.
  7701. */
  7702. animations: import("babylonjs/Animations/animation").Animation[];
  7703. /**
  7704. * An event triggered when the texture is disposed.
  7705. */
  7706. onDisposeObservable: Observable<BaseTexture>;
  7707. private _onDisposeObserver;
  7708. /**
  7709. * Callback triggered when the texture has been disposed.
  7710. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7711. */
  7712. set onDispose(callback: () => void);
  7713. protected _scene: Nullable<Scene>;
  7714. /** @hidden */
  7715. _texture: Nullable<InternalTexture>;
  7716. private _uid;
  7717. /**
  7718. * Define if the texture is preventinga material to render or not.
  7719. * If not and the texture is not ready, the engine will use a default black texture instead.
  7720. */
  7721. get isBlocking(): boolean;
  7722. /**
  7723. * Instantiates a new BaseTexture.
  7724. * Base class of all the textures in babylon.
  7725. * It groups all the common properties the materials, post process, lights... might need
  7726. * in order to make a correct use of the texture.
  7727. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7728. */
  7729. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7730. /**
  7731. * Get the scene the texture belongs to.
  7732. * @returns the scene or null if undefined
  7733. */
  7734. getScene(): Nullable<Scene>;
  7735. /** @hidden */
  7736. protected _getEngine(): Nullable<ThinEngine>;
  7737. /**
  7738. * Checks if the texture has the same transform matrix than another texture
  7739. * @param texture texture to check against
  7740. * @returns true if the transforms are the same, else false
  7741. */
  7742. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7743. /**
  7744. * Get the texture transform matrix used to offset tile the texture for istance.
  7745. * @returns the transformation matrix
  7746. */
  7747. getTextureMatrix(): Matrix;
  7748. /**
  7749. * Get the texture reflection matrix used to rotate/transform the reflection.
  7750. * @returns the reflection matrix
  7751. */
  7752. getReflectionTextureMatrix(): Matrix;
  7753. /**
  7754. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7755. * @returns true if ready or not blocking
  7756. */
  7757. isReadyOrNotBlocking(): boolean;
  7758. /**
  7759. * Scales the texture if is `canRescale()`
  7760. * @param ratio the resize factor we want to use to rescale
  7761. */
  7762. scale(ratio: number): void;
  7763. /**
  7764. * Get if the texture can rescale.
  7765. */
  7766. get canRescale(): boolean;
  7767. /** @hidden */
  7768. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7769. /** @hidden */
  7770. _rebuild(): void;
  7771. /**
  7772. * Clones the texture.
  7773. * @returns the cloned texture
  7774. */
  7775. clone(): Nullable<BaseTexture>;
  7776. /**
  7777. * Get the texture underlying type (INT, FLOAT...)
  7778. */
  7779. get textureType(): number;
  7780. /**
  7781. * Get the texture underlying format (RGB, RGBA...)
  7782. */
  7783. get textureFormat(): number;
  7784. /**
  7785. * Indicates that textures need to be re-calculated for all materials
  7786. */
  7787. protected _markAllSubMeshesAsTexturesDirty(): void;
  7788. /**
  7789. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7790. * This will returns an RGBA array buffer containing either in values (0-255) or
  7791. * float values (0-1) depending of the underlying buffer type.
  7792. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7793. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7794. * @param buffer defines a user defined buffer to fill with data (can be null)
  7795. * @returns The Array buffer containing the pixels data.
  7796. */
  7797. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  7798. /** @hidden */
  7799. get _lodTextureHigh(): Nullable<BaseTexture>;
  7800. /** @hidden */
  7801. get _lodTextureMid(): Nullable<BaseTexture>;
  7802. /** @hidden */
  7803. get _lodTextureLow(): Nullable<BaseTexture>;
  7804. /**
  7805. * Dispose the texture and release its associated resources.
  7806. */
  7807. dispose(): void;
  7808. /**
  7809. * Serialize the texture into a JSON representation that can be parsed later on.
  7810. * @returns the JSON representation of the texture
  7811. */
  7812. serialize(): any;
  7813. /**
  7814. * Helper function to be called back once a list of texture contains only ready textures.
  7815. * @param textures Define the list of textures to wait for
  7816. * @param callback Define the callback triggered once the entire list will be ready
  7817. */
  7818. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  7819. private static _isScene;
  7820. }
  7821. }
  7822. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7823. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7824. /** @hidden */
  7825. export class WebGLDataBuffer extends DataBuffer {
  7826. private _buffer;
  7827. constructor(resource: WebGLBuffer);
  7828. get underlyingResource(): any;
  7829. }
  7830. }
  7831. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7832. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7833. import { Nullable } from "babylonjs/types";
  7834. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7835. /** @hidden */
  7836. export class WebGLPipelineContext implements IPipelineContext {
  7837. engine: ThinEngine;
  7838. program: Nullable<WebGLProgram>;
  7839. context?: WebGLRenderingContext;
  7840. vertexShader?: WebGLShader;
  7841. fragmentShader?: WebGLShader;
  7842. isParallelCompiled: boolean;
  7843. onCompiled?: () => void;
  7844. transformFeedback?: WebGLTransformFeedback | null;
  7845. vertexCompilationError: Nullable<string>;
  7846. fragmentCompilationError: Nullable<string>;
  7847. programLinkError: Nullable<string>;
  7848. programValidationError: Nullable<string>;
  7849. get isAsync(): boolean;
  7850. get isReady(): boolean;
  7851. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7852. _getVertexShaderCode(): string | null;
  7853. _getFragmentShaderCode(): string | null;
  7854. }
  7855. }
  7856. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7857. import { FloatArray, Nullable } from "babylonjs/types";
  7858. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7859. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7860. module "babylonjs/Engines/thinEngine" {
  7861. interface ThinEngine {
  7862. /**
  7863. * Create an uniform buffer
  7864. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7865. * @param elements defines the content of the uniform buffer
  7866. * @returns the webGL uniform buffer
  7867. */
  7868. createUniformBuffer(elements: FloatArray): DataBuffer;
  7869. /**
  7870. * Create a dynamic uniform buffer
  7871. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7872. * @param elements defines the content of the uniform buffer
  7873. * @returns the webGL uniform buffer
  7874. */
  7875. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7876. /**
  7877. * Update an existing uniform buffer
  7878. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7879. * @param uniformBuffer defines the target uniform buffer
  7880. * @param elements defines the content to update
  7881. * @param offset defines the offset in the uniform buffer where update should start
  7882. * @param count defines the size of the data to update
  7883. */
  7884. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7885. /**
  7886. * Bind an uniform buffer to the current webGL context
  7887. * @param buffer defines the buffer to bind
  7888. */
  7889. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7890. /**
  7891. * Bind a buffer to the current webGL context at a given location
  7892. * @param buffer defines the buffer to bind
  7893. * @param location defines the index where to bind the buffer
  7894. */
  7895. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7896. /**
  7897. * Bind a specific block at a given index in a specific shader program
  7898. * @param pipelineContext defines the pipeline context to use
  7899. * @param blockName defines the block name
  7900. * @param index defines the index where to bind the block
  7901. */
  7902. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7903. }
  7904. }
  7905. }
  7906. declare module "babylonjs/Materials/uniformBuffer" {
  7907. import { Nullable, FloatArray } from "babylonjs/types";
  7908. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7909. import { Engine } from "babylonjs/Engines/engine";
  7910. import { Effect } from "babylonjs/Materials/effect";
  7911. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7912. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7913. import { Color3 } from "babylonjs/Maths/math.color";
  7914. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7915. /**
  7916. * Uniform buffer objects.
  7917. *
  7918. * Handles blocks of uniform on the GPU.
  7919. *
  7920. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7921. *
  7922. * For more information, please refer to :
  7923. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7924. */
  7925. export class UniformBuffer {
  7926. private _engine;
  7927. private _buffer;
  7928. private _data;
  7929. private _bufferData;
  7930. private _dynamic?;
  7931. private _uniformLocations;
  7932. private _uniformSizes;
  7933. private _uniformLocationPointer;
  7934. private _needSync;
  7935. private _noUBO;
  7936. private _currentEffect;
  7937. /** @hidden */
  7938. _alreadyBound: boolean;
  7939. private static _MAX_UNIFORM_SIZE;
  7940. private static _tempBuffer;
  7941. /**
  7942. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7943. * This is dynamic to allow compat with webgl 1 and 2.
  7944. * You will need to pass the name of the uniform as well as the value.
  7945. */
  7946. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7947. /**
  7948. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7949. * This is dynamic to allow compat with webgl 1 and 2.
  7950. * You will need to pass the name of the uniform as well as the value.
  7951. */
  7952. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7953. /**
  7954. * Lambda to Update a single float in a uniform buffer.
  7955. * This is dynamic to allow compat with webgl 1 and 2.
  7956. * You will need to pass the name of the uniform as well as the value.
  7957. */
  7958. updateFloat: (name: string, x: number) => void;
  7959. /**
  7960. * Lambda to Update a vec2 of float in a uniform buffer.
  7961. * This is dynamic to allow compat with webgl 1 and 2.
  7962. * You will need to pass the name of the uniform as well as the value.
  7963. */
  7964. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7965. /**
  7966. * Lambda to Update a vec3 of float in a uniform buffer.
  7967. * This is dynamic to allow compat with webgl 1 and 2.
  7968. * You will need to pass the name of the uniform as well as the value.
  7969. */
  7970. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7971. /**
  7972. * Lambda to Update a vec4 of float in a uniform buffer.
  7973. * This is dynamic to allow compat with webgl 1 and 2.
  7974. * You will need to pass the name of the uniform as well as the value.
  7975. */
  7976. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7977. /**
  7978. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7979. * This is dynamic to allow compat with webgl 1 and 2.
  7980. * You will need to pass the name of the uniform as well as the value.
  7981. */
  7982. updateMatrix: (name: string, mat: Matrix) => void;
  7983. /**
  7984. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7985. * This is dynamic to allow compat with webgl 1 and 2.
  7986. * You will need to pass the name of the uniform as well as the value.
  7987. */
  7988. updateVector3: (name: string, vector: Vector3) => void;
  7989. /**
  7990. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7991. * This is dynamic to allow compat with webgl 1 and 2.
  7992. * You will need to pass the name of the uniform as well as the value.
  7993. */
  7994. updateVector4: (name: string, vector: Vector4) => void;
  7995. /**
  7996. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7997. * This is dynamic to allow compat with webgl 1 and 2.
  7998. * You will need to pass the name of the uniform as well as the value.
  7999. */
  8000. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8001. /**
  8002. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8003. * This is dynamic to allow compat with webgl 1 and 2.
  8004. * You will need to pass the name of the uniform as well as the value.
  8005. */
  8006. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8007. /**
  8008. * Instantiates a new Uniform buffer objects.
  8009. *
  8010. * Handles blocks of uniform on the GPU.
  8011. *
  8012. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8013. *
  8014. * For more information, please refer to :
  8015. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8016. * @param engine Define the engine the buffer is associated with
  8017. * @param data Define the data contained in the buffer
  8018. * @param dynamic Define if the buffer is updatable
  8019. */
  8020. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  8021. /**
  8022. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8023. * or just falling back on setUniformXXX calls.
  8024. */
  8025. get useUbo(): boolean;
  8026. /**
  8027. * Indicates if the WebGL underlying uniform buffer is in sync
  8028. * with the javascript cache data.
  8029. */
  8030. get isSync(): boolean;
  8031. /**
  8032. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8033. * Also, a dynamic UniformBuffer will disable cache verification and always
  8034. * update the underlying WebGL uniform buffer to the GPU.
  8035. * @returns if Dynamic, otherwise false
  8036. */
  8037. isDynamic(): boolean;
  8038. /**
  8039. * The data cache on JS side.
  8040. * @returns the underlying data as a float array
  8041. */
  8042. getData(): Float32Array;
  8043. /**
  8044. * The underlying WebGL Uniform buffer.
  8045. * @returns the webgl buffer
  8046. */
  8047. getBuffer(): Nullable<DataBuffer>;
  8048. /**
  8049. * std140 layout specifies how to align data within an UBO structure.
  8050. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8051. * for specs.
  8052. */
  8053. private _fillAlignment;
  8054. /**
  8055. * Adds an uniform in the buffer.
  8056. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8057. * for the layout to be correct !
  8058. * @param name Name of the uniform, as used in the uniform block in the shader.
  8059. * @param size Data size, or data directly.
  8060. */
  8061. addUniform(name: string, size: number | number[]): void;
  8062. /**
  8063. * Adds a Matrix 4x4 to the uniform buffer.
  8064. * @param name Name of the uniform, as used in the uniform block in the shader.
  8065. * @param mat A 4x4 matrix.
  8066. */
  8067. addMatrix(name: string, mat: Matrix): void;
  8068. /**
  8069. * Adds a vec2 to the uniform buffer.
  8070. * @param name Name of the uniform, as used in the uniform block in the shader.
  8071. * @param x Define the x component value of the vec2
  8072. * @param y Define the y component value of the vec2
  8073. */
  8074. addFloat2(name: string, x: number, y: number): void;
  8075. /**
  8076. * Adds a vec3 to the uniform buffer.
  8077. * @param name Name of the uniform, as used in the uniform block in the shader.
  8078. * @param x Define the x component value of the vec3
  8079. * @param y Define the y component value of the vec3
  8080. * @param z Define the z component value of the vec3
  8081. */
  8082. addFloat3(name: string, x: number, y: number, z: number): void;
  8083. /**
  8084. * Adds a vec3 to the uniform buffer.
  8085. * @param name Name of the uniform, as used in the uniform block in the shader.
  8086. * @param color Define the vec3 from a Color
  8087. */
  8088. addColor3(name: string, color: Color3): void;
  8089. /**
  8090. * Adds a vec4 to the uniform buffer.
  8091. * @param name Name of the uniform, as used in the uniform block in the shader.
  8092. * @param color Define the rgb components from a Color
  8093. * @param alpha Define the a component of the vec4
  8094. */
  8095. addColor4(name: string, color: Color3, alpha: number): void;
  8096. /**
  8097. * Adds a vec3 to the uniform buffer.
  8098. * @param name Name of the uniform, as used in the uniform block in the shader.
  8099. * @param vector Define the vec3 components from a Vector
  8100. */
  8101. addVector3(name: string, vector: Vector3): void;
  8102. /**
  8103. * Adds a Matrix 3x3 to the uniform buffer.
  8104. * @param name Name of the uniform, as used in the uniform block in the shader.
  8105. */
  8106. addMatrix3x3(name: string): void;
  8107. /**
  8108. * Adds a Matrix 2x2 to the uniform buffer.
  8109. * @param name Name of the uniform, as used in the uniform block in the shader.
  8110. */
  8111. addMatrix2x2(name: string): void;
  8112. /**
  8113. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8114. */
  8115. create(): void;
  8116. /** @hidden */
  8117. _rebuild(): void;
  8118. /**
  8119. * Updates the WebGL Uniform Buffer on the GPU.
  8120. * If the `dynamic` flag is set to true, no cache comparison is done.
  8121. * Otherwise, the buffer will be updated only if the cache differs.
  8122. */
  8123. update(): void;
  8124. /**
  8125. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8126. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8127. * @param data Define the flattened data
  8128. * @param size Define the size of the data.
  8129. */
  8130. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8131. private _valueCache;
  8132. private _cacheMatrix;
  8133. private _updateMatrix3x3ForUniform;
  8134. private _updateMatrix3x3ForEffect;
  8135. private _updateMatrix2x2ForEffect;
  8136. private _updateMatrix2x2ForUniform;
  8137. private _updateFloatForEffect;
  8138. private _updateFloatForUniform;
  8139. private _updateFloat2ForEffect;
  8140. private _updateFloat2ForUniform;
  8141. private _updateFloat3ForEffect;
  8142. private _updateFloat3ForUniform;
  8143. private _updateFloat4ForEffect;
  8144. private _updateFloat4ForUniform;
  8145. private _updateMatrixForEffect;
  8146. private _updateMatrixForUniform;
  8147. private _updateVector3ForEffect;
  8148. private _updateVector3ForUniform;
  8149. private _updateVector4ForEffect;
  8150. private _updateVector4ForUniform;
  8151. private _updateColor3ForEffect;
  8152. private _updateColor3ForUniform;
  8153. private _updateColor4ForEffect;
  8154. private _updateColor4ForUniform;
  8155. /**
  8156. * Sets a sampler uniform on the effect.
  8157. * @param name Define the name of the sampler.
  8158. * @param texture Define the texture to set in the sampler
  8159. */
  8160. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8161. /**
  8162. * Directly updates the value of the uniform in the cache AND on the GPU.
  8163. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8164. * @param data Define the flattened data
  8165. */
  8166. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8167. /**
  8168. * Binds this uniform buffer to an effect.
  8169. * @param effect Define the effect to bind the buffer to
  8170. * @param name Name of the uniform block in the shader.
  8171. */
  8172. bindToEffect(effect: Effect, name: string): void;
  8173. /**
  8174. * Disposes the uniform buffer.
  8175. */
  8176. dispose(): void;
  8177. }
  8178. }
  8179. declare module "babylonjs/Materials/materialDefines" {
  8180. /**
  8181. * Manages the defines for the Material
  8182. */
  8183. export class MaterialDefines {
  8184. /** @hidden */
  8185. protected _keys: string[];
  8186. private _isDirty;
  8187. /** @hidden */
  8188. _renderId: number;
  8189. /** @hidden */
  8190. _areLightsDirty: boolean;
  8191. /** @hidden */
  8192. _areLightsDisposed: boolean;
  8193. /** @hidden */
  8194. _areAttributesDirty: boolean;
  8195. /** @hidden */
  8196. _areTexturesDirty: boolean;
  8197. /** @hidden */
  8198. _areFresnelDirty: boolean;
  8199. /** @hidden */
  8200. _areMiscDirty: boolean;
  8201. /** @hidden */
  8202. _arePrePassDirty: boolean;
  8203. /** @hidden */
  8204. _areImageProcessingDirty: boolean;
  8205. /** @hidden */
  8206. _normals: boolean;
  8207. /** @hidden */
  8208. _uvs: boolean;
  8209. /** @hidden */
  8210. _needNormals: boolean;
  8211. /** @hidden */
  8212. _needUVs: boolean;
  8213. [id: string]: any;
  8214. /**
  8215. * Specifies if the material needs to be re-calculated
  8216. */
  8217. get isDirty(): boolean;
  8218. /**
  8219. * Marks the material to indicate that it has been re-calculated
  8220. */
  8221. markAsProcessed(): void;
  8222. /**
  8223. * Marks the material to indicate that it needs to be re-calculated
  8224. */
  8225. markAsUnprocessed(): void;
  8226. /**
  8227. * Marks the material to indicate all of its defines need to be re-calculated
  8228. */
  8229. markAllAsDirty(): void;
  8230. /**
  8231. * Marks the material to indicate that image processing needs to be re-calculated
  8232. */
  8233. markAsImageProcessingDirty(): void;
  8234. /**
  8235. * Marks the material to indicate the lights need to be re-calculated
  8236. * @param disposed Defines whether the light is dirty due to dispose or not
  8237. */
  8238. markAsLightDirty(disposed?: boolean): void;
  8239. /**
  8240. * Marks the attribute state as changed
  8241. */
  8242. markAsAttributesDirty(): void;
  8243. /**
  8244. * Marks the texture state as changed
  8245. */
  8246. markAsTexturesDirty(): void;
  8247. /**
  8248. * Marks the fresnel state as changed
  8249. */
  8250. markAsFresnelDirty(): void;
  8251. /**
  8252. * Marks the misc state as changed
  8253. */
  8254. markAsMiscDirty(): void;
  8255. /**
  8256. * Marks the prepass state as changed
  8257. */
  8258. markAsPrePassDirty(): void;
  8259. /**
  8260. * Rebuilds the material defines
  8261. */
  8262. rebuild(): void;
  8263. /**
  8264. * Specifies if two material defines are equal
  8265. * @param other - A material define instance to compare to
  8266. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8267. */
  8268. isEqual(other: MaterialDefines): boolean;
  8269. /**
  8270. * Clones this instance's defines to another instance
  8271. * @param other - material defines to clone values to
  8272. */
  8273. cloneTo(other: MaterialDefines): void;
  8274. /**
  8275. * Resets the material define values
  8276. */
  8277. reset(): void;
  8278. /**
  8279. * Converts the material define values to a string
  8280. * @returns - String of material define information
  8281. */
  8282. toString(): string;
  8283. }
  8284. }
  8285. declare module "babylonjs/Misc/iInspectable" {
  8286. /**
  8287. * Enum that determines the text-wrapping mode to use.
  8288. */
  8289. export enum InspectableType {
  8290. /**
  8291. * Checkbox for booleans
  8292. */
  8293. Checkbox = 0,
  8294. /**
  8295. * Sliders for numbers
  8296. */
  8297. Slider = 1,
  8298. /**
  8299. * Vector3
  8300. */
  8301. Vector3 = 2,
  8302. /**
  8303. * Quaternions
  8304. */
  8305. Quaternion = 3,
  8306. /**
  8307. * Color3
  8308. */
  8309. Color3 = 4,
  8310. /**
  8311. * String
  8312. */
  8313. String = 5
  8314. }
  8315. /**
  8316. * Interface used to define custom inspectable properties.
  8317. * This interface is used by the inspector to display custom property grids
  8318. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8319. */
  8320. export interface IInspectable {
  8321. /**
  8322. * Gets the label to display
  8323. */
  8324. label: string;
  8325. /**
  8326. * Gets the name of the property to edit
  8327. */
  8328. propertyName: string;
  8329. /**
  8330. * Gets the type of the editor to use
  8331. */
  8332. type: InspectableType;
  8333. /**
  8334. * Gets the minimum value of the property when using in "slider" mode
  8335. */
  8336. min?: number;
  8337. /**
  8338. * Gets the maximum value of the property when using in "slider" mode
  8339. */
  8340. max?: number;
  8341. /**
  8342. * Gets the setp to use when using in "slider" mode
  8343. */
  8344. step?: number;
  8345. }
  8346. }
  8347. declare module "babylonjs/Lights/light" {
  8348. import { Nullable } from "babylonjs/types";
  8349. import { Scene } from "babylonjs/scene";
  8350. import { Vector3 } from "babylonjs/Maths/math.vector";
  8351. import { Color3 } from "babylonjs/Maths/math.color";
  8352. import { Node } from "babylonjs/node";
  8353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8354. import { Effect } from "babylonjs/Materials/effect";
  8355. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8356. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  8357. /**
  8358. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8359. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8360. * 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.
  8361. */
  8362. export abstract class Light extends Node {
  8363. /**
  8364. * Falloff Default: light is falling off following the material specification:
  8365. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8366. */
  8367. static readonly FALLOFF_DEFAULT: number;
  8368. /**
  8369. * Falloff Physical: light is falling off following the inverse squared distance law.
  8370. */
  8371. static readonly FALLOFF_PHYSICAL: number;
  8372. /**
  8373. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8374. * to enhance interoperability with other engines.
  8375. */
  8376. static readonly FALLOFF_GLTF: number;
  8377. /**
  8378. * Falloff Standard: light is falling off like in the standard material
  8379. * to enhance interoperability with other materials.
  8380. */
  8381. static readonly FALLOFF_STANDARD: number;
  8382. /**
  8383. * If every light affecting the material is in this lightmapMode,
  8384. * material.lightmapTexture adds or multiplies
  8385. * (depends on material.useLightmapAsShadowmap)
  8386. * after every other light calculations.
  8387. */
  8388. static readonly LIGHTMAP_DEFAULT: number;
  8389. /**
  8390. * material.lightmapTexture as only diffuse lighting from this light
  8391. * adds only specular lighting from this light
  8392. * adds dynamic shadows
  8393. */
  8394. static readonly LIGHTMAP_SPECULAR: number;
  8395. /**
  8396. * material.lightmapTexture as only lighting
  8397. * no light calculation from this light
  8398. * only adds dynamic shadows from this light
  8399. */
  8400. static readonly LIGHTMAP_SHADOWSONLY: number;
  8401. /**
  8402. * Each light type uses the default quantity according to its type:
  8403. * point/spot lights use luminous intensity
  8404. * directional lights use illuminance
  8405. */
  8406. static readonly INTENSITYMODE_AUTOMATIC: number;
  8407. /**
  8408. * lumen (lm)
  8409. */
  8410. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8411. /**
  8412. * candela (lm/sr)
  8413. */
  8414. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8415. /**
  8416. * lux (lm/m^2)
  8417. */
  8418. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8419. /**
  8420. * nit (cd/m^2)
  8421. */
  8422. static readonly INTENSITYMODE_LUMINANCE: number;
  8423. /**
  8424. * Light type const id of the point light.
  8425. */
  8426. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8427. /**
  8428. * Light type const id of the directional light.
  8429. */
  8430. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8431. /**
  8432. * Light type const id of the spot light.
  8433. */
  8434. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8435. /**
  8436. * Light type const id of the hemispheric light.
  8437. */
  8438. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8439. /**
  8440. * Diffuse gives the basic color to an object.
  8441. */
  8442. diffuse: Color3;
  8443. /**
  8444. * Specular produces a highlight color on an object.
  8445. * Note: This is note affecting PBR materials.
  8446. */
  8447. specular: Color3;
  8448. /**
  8449. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8450. * falling off base on range or angle.
  8451. * This can be set to any values in Light.FALLOFF_x.
  8452. *
  8453. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8454. * other types of materials.
  8455. */
  8456. falloffType: number;
  8457. /**
  8458. * Strength of the light.
  8459. * Note: By default it is define in the framework own unit.
  8460. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8461. */
  8462. intensity: number;
  8463. private _range;
  8464. protected _inverseSquaredRange: number;
  8465. /**
  8466. * Defines how far from the source the light is impacting in scene units.
  8467. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8468. */
  8469. get range(): number;
  8470. /**
  8471. * Defines how far from the source the light is impacting in scene units.
  8472. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8473. */
  8474. set range(value: number);
  8475. /**
  8476. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8477. * of light.
  8478. */
  8479. private _photometricScale;
  8480. private _intensityMode;
  8481. /**
  8482. * Gets the photometric scale used to interpret the intensity.
  8483. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8484. */
  8485. get intensityMode(): number;
  8486. /**
  8487. * Sets the photometric scale used to interpret the intensity.
  8488. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8489. */
  8490. set intensityMode(value: number);
  8491. private _radius;
  8492. /**
  8493. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8494. */
  8495. get radius(): number;
  8496. /**
  8497. * sets the light radius used by PBR Materials to simulate soft area lights.
  8498. */
  8499. set radius(value: number);
  8500. private _renderPriority;
  8501. /**
  8502. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8503. * exceeding the number allowed of the materials.
  8504. */
  8505. renderPriority: number;
  8506. private _shadowEnabled;
  8507. /**
  8508. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8509. * the current shadow generator.
  8510. */
  8511. get shadowEnabled(): boolean;
  8512. /**
  8513. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8514. * the current shadow generator.
  8515. */
  8516. set shadowEnabled(value: boolean);
  8517. private _includedOnlyMeshes;
  8518. /**
  8519. * Gets the only meshes impacted by this light.
  8520. */
  8521. get includedOnlyMeshes(): AbstractMesh[];
  8522. /**
  8523. * Sets the only meshes impacted by this light.
  8524. */
  8525. set includedOnlyMeshes(value: AbstractMesh[]);
  8526. private _excludedMeshes;
  8527. /**
  8528. * Gets the meshes not impacted by this light.
  8529. */
  8530. get excludedMeshes(): AbstractMesh[];
  8531. /**
  8532. * Sets the meshes not impacted by this light.
  8533. */
  8534. set excludedMeshes(value: AbstractMesh[]);
  8535. private _excludeWithLayerMask;
  8536. /**
  8537. * Gets the layer id use to find what meshes are not impacted by the light.
  8538. * Inactive if 0
  8539. */
  8540. get excludeWithLayerMask(): number;
  8541. /**
  8542. * Sets the layer id use to find what meshes are not impacted by the light.
  8543. * Inactive if 0
  8544. */
  8545. set excludeWithLayerMask(value: number);
  8546. private _includeOnlyWithLayerMask;
  8547. /**
  8548. * Gets the layer id use to find what meshes are impacted by the light.
  8549. * Inactive if 0
  8550. */
  8551. get includeOnlyWithLayerMask(): number;
  8552. /**
  8553. * Sets the layer id use to find what meshes are impacted by the light.
  8554. * Inactive if 0
  8555. */
  8556. set includeOnlyWithLayerMask(value: number);
  8557. private _lightmapMode;
  8558. /**
  8559. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8560. */
  8561. get lightmapMode(): number;
  8562. /**
  8563. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8564. */
  8565. set lightmapMode(value: number);
  8566. /**
  8567. * Shadow generator associted to the light.
  8568. * @hidden Internal use only.
  8569. */
  8570. _shadowGenerator: Nullable<IShadowGenerator>;
  8571. /**
  8572. * @hidden Internal use only.
  8573. */
  8574. _excludedMeshesIds: string[];
  8575. /**
  8576. * @hidden Internal use only.
  8577. */
  8578. _includedOnlyMeshesIds: string[];
  8579. /**
  8580. * The current light unifom buffer.
  8581. * @hidden Internal use only.
  8582. */
  8583. _uniformBuffer: UniformBuffer;
  8584. /** @hidden */
  8585. _renderId: number;
  8586. /**
  8587. * Creates a Light object in the scene.
  8588. * Documentation : https://doc.babylonjs.com/babylon101/lights
  8589. * @param name The firendly name of the light
  8590. * @param scene The scene the light belongs too
  8591. */
  8592. constructor(name: string, scene: Scene);
  8593. protected abstract _buildUniformLayout(): void;
  8594. /**
  8595. * Sets the passed Effect "effect" with the Light information.
  8596. * @param effect The effect to update
  8597. * @param lightIndex The index of the light in the effect to update
  8598. * @returns The light
  8599. */
  8600. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  8601. /**
  8602. * Sets the passed Effect "effect" with the Light textures.
  8603. * @param effect The effect to update
  8604. * @param lightIndex The index of the light in the effect to update
  8605. * @returns The light
  8606. */
  8607. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  8608. /**
  8609. * Binds the lights information from the scene to the effect for the given mesh.
  8610. * @param lightIndex Light index
  8611. * @param scene The scene where the light belongs to
  8612. * @param effect The effect we are binding the data to
  8613. * @param useSpecular Defines if specular is supported
  8614. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8615. */
  8616. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  8617. /**
  8618. * Sets the passed Effect "effect" with the Light information.
  8619. * @param effect The effect to update
  8620. * @param lightDataUniformName The uniform used to store light data (position or direction)
  8621. * @returns The light
  8622. */
  8623. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  8624. /**
  8625. * Returns the string "Light".
  8626. * @returns the class name
  8627. */
  8628. getClassName(): string;
  8629. /** @hidden */
  8630. readonly _isLight: boolean;
  8631. /**
  8632. * Converts the light information to a readable string for debug purpose.
  8633. * @param fullDetails Supports for multiple levels of logging within scene loading
  8634. * @returns the human readable light info
  8635. */
  8636. toString(fullDetails?: boolean): string;
  8637. /** @hidden */
  8638. protected _syncParentEnabledState(): void;
  8639. /**
  8640. * Set the enabled state of this node.
  8641. * @param value - the new enabled state
  8642. */
  8643. setEnabled(value: boolean): void;
  8644. /**
  8645. * Returns the Light associated shadow generator if any.
  8646. * @return the associated shadow generator.
  8647. */
  8648. getShadowGenerator(): Nullable<IShadowGenerator>;
  8649. /**
  8650. * Returns a Vector3, the absolute light position in the World.
  8651. * @returns the world space position of the light
  8652. */
  8653. getAbsolutePosition(): Vector3;
  8654. /**
  8655. * Specifies if the light will affect the passed mesh.
  8656. * @param mesh The mesh to test against the light
  8657. * @return true the mesh is affected otherwise, false.
  8658. */
  8659. canAffectMesh(mesh: AbstractMesh): boolean;
  8660. /**
  8661. * Sort function to order lights for rendering.
  8662. * @param a First Light object to compare to second.
  8663. * @param b Second Light object to compare first.
  8664. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  8665. */
  8666. static CompareLightsPriority(a: Light, b: Light): number;
  8667. /**
  8668. * Releases resources associated with this node.
  8669. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8670. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8671. */
  8672. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8673. /**
  8674. * Returns the light type ID (integer).
  8675. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8676. */
  8677. getTypeID(): number;
  8678. /**
  8679. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  8680. * @returns the scaled intensity in intensity mode unit
  8681. */
  8682. getScaledIntensity(): number;
  8683. /**
  8684. * Returns a new Light object, named "name", from the current one.
  8685. * @param name The name of the cloned light
  8686. * @param newParent The parent of this light, if it has one
  8687. * @returns the new created light
  8688. */
  8689. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  8690. /**
  8691. * Serializes the current light into a Serialization object.
  8692. * @returns the serialized object.
  8693. */
  8694. serialize(): any;
  8695. /**
  8696. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  8697. * This new light is named "name" and added to the passed scene.
  8698. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  8699. * @param name The friendly name of the light
  8700. * @param scene The scene the new light will belong to
  8701. * @returns the constructor function
  8702. */
  8703. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  8704. /**
  8705. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  8706. * @param parsedLight The JSON representation of the light
  8707. * @param scene The scene to create the parsed light in
  8708. * @returns the created light after parsing
  8709. */
  8710. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  8711. private _hookArrayForExcluded;
  8712. private _hookArrayForIncludedOnly;
  8713. private _resyncMeshes;
  8714. /**
  8715. * Forces the meshes to update their light related information in their rendering used effects
  8716. * @hidden Internal Use Only
  8717. */
  8718. _markMeshesAsLightDirty(): void;
  8719. /**
  8720. * Recomputes the cached photometric scale if needed.
  8721. */
  8722. private _computePhotometricScale;
  8723. /**
  8724. * Returns the Photometric Scale according to the light type and intensity mode.
  8725. */
  8726. private _getPhotometricScale;
  8727. /**
  8728. * Reorder the light in the scene according to their defined priority.
  8729. * @hidden Internal Use Only
  8730. */
  8731. _reorderLightsInScene(): void;
  8732. /**
  8733. * Prepares the list of defines specific to the light type.
  8734. * @param defines the list of defines
  8735. * @param lightIndex defines the index of the light for the effect
  8736. */
  8737. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  8738. }
  8739. }
  8740. declare module "babylonjs/Maths/math.axis" {
  8741. import { Vector3 } from "babylonjs/Maths/math.vector";
  8742. /** Defines supported spaces */
  8743. export enum Space {
  8744. /** Local (object) space */
  8745. LOCAL = 0,
  8746. /** World space */
  8747. WORLD = 1,
  8748. /** Bone space */
  8749. BONE = 2
  8750. }
  8751. /** Defines the 3 main axes */
  8752. export class Axis {
  8753. /** X axis */
  8754. static X: Vector3;
  8755. /** Y axis */
  8756. static Y: Vector3;
  8757. /** Z axis */
  8758. static Z: Vector3;
  8759. }
  8760. /**
  8761. * Defines cartesian components.
  8762. */
  8763. export enum Coordinate {
  8764. /** X axis */
  8765. X = 0,
  8766. /** Y axis */
  8767. Y = 1,
  8768. /** Z axis */
  8769. Z = 2
  8770. }
  8771. }
  8772. declare module "babylonjs/Lights/shadowLight" {
  8773. import { Camera } from "babylonjs/Cameras/camera";
  8774. import { Scene } from "babylonjs/scene";
  8775. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8777. import { Light } from "babylonjs/Lights/light";
  8778. /**
  8779. * Interface describing all the common properties and methods a shadow light needs to implement.
  8780. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8781. * as well as binding the different shadow properties to the effects.
  8782. */
  8783. export interface IShadowLight extends Light {
  8784. /**
  8785. * The light id in the scene (used in scene.findLighById for instance)
  8786. */
  8787. id: string;
  8788. /**
  8789. * The position the shdow will be casted from.
  8790. */
  8791. position: Vector3;
  8792. /**
  8793. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8794. */
  8795. direction: Vector3;
  8796. /**
  8797. * The transformed position. Position of the light in world space taking parenting in account.
  8798. */
  8799. transformedPosition: Vector3;
  8800. /**
  8801. * The transformed direction. Direction of the light in world space taking parenting in account.
  8802. */
  8803. transformedDirection: Vector3;
  8804. /**
  8805. * The friendly name of the light in the scene.
  8806. */
  8807. name: string;
  8808. /**
  8809. * Defines the shadow projection clipping minimum z value.
  8810. */
  8811. shadowMinZ: number;
  8812. /**
  8813. * Defines the shadow projection clipping maximum z value.
  8814. */
  8815. shadowMaxZ: number;
  8816. /**
  8817. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8818. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8819. */
  8820. computeTransformedInformation(): boolean;
  8821. /**
  8822. * Gets the scene the light belongs to.
  8823. * @returns The scene
  8824. */
  8825. getScene(): Scene;
  8826. /**
  8827. * Callback defining a custom Projection Matrix Builder.
  8828. * This can be used to override the default projection matrix computation.
  8829. */
  8830. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8831. /**
  8832. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8833. * @param matrix The materix to updated with the projection information
  8834. * @param viewMatrix The transform matrix of the light
  8835. * @param renderList The list of mesh to render in the map
  8836. * @returns The current light
  8837. */
  8838. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8839. /**
  8840. * Gets the current depth scale used in ESM.
  8841. * @returns The scale
  8842. */
  8843. getDepthScale(): number;
  8844. /**
  8845. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8846. * @returns true if a cube texture needs to be use
  8847. */
  8848. needCube(): boolean;
  8849. /**
  8850. * Detects if the projection matrix requires to be recomputed this frame.
  8851. * @returns true if it requires to be recomputed otherwise, false.
  8852. */
  8853. needProjectionMatrixCompute(): boolean;
  8854. /**
  8855. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8856. */
  8857. forceProjectionMatrixCompute(): void;
  8858. /**
  8859. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8860. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8861. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8862. */
  8863. getShadowDirection(faceIndex?: number): Vector3;
  8864. /**
  8865. * Gets the minZ used for shadow according to both the scene and the light.
  8866. * @param activeCamera The camera we are returning the min for
  8867. * @returns the depth min z
  8868. */
  8869. getDepthMinZ(activeCamera: Camera): number;
  8870. /**
  8871. * Gets the maxZ used for shadow according to both the scene and the light.
  8872. * @param activeCamera The camera we are returning the max for
  8873. * @returns the depth max z
  8874. */
  8875. getDepthMaxZ(activeCamera: Camera): number;
  8876. }
  8877. /**
  8878. * Base implementation IShadowLight
  8879. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8880. */
  8881. export abstract class ShadowLight extends Light implements IShadowLight {
  8882. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8883. protected _position: Vector3;
  8884. protected _setPosition(value: Vector3): void;
  8885. /**
  8886. * Sets the position the shadow will be casted from. Also use as the light position for both
  8887. * point and spot lights.
  8888. */
  8889. get position(): Vector3;
  8890. /**
  8891. * Sets the position the shadow will be casted from. Also use as the light position for both
  8892. * point and spot lights.
  8893. */
  8894. set position(value: Vector3);
  8895. protected _direction: Vector3;
  8896. protected _setDirection(value: Vector3): void;
  8897. /**
  8898. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8899. * Also use as the light direction on spot and directional lights.
  8900. */
  8901. get direction(): Vector3;
  8902. /**
  8903. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8904. * Also use as the light direction on spot and directional lights.
  8905. */
  8906. set direction(value: Vector3);
  8907. protected _shadowMinZ: number;
  8908. /**
  8909. * Gets the shadow projection clipping minimum z value.
  8910. */
  8911. get shadowMinZ(): number;
  8912. /**
  8913. * Sets the shadow projection clipping minimum z value.
  8914. */
  8915. set shadowMinZ(value: number);
  8916. protected _shadowMaxZ: number;
  8917. /**
  8918. * Sets the shadow projection clipping maximum z value.
  8919. */
  8920. get shadowMaxZ(): number;
  8921. /**
  8922. * Gets the shadow projection clipping maximum z value.
  8923. */
  8924. set shadowMaxZ(value: number);
  8925. /**
  8926. * Callback defining a custom Projection Matrix Builder.
  8927. * This can be used to override the default projection matrix computation.
  8928. */
  8929. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8930. /**
  8931. * The transformed position. Position of the light in world space taking parenting in account.
  8932. */
  8933. transformedPosition: Vector3;
  8934. /**
  8935. * The transformed direction. Direction of the light in world space taking parenting in account.
  8936. */
  8937. transformedDirection: Vector3;
  8938. private _needProjectionMatrixCompute;
  8939. /**
  8940. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8941. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8942. */
  8943. computeTransformedInformation(): boolean;
  8944. /**
  8945. * Return the depth scale used for the shadow map.
  8946. * @returns the depth scale.
  8947. */
  8948. getDepthScale(): number;
  8949. /**
  8950. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8951. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8952. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8953. */
  8954. getShadowDirection(faceIndex?: number): Vector3;
  8955. /**
  8956. * Returns the ShadowLight absolute position in the World.
  8957. * @returns the position vector in world space
  8958. */
  8959. getAbsolutePosition(): Vector3;
  8960. /**
  8961. * Sets the ShadowLight direction toward the passed target.
  8962. * @param target The point to target in local space
  8963. * @returns the updated ShadowLight direction
  8964. */
  8965. setDirectionToTarget(target: Vector3): Vector3;
  8966. /**
  8967. * Returns the light rotation in euler definition.
  8968. * @returns the x y z rotation in local space.
  8969. */
  8970. getRotation(): Vector3;
  8971. /**
  8972. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8973. * @returns true if a cube texture needs to be use
  8974. */
  8975. needCube(): boolean;
  8976. /**
  8977. * Detects if the projection matrix requires to be recomputed this frame.
  8978. * @returns true if it requires to be recomputed otherwise, false.
  8979. */
  8980. needProjectionMatrixCompute(): boolean;
  8981. /**
  8982. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8983. */
  8984. forceProjectionMatrixCompute(): void;
  8985. /** @hidden */
  8986. _initCache(): void;
  8987. /** @hidden */
  8988. _isSynchronized(): boolean;
  8989. /**
  8990. * Computes the world matrix of the node
  8991. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8992. * @returns the world matrix
  8993. */
  8994. computeWorldMatrix(force?: boolean): Matrix;
  8995. /**
  8996. * Gets the minZ used for shadow according to both the scene and the light.
  8997. * @param activeCamera The camera we are returning the min for
  8998. * @returns the depth min z
  8999. */
  9000. getDepthMinZ(activeCamera: Camera): number;
  9001. /**
  9002. * Gets the maxZ used for shadow according to both the scene and the light.
  9003. * @param activeCamera The camera we are returning the max for
  9004. * @returns the depth max z
  9005. */
  9006. getDepthMaxZ(activeCamera: Camera): number;
  9007. /**
  9008. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9009. * @param matrix The materix to updated with the projection information
  9010. * @param viewMatrix The transform matrix of the light
  9011. * @param renderList The list of mesh to render in the map
  9012. * @returns The current light
  9013. */
  9014. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9015. }
  9016. }
  9017. declare module "babylonjs/Materials/prePassConfiguration" {
  9018. import { Matrix } from "babylonjs/Maths/math.vector";
  9019. import { Mesh } from "babylonjs/Meshes/mesh";
  9020. import { Scene } from "babylonjs/scene";
  9021. import { Effect } from "babylonjs/Materials/effect";
  9022. /**
  9023. * Configuration needed for prepass-capable materials
  9024. */
  9025. export class PrePassConfiguration {
  9026. /**
  9027. * Previous world matrices of meshes carrying this material
  9028. * Used for computing velocity
  9029. */
  9030. previousWorldMatrices: {
  9031. [index: number]: Matrix;
  9032. };
  9033. /**
  9034. * Previous view project matrix
  9035. * Used for computing velocity
  9036. */
  9037. previousViewProjection: Matrix;
  9038. /**
  9039. * Previous bones of meshes carrying this material
  9040. * Used for computing velocity
  9041. */
  9042. previousBones: {
  9043. [index: number]: Float32Array;
  9044. };
  9045. /**
  9046. * Add the required uniforms to the current list.
  9047. * @param uniforms defines the current uniform list.
  9048. */
  9049. static AddUniforms(uniforms: string[]): void;
  9050. /**
  9051. * Add the required samplers to the current list.
  9052. * @param samplers defines the current sampler list.
  9053. */
  9054. static AddSamplers(samplers: string[]): void;
  9055. /**
  9056. * Binds the material data.
  9057. * @param effect defines the effect to update
  9058. * @param scene defines the scene the material belongs to.
  9059. * @param mesh The mesh
  9060. * @param world World matrix of this mesh
  9061. * @param isFrozen Is the material frozen
  9062. */
  9063. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9064. }
  9065. }
  9066. declare module "babylonjs/Cameras/targetCamera" {
  9067. import { Nullable } from "babylonjs/types";
  9068. import { Camera } from "babylonjs/Cameras/camera";
  9069. import { Scene } from "babylonjs/scene";
  9070. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9071. /**
  9072. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9073. * This is the base of the follow, arc rotate cameras and Free camera
  9074. * @see https://doc.babylonjs.com/features/cameras
  9075. */
  9076. export class TargetCamera extends Camera {
  9077. private static _RigCamTransformMatrix;
  9078. private static _TargetTransformMatrix;
  9079. private static _TargetFocalPoint;
  9080. private _tmpUpVector;
  9081. private _tmpTargetVector;
  9082. /**
  9083. * Define the current direction the camera is moving to
  9084. */
  9085. cameraDirection: Vector3;
  9086. /**
  9087. * Define the current rotation the camera is rotating to
  9088. */
  9089. cameraRotation: Vector2;
  9090. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9091. ignoreParentScaling: boolean;
  9092. /**
  9093. * When set, the up vector of the camera will be updated by the rotation of the camera
  9094. */
  9095. updateUpVectorFromRotation: boolean;
  9096. private _tmpQuaternion;
  9097. /**
  9098. * Define the current rotation of the camera
  9099. */
  9100. rotation: Vector3;
  9101. /**
  9102. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9103. */
  9104. rotationQuaternion: Quaternion;
  9105. /**
  9106. * Define the current speed of the camera
  9107. */
  9108. speed: number;
  9109. /**
  9110. * Add constraint to the camera to prevent it to move freely in all directions and
  9111. * around all axis.
  9112. */
  9113. noRotationConstraint: boolean;
  9114. /**
  9115. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9116. * panning
  9117. */
  9118. invertRotation: boolean;
  9119. /**
  9120. * Speed multiplier for inverse camera panning
  9121. */
  9122. inverseRotationSpeed: number;
  9123. /**
  9124. * Define the current target of the camera as an object or a position.
  9125. */
  9126. lockedTarget: any;
  9127. /** @hidden */
  9128. _currentTarget: Vector3;
  9129. /** @hidden */
  9130. _initialFocalDistance: number;
  9131. /** @hidden */
  9132. _viewMatrix: Matrix;
  9133. /** @hidden */
  9134. _camMatrix: Matrix;
  9135. /** @hidden */
  9136. _cameraTransformMatrix: Matrix;
  9137. /** @hidden */
  9138. _cameraRotationMatrix: Matrix;
  9139. /** @hidden */
  9140. _referencePoint: Vector3;
  9141. /** @hidden */
  9142. _transformedReferencePoint: Vector3;
  9143. /** @hidden */
  9144. _reset: () => void;
  9145. private _defaultUp;
  9146. /**
  9147. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9148. * This is the base of the follow, arc rotate cameras and Free camera
  9149. * @see https://doc.babylonjs.com/features/cameras
  9150. * @param name Defines the name of the camera in the scene
  9151. * @param position Defines the start position of the camera in the scene
  9152. * @param scene Defines the scene the camera belongs to
  9153. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9154. */
  9155. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9156. /**
  9157. * Gets the position in front of the camera at a given distance.
  9158. * @param distance The distance from the camera we want the position to be
  9159. * @returns the position
  9160. */
  9161. getFrontPosition(distance: number): Vector3;
  9162. /** @hidden */
  9163. _getLockedTargetPosition(): Nullable<Vector3>;
  9164. private _storedPosition;
  9165. private _storedRotation;
  9166. private _storedRotationQuaternion;
  9167. /**
  9168. * Store current camera state of the camera (fov, position, rotation, etc..)
  9169. * @returns the camera
  9170. */
  9171. storeState(): Camera;
  9172. /**
  9173. * Restored camera state. You must call storeState() first
  9174. * @returns whether it was successful or not
  9175. * @hidden
  9176. */
  9177. _restoreStateValues(): boolean;
  9178. /** @hidden */
  9179. _initCache(): void;
  9180. /** @hidden */
  9181. _updateCache(ignoreParentClass?: boolean): void;
  9182. /** @hidden */
  9183. _isSynchronizedViewMatrix(): boolean;
  9184. /** @hidden */
  9185. _computeLocalCameraSpeed(): number;
  9186. /**
  9187. * Defines the target the camera should look at.
  9188. * @param target Defines the new target as a Vector or a mesh
  9189. */
  9190. setTarget(target: Vector3): void;
  9191. /**
  9192. * Defines the target point of the camera.
  9193. * The camera looks towards it form the radius distance.
  9194. */
  9195. get target(): Vector3;
  9196. set target(value: Vector3);
  9197. /**
  9198. * Return the current target position of the camera. This value is expressed in local space.
  9199. * @returns the target position
  9200. */
  9201. getTarget(): Vector3;
  9202. /** @hidden */
  9203. _decideIfNeedsToMove(): boolean;
  9204. /** @hidden */
  9205. _updatePosition(): void;
  9206. /** @hidden */
  9207. _checkInputs(): void;
  9208. protected _updateCameraRotationMatrix(): void;
  9209. /**
  9210. * 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)
  9211. * @returns the current camera
  9212. */
  9213. private _rotateUpVectorWithCameraRotationMatrix;
  9214. private _cachedRotationZ;
  9215. private _cachedQuaternionRotationZ;
  9216. /** @hidden */
  9217. _getViewMatrix(): Matrix;
  9218. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9219. /**
  9220. * @hidden
  9221. */
  9222. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9223. /**
  9224. * @hidden
  9225. */
  9226. _updateRigCameras(): void;
  9227. private _getRigCamPositionAndTarget;
  9228. /**
  9229. * Gets the current object class name.
  9230. * @return the class name
  9231. */
  9232. getClassName(): string;
  9233. }
  9234. }
  9235. declare module "babylonjs/Cameras/cameraInputsManager" {
  9236. import { Nullable } from "babylonjs/types";
  9237. import { Camera } from "babylonjs/Cameras/camera";
  9238. /**
  9239. * @ignore
  9240. * This is a list of all the different input types that are available in the application.
  9241. * Fo instance: ArcRotateCameraGamepadInput...
  9242. */
  9243. export var CameraInputTypes: {};
  9244. /**
  9245. * This is the contract to implement in order to create a new input class.
  9246. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9247. */
  9248. export interface ICameraInput<TCamera extends Camera> {
  9249. /**
  9250. * Defines the camera the input is attached to.
  9251. */
  9252. camera: Nullable<TCamera>;
  9253. /**
  9254. * Gets the class name of the current intput.
  9255. * @returns the class name
  9256. */
  9257. getClassName(): string;
  9258. /**
  9259. * Get the friendly name associated with the input class.
  9260. * @returns the input friendly name
  9261. */
  9262. getSimpleName(): string;
  9263. /**
  9264. * Attach the input controls to a specific dom element to get the input from.
  9265. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9266. */
  9267. attachControl(noPreventDefault?: boolean): void;
  9268. /**
  9269. * Detach the current controls from the specified dom element.
  9270. */
  9271. detachControl(): void;
  9272. /**
  9273. * Update the current camera state depending on the inputs that have been used this frame.
  9274. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9275. */
  9276. checkInputs?: () => void;
  9277. }
  9278. /**
  9279. * Represents a map of input types to input instance or input index to input instance.
  9280. */
  9281. export interface CameraInputsMap<TCamera extends Camera> {
  9282. /**
  9283. * Accessor to the input by input type.
  9284. */
  9285. [name: string]: ICameraInput<TCamera>;
  9286. /**
  9287. * Accessor to the input by input index.
  9288. */
  9289. [idx: number]: ICameraInput<TCamera>;
  9290. }
  9291. /**
  9292. * This represents the input manager used within a camera.
  9293. * It helps dealing with all the different kind of input attached to a camera.
  9294. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9295. */
  9296. export class CameraInputsManager<TCamera extends Camera> {
  9297. /**
  9298. * Defines the list of inputs attahed to the camera.
  9299. */
  9300. attached: CameraInputsMap<TCamera>;
  9301. /**
  9302. * Defines the dom element the camera is collecting inputs from.
  9303. * This is null if the controls have not been attached.
  9304. */
  9305. attachedToElement: boolean;
  9306. /**
  9307. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9308. */
  9309. noPreventDefault: boolean;
  9310. /**
  9311. * Defined the camera the input manager belongs to.
  9312. */
  9313. camera: TCamera;
  9314. /**
  9315. * Update the current camera state depending on the inputs that have been used this frame.
  9316. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9317. */
  9318. checkInputs: () => void;
  9319. /**
  9320. * Instantiate a new Camera Input Manager.
  9321. * @param camera Defines the camera the input manager blongs to
  9322. */
  9323. constructor(camera: TCamera);
  9324. /**
  9325. * Add an input method to a camera
  9326. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9327. * @param input camera input method
  9328. */
  9329. add(input: ICameraInput<TCamera>): void;
  9330. /**
  9331. * Remove a specific input method from a camera
  9332. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9333. * @param inputToRemove camera input method
  9334. */
  9335. remove(inputToRemove: ICameraInput<TCamera>): void;
  9336. /**
  9337. * Remove a specific input type from a camera
  9338. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9339. * @param inputType the type of the input to remove
  9340. */
  9341. removeByType(inputType: string): void;
  9342. private _addCheckInputs;
  9343. /**
  9344. * Attach the input controls to the currently attached dom element to listen the events from.
  9345. * @param input Defines the input to attach
  9346. */
  9347. attachInput(input: ICameraInput<TCamera>): void;
  9348. /**
  9349. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9350. * @param element Defines the dom element to collect the events from
  9351. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9352. */
  9353. attachElement(noPreventDefault?: boolean): void;
  9354. /**
  9355. * Detach the current manager inputs controls from a specific dom element.
  9356. * @param element Defines the dom element to collect the events from
  9357. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9358. */
  9359. detachElement(disconnect?: boolean): void;
  9360. /**
  9361. * Rebuild the dynamic inputCheck function from the current list of
  9362. * defined inputs in the manager.
  9363. */
  9364. rebuildInputCheck(): void;
  9365. /**
  9366. * Remove all attached input methods from a camera
  9367. */
  9368. clear(): void;
  9369. /**
  9370. * Serialize the current input manager attached to a camera.
  9371. * This ensures than once parsed,
  9372. * the input associated to the camera will be identical to the current ones
  9373. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9374. */
  9375. serialize(serializedCamera: any): void;
  9376. /**
  9377. * Parses an input manager serialized JSON to restore the previous list of inputs
  9378. * and states associated to a camera.
  9379. * @param parsedCamera Defines the JSON to parse
  9380. */
  9381. parse(parsedCamera: any): void;
  9382. }
  9383. }
  9384. declare module "babylonjs/Events/keyboardEvents" {
  9385. /**
  9386. * Gather the list of keyboard event types as constants.
  9387. */
  9388. export class KeyboardEventTypes {
  9389. /**
  9390. * The keydown event is fired when a key becomes active (pressed).
  9391. */
  9392. static readonly KEYDOWN: number;
  9393. /**
  9394. * The keyup event is fired when a key has been released.
  9395. */
  9396. static readonly KEYUP: number;
  9397. }
  9398. /**
  9399. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9400. */
  9401. export class KeyboardInfo {
  9402. /**
  9403. * Defines the type of event (KeyboardEventTypes)
  9404. */
  9405. type: number;
  9406. /**
  9407. * Defines the related dom event
  9408. */
  9409. event: KeyboardEvent;
  9410. /**
  9411. * Instantiates a new keyboard info.
  9412. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9413. * @param type Defines the type of event (KeyboardEventTypes)
  9414. * @param event Defines the related dom event
  9415. */
  9416. constructor(
  9417. /**
  9418. * Defines the type of event (KeyboardEventTypes)
  9419. */
  9420. type: number,
  9421. /**
  9422. * Defines the related dom event
  9423. */
  9424. event: KeyboardEvent);
  9425. }
  9426. /**
  9427. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9428. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9429. */
  9430. export class KeyboardInfoPre extends KeyboardInfo {
  9431. /**
  9432. * Defines the type of event (KeyboardEventTypes)
  9433. */
  9434. type: number;
  9435. /**
  9436. * Defines the related dom event
  9437. */
  9438. event: KeyboardEvent;
  9439. /**
  9440. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9441. */
  9442. skipOnPointerObservable: boolean;
  9443. /**
  9444. * Instantiates a new keyboard pre info.
  9445. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9446. * @param type Defines the type of event (KeyboardEventTypes)
  9447. * @param event Defines the related dom event
  9448. */
  9449. constructor(
  9450. /**
  9451. * Defines the type of event (KeyboardEventTypes)
  9452. */
  9453. type: number,
  9454. /**
  9455. * Defines the related dom event
  9456. */
  9457. event: KeyboardEvent);
  9458. }
  9459. }
  9460. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9461. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9462. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9463. /**
  9464. * Manage the keyboard inputs to control the movement of a free camera.
  9465. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9466. */
  9467. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9468. /**
  9469. * Defines the camera the input is attached to.
  9470. */
  9471. camera: FreeCamera;
  9472. /**
  9473. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9474. */
  9475. keysUp: number[];
  9476. /**
  9477. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9478. */
  9479. keysUpward: number[];
  9480. /**
  9481. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9482. */
  9483. keysDown: number[];
  9484. /**
  9485. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9486. */
  9487. keysDownward: number[];
  9488. /**
  9489. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9490. */
  9491. keysLeft: number[];
  9492. /**
  9493. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9494. */
  9495. keysRight: number[];
  9496. private _keys;
  9497. private _onCanvasBlurObserver;
  9498. private _onKeyboardObserver;
  9499. private _engine;
  9500. private _scene;
  9501. /**
  9502. * Attach the input controls to a specific dom element to get the input from.
  9503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9504. */
  9505. attachControl(noPreventDefault?: boolean): void;
  9506. /**
  9507. * Detach the current controls from the specified dom element.
  9508. */
  9509. detachControl(): void;
  9510. /**
  9511. * Update the current camera state depending on the inputs that have been used this frame.
  9512. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9513. */
  9514. checkInputs(): void;
  9515. /**
  9516. * Gets the class name of the current intput.
  9517. * @returns the class name
  9518. */
  9519. getClassName(): string;
  9520. /** @hidden */
  9521. _onLostFocus(): void;
  9522. /**
  9523. * Get the friendly name associated with the input class.
  9524. * @returns the input friendly name
  9525. */
  9526. getSimpleName(): string;
  9527. }
  9528. }
  9529. declare module "babylonjs/Actions/action" {
  9530. import { Observable } from "babylonjs/Misc/observable";
  9531. import { Condition } from "babylonjs/Actions/condition";
  9532. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9533. import { Nullable } from "babylonjs/types";
  9534. import { Scene } from "babylonjs/scene";
  9535. import { ActionManager } from "babylonjs/Actions/actionManager";
  9536. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9537. import { Node } from "babylonjs/node";
  9538. /**
  9539. * Interface used to define Action
  9540. */
  9541. export interface IAction {
  9542. /**
  9543. * Trigger for the action
  9544. */
  9545. trigger: number;
  9546. /** Options of the trigger */
  9547. triggerOptions: any;
  9548. /**
  9549. * Gets the trigger parameters
  9550. * @returns the trigger parameters
  9551. */
  9552. getTriggerParameter(): any;
  9553. /**
  9554. * Internal only - executes current action event
  9555. * @hidden
  9556. */
  9557. _executeCurrent(evt?: ActionEvent): void;
  9558. /**
  9559. * Serialize placeholder for child classes
  9560. * @param parent of child
  9561. * @returns the serialized object
  9562. */
  9563. serialize(parent: any): any;
  9564. /**
  9565. * Internal only
  9566. * @hidden
  9567. */
  9568. _prepare(): void;
  9569. /**
  9570. * Internal only - manager for action
  9571. * @hidden
  9572. */
  9573. _actionManager: Nullable<AbstractActionManager>;
  9574. /**
  9575. * Adds action to chain of actions, may be a DoNothingAction
  9576. * @param action defines the next action to execute
  9577. * @returns The action passed in
  9578. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9579. */
  9580. then(action: IAction): IAction;
  9581. }
  9582. /**
  9583. * The action to be carried out following a trigger
  9584. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9585. */
  9586. export class Action implements IAction {
  9587. /** the trigger, with or without parameters, for the action */
  9588. triggerOptions: any;
  9589. /**
  9590. * Trigger for the action
  9591. */
  9592. trigger: number;
  9593. /**
  9594. * Internal only - manager for action
  9595. * @hidden
  9596. */
  9597. _actionManager: ActionManager;
  9598. private _nextActiveAction;
  9599. private _child;
  9600. private _condition?;
  9601. private _triggerParameter;
  9602. /**
  9603. * An event triggered prior to action being executed.
  9604. */
  9605. onBeforeExecuteObservable: Observable<Action>;
  9606. /**
  9607. * Creates a new Action
  9608. * @param triggerOptions the trigger, with or without parameters, for the action
  9609. * @param condition an optional determinant of action
  9610. */
  9611. constructor(
  9612. /** the trigger, with or without parameters, for the action */
  9613. triggerOptions: any, condition?: Condition);
  9614. /**
  9615. * Internal only
  9616. * @hidden
  9617. */
  9618. _prepare(): void;
  9619. /**
  9620. * Gets the trigger parameters
  9621. * @returns the trigger parameters
  9622. */
  9623. getTriggerParameter(): any;
  9624. /**
  9625. * Internal only - executes current action event
  9626. * @hidden
  9627. */
  9628. _executeCurrent(evt?: ActionEvent): void;
  9629. /**
  9630. * Execute placeholder for child classes
  9631. * @param evt optional action event
  9632. */
  9633. execute(evt?: ActionEvent): void;
  9634. /**
  9635. * Skips to next active action
  9636. */
  9637. skipToNextActiveAction(): void;
  9638. /**
  9639. * Adds action to chain of actions, may be a DoNothingAction
  9640. * @param action defines the next action to execute
  9641. * @returns The action passed in
  9642. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9643. */
  9644. then(action: Action): Action;
  9645. /**
  9646. * Internal only
  9647. * @hidden
  9648. */
  9649. _getProperty(propertyPath: string): string;
  9650. /**
  9651. * Internal only
  9652. * @hidden
  9653. */
  9654. _getEffectiveTarget(target: any, propertyPath: string): any;
  9655. /**
  9656. * Serialize placeholder for child classes
  9657. * @param parent of child
  9658. * @returns the serialized object
  9659. */
  9660. serialize(parent: any): any;
  9661. /**
  9662. * Internal only called by serialize
  9663. * @hidden
  9664. */
  9665. protected _serialize(serializedAction: any, parent?: any): any;
  9666. /**
  9667. * Internal only
  9668. * @hidden
  9669. */
  9670. static _SerializeValueAsString: (value: any) => string;
  9671. /**
  9672. * Internal only
  9673. * @hidden
  9674. */
  9675. static _GetTargetProperty: (target: Scene | Node) => {
  9676. name: string;
  9677. targetType: string;
  9678. value: string;
  9679. };
  9680. }
  9681. }
  9682. declare module "babylonjs/Actions/condition" {
  9683. import { ActionManager } from "babylonjs/Actions/actionManager";
  9684. /**
  9685. * A Condition applied to an Action
  9686. */
  9687. export class Condition {
  9688. /**
  9689. * Internal only - manager for action
  9690. * @hidden
  9691. */
  9692. _actionManager: ActionManager;
  9693. /**
  9694. * Internal only
  9695. * @hidden
  9696. */
  9697. _evaluationId: number;
  9698. /**
  9699. * Internal only
  9700. * @hidden
  9701. */
  9702. _currentResult: boolean;
  9703. /**
  9704. * Creates a new Condition
  9705. * @param actionManager the manager of the action the condition is applied to
  9706. */
  9707. constructor(actionManager: ActionManager);
  9708. /**
  9709. * Check if the current condition is valid
  9710. * @returns a boolean
  9711. */
  9712. isValid(): boolean;
  9713. /**
  9714. * Internal only
  9715. * @hidden
  9716. */
  9717. _getProperty(propertyPath: string): string;
  9718. /**
  9719. * Internal only
  9720. * @hidden
  9721. */
  9722. _getEffectiveTarget(target: any, propertyPath: string): any;
  9723. /**
  9724. * Serialize placeholder for child classes
  9725. * @returns the serialized object
  9726. */
  9727. serialize(): any;
  9728. /**
  9729. * Internal only
  9730. * @hidden
  9731. */
  9732. protected _serialize(serializedCondition: any): any;
  9733. }
  9734. /**
  9735. * Defines specific conditional operators as extensions of Condition
  9736. */
  9737. export class ValueCondition extends Condition {
  9738. /** path to specify the property of the target the conditional operator uses */
  9739. propertyPath: string;
  9740. /** the value compared by the conditional operator against the current value of the property */
  9741. value: any;
  9742. /** the conditional operator, default ValueCondition.IsEqual */
  9743. operator: number;
  9744. /**
  9745. * Internal only
  9746. * @hidden
  9747. */
  9748. private static _IsEqual;
  9749. /**
  9750. * Internal only
  9751. * @hidden
  9752. */
  9753. private static _IsDifferent;
  9754. /**
  9755. * Internal only
  9756. * @hidden
  9757. */
  9758. private static _IsGreater;
  9759. /**
  9760. * Internal only
  9761. * @hidden
  9762. */
  9763. private static _IsLesser;
  9764. /**
  9765. * returns the number for IsEqual
  9766. */
  9767. static get IsEqual(): number;
  9768. /**
  9769. * Returns the number for IsDifferent
  9770. */
  9771. static get IsDifferent(): number;
  9772. /**
  9773. * Returns the number for IsGreater
  9774. */
  9775. static get IsGreater(): number;
  9776. /**
  9777. * Returns the number for IsLesser
  9778. */
  9779. static get IsLesser(): number;
  9780. /**
  9781. * Internal only The action manager for the condition
  9782. * @hidden
  9783. */
  9784. _actionManager: ActionManager;
  9785. /**
  9786. * Internal only
  9787. * @hidden
  9788. */
  9789. private _target;
  9790. /**
  9791. * Internal only
  9792. * @hidden
  9793. */
  9794. private _effectiveTarget;
  9795. /**
  9796. * Internal only
  9797. * @hidden
  9798. */
  9799. private _property;
  9800. /**
  9801. * Creates a new ValueCondition
  9802. * @param actionManager manager for the action the condition applies to
  9803. * @param target for the action
  9804. * @param propertyPath path to specify the property of the target the conditional operator uses
  9805. * @param value the value compared by the conditional operator against the current value of the property
  9806. * @param operator the conditional operator, default ValueCondition.IsEqual
  9807. */
  9808. constructor(actionManager: ActionManager, target: any,
  9809. /** path to specify the property of the target the conditional operator uses */
  9810. propertyPath: string,
  9811. /** the value compared by the conditional operator against the current value of the property */
  9812. value: any,
  9813. /** the conditional operator, default ValueCondition.IsEqual */
  9814. operator?: number);
  9815. /**
  9816. * Compares the given value with the property value for the specified conditional operator
  9817. * @returns the result of the comparison
  9818. */
  9819. isValid(): boolean;
  9820. /**
  9821. * Serialize the ValueCondition into a JSON compatible object
  9822. * @returns serialization object
  9823. */
  9824. serialize(): any;
  9825. /**
  9826. * Gets the name of the conditional operator for the ValueCondition
  9827. * @param operator the conditional operator
  9828. * @returns the name
  9829. */
  9830. static GetOperatorName(operator: number): string;
  9831. }
  9832. /**
  9833. * Defines a predicate condition as an extension of Condition
  9834. */
  9835. export class PredicateCondition extends Condition {
  9836. /** defines the predicate function used to validate the condition */
  9837. predicate: () => boolean;
  9838. /**
  9839. * Internal only - manager for action
  9840. * @hidden
  9841. */
  9842. _actionManager: ActionManager;
  9843. /**
  9844. * Creates a new PredicateCondition
  9845. * @param actionManager manager for the action the condition applies to
  9846. * @param predicate defines the predicate function used to validate the condition
  9847. */
  9848. constructor(actionManager: ActionManager,
  9849. /** defines the predicate function used to validate the condition */
  9850. predicate: () => boolean);
  9851. /**
  9852. * @returns the validity of the predicate condition
  9853. */
  9854. isValid(): boolean;
  9855. }
  9856. /**
  9857. * Defines a state condition as an extension of Condition
  9858. */
  9859. export class StateCondition extends Condition {
  9860. /** Value to compare with target state */
  9861. value: string;
  9862. /**
  9863. * Internal only - manager for action
  9864. * @hidden
  9865. */
  9866. _actionManager: ActionManager;
  9867. /**
  9868. * Internal only
  9869. * @hidden
  9870. */
  9871. private _target;
  9872. /**
  9873. * Creates a new StateCondition
  9874. * @param actionManager manager for the action the condition applies to
  9875. * @param target of the condition
  9876. * @param value to compare with target state
  9877. */
  9878. constructor(actionManager: ActionManager, target: any,
  9879. /** Value to compare with target state */
  9880. value: string);
  9881. /**
  9882. * Gets a boolean indicating if the current condition is met
  9883. * @returns the validity of the state
  9884. */
  9885. isValid(): boolean;
  9886. /**
  9887. * Serialize the StateCondition into a JSON compatible object
  9888. * @returns serialization object
  9889. */
  9890. serialize(): any;
  9891. }
  9892. }
  9893. declare module "babylonjs/Actions/directActions" {
  9894. import { Action } from "babylonjs/Actions/action";
  9895. import { Condition } from "babylonjs/Actions/condition";
  9896. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9897. /**
  9898. * This defines an action responsible to toggle a boolean once triggered.
  9899. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9900. */
  9901. export class SwitchBooleanAction extends Action {
  9902. /**
  9903. * The path to the boolean property in the target object
  9904. */
  9905. propertyPath: string;
  9906. private _target;
  9907. private _effectiveTarget;
  9908. private _property;
  9909. /**
  9910. * Instantiate the action
  9911. * @param triggerOptions defines the trigger options
  9912. * @param target defines the object containing the boolean
  9913. * @param propertyPath defines the path to the boolean property in the target object
  9914. * @param condition defines the trigger related conditions
  9915. */
  9916. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9917. /** @hidden */
  9918. _prepare(): void;
  9919. /**
  9920. * Execute the action toggle the boolean value.
  9921. */
  9922. execute(): void;
  9923. /**
  9924. * Serializes the actions and its related information.
  9925. * @param parent defines the object to serialize in
  9926. * @returns the serialized object
  9927. */
  9928. serialize(parent: any): any;
  9929. }
  9930. /**
  9931. * This defines an action responsible to set a the state field of the target
  9932. * to a desired value once triggered.
  9933. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9934. */
  9935. export class SetStateAction extends Action {
  9936. /**
  9937. * The value to store in the state field.
  9938. */
  9939. value: string;
  9940. private _target;
  9941. /**
  9942. * Instantiate the action
  9943. * @param triggerOptions defines the trigger options
  9944. * @param target defines the object containing the state property
  9945. * @param value defines the value to store in the state field
  9946. * @param condition defines the trigger related conditions
  9947. */
  9948. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9949. /**
  9950. * Execute the action and store the value on the target state property.
  9951. */
  9952. execute(): void;
  9953. /**
  9954. * Serializes the actions and its related information.
  9955. * @param parent defines the object to serialize in
  9956. * @returns the serialized object
  9957. */
  9958. serialize(parent: any): any;
  9959. }
  9960. /**
  9961. * This defines an action responsible to set a property of the target
  9962. * to a desired value once triggered.
  9963. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9964. */
  9965. export class SetValueAction extends Action {
  9966. /**
  9967. * The path of the property to set in the target.
  9968. */
  9969. propertyPath: string;
  9970. /**
  9971. * The value to set in the property
  9972. */
  9973. value: any;
  9974. private _target;
  9975. private _effectiveTarget;
  9976. private _property;
  9977. /**
  9978. * Instantiate the action
  9979. * @param triggerOptions defines the trigger options
  9980. * @param target defines the object containing the property
  9981. * @param propertyPath defines the path of the property to set in the target
  9982. * @param value defines the value to set in the property
  9983. * @param condition defines the trigger related conditions
  9984. */
  9985. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9986. /** @hidden */
  9987. _prepare(): void;
  9988. /**
  9989. * Execute the action and set the targetted property to the desired value.
  9990. */
  9991. execute(): void;
  9992. /**
  9993. * Serializes the actions and its related information.
  9994. * @param parent defines the object to serialize in
  9995. * @returns the serialized object
  9996. */
  9997. serialize(parent: any): any;
  9998. }
  9999. /**
  10000. * This defines an action responsible to increment the target value
  10001. * to a desired value once triggered.
  10002. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10003. */
  10004. export class IncrementValueAction extends Action {
  10005. /**
  10006. * The path of the property to increment in the target.
  10007. */
  10008. propertyPath: string;
  10009. /**
  10010. * The value we should increment the property by.
  10011. */
  10012. value: any;
  10013. private _target;
  10014. private _effectiveTarget;
  10015. private _property;
  10016. /**
  10017. * Instantiate the action
  10018. * @param triggerOptions defines the trigger options
  10019. * @param target defines the object containing the property
  10020. * @param propertyPath defines the path of the property to increment in the target
  10021. * @param value defines the value value we should increment the property by
  10022. * @param condition defines the trigger related conditions
  10023. */
  10024. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10025. /** @hidden */
  10026. _prepare(): void;
  10027. /**
  10028. * Execute the action and increment the target of the value amount.
  10029. */
  10030. execute(): void;
  10031. /**
  10032. * Serializes the actions and its related information.
  10033. * @param parent defines the object to serialize in
  10034. * @returns the serialized object
  10035. */
  10036. serialize(parent: any): any;
  10037. }
  10038. /**
  10039. * This defines an action responsible to start an animation once triggered.
  10040. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10041. */
  10042. export class PlayAnimationAction extends Action {
  10043. /**
  10044. * Where the animation should start (animation frame)
  10045. */
  10046. from: number;
  10047. /**
  10048. * Where the animation should stop (animation frame)
  10049. */
  10050. to: number;
  10051. /**
  10052. * Define if the animation should loop or stop after the first play.
  10053. */
  10054. loop?: boolean;
  10055. private _target;
  10056. /**
  10057. * Instantiate the action
  10058. * @param triggerOptions defines the trigger options
  10059. * @param target defines the target animation or animation name
  10060. * @param from defines from where the animation should start (animation frame)
  10061. * @param end defines where the animation should stop (animation frame)
  10062. * @param loop defines if the animation should loop or stop after the first play
  10063. * @param condition defines the trigger related conditions
  10064. */
  10065. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10066. /** @hidden */
  10067. _prepare(): void;
  10068. /**
  10069. * Execute the action and play the animation.
  10070. */
  10071. execute(): void;
  10072. /**
  10073. * Serializes the actions and its related information.
  10074. * @param parent defines the object to serialize in
  10075. * @returns the serialized object
  10076. */
  10077. serialize(parent: any): any;
  10078. }
  10079. /**
  10080. * This defines an action responsible to stop an animation once triggered.
  10081. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10082. */
  10083. export class StopAnimationAction extends Action {
  10084. private _target;
  10085. /**
  10086. * Instantiate the action
  10087. * @param triggerOptions defines the trigger options
  10088. * @param target defines the target animation or animation name
  10089. * @param condition defines the trigger related conditions
  10090. */
  10091. constructor(triggerOptions: any, target: any, condition?: Condition);
  10092. /** @hidden */
  10093. _prepare(): void;
  10094. /**
  10095. * Execute the action and stop the animation.
  10096. */
  10097. execute(): void;
  10098. /**
  10099. * Serializes the actions and its related information.
  10100. * @param parent defines the object to serialize in
  10101. * @returns the serialized object
  10102. */
  10103. serialize(parent: any): any;
  10104. }
  10105. /**
  10106. * This defines an action responsible that does nothing once triggered.
  10107. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10108. */
  10109. export class DoNothingAction extends Action {
  10110. /**
  10111. * Instantiate the action
  10112. * @param triggerOptions defines the trigger options
  10113. * @param condition defines the trigger related conditions
  10114. */
  10115. constructor(triggerOptions?: any, condition?: Condition);
  10116. /**
  10117. * Execute the action and do nothing.
  10118. */
  10119. execute(): void;
  10120. /**
  10121. * Serializes the actions and its related information.
  10122. * @param parent defines the object to serialize in
  10123. * @returns the serialized object
  10124. */
  10125. serialize(parent: any): any;
  10126. }
  10127. /**
  10128. * This defines an action responsible to trigger several actions once triggered.
  10129. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10130. */
  10131. export class CombineAction extends Action {
  10132. /**
  10133. * The list of aggregated animations to run.
  10134. */
  10135. children: Action[];
  10136. /**
  10137. * Instantiate the action
  10138. * @param triggerOptions defines the trigger options
  10139. * @param children defines the list of aggregated animations to run
  10140. * @param condition defines the trigger related conditions
  10141. */
  10142. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10143. /** @hidden */
  10144. _prepare(): void;
  10145. /**
  10146. * Execute the action and executes all the aggregated actions.
  10147. */
  10148. execute(evt: ActionEvent): void;
  10149. /**
  10150. * Serializes the actions and its related information.
  10151. * @param parent defines the object to serialize in
  10152. * @returns the serialized object
  10153. */
  10154. serialize(parent: any): any;
  10155. }
  10156. /**
  10157. * This defines an action responsible to run code (external event) once triggered.
  10158. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10159. */
  10160. export class ExecuteCodeAction extends Action {
  10161. /**
  10162. * The callback function to run.
  10163. */
  10164. func: (evt: ActionEvent) => void;
  10165. /**
  10166. * Instantiate the action
  10167. * @param triggerOptions defines the trigger options
  10168. * @param func defines the callback function to run
  10169. * @param condition defines the trigger related conditions
  10170. */
  10171. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10172. /**
  10173. * Execute the action and run the attached code.
  10174. */
  10175. execute(evt: ActionEvent): void;
  10176. }
  10177. /**
  10178. * This defines an action responsible to set the parent property of the target once triggered.
  10179. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10180. */
  10181. export class SetParentAction extends Action {
  10182. private _parent;
  10183. private _target;
  10184. /**
  10185. * Instantiate the action
  10186. * @param triggerOptions defines the trigger options
  10187. * @param target defines the target containing the parent property
  10188. * @param parent defines from where the animation should start (animation frame)
  10189. * @param condition defines the trigger related conditions
  10190. */
  10191. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10192. /** @hidden */
  10193. _prepare(): void;
  10194. /**
  10195. * Execute the action and set the parent property.
  10196. */
  10197. execute(): void;
  10198. /**
  10199. * Serializes the actions and its related information.
  10200. * @param parent defines the object to serialize in
  10201. * @returns the serialized object
  10202. */
  10203. serialize(parent: any): any;
  10204. }
  10205. }
  10206. declare module "babylonjs/Actions/actionManager" {
  10207. import { Nullable } from "babylonjs/types";
  10208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10209. import { Scene } from "babylonjs/scene";
  10210. import { IAction } from "babylonjs/Actions/action";
  10211. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10212. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10213. /**
  10214. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10215. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10217. */
  10218. export class ActionManager extends AbstractActionManager {
  10219. /**
  10220. * Nothing
  10221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10222. */
  10223. static readonly NothingTrigger: number;
  10224. /**
  10225. * On pick
  10226. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10227. */
  10228. static readonly OnPickTrigger: number;
  10229. /**
  10230. * On left pick
  10231. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10232. */
  10233. static readonly OnLeftPickTrigger: number;
  10234. /**
  10235. * On right pick
  10236. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10237. */
  10238. static readonly OnRightPickTrigger: number;
  10239. /**
  10240. * On center pick
  10241. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10242. */
  10243. static readonly OnCenterPickTrigger: number;
  10244. /**
  10245. * On pick down
  10246. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10247. */
  10248. static readonly OnPickDownTrigger: number;
  10249. /**
  10250. * On double pick
  10251. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10252. */
  10253. static readonly OnDoublePickTrigger: number;
  10254. /**
  10255. * On pick up
  10256. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10257. */
  10258. static readonly OnPickUpTrigger: number;
  10259. /**
  10260. * On pick out.
  10261. * This trigger will only be raised if you also declared a OnPickDown
  10262. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10263. */
  10264. static readonly OnPickOutTrigger: number;
  10265. /**
  10266. * On long press
  10267. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10268. */
  10269. static readonly OnLongPressTrigger: number;
  10270. /**
  10271. * On pointer over
  10272. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10273. */
  10274. static readonly OnPointerOverTrigger: number;
  10275. /**
  10276. * On pointer out
  10277. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10278. */
  10279. static readonly OnPointerOutTrigger: number;
  10280. /**
  10281. * On every frame
  10282. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10283. */
  10284. static readonly OnEveryFrameTrigger: number;
  10285. /**
  10286. * On intersection enter
  10287. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10288. */
  10289. static readonly OnIntersectionEnterTrigger: number;
  10290. /**
  10291. * On intersection exit
  10292. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10293. */
  10294. static readonly OnIntersectionExitTrigger: number;
  10295. /**
  10296. * On key down
  10297. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10298. */
  10299. static readonly OnKeyDownTrigger: number;
  10300. /**
  10301. * On key up
  10302. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10303. */
  10304. static readonly OnKeyUpTrigger: number;
  10305. private _scene;
  10306. /**
  10307. * Creates a new action manager
  10308. * @param scene defines the hosting scene
  10309. */
  10310. constructor(scene: Scene);
  10311. /**
  10312. * Releases all associated resources
  10313. */
  10314. dispose(): void;
  10315. /**
  10316. * Gets hosting scene
  10317. * @returns the hosting scene
  10318. */
  10319. getScene(): Scene;
  10320. /**
  10321. * Does this action manager handles actions of any of the given triggers
  10322. * @param triggers defines the triggers to be tested
  10323. * @return a boolean indicating whether one (or more) of the triggers is handled
  10324. */
  10325. hasSpecificTriggers(triggers: number[]): boolean;
  10326. /**
  10327. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10328. * speed.
  10329. * @param triggerA defines the trigger to be tested
  10330. * @param triggerB defines the trigger to be tested
  10331. * @return a boolean indicating whether one (or more) of the triggers is handled
  10332. */
  10333. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10334. /**
  10335. * Does this action manager handles actions of a given trigger
  10336. * @param trigger defines the trigger to be tested
  10337. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10338. * @return whether the trigger is handled
  10339. */
  10340. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10341. /**
  10342. * Does this action manager has pointer triggers
  10343. */
  10344. get hasPointerTriggers(): boolean;
  10345. /**
  10346. * Does this action manager has pick triggers
  10347. */
  10348. get hasPickTriggers(): boolean;
  10349. /**
  10350. * Registers an action to this action manager
  10351. * @param action defines the action to be registered
  10352. * @return the action amended (prepared) after registration
  10353. */
  10354. registerAction(action: IAction): Nullable<IAction>;
  10355. /**
  10356. * Unregisters an action to this action manager
  10357. * @param action defines the action to be unregistered
  10358. * @return a boolean indicating whether the action has been unregistered
  10359. */
  10360. unregisterAction(action: IAction): Boolean;
  10361. /**
  10362. * Process a specific trigger
  10363. * @param trigger defines the trigger to process
  10364. * @param evt defines the event details to be processed
  10365. */
  10366. processTrigger(trigger: number, evt?: IActionEvent): void;
  10367. /** @hidden */
  10368. _getEffectiveTarget(target: any, propertyPath: string): any;
  10369. /** @hidden */
  10370. _getProperty(propertyPath: string): string;
  10371. /**
  10372. * Serialize this manager to a JSON object
  10373. * @param name defines the property name to store this manager
  10374. * @returns a JSON representation of this manager
  10375. */
  10376. serialize(name: string): any;
  10377. /**
  10378. * Creates a new ActionManager from a JSON data
  10379. * @param parsedActions defines the JSON data to read from
  10380. * @param object defines the hosting mesh
  10381. * @param scene defines the hosting scene
  10382. */
  10383. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10384. /**
  10385. * Get a trigger name by index
  10386. * @param trigger defines the trigger index
  10387. * @returns a trigger name
  10388. */
  10389. static GetTriggerName(trigger: number): string;
  10390. }
  10391. }
  10392. declare module "babylonjs/Culling/ray" {
  10393. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10394. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10396. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10397. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10398. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10399. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10400. import { Plane } from "babylonjs/Maths/math.plane";
  10401. /**
  10402. * Class representing a ray with position and direction
  10403. */
  10404. export class Ray {
  10405. /** origin point */
  10406. origin: Vector3;
  10407. /** direction */
  10408. direction: Vector3;
  10409. /** length of the ray */
  10410. length: number;
  10411. private static readonly _TmpVector3;
  10412. private _tmpRay;
  10413. /**
  10414. * Creates a new ray
  10415. * @param origin origin point
  10416. * @param direction direction
  10417. * @param length length of the ray
  10418. */
  10419. constructor(
  10420. /** origin point */
  10421. origin: Vector3,
  10422. /** direction */
  10423. direction: Vector3,
  10424. /** length of the ray */
  10425. length?: number);
  10426. /**
  10427. * Checks if the ray intersects a box
  10428. * This does not account for the ray lenght by design to improve perfs.
  10429. * @param minimum bound of the box
  10430. * @param maximum bound of the box
  10431. * @param intersectionTreshold extra extend to be added to the box in all direction
  10432. * @returns if the box was hit
  10433. */
  10434. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10435. /**
  10436. * Checks if the ray intersects a box
  10437. * This does not account for the ray lenght by design to improve perfs.
  10438. * @param box the bounding box to check
  10439. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10440. * @returns if the box was hit
  10441. */
  10442. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10443. /**
  10444. * If the ray hits a sphere
  10445. * @param sphere the bounding sphere to check
  10446. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10447. * @returns true if it hits the sphere
  10448. */
  10449. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10450. /**
  10451. * If the ray hits a triange
  10452. * @param vertex0 triangle vertex
  10453. * @param vertex1 triangle vertex
  10454. * @param vertex2 triangle vertex
  10455. * @returns intersection information if hit
  10456. */
  10457. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10458. /**
  10459. * Checks if ray intersects a plane
  10460. * @param plane the plane to check
  10461. * @returns the distance away it was hit
  10462. */
  10463. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10464. /**
  10465. * Calculate the intercept of a ray on a given axis
  10466. * @param axis to check 'x' | 'y' | 'z'
  10467. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10468. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10469. */
  10470. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10471. /**
  10472. * Checks if ray intersects a mesh
  10473. * @param mesh the mesh to check
  10474. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10475. * @returns picking info of the intersecton
  10476. */
  10477. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10478. /**
  10479. * Checks if ray intersects a mesh
  10480. * @param meshes the meshes to check
  10481. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10482. * @param results array to store result in
  10483. * @returns Array of picking infos
  10484. */
  10485. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10486. private _comparePickingInfo;
  10487. private static smallnum;
  10488. private static rayl;
  10489. /**
  10490. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10491. * @param sega the first point of the segment to test the intersection against
  10492. * @param segb the second point of the segment to test the intersection against
  10493. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10494. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10495. */
  10496. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10497. /**
  10498. * Update the ray from viewport position
  10499. * @param x position
  10500. * @param y y position
  10501. * @param viewportWidth viewport width
  10502. * @param viewportHeight viewport height
  10503. * @param world world matrix
  10504. * @param view view matrix
  10505. * @param projection projection matrix
  10506. * @returns this ray updated
  10507. */
  10508. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10509. /**
  10510. * Creates a ray with origin and direction of 0,0,0
  10511. * @returns the new ray
  10512. */
  10513. static Zero(): Ray;
  10514. /**
  10515. * Creates a new ray from screen space and viewport
  10516. * @param x position
  10517. * @param y y position
  10518. * @param viewportWidth viewport width
  10519. * @param viewportHeight viewport height
  10520. * @param world world matrix
  10521. * @param view view matrix
  10522. * @param projection projection matrix
  10523. * @returns new ray
  10524. */
  10525. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10526. /**
  10527. * 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
  10528. * transformed to the given world matrix.
  10529. * @param origin The origin point
  10530. * @param end The end point
  10531. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10532. * @returns the new ray
  10533. */
  10534. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10535. /**
  10536. * Transforms a ray by a matrix
  10537. * @param ray ray to transform
  10538. * @param matrix matrix to apply
  10539. * @returns the resulting new ray
  10540. */
  10541. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10542. /**
  10543. * Transforms a ray by a matrix
  10544. * @param ray ray to transform
  10545. * @param matrix matrix to apply
  10546. * @param result ray to store result in
  10547. */
  10548. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10549. /**
  10550. * Unproject a ray from screen space to object space
  10551. * @param sourceX defines the screen space x coordinate to use
  10552. * @param sourceY defines the screen space y coordinate to use
  10553. * @param viewportWidth defines the current width of the viewport
  10554. * @param viewportHeight defines the current height of the viewport
  10555. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10556. * @param view defines the view matrix to use
  10557. * @param projection defines the projection matrix to use
  10558. */
  10559. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10560. }
  10561. /**
  10562. * Type used to define predicate used to select faces when a mesh intersection is detected
  10563. */
  10564. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10565. module "babylonjs/scene" {
  10566. interface Scene {
  10567. /** @hidden */
  10568. _tempPickingRay: Nullable<Ray>;
  10569. /** @hidden */
  10570. _cachedRayForTransform: Ray;
  10571. /** @hidden */
  10572. _pickWithRayInverseMatrix: Matrix;
  10573. /** @hidden */
  10574. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10575. /** @hidden */
  10576. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10577. /** @hidden */
  10578. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10579. }
  10580. }
  10581. }
  10582. declare module "babylonjs/sceneComponent" {
  10583. import { Scene } from "babylonjs/scene";
  10584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10585. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10586. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10587. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10588. import { Nullable } from "babylonjs/types";
  10589. import { Camera } from "babylonjs/Cameras/camera";
  10590. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10591. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10592. import { AbstractScene } from "babylonjs/abstractScene";
  10593. import { Mesh } from "babylonjs/Meshes/mesh";
  10594. /**
  10595. * Groups all the scene component constants in one place to ease maintenance.
  10596. * @hidden
  10597. */
  10598. export class SceneComponentConstants {
  10599. static readonly NAME_EFFECTLAYER: string;
  10600. static readonly NAME_LAYER: string;
  10601. static readonly NAME_LENSFLARESYSTEM: string;
  10602. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10603. static readonly NAME_PARTICLESYSTEM: string;
  10604. static readonly NAME_GAMEPAD: string;
  10605. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10606. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10607. static readonly NAME_PREPASSRENDERER: string;
  10608. static readonly NAME_DEPTHRENDERER: string;
  10609. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10610. static readonly NAME_SPRITE: string;
  10611. static readonly NAME_SUBSURFACE: string;
  10612. static readonly NAME_OUTLINERENDERER: string;
  10613. static readonly NAME_PROCEDURALTEXTURE: string;
  10614. static readonly NAME_SHADOWGENERATOR: string;
  10615. static readonly NAME_OCTREE: string;
  10616. static readonly NAME_PHYSICSENGINE: string;
  10617. static readonly NAME_AUDIO: string;
  10618. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10619. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10620. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10621. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10622. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10623. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10624. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10625. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10626. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10627. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10628. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10629. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10630. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10631. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10632. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10633. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10634. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10635. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10636. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10637. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10638. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10639. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10640. static readonly STEP_AFTERRENDER_AUDIO: number;
  10641. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10642. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10643. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10644. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10645. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10646. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10647. static readonly STEP_POINTERMOVE_SPRITE: number;
  10648. static readonly STEP_POINTERDOWN_SPRITE: number;
  10649. static readonly STEP_POINTERUP_SPRITE: number;
  10650. }
  10651. /**
  10652. * This represents a scene component.
  10653. *
  10654. * This is used to decouple the dependency the scene is having on the different workloads like
  10655. * layers, post processes...
  10656. */
  10657. export interface ISceneComponent {
  10658. /**
  10659. * The name of the component. Each component must have a unique name.
  10660. */
  10661. name: string;
  10662. /**
  10663. * The scene the component belongs to.
  10664. */
  10665. scene: Scene;
  10666. /**
  10667. * Register the component to one instance of a scene.
  10668. */
  10669. register(): void;
  10670. /**
  10671. * Rebuilds the elements related to this component in case of
  10672. * context lost for instance.
  10673. */
  10674. rebuild(): void;
  10675. /**
  10676. * Disposes the component and the associated ressources.
  10677. */
  10678. dispose(): void;
  10679. }
  10680. /**
  10681. * This represents a SERIALIZABLE scene component.
  10682. *
  10683. * This extends Scene Component to add Serialization methods on top.
  10684. */
  10685. export interface ISceneSerializableComponent extends ISceneComponent {
  10686. /**
  10687. * Adds all the elements from the container to the scene
  10688. * @param container the container holding the elements
  10689. */
  10690. addFromContainer(container: AbstractScene): void;
  10691. /**
  10692. * Removes all the elements in the container from the scene
  10693. * @param container contains the elements to remove
  10694. * @param dispose if the removed element should be disposed (default: false)
  10695. */
  10696. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10697. /**
  10698. * Serializes the component data to the specified json object
  10699. * @param serializationObject The object to serialize to
  10700. */
  10701. serialize(serializationObject: any): void;
  10702. }
  10703. /**
  10704. * Strong typing of a Mesh related stage step action
  10705. */
  10706. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10707. /**
  10708. * Strong typing of a Evaluate Sub Mesh related stage step action
  10709. */
  10710. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10711. /**
  10712. * Strong typing of a pre active Mesh related stage step action
  10713. */
  10714. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10715. /**
  10716. * Strong typing of a Camera related stage step action
  10717. */
  10718. export type CameraStageAction = (camera: Camera) => void;
  10719. /**
  10720. * Strong typing of a Camera Frame buffer related stage step action
  10721. */
  10722. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10723. /**
  10724. * Strong typing of a Render Target related stage step action
  10725. */
  10726. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10727. /**
  10728. * Strong typing of a RenderingGroup related stage step action
  10729. */
  10730. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10731. /**
  10732. * Strong typing of a Mesh Render related stage step action
  10733. */
  10734. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10735. /**
  10736. * Strong typing of a simple stage step action
  10737. */
  10738. export type SimpleStageAction = () => void;
  10739. /**
  10740. * Strong typing of a render target action.
  10741. */
  10742. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10743. /**
  10744. * Strong typing of a pointer move action.
  10745. */
  10746. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10747. /**
  10748. * Strong typing of a pointer up/down action.
  10749. */
  10750. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10751. /**
  10752. * Representation of a stage in the scene (Basically a list of ordered steps)
  10753. * @hidden
  10754. */
  10755. export class Stage<T extends Function> extends Array<{
  10756. index: number;
  10757. component: ISceneComponent;
  10758. action: T;
  10759. }> {
  10760. /**
  10761. * Hide ctor from the rest of the world.
  10762. * @param items The items to add.
  10763. */
  10764. private constructor();
  10765. /**
  10766. * Creates a new Stage.
  10767. * @returns A new instance of a Stage
  10768. */
  10769. static Create<T extends Function>(): Stage<T>;
  10770. /**
  10771. * Registers a step in an ordered way in the targeted stage.
  10772. * @param index Defines the position to register the step in
  10773. * @param component Defines the component attached to the step
  10774. * @param action Defines the action to launch during the step
  10775. */
  10776. registerStep(index: number, component: ISceneComponent, action: T): void;
  10777. /**
  10778. * Clears all the steps from the stage.
  10779. */
  10780. clear(): void;
  10781. }
  10782. }
  10783. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10784. import { Nullable } from "babylonjs/types";
  10785. import { Observable } from "babylonjs/Misc/observable";
  10786. import { Scene } from "babylonjs/scene";
  10787. import { Sprite } from "babylonjs/Sprites/sprite";
  10788. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10789. import { Ray } from "babylonjs/Culling/ray";
  10790. import { Camera } from "babylonjs/Cameras/camera";
  10791. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10792. import { ISceneComponent } from "babylonjs/sceneComponent";
  10793. module "babylonjs/scene" {
  10794. interface Scene {
  10795. /** @hidden */
  10796. _pointerOverSprite: Nullable<Sprite>;
  10797. /** @hidden */
  10798. _pickedDownSprite: Nullable<Sprite>;
  10799. /** @hidden */
  10800. _tempSpritePickingRay: Nullable<Ray>;
  10801. /**
  10802. * All of the sprite managers added to this scene
  10803. * @see https://doc.babylonjs.com/babylon101/sprites
  10804. */
  10805. spriteManagers: Array<ISpriteManager>;
  10806. /**
  10807. * An event triggered when sprites rendering is about to start
  10808. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10809. */
  10810. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10811. /**
  10812. * An event triggered when sprites rendering is done
  10813. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10814. */
  10815. onAfterSpritesRenderingObservable: Observable<Scene>;
  10816. /** @hidden */
  10817. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10818. /** Launch a ray to try to pick a sprite in the scene
  10819. * @param x position on screen
  10820. * @param y position on screen
  10821. * @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
  10822. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10823. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10824. * @returns a PickingInfo
  10825. */
  10826. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10827. /** Use the given ray to pick a sprite in the scene
  10828. * @param ray The ray (in world space) to use to pick meshes
  10829. * @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
  10830. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10831. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10832. * @returns a PickingInfo
  10833. */
  10834. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10835. /** @hidden */
  10836. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10837. /** Launch a ray to try to pick sprites in the scene
  10838. * @param x position on screen
  10839. * @param y position on screen
  10840. * @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
  10841. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10842. * @returns a PickingInfo array
  10843. */
  10844. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10845. /** Use the given ray to pick sprites in the scene
  10846. * @param ray The ray (in world space) to use to pick meshes
  10847. * @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
  10848. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10849. * @returns a PickingInfo array
  10850. */
  10851. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10852. /**
  10853. * Force the sprite under the pointer
  10854. * @param sprite defines the sprite to use
  10855. */
  10856. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10857. /**
  10858. * Gets the sprite under the pointer
  10859. * @returns a Sprite or null if no sprite is under the pointer
  10860. */
  10861. getPointerOverSprite(): Nullable<Sprite>;
  10862. }
  10863. }
  10864. /**
  10865. * Defines the sprite scene component responsible to manage sprites
  10866. * in a given scene.
  10867. */
  10868. export class SpriteSceneComponent implements ISceneComponent {
  10869. /**
  10870. * The component name helpfull to identify the component in the list of scene components.
  10871. */
  10872. readonly name: string;
  10873. /**
  10874. * The scene the component belongs to.
  10875. */
  10876. scene: Scene;
  10877. /** @hidden */
  10878. private _spritePredicate;
  10879. /**
  10880. * Creates a new instance of the component for the given scene
  10881. * @param scene Defines the scene to register the component in
  10882. */
  10883. constructor(scene: Scene);
  10884. /**
  10885. * Registers the component in a given scene
  10886. */
  10887. register(): void;
  10888. /**
  10889. * Rebuilds the elements related to this component in case of
  10890. * context lost for instance.
  10891. */
  10892. rebuild(): void;
  10893. /**
  10894. * Disposes the component and the associated ressources.
  10895. */
  10896. dispose(): void;
  10897. private _pickSpriteButKeepRay;
  10898. private _pointerMove;
  10899. private _pointerDown;
  10900. private _pointerUp;
  10901. }
  10902. }
  10903. declare module "babylonjs/Misc/timingTools" {
  10904. /**
  10905. * Class used to provide helper for timing
  10906. */
  10907. export class TimingTools {
  10908. /**
  10909. * Polyfill for setImmediate
  10910. * @param action defines the action to execute after the current execution block
  10911. */
  10912. static SetImmediate(action: () => void): void;
  10913. }
  10914. }
  10915. declare module "babylonjs/Misc/instantiationTools" {
  10916. /**
  10917. * Class used to enable instatition of objects by class name
  10918. */
  10919. export class InstantiationTools {
  10920. /**
  10921. * Use this object to register external classes like custom textures or material
  10922. * to allow the laoders to instantiate them
  10923. */
  10924. static RegisteredExternalClasses: {
  10925. [key: string]: Object;
  10926. };
  10927. /**
  10928. * Tries to instantiate a new object from a given class name
  10929. * @param className defines the class name to instantiate
  10930. * @returns the new object or null if the system was not able to do the instantiation
  10931. */
  10932. static Instantiate(className: string): any;
  10933. }
  10934. }
  10935. declare module "babylonjs/Misc/copyTools" {
  10936. import { Nullable } from "babylonjs/types";
  10937. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  10938. /**
  10939. * Class used to host copy specific utilities
  10940. */
  10941. export class CopyTools {
  10942. /**
  10943. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  10944. * @param texture defines the texture to read pixels from
  10945. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  10946. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  10947. * @returns The base64 encoded string or null
  10948. */
  10949. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  10950. }
  10951. }
  10952. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  10953. /**
  10954. * Define options used to create a depth texture
  10955. */
  10956. export class DepthTextureCreationOptions {
  10957. /** Specifies whether or not a stencil should be allocated in the texture */
  10958. generateStencil?: boolean;
  10959. /** Specifies whether or not bilinear filtering is enable on the texture */
  10960. bilinearFiltering?: boolean;
  10961. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10962. comparisonFunction?: number;
  10963. /** Specifies if the created texture is a cube texture */
  10964. isCube?: boolean;
  10965. }
  10966. }
  10967. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  10968. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10969. import { Nullable } from "babylonjs/types";
  10970. import { Scene } from "babylonjs/scene";
  10971. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  10972. module "babylonjs/Engines/thinEngine" {
  10973. interface ThinEngine {
  10974. /**
  10975. * Creates a depth stencil cube texture.
  10976. * This is only available in WebGL 2.
  10977. * @param size The size of face edge in the cube texture.
  10978. * @param options The options defining the cube texture.
  10979. * @returns The cube texture
  10980. */
  10981. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  10982. /**
  10983. * Creates a cube texture
  10984. * @param rootUrl defines the url where the files to load is located
  10985. * @param scene defines the current scene
  10986. * @param files defines the list of files to load (1 per face)
  10987. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10988. * @param onLoad defines an optional callback raised when the texture is loaded
  10989. * @param onError defines an optional callback raised if there is an issue to load the texture
  10990. * @param format defines the format of the data
  10991. * @param forcedExtension defines the extension to use to pick the right loader
  10992. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10993. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10994. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10995. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10996. * @param loaderOptions options to be passed to the loader
  10997. * @returns the cube texture as an InternalTexture
  10998. */
  10999. 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;
  11000. /**
  11001. * Creates a cube texture
  11002. * @param rootUrl defines the url where the files to load is located
  11003. * @param scene defines the current scene
  11004. * @param files defines the list of files to load (1 per face)
  11005. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11006. * @param onLoad defines an optional callback raised when the texture is loaded
  11007. * @param onError defines an optional callback raised if there is an issue to load the texture
  11008. * @param format defines the format of the data
  11009. * @param forcedExtension defines the extension to use to pick the right loader
  11010. * @returns the cube texture as an InternalTexture
  11011. */
  11012. 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;
  11013. /**
  11014. * Creates a cube texture
  11015. * @param rootUrl defines the url where the files to load is located
  11016. * @param scene defines the current scene
  11017. * @param files defines the list of files to load (1 per face)
  11018. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11019. * @param onLoad defines an optional callback raised when the texture is loaded
  11020. * @param onError defines an optional callback raised if there is an issue to load the texture
  11021. * @param format defines the format of the data
  11022. * @param forcedExtension defines the extension to use to pick the right loader
  11023. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11024. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11025. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11026. * @returns the cube texture as an InternalTexture
  11027. */
  11028. 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;
  11029. /** @hidden */
  11030. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11031. /** @hidden */
  11032. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11033. /** @hidden */
  11034. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11035. /** @hidden */
  11036. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11037. /**
  11038. * @hidden
  11039. */
  11040. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11041. }
  11042. }
  11043. }
  11044. declare module "babylonjs/Materials/Textures/cubeTexture" {
  11045. import { Nullable } from "babylonjs/types";
  11046. import { Scene } from "babylonjs/scene";
  11047. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11048. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11049. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11050. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  11051. import { Observable } from "babylonjs/Misc/observable";
  11052. /**
  11053. * Class for creating a cube texture
  11054. */
  11055. export class CubeTexture extends BaseTexture {
  11056. private _delayedOnLoad;
  11057. /**
  11058. * Observable triggered once the texture has been loaded.
  11059. */
  11060. onLoadObservable: Observable<CubeTexture>;
  11061. /**
  11062. * The url of the texture
  11063. */
  11064. url: string;
  11065. /**
  11066. * Gets or sets the center of the bounding box associated with the cube texture.
  11067. * It must define where the camera used to render the texture was set
  11068. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11069. */
  11070. boundingBoxPosition: Vector3;
  11071. private _boundingBoxSize;
  11072. /**
  11073. * Gets or sets the size of the bounding box associated with the cube texture
  11074. * When defined, the cubemap will switch to local mode
  11075. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11076. * @example https://www.babylonjs-playground.com/#RNASML
  11077. */
  11078. set boundingBoxSize(value: Vector3);
  11079. /**
  11080. * Returns the bounding box size
  11081. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11082. */
  11083. get boundingBoxSize(): Vector3;
  11084. protected _rotationY: number;
  11085. /**
  11086. * Sets texture matrix rotation angle around Y axis in radians.
  11087. */
  11088. set rotationY(value: number);
  11089. /**
  11090. * Gets texture matrix rotation angle around Y axis radians.
  11091. */
  11092. get rotationY(): number;
  11093. /**
  11094. * Are mip maps generated for this texture or not.
  11095. */
  11096. get noMipmap(): boolean;
  11097. private _noMipmap;
  11098. private _files;
  11099. protected _forcedExtension: Nullable<string>;
  11100. private _extensions;
  11101. private _textureMatrix;
  11102. private _format;
  11103. private _createPolynomials;
  11104. private _loaderOptions;
  11105. /**
  11106. * Creates a cube texture from an array of image urls
  11107. * @param files defines an array of image urls
  11108. * @param scene defines the hosting scene
  11109. * @param noMipmap specifies if mip maps are not used
  11110. * @returns a cube texture
  11111. */
  11112. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11113. /**
  11114. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11115. * @param url defines the url of the prefiltered texture
  11116. * @param scene defines the scene the texture is attached to
  11117. * @param forcedExtension defines the extension of the file if different from the url
  11118. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11119. * @return the prefiltered texture
  11120. */
  11121. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11122. /**
  11123. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11124. * as prefiltered data.
  11125. * @param rootUrl defines the url of the texture or the root name of the six images
  11126. * @param null defines the scene or engine the texture is attached to
  11127. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11128. * @param noMipmap defines if mipmaps should be created or not
  11129. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11130. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11131. * @param onError defines a callback triggered in case of error during load
  11132. * @param format defines the internal format to use for the texture once loaded
  11133. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11134. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11135. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11136. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11137. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11138. * @param loaderOptions options to be passed to the loader
  11139. * @return the cube texture
  11140. */
  11141. 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);
  11142. /**
  11143. * Get the current class name of the texture useful for serialization or dynamic coding.
  11144. * @returns "CubeTexture"
  11145. */
  11146. getClassName(): string;
  11147. /**
  11148. * Update the url (and optional buffer) of this texture if url was null during construction.
  11149. * @param url the url of the texture
  11150. * @param forcedExtension defines the extension to use
  11151. * @param onLoad callback called when the texture is loaded (defaults to null)
  11152. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11153. */
  11154. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11155. /**
  11156. * Delays loading of the cube texture
  11157. * @param forcedExtension defines the extension to use
  11158. */
  11159. delayLoad(forcedExtension?: string): void;
  11160. /**
  11161. * Returns the reflection texture matrix
  11162. * @returns the reflection texture matrix
  11163. */
  11164. getReflectionTextureMatrix(): Matrix;
  11165. /**
  11166. * Sets the reflection texture matrix
  11167. * @param value Reflection texture matrix
  11168. */
  11169. setReflectionTextureMatrix(value: Matrix): void;
  11170. /**
  11171. * Parses text to create a cube texture
  11172. * @param parsedTexture define the serialized text to read from
  11173. * @param scene defines the hosting scene
  11174. * @param rootUrl defines the root url of the cube texture
  11175. * @returns a cube texture
  11176. */
  11177. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11178. /**
  11179. * Makes a clone, or deep copy, of the cube texture
  11180. * @returns a new cube texture
  11181. */
  11182. clone(): CubeTexture;
  11183. }
  11184. }
  11185. declare module "babylonjs/Materials/colorCurves" {
  11186. import { Effect } from "babylonjs/Materials/effect";
  11187. /**
  11188. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11189. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11190. * 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;
  11191. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11192. */
  11193. export class ColorCurves {
  11194. private _dirty;
  11195. private _tempColor;
  11196. private _globalCurve;
  11197. private _highlightsCurve;
  11198. private _midtonesCurve;
  11199. private _shadowsCurve;
  11200. private _positiveCurve;
  11201. private _negativeCurve;
  11202. private _globalHue;
  11203. private _globalDensity;
  11204. private _globalSaturation;
  11205. private _globalExposure;
  11206. /**
  11207. * Gets the global Hue value.
  11208. * 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).
  11209. */
  11210. get globalHue(): number;
  11211. /**
  11212. * Sets the global Hue value.
  11213. * 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).
  11214. */
  11215. set globalHue(value: number);
  11216. /**
  11217. * Gets the global Density value.
  11218. * 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.
  11219. * Values less than zero provide a filter of opposite hue.
  11220. */
  11221. get globalDensity(): number;
  11222. /**
  11223. * Sets the global Density value.
  11224. * 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.
  11225. * Values less than zero provide a filter of opposite hue.
  11226. */
  11227. set globalDensity(value: number);
  11228. /**
  11229. * Gets the global Saturation value.
  11230. * 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.
  11231. */
  11232. get globalSaturation(): number;
  11233. /**
  11234. * Sets the global Saturation value.
  11235. * 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.
  11236. */
  11237. set globalSaturation(value: number);
  11238. /**
  11239. * Gets the global Exposure value.
  11240. * 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.
  11241. */
  11242. get globalExposure(): number;
  11243. /**
  11244. * Sets the global Exposure value.
  11245. * 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.
  11246. */
  11247. set globalExposure(value: number);
  11248. private _highlightsHue;
  11249. private _highlightsDensity;
  11250. private _highlightsSaturation;
  11251. private _highlightsExposure;
  11252. /**
  11253. * Gets the highlights Hue value.
  11254. * 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).
  11255. */
  11256. get highlightsHue(): number;
  11257. /**
  11258. * Sets the highlights Hue value.
  11259. * 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).
  11260. */
  11261. set highlightsHue(value: number);
  11262. /**
  11263. * Gets the highlights Density value.
  11264. * 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.
  11265. * Values less than zero provide a filter of opposite hue.
  11266. */
  11267. get highlightsDensity(): number;
  11268. /**
  11269. * Sets the highlights Density value.
  11270. * 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.
  11271. * Values less than zero provide a filter of opposite hue.
  11272. */
  11273. set highlightsDensity(value: number);
  11274. /**
  11275. * Gets the highlights Saturation value.
  11276. * 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.
  11277. */
  11278. get highlightsSaturation(): number;
  11279. /**
  11280. * Sets the highlights Saturation value.
  11281. * 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.
  11282. */
  11283. set highlightsSaturation(value: number);
  11284. /**
  11285. * Gets the highlights Exposure value.
  11286. * 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.
  11287. */
  11288. get highlightsExposure(): number;
  11289. /**
  11290. * Sets the highlights Exposure value.
  11291. * 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.
  11292. */
  11293. set highlightsExposure(value: number);
  11294. private _midtonesHue;
  11295. private _midtonesDensity;
  11296. private _midtonesSaturation;
  11297. private _midtonesExposure;
  11298. /**
  11299. * Gets the midtones Hue value.
  11300. * 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).
  11301. */
  11302. get midtonesHue(): number;
  11303. /**
  11304. * Sets the midtones Hue value.
  11305. * 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).
  11306. */
  11307. set midtonesHue(value: number);
  11308. /**
  11309. * Gets the midtones Density value.
  11310. * 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.
  11311. * Values less than zero provide a filter of opposite hue.
  11312. */
  11313. get midtonesDensity(): number;
  11314. /**
  11315. * Sets the midtones Density value.
  11316. * 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.
  11317. * Values less than zero provide a filter of opposite hue.
  11318. */
  11319. set midtonesDensity(value: number);
  11320. /**
  11321. * Gets the midtones Saturation value.
  11322. * 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.
  11323. */
  11324. get midtonesSaturation(): number;
  11325. /**
  11326. * Sets the midtones Saturation value.
  11327. * 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.
  11328. */
  11329. set midtonesSaturation(value: number);
  11330. /**
  11331. * Gets the midtones Exposure value.
  11332. * 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.
  11333. */
  11334. get midtonesExposure(): number;
  11335. /**
  11336. * Sets the midtones Exposure value.
  11337. * 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.
  11338. */
  11339. set midtonesExposure(value: number);
  11340. private _shadowsHue;
  11341. private _shadowsDensity;
  11342. private _shadowsSaturation;
  11343. private _shadowsExposure;
  11344. /**
  11345. * Gets the shadows Hue value.
  11346. * 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).
  11347. */
  11348. get shadowsHue(): number;
  11349. /**
  11350. * Sets the shadows Hue value.
  11351. * 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).
  11352. */
  11353. set shadowsHue(value: number);
  11354. /**
  11355. * Gets the shadows Density value.
  11356. * 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.
  11357. * Values less than zero provide a filter of opposite hue.
  11358. */
  11359. get shadowsDensity(): number;
  11360. /**
  11361. * Sets the shadows Density value.
  11362. * 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.
  11363. * Values less than zero provide a filter of opposite hue.
  11364. */
  11365. set shadowsDensity(value: number);
  11366. /**
  11367. * Gets the shadows Saturation value.
  11368. * 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.
  11369. */
  11370. get shadowsSaturation(): number;
  11371. /**
  11372. * Sets the shadows Saturation value.
  11373. * 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.
  11374. */
  11375. set shadowsSaturation(value: number);
  11376. /**
  11377. * Gets the shadows Exposure value.
  11378. * 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.
  11379. */
  11380. get shadowsExposure(): number;
  11381. /**
  11382. * Sets the shadows Exposure value.
  11383. * 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.
  11384. */
  11385. set shadowsExposure(value: number);
  11386. /**
  11387. * Returns the class name
  11388. * @returns The class name
  11389. */
  11390. getClassName(): string;
  11391. /**
  11392. * Binds the color curves to the shader.
  11393. * @param colorCurves The color curve to bind
  11394. * @param effect The effect to bind to
  11395. * @param positiveUniform The positive uniform shader parameter
  11396. * @param neutralUniform The neutral uniform shader parameter
  11397. * @param negativeUniform The negative uniform shader parameter
  11398. */
  11399. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11400. /**
  11401. * Prepare the list of uniforms associated with the ColorCurves effects.
  11402. * @param uniformsList The list of uniforms used in the effect
  11403. */
  11404. static PrepareUniforms(uniformsList: string[]): void;
  11405. /**
  11406. * Returns color grading data based on a hue, density, saturation and exposure value.
  11407. * @param filterHue The hue of the color filter.
  11408. * @param filterDensity The density of the color filter.
  11409. * @param saturation The saturation.
  11410. * @param exposure The exposure.
  11411. * @param result The result data container.
  11412. */
  11413. private getColorGradingDataToRef;
  11414. /**
  11415. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11416. * @param value The input slider value in range [-100,100].
  11417. * @returns Adjusted value.
  11418. */
  11419. private static applyColorGradingSliderNonlinear;
  11420. /**
  11421. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11422. * @param hue The hue (H) input.
  11423. * @param saturation The saturation (S) input.
  11424. * @param brightness The brightness (B) input.
  11425. * @result An RGBA color represented as Vector4.
  11426. */
  11427. private static fromHSBToRef;
  11428. /**
  11429. * Returns a value clamped between min and max
  11430. * @param value The value to clamp
  11431. * @param min The minimum of value
  11432. * @param max The maximum of value
  11433. * @returns The clamped value.
  11434. */
  11435. private static clamp;
  11436. /**
  11437. * Clones the current color curve instance.
  11438. * @return The cloned curves
  11439. */
  11440. clone(): ColorCurves;
  11441. /**
  11442. * Serializes the current color curve instance to a json representation.
  11443. * @return a JSON representation
  11444. */
  11445. serialize(): any;
  11446. /**
  11447. * Parses the color curve from a json representation.
  11448. * @param source the JSON source to parse
  11449. * @return The parsed curves
  11450. */
  11451. static Parse(source: any): ColorCurves;
  11452. }
  11453. }
  11454. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  11455. import { Observable } from "babylonjs/Misc/observable";
  11456. import { Nullable } from "babylonjs/types";
  11457. import { Color4 } from "babylonjs/Maths/math.color";
  11458. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11459. import { Effect } from "babylonjs/Materials/effect";
  11460. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11461. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  11462. /**
  11463. * Interface to follow in your material defines to integrate easily the
  11464. * Image proccessing functions.
  11465. * @hidden
  11466. */
  11467. export interface IImageProcessingConfigurationDefines {
  11468. IMAGEPROCESSING: boolean;
  11469. VIGNETTE: boolean;
  11470. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11471. VIGNETTEBLENDMODEOPAQUE: boolean;
  11472. TONEMAPPING: boolean;
  11473. TONEMAPPING_ACES: boolean;
  11474. CONTRAST: boolean;
  11475. EXPOSURE: boolean;
  11476. COLORCURVES: boolean;
  11477. COLORGRADING: boolean;
  11478. COLORGRADING3D: boolean;
  11479. SAMPLER3DGREENDEPTH: boolean;
  11480. SAMPLER3DBGRMAP: boolean;
  11481. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11482. }
  11483. /**
  11484. * @hidden
  11485. */
  11486. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11487. IMAGEPROCESSING: boolean;
  11488. VIGNETTE: boolean;
  11489. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11490. VIGNETTEBLENDMODEOPAQUE: boolean;
  11491. TONEMAPPING: boolean;
  11492. TONEMAPPING_ACES: boolean;
  11493. CONTRAST: boolean;
  11494. COLORCURVES: boolean;
  11495. COLORGRADING: boolean;
  11496. COLORGRADING3D: boolean;
  11497. SAMPLER3DGREENDEPTH: boolean;
  11498. SAMPLER3DBGRMAP: boolean;
  11499. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11500. EXPOSURE: boolean;
  11501. constructor();
  11502. }
  11503. /**
  11504. * This groups together the common properties used for image processing either in direct forward pass
  11505. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11506. * or not.
  11507. */
  11508. export class ImageProcessingConfiguration {
  11509. /**
  11510. * Default tone mapping applied in BabylonJS.
  11511. */
  11512. static readonly TONEMAPPING_STANDARD: number;
  11513. /**
  11514. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11515. * to other engines rendering to increase portability.
  11516. */
  11517. static readonly TONEMAPPING_ACES: number;
  11518. /**
  11519. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11520. */
  11521. colorCurves: Nullable<ColorCurves>;
  11522. private _colorCurvesEnabled;
  11523. /**
  11524. * Gets wether the color curves effect is enabled.
  11525. */
  11526. get colorCurvesEnabled(): boolean;
  11527. /**
  11528. * Sets wether the color curves effect is enabled.
  11529. */
  11530. set colorCurvesEnabled(value: boolean);
  11531. private _colorGradingTexture;
  11532. /**
  11533. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11534. */
  11535. get colorGradingTexture(): Nullable<BaseTexture>;
  11536. /**
  11537. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11538. */
  11539. set colorGradingTexture(value: Nullable<BaseTexture>);
  11540. private _colorGradingEnabled;
  11541. /**
  11542. * Gets wether the color grading effect is enabled.
  11543. */
  11544. get colorGradingEnabled(): boolean;
  11545. /**
  11546. * Sets wether the color grading effect is enabled.
  11547. */
  11548. set colorGradingEnabled(value: boolean);
  11549. private _colorGradingWithGreenDepth;
  11550. /**
  11551. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11552. */
  11553. get colorGradingWithGreenDepth(): boolean;
  11554. /**
  11555. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11556. */
  11557. set colorGradingWithGreenDepth(value: boolean);
  11558. private _colorGradingBGR;
  11559. /**
  11560. * Gets wether the color grading texture contains BGR values.
  11561. */
  11562. get colorGradingBGR(): boolean;
  11563. /**
  11564. * Sets wether the color grading texture contains BGR values.
  11565. */
  11566. set colorGradingBGR(value: boolean);
  11567. /** @hidden */
  11568. _exposure: number;
  11569. /**
  11570. * Gets the Exposure used in the effect.
  11571. */
  11572. get exposure(): number;
  11573. /**
  11574. * Sets the Exposure used in the effect.
  11575. */
  11576. set exposure(value: number);
  11577. private _toneMappingEnabled;
  11578. /**
  11579. * Gets wether the tone mapping effect is enabled.
  11580. */
  11581. get toneMappingEnabled(): boolean;
  11582. /**
  11583. * Sets wether the tone mapping effect is enabled.
  11584. */
  11585. set toneMappingEnabled(value: boolean);
  11586. private _toneMappingType;
  11587. /**
  11588. * Gets the type of tone mapping effect.
  11589. */
  11590. get toneMappingType(): number;
  11591. /**
  11592. * Sets the type of tone mapping effect used in BabylonJS.
  11593. */
  11594. set toneMappingType(value: number);
  11595. protected _contrast: number;
  11596. /**
  11597. * Gets the contrast used in the effect.
  11598. */
  11599. get contrast(): number;
  11600. /**
  11601. * Sets the contrast used in the effect.
  11602. */
  11603. set contrast(value: number);
  11604. /**
  11605. * Vignette stretch size.
  11606. */
  11607. vignetteStretch: number;
  11608. /**
  11609. * Vignette centre X Offset.
  11610. */
  11611. vignetteCentreX: number;
  11612. /**
  11613. * Vignette centre Y Offset.
  11614. */
  11615. vignetteCentreY: number;
  11616. /**
  11617. * Vignette weight or intensity of the vignette effect.
  11618. */
  11619. vignetteWeight: number;
  11620. /**
  11621. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11622. * if vignetteEnabled is set to true.
  11623. */
  11624. vignetteColor: Color4;
  11625. /**
  11626. * Camera field of view used by the Vignette effect.
  11627. */
  11628. vignetteCameraFov: number;
  11629. private _vignetteBlendMode;
  11630. /**
  11631. * Gets the vignette blend mode allowing different kind of effect.
  11632. */
  11633. get vignetteBlendMode(): number;
  11634. /**
  11635. * Sets the vignette blend mode allowing different kind of effect.
  11636. */
  11637. set vignetteBlendMode(value: number);
  11638. private _vignetteEnabled;
  11639. /**
  11640. * Gets wether the vignette effect is enabled.
  11641. */
  11642. get vignetteEnabled(): boolean;
  11643. /**
  11644. * Sets wether the vignette effect is enabled.
  11645. */
  11646. set vignetteEnabled(value: boolean);
  11647. private _applyByPostProcess;
  11648. /**
  11649. * Gets wether the image processing is applied through a post process or not.
  11650. */
  11651. get applyByPostProcess(): boolean;
  11652. /**
  11653. * Sets wether the image processing is applied through a post process or not.
  11654. */
  11655. set applyByPostProcess(value: boolean);
  11656. private _isEnabled;
  11657. /**
  11658. * Gets wether the image processing is enabled or not.
  11659. */
  11660. get isEnabled(): boolean;
  11661. /**
  11662. * Sets wether the image processing is enabled or not.
  11663. */
  11664. set isEnabled(value: boolean);
  11665. /**
  11666. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11667. */
  11668. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11669. /**
  11670. * Method called each time the image processing information changes requires to recompile the effect.
  11671. */
  11672. protected _updateParameters(): void;
  11673. /**
  11674. * Gets the current class name.
  11675. * @return "ImageProcessingConfiguration"
  11676. */
  11677. getClassName(): string;
  11678. /**
  11679. * Prepare the list of uniforms associated with the Image Processing effects.
  11680. * @param uniforms The list of uniforms used in the effect
  11681. * @param defines the list of defines currently in use
  11682. */
  11683. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11684. /**
  11685. * Prepare the list of samplers associated with the Image Processing effects.
  11686. * @param samplersList The list of uniforms used in the effect
  11687. * @param defines the list of defines currently in use
  11688. */
  11689. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11690. /**
  11691. * Prepare the list of defines associated to the shader.
  11692. * @param defines the list of defines to complete
  11693. * @param forPostProcess Define if we are currently in post process mode or not
  11694. */
  11695. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11696. /**
  11697. * Returns true if all the image processing information are ready.
  11698. * @returns True if ready, otherwise, false
  11699. */
  11700. isReady(): boolean;
  11701. /**
  11702. * Binds the image processing to the shader.
  11703. * @param effect The effect to bind to
  11704. * @param overrideAspectRatio Override the aspect ratio of the effect
  11705. */
  11706. bind(effect: Effect, overrideAspectRatio?: number): void;
  11707. /**
  11708. * Clones the current image processing instance.
  11709. * @return The cloned image processing
  11710. */
  11711. clone(): ImageProcessingConfiguration;
  11712. /**
  11713. * Serializes the current image processing instance to a json representation.
  11714. * @return a JSON representation
  11715. */
  11716. serialize(): any;
  11717. /**
  11718. * Parses the image processing from a json representation.
  11719. * @param source the JSON source to parse
  11720. * @return The parsed image processing
  11721. */
  11722. static Parse(source: any): ImageProcessingConfiguration;
  11723. private static _VIGNETTEMODE_MULTIPLY;
  11724. private static _VIGNETTEMODE_OPAQUE;
  11725. /**
  11726. * Used to apply the vignette as a mix with the pixel color.
  11727. */
  11728. static get VIGNETTEMODE_MULTIPLY(): number;
  11729. /**
  11730. * Used to apply the vignette as a replacement of the pixel color.
  11731. */
  11732. static get VIGNETTEMODE_OPAQUE(): number;
  11733. }
  11734. }
  11735. declare module "babylonjs/Shaders/postprocess.vertex" {
  11736. /** @hidden */
  11737. export var postprocessVertexShader: {
  11738. name: string;
  11739. shader: string;
  11740. };
  11741. }
  11742. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  11743. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11744. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11745. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  11746. /**
  11747. * Type used to define a render target texture size (either with a number or with a rect width and height)
  11748. */
  11749. export type RenderTargetTextureSize = number | {
  11750. width: number;
  11751. height: number;
  11752. layers?: number;
  11753. };
  11754. module "babylonjs/Engines/thinEngine" {
  11755. interface ThinEngine {
  11756. /**
  11757. * Creates a new render target texture
  11758. * @param size defines the size of the texture
  11759. * @param options defines the options used to create the texture
  11760. * @returns a new render target texture stored in an InternalTexture
  11761. */
  11762. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11763. /**
  11764. * Creates a depth stencil texture.
  11765. * This is only available in WebGL 2 or with the depth texture extension available.
  11766. * @param size The size of face edge in the texture.
  11767. * @param options The options defining the texture.
  11768. * @returns The texture
  11769. */
  11770. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11771. /** @hidden */
  11772. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11773. }
  11774. }
  11775. }
  11776. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  11777. /**
  11778. * Defines the kind of connection point for node based material
  11779. */
  11780. export enum NodeMaterialBlockConnectionPointTypes {
  11781. /** Float */
  11782. Float = 1,
  11783. /** Int */
  11784. Int = 2,
  11785. /** Vector2 */
  11786. Vector2 = 4,
  11787. /** Vector3 */
  11788. Vector3 = 8,
  11789. /** Vector4 */
  11790. Vector4 = 16,
  11791. /** Color3 */
  11792. Color3 = 32,
  11793. /** Color4 */
  11794. Color4 = 64,
  11795. /** Matrix */
  11796. Matrix = 128,
  11797. /** Custom object */
  11798. Object = 256,
  11799. /** Detect type based on connection */
  11800. AutoDetect = 1024,
  11801. /** Output type that will be defined by input type */
  11802. BasedOnInput = 2048
  11803. }
  11804. }
  11805. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  11806. /**
  11807. * Enum used to define the target of a block
  11808. */
  11809. export enum NodeMaterialBlockTargets {
  11810. /** Vertex shader */
  11811. Vertex = 1,
  11812. /** Fragment shader */
  11813. Fragment = 2,
  11814. /** Neutral */
  11815. Neutral = 4,
  11816. /** Vertex and Fragment */
  11817. VertexAndFragment = 3
  11818. }
  11819. }
  11820. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  11821. /**
  11822. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  11823. */
  11824. export enum NodeMaterialBlockConnectionPointMode {
  11825. /** Value is an uniform */
  11826. Uniform = 0,
  11827. /** Value is a mesh attribute */
  11828. Attribute = 1,
  11829. /** Value is a varying between vertex and fragment shaders */
  11830. Varying = 2,
  11831. /** Mode is undefined */
  11832. Undefined = 3
  11833. }
  11834. }
  11835. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  11836. /**
  11837. * Enum used to define system values e.g. values automatically provided by the system
  11838. */
  11839. export enum NodeMaterialSystemValues {
  11840. /** World */
  11841. World = 1,
  11842. /** View */
  11843. View = 2,
  11844. /** Projection */
  11845. Projection = 3,
  11846. /** ViewProjection */
  11847. ViewProjection = 4,
  11848. /** WorldView */
  11849. WorldView = 5,
  11850. /** WorldViewProjection */
  11851. WorldViewProjection = 6,
  11852. /** CameraPosition */
  11853. CameraPosition = 7,
  11854. /** Fog Color */
  11855. FogColor = 8,
  11856. /** Delta time */
  11857. DeltaTime = 9
  11858. }
  11859. }
  11860. declare module "babylonjs/Maths/math.frustum" {
  11861. import { Matrix } from "babylonjs/Maths/math.vector";
  11862. import { DeepImmutable } from "babylonjs/types";
  11863. import { Plane } from "babylonjs/Maths/math.plane";
  11864. /**
  11865. * Represents a camera frustum
  11866. */
  11867. export class Frustum {
  11868. /**
  11869. * Gets the planes representing the frustum
  11870. * @param transform matrix to be applied to the returned planes
  11871. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  11872. */
  11873. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  11874. /**
  11875. * Gets the near frustum plane transformed by the transform matrix
  11876. * @param transform transformation matrix to be applied to the resulting frustum plane
  11877. * @param frustumPlane the resuling frustum plane
  11878. */
  11879. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11880. /**
  11881. * Gets the far frustum plane transformed by the transform matrix
  11882. * @param transform transformation matrix to be applied to the resulting frustum plane
  11883. * @param frustumPlane the resuling frustum plane
  11884. */
  11885. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11886. /**
  11887. * Gets the left frustum plane transformed by the transform matrix
  11888. * @param transform transformation matrix to be applied to the resulting frustum plane
  11889. * @param frustumPlane the resuling frustum plane
  11890. */
  11891. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11892. /**
  11893. * Gets the right frustum plane transformed by the transform matrix
  11894. * @param transform transformation matrix to be applied to the resulting frustum plane
  11895. * @param frustumPlane the resuling frustum plane
  11896. */
  11897. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11898. /**
  11899. * Gets the top frustum plane transformed by the transform matrix
  11900. * @param transform transformation matrix to be applied to the resulting frustum plane
  11901. * @param frustumPlane the resuling frustum plane
  11902. */
  11903. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11904. /**
  11905. * Gets the bottom frustum plane transformed by the transform matrix
  11906. * @param transform transformation matrix to be applied to the resulting frustum plane
  11907. * @param frustumPlane the resuling frustum plane
  11908. */
  11909. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11910. /**
  11911. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  11912. * @param transform transformation matrix to be applied to the resulting frustum planes
  11913. * @param frustumPlanes the resuling frustum planes
  11914. */
  11915. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  11916. }
  11917. }
  11918. declare module "babylonjs/Maths/math.vertexFormat" {
  11919. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11920. /**
  11921. * Contains position and normal vectors for a vertex
  11922. */
  11923. export class PositionNormalVertex {
  11924. /** the position of the vertex (defaut: 0,0,0) */
  11925. position: Vector3;
  11926. /** the normal of the vertex (defaut: 0,1,0) */
  11927. normal: Vector3;
  11928. /**
  11929. * Creates a PositionNormalVertex
  11930. * @param position the position of the vertex (defaut: 0,0,0)
  11931. * @param normal the normal of the vertex (defaut: 0,1,0)
  11932. */
  11933. constructor(
  11934. /** the position of the vertex (defaut: 0,0,0) */
  11935. position?: Vector3,
  11936. /** the normal of the vertex (defaut: 0,1,0) */
  11937. normal?: Vector3);
  11938. /**
  11939. * Clones the PositionNormalVertex
  11940. * @returns the cloned PositionNormalVertex
  11941. */
  11942. clone(): PositionNormalVertex;
  11943. }
  11944. /**
  11945. * Contains position, normal and uv vectors for a vertex
  11946. */
  11947. export class PositionNormalTextureVertex {
  11948. /** the position of the vertex (defaut: 0,0,0) */
  11949. position: Vector3;
  11950. /** the normal of the vertex (defaut: 0,1,0) */
  11951. normal: Vector3;
  11952. /** the uv of the vertex (default: 0,0) */
  11953. uv: Vector2;
  11954. /**
  11955. * Creates a PositionNormalTextureVertex
  11956. * @param position the position of the vertex (defaut: 0,0,0)
  11957. * @param normal the normal of the vertex (defaut: 0,1,0)
  11958. * @param uv the uv of the vertex (default: 0,0)
  11959. */
  11960. constructor(
  11961. /** the position of the vertex (defaut: 0,0,0) */
  11962. position?: Vector3,
  11963. /** the normal of the vertex (defaut: 0,1,0) */
  11964. normal?: Vector3,
  11965. /** the uv of the vertex (default: 0,0) */
  11966. uv?: Vector2);
  11967. /**
  11968. * Clones the PositionNormalTextureVertex
  11969. * @returns the cloned PositionNormalTextureVertex
  11970. */
  11971. clone(): PositionNormalTextureVertex;
  11972. }
  11973. }
  11974. declare module "babylonjs/Maths/math" {
  11975. export * from "babylonjs/Maths/math.axis";
  11976. export * from "babylonjs/Maths/math.color";
  11977. export * from "babylonjs/Maths/math.constants";
  11978. export * from "babylonjs/Maths/math.frustum";
  11979. export * from "babylonjs/Maths/math.path";
  11980. export * from "babylonjs/Maths/math.plane";
  11981. export * from "babylonjs/Maths/math.size";
  11982. export * from "babylonjs/Maths/math.vector";
  11983. export * from "babylonjs/Maths/math.vertexFormat";
  11984. export * from "babylonjs/Maths/math.viewport";
  11985. }
  11986. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  11987. /**
  11988. * Enum defining the type of animations supported by InputBlock
  11989. */
  11990. export enum AnimatedInputBlockTypes {
  11991. /** No animation */
  11992. None = 0,
  11993. /** Time based animation. Will only work for floats */
  11994. Time = 1
  11995. }
  11996. }
  11997. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  11998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  11999. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12000. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  12001. import { Nullable } from "babylonjs/types";
  12002. import { Effect } from "babylonjs/Materials/effect";
  12003. import { Matrix } from "babylonjs/Maths/math.vector";
  12004. import { Scene } from "babylonjs/scene";
  12005. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12006. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12007. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12008. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  12009. import { Observable } from "babylonjs/Misc/observable";
  12010. /**
  12011. * Block used to expose an input value
  12012. */
  12013. export class InputBlock extends NodeMaterialBlock {
  12014. private _mode;
  12015. private _associatedVariableName;
  12016. private _storedValue;
  12017. private _valueCallback;
  12018. private _type;
  12019. private _animationType;
  12020. /** Gets or set a value used to limit the range of float values */
  12021. min: number;
  12022. /** Gets or set a value used to limit the range of float values */
  12023. max: number;
  12024. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12025. isBoolean: boolean;
  12026. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12027. matrixMode: number;
  12028. /** @hidden */
  12029. _systemValue: Nullable<NodeMaterialSystemValues>;
  12030. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12031. isConstant: boolean;
  12032. /** Gets or sets the group to use to display this block in the Inspector */
  12033. groupInInspector: string;
  12034. /** Gets an observable raised when the value is changed */
  12035. onValueChangedObservable: Observable<InputBlock>;
  12036. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12037. convertToGammaSpace: boolean;
  12038. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12039. convertToLinearSpace: boolean;
  12040. /**
  12041. * Gets or sets the connection point type (default is float)
  12042. */
  12043. get type(): NodeMaterialBlockConnectionPointTypes;
  12044. /**
  12045. * Creates a new InputBlock
  12046. * @param name defines the block name
  12047. * @param target defines the target of that block (Vertex by default)
  12048. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12049. */
  12050. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12051. /**
  12052. * Validates if a name is a reserve word.
  12053. * @param newName the new name to be given to the node.
  12054. * @returns false if the name is a reserve word, else true.
  12055. */
  12056. validateBlockName(newName: string): boolean;
  12057. /**
  12058. * Gets the output component
  12059. */
  12060. get output(): NodeMaterialConnectionPoint;
  12061. /**
  12062. * Set the source of this connection point to a vertex attribute
  12063. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12064. * @returns the current connection point
  12065. */
  12066. setAsAttribute(attributeName?: string): InputBlock;
  12067. /**
  12068. * Set the source of this connection point to a system value
  12069. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12070. * @returns the current connection point
  12071. */
  12072. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12073. /**
  12074. * Gets or sets the value of that point.
  12075. * Please note that this value will be ignored if valueCallback is defined
  12076. */
  12077. get value(): any;
  12078. set value(value: any);
  12079. /**
  12080. * Gets or sets a callback used to get the value of that point.
  12081. * Please note that setting this value will force the connection point to ignore the value property
  12082. */
  12083. get valueCallback(): () => any;
  12084. set valueCallback(value: () => any);
  12085. /**
  12086. * Gets or sets the associated variable name in the shader
  12087. */
  12088. get associatedVariableName(): string;
  12089. set associatedVariableName(value: string);
  12090. /** Gets or sets the type of animation applied to the input */
  12091. get animationType(): AnimatedInputBlockTypes;
  12092. set animationType(value: AnimatedInputBlockTypes);
  12093. /**
  12094. * Gets a boolean indicating that this connection point not defined yet
  12095. */
  12096. get isUndefined(): boolean;
  12097. /**
  12098. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12099. * In this case the connection point name must be the name of the uniform to use.
  12100. * Can only be set on inputs
  12101. */
  12102. get isUniform(): boolean;
  12103. set isUniform(value: boolean);
  12104. /**
  12105. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12106. * In this case the connection point name must be the name of the attribute to use
  12107. * Can only be set on inputs
  12108. */
  12109. get isAttribute(): boolean;
  12110. set isAttribute(value: boolean);
  12111. /**
  12112. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12113. * Can only be set on exit points
  12114. */
  12115. get isVarying(): boolean;
  12116. set isVarying(value: boolean);
  12117. /**
  12118. * Gets a boolean indicating that the current connection point is a system value
  12119. */
  12120. get isSystemValue(): boolean;
  12121. /**
  12122. * Gets or sets the current well known value or null if not defined as a system value
  12123. */
  12124. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12125. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12126. /**
  12127. * Gets the current class name
  12128. * @returns the class name
  12129. */
  12130. getClassName(): string;
  12131. /**
  12132. * Animate the input if animationType !== None
  12133. * @param scene defines the rendering scene
  12134. */
  12135. animate(scene: Scene): void;
  12136. private _emitDefine;
  12137. initialize(state: NodeMaterialBuildState): void;
  12138. /**
  12139. * Set the input block to its default value (based on its type)
  12140. */
  12141. setDefaultValue(): void;
  12142. private _emitConstant;
  12143. /** @hidden */
  12144. get _noContextSwitch(): boolean;
  12145. private _emit;
  12146. /** @hidden */
  12147. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12148. /** @hidden */
  12149. _transmit(effect: Effect, scene: Scene): void;
  12150. protected _buildBlock(state: NodeMaterialBuildState): void;
  12151. protected _dumpPropertiesCode(): string;
  12152. dispose(): void;
  12153. serialize(): any;
  12154. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12155. }
  12156. }
  12157. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  12158. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12159. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12160. import { Nullable } from "babylonjs/types";
  12161. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  12162. import { Observable } from "babylonjs/Misc/observable";
  12163. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12164. /**
  12165. * Enum used to define the compatibility state between two connection points
  12166. */
  12167. export enum NodeMaterialConnectionPointCompatibilityStates {
  12168. /** Points are compatibles */
  12169. Compatible = 0,
  12170. /** Points are incompatible because of their types */
  12171. TypeIncompatible = 1,
  12172. /** Points are incompatible because of their targets (vertex vs fragment) */
  12173. TargetIncompatible = 2
  12174. }
  12175. /**
  12176. * Defines the direction of a connection point
  12177. */
  12178. export enum NodeMaterialConnectionPointDirection {
  12179. /** Input */
  12180. Input = 0,
  12181. /** Output */
  12182. Output = 1
  12183. }
  12184. /**
  12185. * Defines a connection point for a block
  12186. */
  12187. export class NodeMaterialConnectionPoint {
  12188. /**
  12189. * Checks if two types are equivalent
  12190. * @param type1 type 1 to check
  12191. * @param type2 type 2 to check
  12192. * @returns true if both types are equivalent, else false
  12193. */
  12194. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12195. /** @hidden */
  12196. _ownerBlock: NodeMaterialBlock;
  12197. /** @hidden */
  12198. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12199. private _endpoints;
  12200. private _associatedVariableName;
  12201. private _direction;
  12202. /** @hidden */
  12203. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12204. /** @hidden */
  12205. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12206. /** @hidden */
  12207. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12208. private _type;
  12209. /** @hidden */
  12210. _enforceAssociatedVariableName: boolean;
  12211. /** Gets the direction of the point */
  12212. get direction(): NodeMaterialConnectionPointDirection;
  12213. /** Indicates that this connection point needs dual validation before being connected to another point */
  12214. needDualDirectionValidation: boolean;
  12215. /**
  12216. * Gets or sets the additional types supported by this connection point
  12217. */
  12218. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12219. /**
  12220. * Gets or sets the additional types excluded by this connection point
  12221. */
  12222. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12223. /**
  12224. * Observable triggered when this point is connected
  12225. */
  12226. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12227. /**
  12228. * Gets or sets the associated variable name in the shader
  12229. */
  12230. get associatedVariableName(): string;
  12231. set associatedVariableName(value: string);
  12232. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12233. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12234. /**
  12235. * Gets or sets the connection point type (default is float)
  12236. */
  12237. get type(): NodeMaterialBlockConnectionPointTypes;
  12238. set type(value: NodeMaterialBlockConnectionPointTypes);
  12239. /**
  12240. * Gets or sets the connection point name
  12241. */
  12242. name: string;
  12243. /**
  12244. * Gets or sets the connection point name
  12245. */
  12246. displayName: string;
  12247. /**
  12248. * Gets or sets a boolean indicating that this connection point can be omitted
  12249. */
  12250. isOptional: boolean;
  12251. /**
  12252. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12253. */
  12254. isExposedOnFrame: boolean;
  12255. /**
  12256. * Gets or sets number indicating the position that the port is exposed to on a frame
  12257. */
  12258. exposedPortPosition: number;
  12259. /**
  12260. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12261. */
  12262. define: string;
  12263. /** @hidden */
  12264. _prioritizeVertex: boolean;
  12265. private _target;
  12266. /** Gets or sets the target of that connection point */
  12267. get target(): NodeMaterialBlockTargets;
  12268. set target(value: NodeMaterialBlockTargets);
  12269. /**
  12270. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12271. */
  12272. get isConnected(): boolean;
  12273. /**
  12274. * Gets a boolean indicating that the current point is connected to an input block
  12275. */
  12276. get isConnectedToInputBlock(): boolean;
  12277. /**
  12278. * Gets a the connected input block (if any)
  12279. */
  12280. get connectInputBlock(): Nullable<InputBlock>;
  12281. /** Get the other side of the connection (if any) */
  12282. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12283. /** Get the block that owns this connection point */
  12284. get ownerBlock(): NodeMaterialBlock;
  12285. /** Get the block connected on the other side of this connection (if any) */
  12286. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12287. /** Get the block connected on the endpoints of this connection (if any) */
  12288. get connectedBlocks(): Array<NodeMaterialBlock>;
  12289. /** Gets the list of connected endpoints */
  12290. get endpoints(): NodeMaterialConnectionPoint[];
  12291. /** Gets a boolean indicating if that output point is connected to at least one input */
  12292. get hasEndpoints(): boolean;
  12293. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12294. get isConnectedInVertexShader(): boolean;
  12295. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12296. get isConnectedInFragmentShader(): boolean;
  12297. /**
  12298. * Creates a block suitable to be used as an input for this input point.
  12299. * If null is returned, a block based on the point type will be created.
  12300. * @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
  12301. */
  12302. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12303. /**
  12304. * Creates a new connection point
  12305. * @param name defines the connection point name
  12306. * @param ownerBlock defines the block hosting this connection point
  12307. * @param direction defines the direction of the connection point
  12308. */
  12309. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12310. /**
  12311. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12312. * @returns the class name
  12313. */
  12314. getClassName(): string;
  12315. /**
  12316. * Gets a boolean indicating if the current point can be connected to another point
  12317. * @param connectionPoint defines the other connection point
  12318. * @returns a boolean
  12319. */
  12320. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12321. /**
  12322. * Gets a number indicating if the current point can be connected to another point
  12323. * @param connectionPoint defines the other connection point
  12324. * @returns a number defining the compatibility state
  12325. */
  12326. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12327. /**
  12328. * Connect this point to another connection point
  12329. * @param connectionPoint defines the other connection point
  12330. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12331. * @returns the current connection point
  12332. */
  12333. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12334. /**
  12335. * Disconnect this point from one of his endpoint
  12336. * @param endpoint defines the other connection point
  12337. * @returns the current connection point
  12338. */
  12339. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12340. /**
  12341. * Serializes this point in a JSON representation
  12342. * @param isInput defines if the connection point is an input (default is true)
  12343. * @returns the serialized point object
  12344. */
  12345. serialize(isInput?: boolean): any;
  12346. /**
  12347. * Release resources
  12348. */
  12349. dispose(): void;
  12350. }
  12351. }
  12352. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  12353. /**
  12354. * Enum used to define the material modes
  12355. */
  12356. export enum NodeMaterialModes {
  12357. /** Regular material */
  12358. Material = 0,
  12359. /** For post process */
  12360. PostProcess = 1,
  12361. /** For particle system */
  12362. Particle = 2,
  12363. /** For procedural texture */
  12364. ProceduralTexture = 3
  12365. }
  12366. }
  12367. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  12368. /** @hidden */
  12369. export var helperFunctions: {
  12370. name: string;
  12371. shader: string;
  12372. };
  12373. }
  12374. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  12375. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12376. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12377. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12378. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12380. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12381. import { Effect } from "babylonjs/Materials/effect";
  12382. import { Mesh } from "babylonjs/Meshes/mesh";
  12383. import { Nullable } from "babylonjs/types";
  12384. import { Texture } from "babylonjs/Materials/Textures/texture";
  12385. import { Scene } from "babylonjs/scene";
  12386. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12387. /**
  12388. * Block used to read a texture from a sampler
  12389. */
  12390. export class TextureBlock extends NodeMaterialBlock {
  12391. private _defineName;
  12392. private _linearDefineName;
  12393. private _gammaDefineName;
  12394. private _tempTextureRead;
  12395. private _samplerName;
  12396. private _transformedUVName;
  12397. private _textureTransformName;
  12398. private _textureInfoName;
  12399. private _mainUVName;
  12400. private _mainUVDefineName;
  12401. private _fragmentOnly;
  12402. /**
  12403. * Gets or sets the texture associated with the node
  12404. */
  12405. texture: Nullable<Texture>;
  12406. /**
  12407. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12408. */
  12409. convertToGammaSpace: boolean;
  12410. /**
  12411. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12412. */
  12413. convertToLinearSpace: boolean;
  12414. /**
  12415. * Create a new TextureBlock
  12416. * @param name defines the block name
  12417. */
  12418. constructor(name: string, fragmentOnly?: boolean);
  12419. /**
  12420. * Gets the current class name
  12421. * @returns the class name
  12422. */
  12423. getClassName(): string;
  12424. /**
  12425. * Gets the uv input component
  12426. */
  12427. get uv(): NodeMaterialConnectionPoint;
  12428. /**
  12429. * Gets the rgba output component
  12430. */
  12431. get rgba(): NodeMaterialConnectionPoint;
  12432. /**
  12433. * Gets the rgb output component
  12434. */
  12435. get rgb(): NodeMaterialConnectionPoint;
  12436. /**
  12437. * Gets the r output component
  12438. */
  12439. get r(): NodeMaterialConnectionPoint;
  12440. /**
  12441. * Gets the g output component
  12442. */
  12443. get g(): NodeMaterialConnectionPoint;
  12444. /**
  12445. * Gets the b output component
  12446. */
  12447. get b(): NodeMaterialConnectionPoint;
  12448. /**
  12449. * Gets the a output component
  12450. */
  12451. get a(): NodeMaterialConnectionPoint;
  12452. get target(): NodeMaterialBlockTargets;
  12453. autoConfigure(material: NodeMaterial): void;
  12454. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12455. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12456. isReady(): boolean;
  12457. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12458. private get _isMixed();
  12459. private _injectVertexCode;
  12460. private _writeTextureRead;
  12461. private _writeOutput;
  12462. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12463. protected _dumpPropertiesCode(): string;
  12464. serialize(): any;
  12465. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12466. }
  12467. }
  12468. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  12469. /** @hidden */
  12470. export var reflectionFunction: {
  12471. name: string;
  12472. shader: string;
  12473. };
  12474. }
  12475. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  12476. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12477. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12478. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12479. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12481. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12482. import { Effect } from "babylonjs/Materials/effect";
  12483. import { Mesh } from "babylonjs/Meshes/mesh";
  12484. import { Nullable } from "babylonjs/types";
  12485. import { Scene } from "babylonjs/scene";
  12486. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  12487. /**
  12488. * Base block used to read a reflection texture from a sampler
  12489. */
  12490. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12491. /** @hidden */
  12492. _define3DName: string;
  12493. /** @hidden */
  12494. _defineCubicName: string;
  12495. /** @hidden */
  12496. _defineExplicitName: string;
  12497. /** @hidden */
  12498. _defineProjectionName: string;
  12499. /** @hidden */
  12500. _defineLocalCubicName: string;
  12501. /** @hidden */
  12502. _defineSphericalName: string;
  12503. /** @hidden */
  12504. _definePlanarName: string;
  12505. /** @hidden */
  12506. _defineEquirectangularName: string;
  12507. /** @hidden */
  12508. _defineMirroredEquirectangularFixedName: string;
  12509. /** @hidden */
  12510. _defineEquirectangularFixedName: string;
  12511. /** @hidden */
  12512. _defineSkyboxName: string;
  12513. /** @hidden */
  12514. _defineOppositeZ: string;
  12515. /** @hidden */
  12516. _cubeSamplerName: string;
  12517. /** @hidden */
  12518. _2DSamplerName: string;
  12519. protected _positionUVWName: string;
  12520. protected _directionWName: string;
  12521. protected _reflectionVectorName: string;
  12522. /** @hidden */
  12523. _reflectionCoordsName: string;
  12524. /** @hidden */
  12525. _reflectionMatrixName: string;
  12526. protected _reflectionColorName: string;
  12527. /**
  12528. * Gets or sets the texture associated with the node
  12529. */
  12530. texture: Nullable<BaseTexture>;
  12531. /**
  12532. * Create a new ReflectionTextureBaseBlock
  12533. * @param name defines the block name
  12534. */
  12535. constructor(name: string);
  12536. /**
  12537. * Gets the current class name
  12538. * @returns the class name
  12539. */
  12540. getClassName(): string;
  12541. /**
  12542. * Gets the world position input component
  12543. */
  12544. abstract get position(): NodeMaterialConnectionPoint;
  12545. /**
  12546. * Gets the world position input component
  12547. */
  12548. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12549. /**
  12550. * Gets the world normal input component
  12551. */
  12552. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12553. /**
  12554. * Gets the world input component
  12555. */
  12556. abstract get world(): NodeMaterialConnectionPoint;
  12557. /**
  12558. * Gets the camera (or eye) position component
  12559. */
  12560. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12561. /**
  12562. * Gets the view input component
  12563. */
  12564. abstract get view(): NodeMaterialConnectionPoint;
  12565. protected _getTexture(): Nullable<BaseTexture>;
  12566. autoConfigure(material: NodeMaterial): void;
  12567. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12568. isReady(): boolean;
  12569. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12570. /**
  12571. * Gets the code to inject in the vertex shader
  12572. * @param state current state of the node material building
  12573. * @returns the shader code
  12574. */
  12575. handleVertexSide(state: NodeMaterialBuildState): string;
  12576. /**
  12577. * Handles the inits for the fragment code path
  12578. * @param state node material build state
  12579. */
  12580. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12581. /**
  12582. * Generates the reflection coords code for the fragment code path
  12583. * @param worldNormalVarName name of the world normal variable
  12584. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12585. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12586. * @returns the shader code
  12587. */
  12588. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12589. /**
  12590. * Generates the reflection color code for the fragment code path
  12591. * @param lodVarName name of the lod variable
  12592. * @param swizzleLookupTexture swizzle to use for the final color variable
  12593. * @returns the shader code
  12594. */
  12595. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12596. /**
  12597. * Generates the code corresponding to the connected output points
  12598. * @param state node material build state
  12599. * @param varName name of the variable to output
  12600. * @returns the shader code
  12601. */
  12602. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12603. protected _buildBlock(state: NodeMaterialBuildState): this;
  12604. protected _dumpPropertiesCode(): string;
  12605. serialize(): any;
  12606. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12607. }
  12608. }
  12609. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  12610. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12611. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12612. import { Nullable } from "babylonjs/types";
  12613. /**
  12614. * Defines a connection point to be used for points with a custom object type
  12615. */
  12616. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12617. private _blockType;
  12618. private _blockName;
  12619. private _nameForCheking?;
  12620. /**
  12621. * Creates a new connection point
  12622. * @param name defines the connection point name
  12623. * @param ownerBlock defines the block hosting this connection point
  12624. * @param direction defines the direction of the connection point
  12625. */
  12626. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12627. /**
  12628. * Gets a number indicating if the current point can be connected to another point
  12629. * @param connectionPoint defines the other connection point
  12630. * @returns a number defining the compatibility state
  12631. */
  12632. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12633. /**
  12634. * Creates a block suitable to be used as an input for this input point.
  12635. * If null is returned, a block based on the point type will be created.
  12636. * @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
  12637. */
  12638. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12639. }
  12640. }
  12641. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  12642. /**
  12643. * Enum defining the type of properties that can be edited in the property pages in the NME
  12644. */
  12645. export enum PropertyTypeForEdition {
  12646. /** property is a boolean */
  12647. Boolean = 0,
  12648. /** property is a float */
  12649. Float = 1,
  12650. /** property is a Vector2 */
  12651. Vector2 = 2,
  12652. /** property is a list of values */
  12653. List = 3
  12654. }
  12655. /**
  12656. * Interface that defines an option in a variable of type list
  12657. */
  12658. export interface IEditablePropertyListOption {
  12659. /** label of the option */
  12660. "label": string;
  12661. /** value of the option */
  12662. "value": number;
  12663. }
  12664. /**
  12665. * Interface that defines the options available for an editable property
  12666. */
  12667. export interface IEditablePropertyOption {
  12668. /** min value */
  12669. "min"?: number;
  12670. /** max value */
  12671. "max"?: number;
  12672. /** notifiers: indicates which actions to take when the property is changed */
  12673. "notifiers"?: {
  12674. /** the material should be rebuilt */
  12675. "rebuild"?: boolean;
  12676. /** the preview should be updated */
  12677. "update"?: boolean;
  12678. };
  12679. /** list of the options for a variable of type list */
  12680. "options"?: IEditablePropertyListOption[];
  12681. }
  12682. /**
  12683. * Interface that describes an editable property
  12684. */
  12685. export interface IPropertyDescriptionForEdition {
  12686. /** name of the property */
  12687. "propertyName": string;
  12688. /** display name of the property */
  12689. "displayName": string;
  12690. /** type of the property */
  12691. "type": PropertyTypeForEdition;
  12692. /** group of the property - all properties with the same group value will be displayed in a specific section */
  12693. "groupName": string;
  12694. /** options for the property */
  12695. "options": IEditablePropertyOption;
  12696. }
  12697. /**
  12698. * Decorator that flags a property in a node material block as being editable
  12699. */
  12700. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  12701. }
  12702. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  12703. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12704. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12705. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12707. import { Nullable } from "babylonjs/types";
  12708. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12709. import { Mesh } from "babylonjs/Meshes/mesh";
  12710. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12711. import { Effect } from "babylonjs/Materials/effect";
  12712. import { Scene } from "babylonjs/scene";
  12713. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12714. /**
  12715. * Block used to implement the refraction part of the sub surface module of the PBR material
  12716. */
  12717. export class RefractionBlock extends NodeMaterialBlock {
  12718. /** @hidden */
  12719. _define3DName: string;
  12720. /** @hidden */
  12721. _refractionMatrixName: string;
  12722. /** @hidden */
  12723. _defineLODRefractionAlpha: string;
  12724. /** @hidden */
  12725. _defineLinearSpecularRefraction: string;
  12726. /** @hidden */
  12727. _defineOppositeZ: string;
  12728. /** @hidden */
  12729. _cubeSamplerName: string;
  12730. /** @hidden */
  12731. _2DSamplerName: string;
  12732. /** @hidden */
  12733. _vRefractionMicrosurfaceInfosName: string;
  12734. /** @hidden */
  12735. _vRefractionInfosName: string;
  12736. private _scene;
  12737. /**
  12738. * The properties below are set by the main PBR block prior to calling methods of this class.
  12739. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  12740. * It's less burden on the user side in the editor part.
  12741. */
  12742. /** @hidden */
  12743. viewConnectionPoint: NodeMaterialConnectionPoint;
  12744. /** @hidden */
  12745. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  12746. /**
  12747. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  12748. * Materials half opaque for instance using refraction could benefit from this control.
  12749. */
  12750. linkRefractionWithTransparency: boolean;
  12751. /**
  12752. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  12753. */
  12754. invertRefractionY: boolean;
  12755. /**
  12756. * Gets or sets the texture associated with the node
  12757. */
  12758. texture: Nullable<BaseTexture>;
  12759. /**
  12760. * Create a new RefractionBlock
  12761. * @param name defines the block name
  12762. */
  12763. constructor(name: string);
  12764. /**
  12765. * Gets the current class name
  12766. * @returns the class name
  12767. */
  12768. getClassName(): string;
  12769. /**
  12770. * Gets the intensity input component
  12771. */
  12772. get intensity(): NodeMaterialConnectionPoint;
  12773. /**
  12774. * Gets the tint at distance input component
  12775. */
  12776. get tintAtDistance(): NodeMaterialConnectionPoint;
  12777. /**
  12778. * Gets the view input component
  12779. */
  12780. get view(): NodeMaterialConnectionPoint;
  12781. /**
  12782. * Gets the refraction object output component
  12783. */
  12784. get refraction(): NodeMaterialConnectionPoint;
  12785. /**
  12786. * Returns true if the block has a texture
  12787. */
  12788. get hasTexture(): boolean;
  12789. protected _getTexture(): Nullable<BaseTexture>;
  12790. autoConfigure(material: NodeMaterial): void;
  12791. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12792. isReady(): boolean;
  12793. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  12794. /**
  12795. * Gets the main code of the block (fragment side)
  12796. * @param state current state of the node material building
  12797. * @returns the shader code
  12798. */
  12799. getCode(state: NodeMaterialBuildState): string;
  12800. protected _buildBlock(state: NodeMaterialBuildState): this;
  12801. protected _dumpPropertiesCode(): string;
  12802. serialize(): any;
  12803. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12804. }
  12805. }
  12806. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  12807. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12808. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12809. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12810. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12812. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12813. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12814. import { Nullable } from "babylonjs/types";
  12815. import { Scene } from "babylonjs/scene";
  12816. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12817. /**
  12818. * Base block used as input for post process
  12819. */
  12820. export class CurrentScreenBlock extends NodeMaterialBlock {
  12821. private _samplerName;
  12822. private _linearDefineName;
  12823. private _gammaDefineName;
  12824. private _mainUVName;
  12825. private _tempTextureRead;
  12826. /**
  12827. * Gets or sets the texture associated with the node
  12828. */
  12829. texture: Nullable<BaseTexture>;
  12830. /**
  12831. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12832. */
  12833. convertToGammaSpace: boolean;
  12834. /**
  12835. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12836. */
  12837. convertToLinearSpace: boolean;
  12838. /**
  12839. * Create a new CurrentScreenBlock
  12840. * @param name defines the block name
  12841. */
  12842. constructor(name: string);
  12843. /**
  12844. * Gets the current class name
  12845. * @returns the class name
  12846. */
  12847. getClassName(): string;
  12848. /**
  12849. * Gets the uv input component
  12850. */
  12851. get uv(): NodeMaterialConnectionPoint;
  12852. /**
  12853. * Gets the rgba output component
  12854. */
  12855. get rgba(): NodeMaterialConnectionPoint;
  12856. /**
  12857. * Gets the rgb output component
  12858. */
  12859. get rgb(): NodeMaterialConnectionPoint;
  12860. /**
  12861. * Gets the r output component
  12862. */
  12863. get r(): NodeMaterialConnectionPoint;
  12864. /**
  12865. * Gets the g output component
  12866. */
  12867. get g(): NodeMaterialConnectionPoint;
  12868. /**
  12869. * Gets the b output component
  12870. */
  12871. get b(): NodeMaterialConnectionPoint;
  12872. /**
  12873. * Gets the a output component
  12874. */
  12875. get a(): NodeMaterialConnectionPoint;
  12876. /**
  12877. * Initialize the block and prepare the context for build
  12878. * @param state defines the state that will be used for the build
  12879. */
  12880. initialize(state: NodeMaterialBuildState): void;
  12881. get target(): NodeMaterialBlockTargets;
  12882. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12883. isReady(): boolean;
  12884. private _injectVertexCode;
  12885. private _writeTextureRead;
  12886. private _writeOutput;
  12887. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12888. serialize(): any;
  12889. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12890. }
  12891. }
  12892. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  12893. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12894. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12895. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12897. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12898. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12899. import { Nullable } from "babylonjs/types";
  12900. import { Scene } from "babylonjs/scene";
  12901. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12902. /**
  12903. * Base block used for the particle texture
  12904. */
  12905. export class ParticleTextureBlock extends NodeMaterialBlock {
  12906. private _samplerName;
  12907. private _linearDefineName;
  12908. private _gammaDefineName;
  12909. private _tempTextureRead;
  12910. /**
  12911. * Gets or sets the texture associated with the node
  12912. */
  12913. texture: Nullable<BaseTexture>;
  12914. /**
  12915. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12916. */
  12917. convertToGammaSpace: boolean;
  12918. /**
  12919. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12920. */
  12921. convertToLinearSpace: boolean;
  12922. /**
  12923. * Create a new ParticleTextureBlock
  12924. * @param name defines the block name
  12925. */
  12926. constructor(name: string);
  12927. /**
  12928. * Gets the current class name
  12929. * @returns the class name
  12930. */
  12931. getClassName(): string;
  12932. /**
  12933. * Gets the uv input component
  12934. */
  12935. get uv(): NodeMaterialConnectionPoint;
  12936. /**
  12937. * Gets the rgba output component
  12938. */
  12939. get rgba(): NodeMaterialConnectionPoint;
  12940. /**
  12941. * Gets the rgb output component
  12942. */
  12943. get rgb(): NodeMaterialConnectionPoint;
  12944. /**
  12945. * Gets the r output component
  12946. */
  12947. get r(): NodeMaterialConnectionPoint;
  12948. /**
  12949. * Gets the g output component
  12950. */
  12951. get g(): NodeMaterialConnectionPoint;
  12952. /**
  12953. * Gets the b output component
  12954. */
  12955. get b(): NodeMaterialConnectionPoint;
  12956. /**
  12957. * Gets the a output component
  12958. */
  12959. get a(): NodeMaterialConnectionPoint;
  12960. /**
  12961. * Initialize the block and prepare the context for build
  12962. * @param state defines the state that will be used for the build
  12963. */
  12964. initialize(state: NodeMaterialBuildState): void;
  12965. autoConfigure(material: NodeMaterial): void;
  12966. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12967. isReady(): boolean;
  12968. private _writeOutput;
  12969. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12970. serialize(): any;
  12971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12972. }
  12973. }
  12974. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  12975. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12977. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  12978. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  12979. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  12980. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  12981. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  12982. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  12983. import { Scene } from "babylonjs/scene";
  12984. /**
  12985. * Class used to store shared data between 2 NodeMaterialBuildState
  12986. */
  12987. export class NodeMaterialBuildStateSharedData {
  12988. /**
  12989. * Gets the list of emitted varyings
  12990. */
  12991. temps: string[];
  12992. /**
  12993. * Gets the list of emitted varyings
  12994. */
  12995. varyings: string[];
  12996. /**
  12997. * Gets the varying declaration string
  12998. */
  12999. varyingDeclaration: string;
  13000. /**
  13001. * Input blocks
  13002. */
  13003. inputBlocks: InputBlock[];
  13004. /**
  13005. * Input blocks
  13006. */
  13007. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13008. /**
  13009. * Bindable blocks (Blocks that need to set data to the effect)
  13010. */
  13011. bindableBlocks: NodeMaterialBlock[];
  13012. /**
  13013. * List of blocks that can provide a compilation fallback
  13014. */
  13015. blocksWithFallbacks: NodeMaterialBlock[];
  13016. /**
  13017. * List of blocks that can provide a define update
  13018. */
  13019. blocksWithDefines: NodeMaterialBlock[];
  13020. /**
  13021. * List of blocks that can provide a repeatable content
  13022. */
  13023. repeatableContentBlocks: NodeMaterialBlock[];
  13024. /**
  13025. * List of blocks that can provide a dynamic list of uniforms
  13026. */
  13027. dynamicUniformBlocks: NodeMaterialBlock[];
  13028. /**
  13029. * List of blocks that can block the isReady function for the material
  13030. */
  13031. blockingBlocks: NodeMaterialBlock[];
  13032. /**
  13033. * Gets the list of animated inputs
  13034. */
  13035. animatedInputs: InputBlock[];
  13036. /**
  13037. * Build Id used to avoid multiple recompilations
  13038. */
  13039. buildId: number;
  13040. /** List of emitted variables */
  13041. variableNames: {
  13042. [key: string]: number;
  13043. };
  13044. /** List of emitted defines */
  13045. defineNames: {
  13046. [key: string]: number;
  13047. };
  13048. /** Should emit comments? */
  13049. emitComments: boolean;
  13050. /** Emit build activity */
  13051. verbose: boolean;
  13052. /** Gets or sets the hosting scene */
  13053. scene: Scene;
  13054. /**
  13055. * Gets the compilation hints emitted at compilation time
  13056. */
  13057. hints: {
  13058. needWorldViewMatrix: boolean;
  13059. needWorldViewProjectionMatrix: boolean;
  13060. needAlphaBlending: boolean;
  13061. needAlphaTesting: boolean;
  13062. };
  13063. /**
  13064. * List of compilation checks
  13065. */
  13066. checks: {
  13067. emitVertex: boolean;
  13068. emitFragment: boolean;
  13069. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13070. };
  13071. /**
  13072. * Is vertex program allowed to be empty?
  13073. */
  13074. allowEmptyVertexProgram: boolean;
  13075. /** Creates a new shared data */
  13076. constructor();
  13077. /**
  13078. * Emits console errors and exceptions if there is a failing check
  13079. */
  13080. emitErrors(): void;
  13081. }
  13082. }
  13083. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  13084. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13085. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13086. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  13087. /**
  13088. * Class used to store node based material build state
  13089. */
  13090. export class NodeMaterialBuildState {
  13091. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13092. supportUniformBuffers: boolean;
  13093. /**
  13094. * Gets the list of emitted attributes
  13095. */
  13096. attributes: string[];
  13097. /**
  13098. * Gets the list of emitted uniforms
  13099. */
  13100. uniforms: string[];
  13101. /**
  13102. * Gets the list of emitted constants
  13103. */
  13104. constants: string[];
  13105. /**
  13106. * Gets the list of emitted samplers
  13107. */
  13108. samplers: string[];
  13109. /**
  13110. * Gets the list of emitted functions
  13111. */
  13112. functions: {
  13113. [key: string]: string;
  13114. };
  13115. /**
  13116. * Gets the list of emitted extensions
  13117. */
  13118. extensions: {
  13119. [key: string]: string;
  13120. };
  13121. /**
  13122. * Gets the target of the compilation state
  13123. */
  13124. target: NodeMaterialBlockTargets;
  13125. /**
  13126. * Gets the list of emitted counters
  13127. */
  13128. counters: {
  13129. [key: string]: number;
  13130. };
  13131. /**
  13132. * Shared data between multiple NodeMaterialBuildState instances
  13133. */
  13134. sharedData: NodeMaterialBuildStateSharedData;
  13135. /** @hidden */
  13136. _vertexState: NodeMaterialBuildState;
  13137. /** @hidden */
  13138. _attributeDeclaration: string;
  13139. /** @hidden */
  13140. _uniformDeclaration: string;
  13141. /** @hidden */
  13142. _constantDeclaration: string;
  13143. /** @hidden */
  13144. _samplerDeclaration: string;
  13145. /** @hidden */
  13146. _varyingTransfer: string;
  13147. /** @hidden */
  13148. _injectAtEnd: string;
  13149. private _repeatableContentAnchorIndex;
  13150. /** @hidden */
  13151. _builtCompilationString: string;
  13152. /**
  13153. * Gets the emitted compilation strings
  13154. */
  13155. compilationString: string;
  13156. /**
  13157. * Finalize the compilation strings
  13158. * @param state defines the current compilation state
  13159. */
  13160. finalize(state: NodeMaterialBuildState): void;
  13161. /** @hidden */
  13162. get _repeatableContentAnchor(): string;
  13163. /** @hidden */
  13164. _getFreeVariableName(prefix: string): string;
  13165. /** @hidden */
  13166. _getFreeDefineName(prefix: string): string;
  13167. /** @hidden */
  13168. _excludeVariableName(name: string): void;
  13169. /** @hidden */
  13170. _emit2DSampler(name: string): void;
  13171. /** @hidden */
  13172. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13173. /** @hidden */
  13174. _emitExtension(name: string, extension: string, define?: string): void;
  13175. /** @hidden */
  13176. _emitFunction(name: string, code: string, comments: string): void;
  13177. /** @hidden */
  13178. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13179. replaceStrings?: {
  13180. search: RegExp;
  13181. replace: string;
  13182. }[];
  13183. repeatKey?: string;
  13184. }): string;
  13185. /** @hidden */
  13186. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13187. repeatKey?: string;
  13188. removeAttributes?: boolean;
  13189. removeUniforms?: boolean;
  13190. removeVaryings?: boolean;
  13191. removeIfDef?: boolean;
  13192. replaceStrings?: {
  13193. search: RegExp;
  13194. replace: string;
  13195. }[];
  13196. }, storeKey?: string): void;
  13197. /** @hidden */
  13198. _registerTempVariable(name: string): boolean;
  13199. /** @hidden */
  13200. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13201. /** @hidden */
  13202. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13203. /** @hidden */
  13204. _emitFloat(value: number): string;
  13205. }
  13206. }
  13207. declare module "babylonjs/Misc/uniqueIdGenerator" {
  13208. /**
  13209. * Helper class used to generate session unique ID
  13210. */
  13211. export class UniqueIdGenerator {
  13212. private static _UniqueIdCounter;
  13213. /**
  13214. * Gets an unique (relatively to the current scene) Id
  13215. */
  13216. static get UniqueId(): number;
  13217. }
  13218. }
  13219. declare module "babylonjs/Materials/effectFallbacks" {
  13220. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  13221. import { Effect } from "babylonjs/Materials/effect";
  13222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13223. /**
  13224. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13225. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13226. */
  13227. export class EffectFallbacks implements IEffectFallbacks {
  13228. private _defines;
  13229. private _currentRank;
  13230. private _maxRank;
  13231. private _mesh;
  13232. /**
  13233. * Removes the fallback from the bound mesh.
  13234. */
  13235. unBindMesh(): void;
  13236. /**
  13237. * Adds a fallback on the specified property.
  13238. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13239. * @param define The name of the define in the shader
  13240. */
  13241. addFallback(rank: number, define: string): void;
  13242. /**
  13243. * Sets the mesh to use CPU skinning when needing to fallback.
  13244. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13245. * @param mesh The mesh to use the fallbacks.
  13246. */
  13247. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13248. /**
  13249. * Checks to see if more fallbacks are still availible.
  13250. */
  13251. get hasMoreFallbacks(): boolean;
  13252. /**
  13253. * Removes the defines that should be removed when falling back.
  13254. * @param currentDefines defines the current define statements for the shader.
  13255. * @param effect defines the current effect we try to compile
  13256. * @returns The resulting defines with defines of the current rank removed.
  13257. */
  13258. reduce(currentDefines: string, effect: Effect): string;
  13259. }
  13260. }
  13261. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  13262. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13263. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13264. import { Nullable } from "babylonjs/types";
  13265. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13266. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13267. import { Effect } from "babylonjs/Materials/effect";
  13268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13269. import { Mesh } from "babylonjs/Meshes/mesh";
  13270. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13271. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13272. import { Scene } from "babylonjs/scene";
  13273. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  13274. /**
  13275. * Defines a block that can be used inside a node based material
  13276. */
  13277. export class NodeMaterialBlock {
  13278. private _buildId;
  13279. private _buildTarget;
  13280. private _target;
  13281. private _isFinalMerger;
  13282. private _isInput;
  13283. private _name;
  13284. protected _isUnique: boolean;
  13285. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13286. inputsAreExclusive: boolean;
  13287. /** @hidden */
  13288. _codeVariableName: string;
  13289. /** @hidden */
  13290. _inputs: NodeMaterialConnectionPoint[];
  13291. /** @hidden */
  13292. _outputs: NodeMaterialConnectionPoint[];
  13293. /** @hidden */
  13294. _preparationId: number;
  13295. /**
  13296. * Gets the name of the block
  13297. */
  13298. get name(): string;
  13299. /**
  13300. * Sets the name of the block. Will check if the name is valid.
  13301. */
  13302. set name(newName: string);
  13303. /**
  13304. * Gets or sets the unique id of the node
  13305. */
  13306. uniqueId: number;
  13307. /**
  13308. * Gets or sets the comments associated with this block
  13309. */
  13310. comments: string;
  13311. /**
  13312. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13313. */
  13314. get isUnique(): boolean;
  13315. /**
  13316. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13317. */
  13318. get isFinalMerger(): boolean;
  13319. /**
  13320. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13321. */
  13322. get isInput(): boolean;
  13323. /**
  13324. * Gets or sets the build Id
  13325. */
  13326. get buildId(): number;
  13327. set buildId(value: number);
  13328. /**
  13329. * Gets or sets the target of the block
  13330. */
  13331. get target(): NodeMaterialBlockTargets;
  13332. set target(value: NodeMaterialBlockTargets);
  13333. /**
  13334. * Gets the list of input points
  13335. */
  13336. get inputs(): NodeMaterialConnectionPoint[];
  13337. /** Gets the list of output points */
  13338. get outputs(): NodeMaterialConnectionPoint[];
  13339. /**
  13340. * Find an input by its name
  13341. * @param name defines the name of the input to look for
  13342. * @returns the input or null if not found
  13343. */
  13344. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13345. /**
  13346. * Find an output by its name
  13347. * @param name defines the name of the outputto look for
  13348. * @returns the output or null if not found
  13349. */
  13350. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13351. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13352. visibleInInspector: boolean;
  13353. /**
  13354. * Creates a new NodeMaterialBlock
  13355. * @param name defines the block name
  13356. * @param target defines the target of that block (Vertex by default)
  13357. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13358. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13359. */
  13360. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13361. /**
  13362. * Initialize the block and prepare the context for build
  13363. * @param state defines the state that will be used for the build
  13364. */
  13365. initialize(state: NodeMaterialBuildState): void;
  13366. /**
  13367. * Bind data to effect. Will only be called for blocks with isBindable === true
  13368. * @param effect defines the effect to bind data to
  13369. * @param nodeMaterial defines the hosting NodeMaterial
  13370. * @param mesh defines the mesh that will be rendered
  13371. * @param subMesh defines the submesh that will be rendered
  13372. */
  13373. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13374. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13375. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13376. protected _writeFloat(value: number): string;
  13377. /**
  13378. * Gets the current class name e.g. "NodeMaterialBlock"
  13379. * @returns the class name
  13380. */
  13381. getClassName(): string;
  13382. /**
  13383. * Register a new input. Must be called inside a block constructor
  13384. * @param name defines the connection point name
  13385. * @param type defines the connection point type
  13386. * @param isOptional defines a boolean indicating that this input can be omitted
  13387. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13388. * @param point an already created connection point. If not provided, create a new one
  13389. * @returns the current block
  13390. */
  13391. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13392. /**
  13393. * Register a new output. Must be called inside a block constructor
  13394. * @param name defines the connection point name
  13395. * @param type defines the connection point type
  13396. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13397. * @param point an already created connection point. If not provided, create a new one
  13398. * @returns the current block
  13399. */
  13400. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13401. /**
  13402. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13403. * @param forOutput defines an optional connection point to check compatibility with
  13404. * @returns the first available input or null
  13405. */
  13406. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13407. /**
  13408. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13409. * @param forBlock defines an optional block to check compatibility with
  13410. * @returns the first available input or null
  13411. */
  13412. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13413. /**
  13414. * Gets the sibling of the given output
  13415. * @param current defines the current output
  13416. * @returns the next output in the list or null
  13417. */
  13418. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13419. /**
  13420. * Connect current block with another block
  13421. * @param other defines the block to connect with
  13422. * @param options define the various options to help pick the right connections
  13423. * @returns the current block
  13424. */
  13425. connectTo(other: NodeMaterialBlock, options?: {
  13426. input?: string;
  13427. output?: string;
  13428. outputSwizzle?: string;
  13429. }): this | undefined;
  13430. protected _buildBlock(state: NodeMaterialBuildState): void;
  13431. /**
  13432. * Add uniforms, samplers and uniform buffers at compilation time
  13433. * @param state defines the state to update
  13434. * @param nodeMaterial defines the node material requesting the update
  13435. * @param defines defines the material defines to update
  13436. * @param uniformBuffers defines the list of uniform buffer names
  13437. */
  13438. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13439. /**
  13440. * Add potential fallbacks if shader compilation fails
  13441. * @param mesh defines the mesh to be rendered
  13442. * @param fallbacks defines the current prioritized list of fallbacks
  13443. */
  13444. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13445. /**
  13446. * Initialize defines for shader compilation
  13447. * @param mesh defines the mesh to be rendered
  13448. * @param nodeMaterial defines the node material requesting the update
  13449. * @param defines defines the material defines to update
  13450. * @param useInstances specifies that instances should be used
  13451. */
  13452. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13453. /**
  13454. * Update defines for shader compilation
  13455. * @param mesh defines the mesh to be rendered
  13456. * @param nodeMaterial defines the node material requesting the update
  13457. * @param defines defines the material defines to update
  13458. * @param useInstances specifies that instances should be used
  13459. * @param subMesh defines which submesh to render
  13460. */
  13461. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13462. /**
  13463. * Lets the block try to connect some inputs automatically
  13464. * @param material defines the hosting NodeMaterial
  13465. */
  13466. autoConfigure(material: NodeMaterial): void;
  13467. /**
  13468. * Function called when a block is declared as repeatable content generator
  13469. * @param vertexShaderState defines the current compilation state for the vertex shader
  13470. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13471. * @param mesh defines the mesh to be rendered
  13472. * @param defines defines the material defines to update
  13473. */
  13474. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13475. /**
  13476. * Checks if the block is ready
  13477. * @param mesh defines the mesh to be rendered
  13478. * @param nodeMaterial defines the node material requesting the update
  13479. * @param defines defines the material defines to update
  13480. * @param useInstances specifies that instances should be used
  13481. * @returns true if the block is ready
  13482. */
  13483. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13484. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13485. private _processBuild;
  13486. /**
  13487. * Validates the new name for the block node.
  13488. * @param newName the new name to be given to the node.
  13489. * @returns false if the name is a reserve word, else true.
  13490. */
  13491. validateBlockName(newName: string): boolean;
  13492. /**
  13493. * Compile the current node and generate the shader code
  13494. * @param state defines the current compilation state (uniforms, samplers, current string)
  13495. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13496. * @returns true if already built
  13497. */
  13498. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13499. protected _inputRename(name: string): string;
  13500. protected _outputRename(name: string): string;
  13501. protected _dumpPropertiesCode(): string;
  13502. /** @hidden */
  13503. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13504. /** @hidden */
  13505. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13506. /**
  13507. * Clone the current block to a new identical block
  13508. * @param scene defines the hosting scene
  13509. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13510. * @returns a copy of the current block
  13511. */
  13512. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13513. /**
  13514. * Serializes this block in a JSON representation
  13515. * @returns the serialized block object
  13516. */
  13517. serialize(): any;
  13518. /** @hidden */
  13519. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13520. private _deserializePortDisplayNamesAndExposedOnFrame;
  13521. /**
  13522. * Release resources
  13523. */
  13524. dispose(): void;
  13525. }
  13526. }
  13527. declare module "babylonjs/Materials/pushMaterial" {
  13528. import { Nullable } from "babylonjs/types";
  13529. import { Scene } from "babylonjs/scene";
  13530. import { Matrix } from "babylonjs/Maths/math.vector";
  13531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13532. import { Mesh } from "babylonjs/Meshes/mesh";
  13533. import { Material } from "babylonjs/Materials/material";
  13534. import { Effect } from "babylonjs/Materials/effect";
  13535. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13536. /**
  13537. * Base class of materials working in push mode in babylon JS
  13538. * @hidden
  13539. */
  13540. export class PushMaterial extends Material {
  13541. protected _activeEffect: Effect;
  13542. protected _normalMatrix: Matrix;
  13543. constructor(name: string, scene: Scene);
  13544. getEffect(): Effect;
  13545. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13546. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13547. /**
  13548. * Binds the given world matrix to the active effect
  13549. *
  13550. * @param world the matrix to bind
  13551. */
  13552. bindOnlyWorldMatrix(world: Matrix): void;
  13553. /**
  13554. * Binds the given normal matrix to the active effect
  13555. *
  13556. * @param normalMatrix the matrix to bind
  13557. */
  13558. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13559. bind(world: Matrix, mesh?: Mesh): void;
  13560. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13561. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13562. }
  13563. }
  13564. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  13565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13566. /**
  13567. * Root class for all node material optimizers
  13568. */
  13569. export class NodeMaterialOptimizer {
  13570. /**
  13571. * Function used to optimize a NodeMaterial graph
  13572. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13573. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13574. */
  13575. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13576. }
  13577. }
  13578. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  13579. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13580. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13582. import { Scene } from "babylonjs/scene";
  13583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13584. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13585. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13586. /**
  13587. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13588. */
  13589. export class TransformBlock extends NodeMaterialBlock {
  13590. /**
  13591. * Defines the value to use to complement W value to transform it to a Vector4
  13592. */
  13593. complementW: number;
  13594. /**
  13595. * Defines the value to use to complement z value to transform it to a Vector4
  13596. */
  13597. complementZ: number;
  13598. /**
  13599. * Creates a new TransformBlock
  13600. * @param name defines the block name
  13601. */
  13602. constructor(name: string);
  13603. /**
  13604. * Gets the current class name
  13605. * @returns the class name
  13606. */
  13607. getClassName(): string;
  13608. /**
  13609. * Gets the vector input
  13610. */
  13611. get vector(): NodeMaterialConnectionPoint;
  13612. /**
  13613. * Gets the output component
  13614. */
  13615. get output(): NodeMaterialConnectionPoint;
  13616. /**
  13617. * Gets the xyz output component
  13618. */
  13619. get xyz(): NodeMaterialConnectionPoint;
  13620. /**
  13621. * Gets the matrix transform input
  13622. */
  13623. get transform(): NodeMaterialConnectionPoint;
  13624. protected _buildBlock(state: NodeMaterialBuildState): this;
  13625. /**
  13626. * Update defines for shader compilation
  13627. * @param mesh defines the mesh to be rendered
  13628. * @param nodeMaterial defines the node material requesting the update
  13629. * @param defines defines the material defines to update
  13630. * @param useInstances specifies that instances should be used
  13631. * @param subMesh defines which submesh to render
  13632. */
  13633. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13634. serialize(): any;
  13635. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13636. protected _dumpPropertiesCode(): string;
  13637. }
  13638. }
  13639. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  13640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13641. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13642. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13643. /**
  13644. * Block used to output the vertex position
  13645. */
  13646. export class VertexOutputBlock extends NodeMaterialBlock {
  13647. /**
  13648. * Creates a new VertexOutputBlock
  13649. * @param name defines the block name
  13650. */
  13651. constructor(name: string);
  13652. /**
  13653. * Gets the current class name
  13654. * @returns the class name
  13655. */
  13656. getClassName(): string;
  13657. /**
  13658. * Gets the vector input component
  13659. */
  13660. get vector(): NodeMaterialConnectionPoint;
  13661. protected _buildBlock(state: NodeMaterialBuildState): this;
  13662. }
  13663. }
  13664. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  13665. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13666. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13667. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13668. /**
  13669. * Block used to output the final color
  13670. */
  13671. export class FragmentOutputBlock extends NodeMaterialBlock {
  13672. /**
  13673. * Create a new FragmentOutputBlock
  13674. * @param name defines the block name
  13675. */
  13676. constructor(name: string);
  13677. /**
  13678. * Gets the current class name
  13679. * @returns the class name
  13680. */
  13681. getClassName(): string;
  13682. /**
  13683. * Gets the rgba input component
  13684. */
  13685. get rgba(): NodeMaterialConnectionPoint;
  13686. /**
  13687. * Gets the rgb input component
  13688. */
  13689. get rgb(): NodeMaterialConnectionPoint;
  13690. /**
  13691. * Gets the a input component
  13692. */
  13693. get a(): NodeMaterialConnectionPoint;
  13694. protected _buildBlock(state: NodeMaterialBuildState): this;
  13695. }
  13696. }
  13697. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  13698. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13699. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13700. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13701. /**
  13702. * Block used for the particle ramp gradient section
  13703. */
  13704. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13705. /**
  13706. * Create a new ParticleRampGradientBlock
  13707. * @param name defines the block name
  13708. */
  13709. constructor(name: string);
  13710. /**
  13711. * Gets the current class name
  13712. * @returns the class name
  13713. */
  13714. getClassName(): string;
  13715. /**
  13716. * Gets the color input component
  13717. */
  13718. get color(): NodeMaterialConnectionPoint;
  13719. /**
  13720. * Gets the rampColor output component
  13721. */
  13722. get rampColor(): NodeMaterialConnectionPoint;
  13723. /**
  13724. * Initialize the block and prepare the context for build
  13725. * @param state defines the state that will be used for the build
  13726. */
  13727. initialize(state: NodeMaterialBuildState): void;
  13728. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13729. }
  13730. }
  13731. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  13732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13733. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13735. /**
  13736. * Block used for the particle blend multiply section
  13737. */
  13738. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13739. /**
  13740. * Create a new ParticleBlendMultiplyBlock
  13741. * @param name defines the block name
  13742. */
  13743. constructor(name: string);
  13744. /**
  13745. * Gets the current class name
  13746. * @returns the class name
  13747. */
  13748. getClassName(): string;
  13749. /**
  13750. * Gets the color input component
  13751. */
  13752. get color(): NodeMaterialConnectionPoint;
  13753. /**
  13754. * Gets the alphaTexture input component
  13755. */
  13756. get alphaTexture(): NodeMaterialConnectionPoint;
  13757. /**
  13758. * Gets the alphaColor input component
  13759. */
  13760. get alphaColor(): NodeMaterialConnectionPoint;
  13761. /**
  13762. * Gets the blendColor output component
  13763. */
  13764. get blendColor(): NodeMaterialConnectionPoint;
  13765. /**
  13766. * Initialize the block and prepare the context for build
  13767. * @param state defines the state that will be used for the build
  13768. */
  13769. initialize(state: NodeMaterialBuildState): void;
  13770. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13771. }
  13772. }
  13773. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  13774. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13775. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13776. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13777. /**
  13778. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  13779. */
  13780. export class VectorMergerBlock extends NodeMaterialBlock {
  13781. /**
  13782. * Create a new VectorMergerBlock
  13783. * @param name defines the block name
  13784. */
  13785. constructor(name: string);
  13786. /**
  13787. * Gets the current class name
  13788. * @returns the class name
  13789. */
  13790. getClassName(): string;
  13791. /**
  13792. * Gets the xyz component (input)
  13793. */
  13794. get xyzIn(): NodeMaterialConnectionPoint;
  13795. /**
  13796. * Gets the xy component (input)
  13797. */
  13798. get xyIn(): NodeMaterialConnectionPoint;
  13799. /**
  13800. * Gets the x component (input)
  13801. */
  13802. get x(): NodeMaterialConnectionPoint;
  13803. /**
  13804. * Gets the y component (input)
  13805. */
  13806. get y(): NodeMaterialConnectionPoint;
  13807. /**
  13808. * Gets the z component (input)
  13809. */
  13810. get z(): NodeMaterialConnectionPoint;
  13811. /**
  13812. * Gets the w component (input)
  13813. */
  13814. get w(): NodeMaterialConnectionPoint;
  13815. /**
  13816. * Gets the xyzw component (output)
  13817. */
  13818. get xyzw(): NodeMaterialConnectionPoint;
  13819. /**
  13820. * Gets the xyz component (output)
  13821. */
  13822. get xyzOut(): NodeMaterialConnectionPoint;
  13823. /**
  13824. * Gets the xy component (output)
  13825. */
  13826. get xyOut(): NodeMaterialConnectionPoint;
  13827. /**
  13828. * Gets the xy component (output)
  13829. * @deprecated Please use xyOut instead.
  13830. */
  13831. get xy(): NodeMaterialConnectionPoint;
  13832. /**
  13833. * Gets the xyz component (output)
  13834. * @deprecated Please use xyzOut instead.
  13835. */
  13836. get xyz(): NodeMaterialConnectionPoint;
  13837. protected _buildBlock(state: NodeMaterialBuildState): this;
  13838. }
  13839. }
  13840. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  13841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13844. import { Vector2 } from "babylonjs/Maths/math.vector";
  13845. import { Scene } from "babylonjs/scene";
  13846. /**
  13847. * Block used to remap a float from a range to a new one
  13848. */
  13849. export class RemapBlock extends NodeMaterialBlock {
  13850. /**
  13851. * Gets or sets the source range
  13852. */
  13853. sourceRange: Vector2;
  13854. /**
  13855. * Gets or sets the target range
  13856. */
  13857. targetRange: Vector2;
  13858. /**
  13859. * Creates a new RemapBlock
  13860. * @param name defines the block name
  13861. */
  13862. constructor(name: string);
  13863. /**
  13864. * Gets the current class name
  13865. * @returns the class name
  13866. */
  13867. getClassName(): string;
  13868. /**
  13869. * Gets the input component
  13870. */
  13871. get input(): NodeMaterialConnectionPoint;
  13872. /**
  13873. * Gets the source min input component
  13874. */
  13875. get sourceMin(): NodeMaterialConnectionPoint;
  13876. /**
  13877. * Gets the source max input component
  13878. */
  13879. get sourceMax(): NodeMaterialConnectionPoint;
  13880. /**
  13881. * Gets the target min input component
  13882. */
  13883. get targetMin(): NodeMaterialConnectionPoint;
  13884. /**
  13885. * Gets the target max input component
  13886. */
  13887. get targetMax(): NodeMaterialConnectionPoint;
  13888. /**
  13889. * Gets the output component
  13890. */
  13891. get output(): NodeMaterialConnectionPoint;
  13892. protected _buildBlock(state: NodeMaterialBuildState): this;
  13893. protected _dumpPropertiesCode(): string;
  13894. serialize(): any;
  13895. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13896. }
  13897. }
  13898. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  13899. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13900. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13901. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13902. /**
  13903. * Block used to multiply 2 values
  13904. */
  13905. export class MultiplyBlock extends NodeMaterialBlock {
  13906. /**
  13907. * Creates a new MultiplyBlock
  13908. * @param name defines the block name
  13909. */
  13910. constructor(name: string);
  13911. /**
  13912. * Gets the current class name
  13913. * @returns the class name
  13914. */
  13915. getClassName(): string;
  13916. /**
  13917. * Gets the left operand input component
  13918. */
  13919. get left(): NodeMaterialConnectionPoint;
  13920. /**
  13921. * Gets the right operand input component
  13922. */
  13923. get right(): NodeMaterialConnectionPoint;
  13924. /**
  13925. * Gets the output component
  13926. */
  13927. get output(): NodeMaterialConnectionPoint;
  13928. protected _buildBlock(state: NodeMaterialBuildState): this;
  13929. }
  13930. }
  13931. declare module "babylonjs/Misc/gradients" {
  13932. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13933. /** Interface used by value gradients (color, factor, ...) */
  13934. export interface IValueGradient {
  13935. /**
  13936. * Gets or sets the gradient value (between 0 and 1)
  13937. */
  13938. gradient: number;
  13939. }
  13940. /** Class used to store color4 gradient */
  13941. export class ColorGradient implements IValueGradient {
  13942. /**
  13943. * Gets or sets the gradient value (between 0 and 1)
  13944. */
  13945. gradient: number;
  13946. /**
  13947. * Gets or sets first associated color
  13948. */
  13949. color1: Color4;
  13950. /**
  13951. * Gets or sets second associated color
  13952. */
  13953. color2?: Color4 | undefined;
  13954. /**
  13955. * Creates a new color4 gradient
  13956. * @param gradient gets or sets the gradient value (between 0 and 1)
  13957. * @param color1 gets or sets first associated color
  13958. * @param color2 gets or sets first second color
  13959. */
  13960. constructor(
  13961. /**
  13962. * Gets or sets the gradient value (between 0 and 1)
  13963. */
  13964. gradient: number,
  13965. /**
  13966. * Gets or sets first associated color
  13967. */
  13968. color1: Color4,
  13969. /**
  13970. * Gets or sets second associated color
  13971. */
  13972. color2?: Color4 | undefined);
  13973. /**
  13974. * Will get a color picked randomly between color1 and color2.
  13975. * If color2 is undefined then color1 will be used
  13976. * @param result defines the target Color4 to store the result in
  13977. */
  13978. getColorToRef(result: Color4): void;
  13979. }
  13980. /** Class used to store color 3 gradient */
  13981. export class Color3Gradient implements IValueGradient {
  13982. /**
  13983. * Gets or sets the gradient value (between 0 and 1)
  13984. */
  13985. gradient: number;
  13986. /**
  13987. * Gets or sets the associated color
  13988. */
  13989. color: Color3;
  13990. /**
  13991. * Creates a new color3 gradient
  13992. * @param gradient gets or sets the gradient value (between 0 and 1)
  13993. * @param color gets or sets associated color
  13994. */
  13995. constructor(
  13996. /**
  13997. * Gets or sets the gradient value (between 0 and 1)
  13998. */
  13999. gradient: number,
  14000. /**
  14001. * Gets or sets the associated color
  14002. */
  14003. color: Color3);
  14004. }
  14005. /** Class used to store factor gradient */
  14006. export class FactorGradient implements IValueGradient {
  14007. /**
  14008. * Gets or sets the gradient value (between 0 and 1)
  14009. */
  14010. gradient: number;
  14011. /**
  14012. * Gets or sets first associated factor
  14013. */
  14014. factor1: number;
  14015. /**
  14016. * Gets or sets second associated factor
  14017. */
  14018. factor2?: number | undefined;
  14019. /**
  14020. * Creates a new factor gradient
  14021. * @param gradient gets or sets the gradient value (between 0 and 1)
  14022. * @param factor1 gets or sets first associated factor
  14023. * @param factor2 gets or sets second associated factor
  14024. */
  14025. constructor(
  14026. /**
  14027. * Gets or sets the gradient value (between 0 and 1)
  14028. */
  14029. gradient: number,
  14030. /**
  14031. * Gets or sets first associated factor
  14032. */
  14033. factor1: number,
  14034. /**
  14035. * Gets or sets second associated factor
  14036. */
  14037. factor2?: number | undefined);
  14038. /**
  14039. * Will get a number picked randomly between factor1 and factor2.
  14040. * If factor2 is undefined then factor1 will be used
  14041. * @returns the picked number
  14042. */
  14043. getFactor(): number;
  14044. }
  14045. /**
  14046. * Helper used to simplify some generic gradient tasks
  14047. */
  14048. export class GradientHelper {
  14049. /**
  14050. * Gets the current gradient from an array of IValueGradient
  14051. * @param ratio defines the current ratio to get
  14052. * @param gradients defines the array of IValueGradient
  14053. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14054. */
  14055. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14056. }
  14057. }
  14058. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  14059. import { Nullable } from "babylonjs/types";
  14060. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14061. import { Scene } from "babylonjs/scene";
  14062. module "babylonjs/Engines/thinEngine" {
  14063. interface ThinEngine {
  14064. /**
  14065. * Creates a raw texture
  14066. * @param data defines the data to store in the texture
  14067. * @param width defines the width of the texture
  14068. * @param height defines the height of the texture
  14069. * @param format defines the format of the data
  14070. * @param generateMipMaps defines if the engine should generate the mip levels
  14071. * @param invertY defines if data must be stored with Y axis inverted
  14072. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14073. * @param compression defines the compression used (null by default)
  14074. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14075. * @returns the raw texture inside an InternalTexture
  14076. */
  14077. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14078. /**
  14079. * Update a raw texture
  14080. * @param texture defines the texture to update
  14081. * @param data defines the data to store in the texture
  14082. * @param format defines the format of the data
  14083. * @param invertY defines if data must be stored with Y axis inverted
  14084. */
  14085. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14086. /**
  14087. * Update a raw texture
  14088. * @param texture defines the texture to update
  14089. * @param data defines the data to store in the texture
  14090. * @param format defines the format of the data
  14091. * @param invertY defines if data must be stored with Y axis inverted
  14092. * @param compression defines the compression used (null by default)
  14093. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14094. */
  14095. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14096. /**
  14097. * Creates a new raw cube texture
  14098. * @param data defines the array of data to use to create each face
  14099. * @param size defines the size of the textures
  14100. * @param format defines the format of the data
  14101. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14102. * @param generateMipMaps defines if the engine should generate the mip levels
  14103. * @param invertY defines if data must be stored with Y axis inverted
  14104. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14105. * @param compression defines the compression used (null by default)
  14106. * @returns the cube texture as an InternalTexture
  14107. */
  14108. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14109. /**
  14110. * Update a raw cube texture
  14111. * @param texture defines the texture to udpdate
  14112. * @param data defines the data to store
  14113. * @param format defines the data format
  14114. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14115. * @param invertY defines if data must be stored with Y axis inverted
  14116. */
  14117. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14118. /**
  14119. * Update a raw cube texture
  14120. * @param texture defines the texture to udpdate
  14121. * @param data defines the data to store
  14122. * @param format defines the data format
  14123. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14124. * @param invertY defines if data must be stored with Y axis inverted
  14125. * @param compression defines the compression used (null by default)
  14126. */
  14127. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14128. /**
  14129. * Update a raw cube texture
  14130. * @param texture defines the texture to udpdate
  14131. * @param data defines the data to store
  14132. * @param format defines the data format
  14133. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14134. * @param invertY defines if data must be stored with Y axis inverted
  14135. * @param compression defines the compression used (null by default)
  14136. * @param level defines which level of the texture to update
  14137. */
  14138. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14139. /**
  14140. * Creates a new raw cube texture from a specified url
  14141. * @param url defines the url where the data is located
  14142. * @param scene defines the current scene
  14143. * @param size defines the size of the textures
  14144. * @param format defines the format of the data
  14145. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14146. * @param noMipmap defines if the engine should avoid generating the mip levels
  14147. * @param callback defines a callback used to extract texture data from loaded data
  14148. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14149. * @param onLoad defines a callback called when texture is loaded
  14150. * @param onError defines a callback called if there is an error
  14151. * @returns the cube texture as an InternalTexture
  14152. */
  14153. 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;
  14154. /**
  14155. * Creates a new raw cube texture from a specified url
  14156. * @param url defines the url where the data is located
  14157. * @param scene defines the current scene
  14158. * @param size defines the size of the textures
  14159. * @param format defines the format of the data
  14160. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14161. * @param noMipmap defines if the engine should avoid generating the mip levels
  14162. * @param callback defines a callback used to extract texture data from loaded data
  14163. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14164. * @param onLoad defines a callback called when texture is loaded
  14165. * @param onError defines a callback called if there is an error
  14166. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14167. * @param invertY defines if data must be stored with Y axis inverted
  14168. * @returns the cube texture as an InternalTexture
  14169. */
  14170. 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;
  14171. /**
  14172. * Creates a new raw 3D texture
  14173. * @param data defines the data used to create the texture
  14174. * @param width defines the width of the texture
  14175. * @param height defines the height of the texture
  14176. * @param depth defines the depth of the texture
  14177. * @param format defines the format of the texture
  14178. * @param generateMipMaps defines if the engine must generate mip levels
  14179. * @param invertY defines if data must be stored with Y axis inverted
  14180. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14181. * @param compression defines the compressed used (can be null)
  14182. * @param textureType defines the compressed used (can be null)
  14183. * @returns a new raw 3D texture (stored in an InternalTexture)
  14184. */
  14185. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14186. /**
  14187. * Update a raw 3D texture
  14188. * @param texture defines the texture to update
  14189. * @param data defines the data to store
  14190. * @param format defines the data format
  14191. * @param invertY defines if data must be stored with Y axis inverted
  14192. */
  14193. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14194. /**
  14195. * Update a raw 3D texture
  14196. * @param texture defines the texture to update
  14197. * @param data defines the data to store
  14198. * @param format defines the data format
  14199. * @param invertY defines if data must be stored with Y axis inverted
  14200. * @param compression defines the used compression (can be null)
  14201. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14202. */
  14203. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14204. /**
  14205. * Creates a new raw 2D array texture
  14206. * @param data defines the data used to create the texture
  14207. * @param width defines the width of the texture
  14208. * @param height defines the height of the texture
  14209. * @param depth defines the number of layers of the texture
  14210. * @param format defines the format of the texture
  14211. * @param generateMipMaps defines if the engine must generate mip levels
  14212. * @param invertY defines if data must be stored with Y axis inverted
  14213. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14214. * @param compression defines the compressed used (can be null)
  14215. * @param textureType defines the compressed used (can be null)
  14216. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14217. */
  14218. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14219. /**
  14220. * Update a raw 2D array texture
  14221. * @param texture defines the texture to update
  14222. * @param data defines the data to store
  14223. * @param format defines the data format
  14224. * @param invertY defines if data must be stored with Y axis inverted
  14225. */
  14226. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14227. /**
  14228. * Update a raw 2D array texture
  14229. * @param texture defines the texture to update
  14230. * @param data defines the data to store
  14231. * @param format defines the data format
  14232. * @param invertY defines if data must be stored with Y axis inverted
  14233. * @param compression defines the used compression (can be null)
  14234. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14235. */
  14236. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14237. }
  14238. }
  14239. }
  14240. declare module "babylonjs/Materials/Textures/rawTexture" {
  14241. import { Texture } from "babylonjs/Materials/Textures/texture";
  14242. import "babylonjs/Engines/Extensions/engine.rawTexture";
  14243. import { Nullable } from "babylonjs/types";
  14244. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14245. import { Scene } from "babylonjs/scene";
  14246. /**
  14247. * Raw texture can help creating a texture directly from an array of data.
  14248. * This can be super useful if you either get the data from an uncompressed source or
  14249. * if you wish to create your texture pixel by pixel.
  14250. */
  14251. export class RawTexture extends Texture {
  14252. /**
  14253. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14254. */
  14255. format: number;
  14256. /**
  14257. * Instantiates a new RawTexture.
  14258. * Raw texture can help creating a texture directly from an array of data.
  14259. * This can be super useful if you either get the data from an uncompressed source or
  14260. * if you wish to create your texture pixel by pixel.
  14261. * @param data define the array of data to use to create the texture
  14262. * @param width define the width of the texture
  14263. * @param height define the height of the texture
  14264. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14265. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14266. * @param generateMipMaps define whether mip maps should be generated or not
  14267. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14268. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14269. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14270. */
  14271. constructor(data: ArrayBufferView, width: number, height: number,
  14272. /**
  14273. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14274. */
  14275. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14276. /**
  14277. * Updates the texture underlying data.
  14278. * @param data Define the new data of the texture
  14279. */
  14280. update(data: ArrayBufferView): void;
  14281. /**
  14282. * Creates a luminance texture from some data.
  14283. * @param data Define the texture data
  14284. * @param width Define the width of the texture
  14285. * @param height Define the height of the texture
  14286. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14287. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14288. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14289. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14290. * @returns the luminance texture
  14291. */
  14292. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14293. /**
  14294. * Creates a luminance alpha texture from some data.
  14295. * @param data Define the texture data
  14296. * @param width Define the width of the texture
  14297. * @param height Define the height of the texture
  14298. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14299. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14300. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14301. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14302. * @returns the luminance alpha texture
  14303. */
  14304. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14305. /**
  14306. * Creates an alpha texture from some data.
  14307. * @param data Define the texture data
  14308. * @param width Define the width of the texture
  14309. * @param height Define the height of the texture
  14310. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14311. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14312. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14313. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14314. * @returns the alpha texture
  14315. */
  14316. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14317. /**
  14318. * Creates a RGB texture from some data.
  14319. * @param data Define the texture data
  14320. * @param width Define the width of the texture
  14321. * @param height Define the height of the texture
  14322. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14323. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14324. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14325. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14326. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14327. * @returns the RGB alpha texture
  14328. */
  14329. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14330. /**
  14331. * Creates a RGBA texture from some data.
  14332. * @param data Define the texture data
  14333. * @param width Define the width of the texture
  14334. * @param height Define the height of the texture
  14335. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14336. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14337. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14338. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14339. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14340. * @returns the RGBA texture
  14341. */
  14342. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14343. /**
  14344. * Creates a R texture from some data.
  14345. * @param data Define the texture data
  14346. * @param width Define the width of the texture
  14347. * @param height Define the height of the texture
  14348. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14349. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14350. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14351. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14352. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14353. * @returns the R texture
  14354. */
  14355. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14356. }
  14357. }
  14358. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  14359. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  14360. import { IndicesArray, DataArray } from "babylonjs/types";
  14361. module "babylonjs/Engines/thinEngine" {
  14362. interface ThinEngine {
  14363. /**
  14364. * Update a dynamic index buffer
  14365. * @param indexBuffer defines the target index buffer
  14366. * @param indices defines the data to update
  14367. * @param offset defines the offset in the target index buffer where update should start
  14368. */
  14369. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14370. /**
  14371. * Updates a dynamic vertex buffer.
  14372. * @param vertexBuffer the vertex buffer to update
  14373. * @param data the data used to update the vertex buffer
  14374. * @param byteOffset the byte offset of the data
  14375. * @param byteLength the byte length of the data
  14376. */
  14377. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14378. }
  14379. }
  14380. }
  14381. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14382. import { Scene } from "babylonjs/scene";
  14383. import { ISceneComponent } from "babylonjs/sceneComponent";
  14384. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14385. module "babylonjs/abstractScene" {
  14386. interface AbstractScene {
  14387. /**
  14388. * The list of procedural textures added to the scene
  14389. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14390. */
  14391. proceduralTextures: Array<ProceduralTexture>;
  14392. }
  14393. }
  14394. /**
  14395. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14396. * in a given scene.
  14397. */
  14398. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14399. /**
  14400. * The component name helpfull to identify the component in the list of scene components.
  14401. */
  14402. readonly name: string;
  14403. /**
  14404. * The scene the component belongs to.
  14405. */
  14406. scene: Scene;
  14407. /**
  14408. * Creates a new instance of the component for the given scene
  14409. * @param scene Defines the scene to register the component in
  14410. */
  14411. constructor(scene: Scene);
  14412. /**
  14413. * Registers the component in a given scene
  14414. */
  14415. register(): void;
  14416. /**
  14417. * Rebuilds the elements related to this component in case of
  14418. * context lost for instance.
  14419. */
  14420. rebuild(): void;
  14421. /**
  14422. * Disposes the component and the associated ressources.
  14423. */
  14424. dispose(): void;
  14425. private _beforeClear;
  14426. }
  14427. }
  14428. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  14429. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14430. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14431. module "babylonjs/Engines/thinEngine" {
  14432. interface ThinEngine {
  14433. /**
  14434. * Creates a new render target cube texture
  14435. * @param size defines the size of the texture
  14436. * @param options defines the options used to create the texture
  14437. * @returns a new render target cube texture stored in an InternalTexture
  14438. */
  14439. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14440. }
  14441. }
  14442. }
  14443. declare module "babylonjs/Shaders/procedural.vertex" {
  14444. /** @hidden */
  14445. export var proceduralVertexShader: {
  14446. name: string;
  14447. shader: string;
  14448. };
  14449. }
  14450. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14451. import { Observable } from "babylonjs/Misc/observable";
  14452. import { Nullable } from "babylonjs/types";
  14453. import { Scene } from "babylonjs/scene";
  14454. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  14455. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  14456. import { Effect } from "babylonjs/Materials/effect";
  14457. import { Texture } from "babylonjs/Materials/Textures/texture";
  14458. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14459. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  14460. import "babylonjs/Shaders/procedural.vertex";
  14461. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  14462. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  14463. /**
  14464. * 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.
  14465. * This is the base class of any Procedural texture and contains most of the shareable code.
  14466. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14467. */
  14468. export class ProceduralTexture extends Texture {
  14469. /**
  14470. * Define if the texture is enabled or not (disabled texture will not render)
  14471. */
  14472. isEnabled: boolean;
  14473. /**
  14474. * Define if the texture must be cleared before rendering (default is true)
  14475. */
  14476. autoClear: boolean;
  14477. /**
  14478. * Callback called when the texture is generated
  14479. */
  14480. onGenerated: () => void;
  14481. /**
  14482. * Event raised when the texture is generated
  14483. */
  14484. onGeneratedObservable: Observable<ProceduralTexture>;
  14485. /**
  14486. * Event raised before the texture is generated
  14487. */
  14488. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14489. /**
  14490. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14491. */
  14492. nodeMaterialSource: Nullable<NodeMaterial>;
  14493. /** @hidden */
  14494. _generateMipMaps: boolean;
  14495. /** @hidden **/
  14496. _effect: Effect;
  14497. /** @hidden */
  14498. _textures: {
  14499. [key: string]: Texture;
  14500. };
  14501. /** @hidden */
  14502. protected _fallbackTexture: Nullable<Texture>;
  14503. private _size;
  14504. private _currentRefreshId;
  14505. private _frameId;
  14506. private _refreshRate;
  14507. private _vertexBuffers;
  14508. private _indexBuffer;
  14509. private _uniforms;
  14510. private _samplers;
  14511. private _fragment;
  14512. private _floats;
  14513. private _ints;
  14514. private _floatsArrays;
  14515. private _colors3;
  14516. private _colors4;
  14517. private _vectors2;
  14518. private _vectors3;
  14519. private _matrices;
  14520. private _fallbackTextureUsed;
  14521. private _fullEngine;
  14522. private _cachedDefines;
  14523. private _contentUpdateId;
  14524. private _contentData;
  14525. /**
  14526. * Instantiates a new procedural texture.
  14527. * 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.
  14528. * This is the base class of any Procedural texture and contains most of the shareable code.
  14529. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14530. * @param name Define the name of the texture
  14531. * @param size Define the size of the texture to create
  14532. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14533. * @param scene Define the scene the texture belongs to
  14534. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14535. * @param generateMipMaps Define if the texture should creates mip maps or not
  14536. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14537. * @param textureType The FBO internal texture type
  14538. */
  14539. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14540. /**
  14541. * The effect that is created when initializing the post process.
  14542. * @returns The created effect corresponding the the postprocess.
  14543. */
  14544. getEffect(): Effect;
  14545. /**
  14546. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14547. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14548. */
  14549. getContent(): Nullable<ArrayBufferView>;
  14550. private _createIndexBuffer;
  14551. /** @hidden */
  14552. _rebuild(): void;
  14553. /**
  14554. * Resets the texture in order to recreate its associated resources.
  14555. * This can be called in case of context loss
  14556. */
  14557. reset(): void;
  14558. protected _getDefines(): string;
  14559. /**
  14560. * Is the texture ready to be used ? (rendered at least once)
  14561. * @returns true if ready, otherwise, false.
  14562. */
  14563. isReady(): boolean;
  14564. /**
  14565. * Resets the refresh counter of the texture and start bak from scratch.
  14566. * Could be useful to regenerate the texture if it is setup to render only once.
  14567. */
  14568. resetRefreshCounter(): void;
  14569. /**
  14570. * Set the fragment shader to use in order to render the texture.
  14571. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14572. */
  14573. setFragment(fragment: any): void;
  14574. /**
  14575. * Define the refresh rate of the texture or the rendering frequency.
  14576. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14577. */
  14578. get refreshRate(): number;
  14579. set refreshRate(value: number);
  14580. /** @hidden */
  14581. _shouldRender(): boolean;
  14582. /**
  14583. * Get the size the texture is rendering at.
  14584. * @returns the size (on cube texture it is always squared)
  14585. */
  14586. getRenderSize(): RenderTargetTextureSize;
  14587. /**
  14588. * Resize the texture to new value.
  14589. * @param size Define the new size the texture should have
  14590. * @param generateMipMaps Define whether the new texture should create mip maps
  14591. */
  14592. resize(size: number, generateMipMaps: boolean): void;
  14593. private _checkUniform;
  14594. /**
  14595. * Set a texture in the shader program used to render.
  14596. * @param name Define the name of the uniform samplers as defined in the shader
  14597. * @param texture Define the texture to bind to this sampler
  14598. * @return the texture itself allowing "fluent" like uniform updates
  14599. */
  14600. setTexture(name: string, texture: Texture): ProceduralTexture;
  14601. /**
  14602. * Set a float in the shader.
  14603. * @param name Define the name of the uniform as defined in the shader
  14604. * @param value Define the value to give to the uniform
  14605. * @return the texture itself allowing "fluent" like uniform updates
  14606. */
  14607. setFloat(name: string, value: number): ProceduralTexture;
  14608. /**
  14609. * Set a int in the shader.
  14610. * @param name Define the name of the uniform as defined in the shader
  14611. * @param value Define the value to give to the uniform
  14612. * @return the texture itself allowing "fluent" like uniform updates
  14613. */
  14614. setInt(name: string, value: number): ProceduralTexture;
  14615. /**
  14616. * Set an array of floats in the shader.
  14617. * @param name Define the name of the uniform as defined in the shader
  14618. * @param value Define the value to give to the uniform
  14619. * @return the texture itself allowing "fluent" like uniform updates
  14620. */
  14621. setFloats(name: string, value: number[]): ProceduralTexture;
  14622. /**
  14623. * Set a vec3 in the shader from a Color3.
  14624. * @param name Define the name of the uniform as defined in the shader
  14625. * @param value Define the value to give to the uniform
  14626. * @return the texture itself allowing "fluent" like uniform updates
  14627. */
  14628. setColor3(name: string, value: Color3): ProceduralTexture;
  14629. /**
  14630. * Set a vec4 in the shader from a Color4.
  14631. * @param name Define the name of the uniform as defined in the shader
  14632. * @param value Define the value to give to the uniform
  14633. * @return the texture itself allowing "fluent" like uniform updates
  14634. */
  14635. setColor4(name: string, value: Color4): ProceduralTexture;
  14636. /**
  14637. * Set a vec2 in the shader from a Vector2.
  14638. * @param name Define the name of the uniform as defined in the shader
  14639. * @param value Define the value to give to the uniform
  14640. * @return the texture itself allowing "fluent" like uniform updates
  14641. */
  14642. setVector2(name: string, value: Vector2): ProceduralTexture;
  14643. /**
  14644. * Set a vec3 in the shader from a Vector3.
  14645. * @param name Define the name of the uniform as defined in the shader
  14646. * @param value Define the value to give to the uniform
  14647. * @return the texture itself allowing "fluent" like uniform updates
  14648. */
  14649. setVector3(name: string, value: Vector3): ProceduralTexture;
  14650. /**
  14651. * Set a mat4 in the shader from a MAtrix.
  14652. * @param name Define the name of the uniform as defined in the shader
  14653. * @param value Define the value to give to the uniform
  14654. * @return the texture itself allowing "fluent" like uniform updates
  14655. */
  14656. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14657. /**
  14658. * Render the texture to its associated render target.
  14659. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14660. */
  14661. render(useCameraPostProcess?: boolean): void;
  14662. /**
  14663. * Clone the texture.
  14664. * @returns the cloned texture
  14665. */
  14666. clone(): ProceduralTexture;
  14667. /**
  14668. * Dispose the texture and release its asoociated resources.
  14669. */
  14670. dispose(): void;
  14671. }
  14672. }
  14673. declare module "babylonjs/Particles/baseParticleSystem" {
  14674. import { Nullable } from "babylonjs/types";
  14675. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14677. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14678. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  14679. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14680. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14681. import { Color4 } from "babylonjs/Maths/math.color";
  14682. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14683. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  14684. import { Animation } from "babylonjs/Animations/animation";
  14685. import { Scene } from "babylonjs/scene";
  14686. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14687. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14688. /**
  14689. * This represents the base class for particle system in Babylon.
  14690. * 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.
  14691. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14692. * @example https://doc.babylonjs.com/babylon101/particles
  14693. */
  14694. export class BaseParticleSystem {
  14695. /**
  14696. * Source color is added to the destination color without alpha affecting the result
  14697. */
  14698. static BLENDMODE_ONEONE: number;
  14699. /**
  14700. * Blend current color and particle color using particle’s alpha
  14701. */
  14702. static BLENDMODE_STANDARD: number;
  14703. /**
  14704. * Add current color and particle color multiplied by particle’s alpha
  14705. */
  14706. static BLENDMODE_ADD: number;
  14707. /**
  14708. * Multiply current color with particle color
  14709. */
  14710. static BLENDMODE_MULTIPLY: number;
  14711. /**
  14712. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14713. */
  14714. static BLENDMODE_MULTIPLYADD: number;
  14715. /**
  14716. * List of animations used by the particle system.
  14717. */
  14718. animations: Animation[];
  14719. /**
  14720. * Gets or sets the unique id of the particle system
  14721. */
  14722. uniqueId: number;
  14723. /**
  14724. * The id of the Particle system.
  14725. */
  14726. id: string;
  14727. /**
  14728. * The friendly name of the Particle system.
  14729. */
  14730. name: string;
  14731. /**
  14732. * Snippet ID if the particle system was created from the snippet server
  14733. */
  14734. snippetId: string;
  14735. /**
  14736. * The rendering group used by the Particle system to chose when to render.
  14737. */
  14738. renderingGroupId: number;
  14739. /**
  14740. * The emitter represents the Mesh or position we are attaching the particle system to.
  14741. */
  14742. emitter: Nullable<AbstractMesh | Vector3>;
  14743. /**
  14744. * The maximum number of particles to emit per frame
  14745. */
  14746. emitRate: number;
  14747. /**
  14748. * If you want to launch only a few particles at once, that can be done, as well.
  14749. */
  14750. manualEmitCount: number;
  14751. /**
  14752. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14753. */
  14754. updateSpeed: number;
  14755. /**
  14756. * The amount of time the particle system is running (depends of the overall update speed).
  14757. */
  14758. targetStopDuration: number;
  14759. /**
  14760. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14761. */
  14762. disposeOnStop: boolean;
  14763. /**
  14764. * Minimum power of emitting particles.
  14765. */
  14766. minEmitPower: number;
  14767. /**
  14768. * Maximum power of emitting particles.
  14769. */
  14770. maxEmitPower: number;
  14771. /**
  14772. * Minimum life time of emitting particles.
  14773. */
  14774. minLifeTime: number;
  14775. /**
  14776. * Maximum life time of emitting particles.
  14777. */
  14778. maxLifeTime: number;
  14779. /**
  14780. * Minimum Size of emitting particles.
  14781. */
  14782. minSize: number;
  14783. /**
  14784. * Maximum Size of emitting particles.
  14785. */
  14786. maxSize: number;
  14787. /**
  14788. * Minimum scale of emitting particles on X axis.
  14789. */
  14790. minScaleX: number;
  14791. /**
  14792. * Maximum scale of emitting particles on X axis.
  14793. */
  14794. maxScaleX: number;
  14795. /**
  14796. * Minimum scale of emitting particles on Y axis.
  14797. */
  14798. minScaleY: number;
  14799. /**
  14800. * Maximum scale of emitting particles on Y axis.
  14801. */
  14802. maxScaleY: number;
  14803. /**
  14804. * Gets or sets the minimal initial rotation in radians.
  14805. */
  14806. minInitialRotation: number;
  14807. /**
  14808. * Gets or sets the maximal initial rotation in radians.
  14809. */
  14810. maxInitialRotation: number;
  14811. /**
  14812. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14813. */
  14814. minAngularSpeed: number;
  14815. /**
  14816. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14817. */
  14818. maxAngularSpeed: number;
  14819. /**
  14820. * The texture used to render each particle. (this can be a spritesheet)
  14821. */
  14822. particleTexture: Nullable<BaseTexture>;
  14823. /**
  14824. * The layer mask we are rendering the particles through.
  14825. */
  14826. layerMask: number;
  14827. /**
  14828. * This can help using your own shader to render the particle system.
  14829. * The according effect will be created
  14830. */
  14831. customShader: any;
  14832. /**
  14833. * By default particle system starts as soon as they are created. This prevents the
  14834. * automatic start to happen and let you decide when to start emitting particles.
  14835. */
  14836. preventAutoStart: boolean;
  14837. private _noiseTexture;
  14838. /**
  14839. * Gets or sets a texture used to add random noise to particle positions
  14840. */
  14841. get noiseTexture(): Nullable<ProceduralTexture>;
  14842. set noiseTexture(value: Nullable<ProceduralTexture>);
  14843. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14844. noiseStrength: Vector3;
  14845. /**
  14846. * Callback triggered when the particle animation is ending.
  14847. */
  14848. onAnimationEnd: Nullable<() => void>;
  14849. /**
  14850. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14851. */
  14852. blendMode: number;
  14853. /**
  14854. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14855. * to override the particles.
  14856. */
  14857. forceDepthWrite: boolean;
  14858. /** 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 */
  14859. preWarmCycles: number;
  14860. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14861. preWarmStepOffset: number;
  14862. /**
  14863. * 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)
  14864. */
  14865. spriteCellChangeSpeed: number;
  14866. /**
  14867. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14868. */
  14869. startSpriteCellID: number;
  14870. /**
  14871. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14872. */
  14873. endSpriteCellID: number;
  14874. /**
  14875. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14876. */
  14877. spriteCellWidth: number;
  14878. /**
  14879. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14880. */
  14881. spriteCellHeight: number;
  14882. /**
  14883. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14884. */
  14885. spriteRandomStartCell: boolean;
  14886. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14887. translationPivot: Vector2;
  14888. /** @hidden */
  14889. protected _isAnimationSheetEnabled: boolean;
  14890. /**
  14891. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14892. */
  14893. beginAnimationOnStart: boolean;
  14894. /**
  14895. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14896. */
  14897. beginAnimationFrom: number;
  14898. /**
  14899. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14900. */
  14901. beginAnimationTo: number;
  14902. /**
  14903. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14904. */
  14905. beginAnimationLoop: boolean;
  14906. /**
  14907. * Gets or sets a world offset applied to all particles
  14908. */
  14909. worldOffset: Vector3;
  14910. /**
  14911. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14912. */
  14913. get isAnimationSheetEnabled(): boolean;
  14914. set isAnimationSheetEnabled(value: boolean);
  14915. /**
  14916. * Get hosting scene
  14917. * @returns the scene
  14918. */
  14919. getScene(): Nullable<Scene>;
  14920. /**
  14921. * You can use gravity if you want to give an orientation to your particles.
  14922. */
  14923. gravity: Vector3;
  14924. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14925. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14926. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14927. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14928. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14929. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14930. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14931. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14932. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14933. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14934. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14935. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14936. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14937. /**
  14938. * Defines the delay in milliseconds before starting the system (0 by default)
  14939. */
  14940. startDelay: number;
  14941. /**
  14942. * Gets the current list of drag gradients.
  14943. * You must use addDragGradient and removeDragGradient to udpate this list
  14944. * @returns the list of drag gradients
  14945. */
  14946. getDragGradients(): Nullable<Array<FactorGradient>>;
  14947. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14948. limitVelocityDamping: number;
  14949. /**
  14950. * Gets the current list of limit velocity gradients.
  14951. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14952. * @returns the list of limit velocity gradients
  14953. */
  14954. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14955. /**
  14956. * Gets the current list of color gradients.
  14957. * You must use addColorGradient and removeColorGradient to udpate this list
  14958. * @returns the list of color gradients
  14959. */
  14960. getColorGradients(): Nullable<Array<ColorGradient>>;
  14961. /**
  14962. * Gets the current list of size gradients.
  14963. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14964. * @returns the list of size gradients
  14965. */
  14966. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14967. /**
  14968. * Gets the current list of color remap gradients.
  14969. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14970. * @returns the list of color remap gradients
  14971. */
  14972. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14973. /**
  14974. * Gets the current list of alpha remap gradients.
  14975. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14976. * @returns the list of alpha remap gradients
  14977. */
  14978. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14979. /**
  14980. * Gets the current list of life time gradients.
  14981. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14982. * @returns the list of life time gradients
  14983. */
  14984. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14985. /**
  14986. * Gets the current list of angular speed gradients.
  14987. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14988. * @returns the list of angular speed gradients
  14989. */
  14990. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14991. /**
  14992. * Gets the current list of velocity gradients.
  14993. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14994. * @returns the list of velocity gradients
  14995. */
  14996. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14997. /**
  14998. * Gets the current list of start size gradients.
  14999. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15000. * @returns the list of start size gradients
  15001. */
  15002. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15003. /**
  15004. * Gets the current list of emit rate gradients.
  15005. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15006. * @returns the list of emit rate gradients
  15007. */
  15008. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15009. /**
  15010. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15011. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15012. */
  15013. get direction1(): Vector3;
  15014. set direction1(value: Vector3);
  15015. /**
  15016. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15017. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15018. */
  15019. get direction2(): Vector3;
  15020. set direction2(value: Vector3);
  15021. /**
  15022. * 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.
  15023. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15024. */
  15025. get minEmitBox(): Vector3;
  15026. set minEmitBox(value: Vector3);
  15027. /**
  15028. * 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.
  15029. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15030. */
  15031. get maxEmitBox(): Vector3;
  15032. set maxEmitBox(value: Vector3);
  15033. /**
  15034. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15035. */
  15036. color1: Color4;
  15037. /**
  15038. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15039. */
  15040. color2: Color4;
  15041. /**
  15042. * Color the particle will have at the end of its lifetime
  15043. */
  15044. colorDead: Color4;
  15045. /**
  15046. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15047. */
  15048. textureMask: Color4;
  15049. /**
  15050. * The particle emitter type defines the emitter used by the particle system.
  15051. * It can be for example box, sphere, or cone...
  15052. */
  15053. particleEmitterType: IParticleEmitterType;
  15054. /** @hidden */
  15055. _isSubEmitter: boolean;
  15056. /**
  15057. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15058. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15059. */
  15060. billboardMode: number;
  15061. protected _isBillboardBased: boolean;
  15062. /**
  15063. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15064. */
  15065. get isBillboardBased(): boolean;
  15066. set isBillboardBased(value: boolean);
  15067. /**
  15068. * The scene the particle system belongs to.
  15069. */
  15070. protected _scene: Nullable<Scene>;
  15071. /**
  15072. * The engine the particle system belongs to.
  15073. */
  15074. protected _engine: ThinEngine;
  15075. /**
  15076. * Local cache of defines for image processing.
  15077. */
  15078. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15079. /**
  15080. * Default configuration related to image processing available in the standard Material.
  15081. */
  15082. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15083. /**
  15084. * Gets the image processing configuration used either in this material.
  15085. */
  15086. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15087. /**
  15088. * Sets the Default image processing configuration used either in the this material.
  15089. *
  15090. * If sets to null, the scene one is in use.
  15091. */
  15092. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15093. /**
  15094. * Attaches a new image processing configuration to the Standard Material.
  15095. * @param configuration
  15096. */
  15097. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15098. /** @hidden */
  15099. protected _reset(): void;
  15100. /** @hidden */
  15101. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15102. /**
  15103. * Instantiates a particle system.
  15104. * 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.
  15105. * @param name The name of the particle system
  15106. */
  15107. constructor(name: string);
  15108. /**
  15109. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15110. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15111. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15112. * @returns the emitter
  15113. */
  15114. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15115. /**
  15116. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15117. * @param radius The radius of the hemisphere to emit from
  15118. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15119. * @returns the emitter
  15120. */
  15121. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15122. /**
  15123. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15124. * @param radius The radius of the sphere to emit from
  15125. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15126. * @returns the emitter
  15127. */
  15128. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15129. /**
  15130. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15131. * @param radius The radius of the sphere to emit from
  15132. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15133. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15134. * @returns the emitter
  15135. */
  15136. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15137. /**
  15138. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15139. * @param radius The radius of the emission cylinder
  15140. * @param height The height of the emission cylinder
  15141. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15142. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15143. * @returns the emitter
  15144. */
  15145. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15146. /**
  15147. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15148. * @param radius The radius of the cylinder to emit from
  15149. * @param height The height of the emission cylinder
  15150. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15151. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15152. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15153. * @returns the emitter
  15154. */
  15155. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15156. /**
  15157. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15158. * @param radius The radius of the cone to emit from
  15159. * @param angle The base angle of the cone
  15160. * @returns the emitter
  15161. */
  15162. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15163. /**
  15164. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15165. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15166. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15167. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15168. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15169. * @returns the emitter
  15170. */
  15171. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15172. }
  15173. }
  15174. declare module "babylonjs/Particles/subEmitter" {
  15175. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15176. import { Scene } from "babylonjs/scene";
  15177. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15178. /**
  15179. * Type of sub emitter
  15180. */
  15181. export enum SubEmitterType {
  15182. /**
  15183. * Attached to the particle over it's lifetime
  15184. */
  15185. ATTACHED = 0,
  15186. /**
  15187. * Created when the particle dies
  15188. */
  15189. END = 1
  15190. }
  15191. /**
  15192. * Sub emitter class used to emit particles from an existing particle
  15193. */
  15194. export class SubEmitter {
  15195. /**
  15196. * the particle system to be used by the sub emitter
  15197. */
  15198. particleSystem: ParticleSystem;
  15199. /**
  15200. * Type of the submitter (Default: END)
  15201. */
  15202. type: SubEmitterType;
  15203. /**
  15204. * 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)
  15205. * Note: This only is supported when using an emitter of type Mesh
  15206. */
  15207. inheritDirection: boolean;
  15208. /**
  15209. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15210. */
  15211. inheritedVelocityAmount: number;
  15212. /**
  15213. * Creates a sub emitter
  15214. * @param particleSystem the particle system to be used by the sub emitter
  15215. */
  15216. constructor(
  15217. /**
  15218. * the particle system to be used by the sub emitter
  15219. */
  15220. particleSystem: ParticleSystem);
  15221. /**
  15222. * Clones the sub emitter
  15223. * @returns the cloned sub emitter
  15224. */
  15225. clone(): SubEmitter;
  15226. /**
  15227. * Serialize current object to a JSON object
  15228. * @returns the serialized object
  15229. */
  15230. serialize(): any;
  15231. /** @hidden */
  15232. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15233. /**
  15234. * Creates a new SubEmitter from a serialized JSON version
  15235. * @param serializationObject defines the JSON object to read from
  15236. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15237. * @param rootUrl defines the rootUrl for data loading
  15238. * @returns a new SubEmitter
  15239. */
  15240. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15241. /** Release associated resources */
  15242. dispose(): void;
  15243. }
  15244. }
  15245. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15246. /** @hidden */
  15247. export var clipPlaneFragmentDeclaration: {
  15248. name: string;
  15249. shader: string;
  15250. };
  15251. }
  15252. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15253. /** @hidden */
  15254. export var imageProcessingDeclaration: {
  15255. name: string;
  15256. shader: string;
  15257. };
  15258. }
  15259. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15260. /** @hidden */
  15261. export var imageProcessingFunctions: {
  15262. name: string;
  15263. shader: string;
  15264. };
  15265. }
  15266. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15267. /** @hidden */
  15268. export var clipPlaneFragment: {
  15269. name: string;
  15270. shader: string;
  15271. };
  15272. }
  15273. declare module "babylonjs/Shaders/particles.fragment" {
  15274. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15275. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15276. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15277. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15278. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15279. /** @hidden */
  15280. export var particlesPixelShader: {
  15281. name: string;
  15282. shader: string;
  15283. };
  15284. }
  15285. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15286. /** @hidden */
  15287. export var clipPlaneVertexDeclaration: {
  15288. name: string;
  15289. shader: string;
  15290. };
  15291. }
  15292. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15293. /** @hidden */
  15294. export var clipPlaneVertex: {
  15295. name: string;
  15296. shader: string;
  15297. };
  15298. }
  15299. declare module "babylonjs/Shaders/particles.vertex" {
  15300. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15301. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15302. /** @hidden */
  15303. export var particlesVertexShader: {
  15304. name: string;
  15305. shader: string;
  15306. };
  15307. }
  15308. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  15309. import { Nullable } from "babylonjs/types";
  15310. import { Plane } from "babylonjs/Maths/math";
  15311. /**
  15312. * Interface used to define entities containing multiple clip planes
  15313. */
  15314. export interface IClipPlanesHolder {
  15315. /**
  15316. * Gets or sets the active clipplane 1
  15317. */
  15318. clipPlane: Nullable<Plane>;
  15319. /**
  15320. * Gets or sets the active clipplane 2
  15321. */
  15322. clipPlane2: Nullable<Plane>;
  15323. /**
  15324. * Gets or sets the active clipplane 3
  15325. */
  15326. clipPlane3: Nullable<Plane>;
  15327. /**
  15328. * Gets or sets the active clipplane 4
  15329. */
  15330. clipPlane4: Nullable<Plane>;
  15331. /**
  15332. * Gets or sets the active clipplane 5
  15333. */
  15334. clipPlane5: Nullable<Plane>;
  15335. /**
  15336. * Gets or sets the active clipplane 6
  15337. */
  15338. clipPlane6: Nullable<Plane>;
  15339. }
  15340. }
  15341. declare module "babylonjs/Materials/thinMaterialHelper" {
  15342. import { Effect } from "babylonjs/Materials/effect";
  15343. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  15344. /**
  15345. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15346. *
  15347. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15348. *
  15349. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15350. */
  15351. export class ThinMaterialHelper {
  15352. /**
  15353. * Binds the clip plane information from the holder to the effect.
  15354. * @param effect The effect we are binding the data to
  15355. * @param holder The entity containing the clip plane information
  15356. */
  15357. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15358. }
  15359. }
  15360. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  15361. module "babylonjs/Engines/thinEngine" {
  15362. interface ThinEngine {
  15363. /**
  15364. * Sets alpha constants used by some alpha blending modes
  15365. * @param r defines the red component
  15366. * @param g defines the green component
  15367. * @param b defines the blue component
  15368. * @param a defines the alpha component
  15369. */
  15370. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15371. /**
  15372. * Sets the current alpha mode
  15373. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15374. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15375. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15376. */
  15377. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15378. /**
  15379. * Gets the current alpha mode
  15380. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15381. * @returns the current alpha mode
  15382. */
  15383. getAlphaMode(): number;
  15384. /**
  15385. * Sets the current alpha equation
  15386. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15387. */
  15388. setAlphaEquation(equation: number): void;
  15389. /**
  15390. * Gets the current alpha equation.
  15391. * @returns the current alpha equation
  15392. */
  15393. getAlphaEquation(): number;
  15394. }
  15395. }
  15396. }
  15397. declare module "babylonjs/Particles/particleSystem" {
  15398. import { Nullable } from "babylonjs/types";
  15399. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  15400. import { Observable } from "babylonjs/Misc/observable";
  15401. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15402. import { Effect } from "babylonjs/Materials/effect";
  15403. import { IDisposable } from "babylonjs/scene";
  15404. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15405. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15406. import { Particle } from "babylonjs/Particles/particle";
  15407. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15408. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15409. import "babylonjs/Shaders/particles.fragment";
  15410. import "babylonjs/Shaders/particles.vertex";
  15411. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  15412. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15413. import "babylonjs/Engines/Extensions/engine.alpha";
  15414. import { Scene } from "babylonjs/scene";
  15415. /**
  15416. * This represents a particle system in Babylon.
  15417. * 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.
  15418. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15419. * @example https://doc.babylonjs.com/babylon101/particles
  15420. */
  15421. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15422. /**
  15423. * Billboard mode will only apply to Y axis
  15424. */
  15425. static readonly BILLBOARDMODE_Y: number;
  15426. /**
  15427. * Billboard mode will apply to all axes
  15428. */
  15429. static readonly BILLBOARDMODE_ALL: number;
  15430. /**
  15431. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15432. */
  15433. static readonly BILLBOARDMODE_STRETCHED: number;
  15434. /**
  15435. * This function can be defined to provide custom update for active particles.
  15436. * This function will be called instead of regular update (age, position, color, etc.).
  15437. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15438. */
  15439. updateFunction: (particles: Particle[]) => void;
  15440. private _emitterWorldMatrix;
  15441. /**
  15442. * This function can be defined to specify initial direction for every new particle.
  15443. * It by default use the emitterType defined function
  15444. */
  15445. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15446. /**
  15447. * This function can be defined to specify initial position for every new particle.
  15448. * It by default use the emitterType defined function
  15449. */
  15450. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15451. /**
  15452. * @hidden
  15453. */
  15454. _inheritedVelocityOffset: Vector3;
  15455. /**
  15456. * An event triggered when the system is disposed
  15457. */
  15458. onDisposeObservable: Observable<IParticleSystem>;
  15459. /**
  15460. * An event triggered when the system is stopped
  15461. */
  15462. onStoppedObservable: Observable<IParticleSystem>;
  15463. private _onDisposeObserver;
  15464. /**
  15465. * Sets a callback that will be triggered when the system is disposed
  15466. */
  15467. set onDispose(callback: () => void);
  15468. private _particles;
  15469. private _epsilon;
  15470. private _capacity;
  15471. private _stockParticles;
  15472. private _newPartsExcess;
  15473. private _vertexData;
  15474. private _vertexBuffer;
  15475. private _vertexBuffers;
  15476. private _spriteBuffer;
  15477. private _indexBuffer;
  15478. private _effect;
  15479. private _customEffect;
  15480. private _cachedDefines;
  15481. private _scaledColorStep;
  15482. private _colorDiff;
  15483. private _scaledDirection;
  15484. private _scaledGravity;
  15485. private _currentRenderId;
  15486. private _alive;
  15487. private _useInstancing;
  15488. private _vertexArrayObject;
  15489. private _started;
  15490. private _stopped;
  15491. private _actualFrame;
  15492. private _scaledUpdateSpeed;
  15493. private _vertexBufferSize;
  15494. /** @hidden */
  15495. _currentEmitRateGradient: Nullable<FactorGradient>;
  15496. /** @hidden */
  15497. _currentEmitRate1: number;
  15498. /** @hidden */
  15499. _currentEmitRate2: number;
  15500. /** @hidden */
  15501. _currentStartSizeGradient: Nullable<FactorGradient>;
  15502. /** @hidden */
  15503. _currentStartSize1: number;
  15504. /** @hidden */
  15505. _currentStartSize2: number;
  15506. private readonly _rawTextureWidth;
  15507. private _rampGradientsTexture;
  15508. private _useRampGradients;
  15509. /** Gets or sets a matrix to use to compute projection */
  15510. defaultProjectionMatrix: Matrix;
  15511. /** Gets or sets a matrix to use to compute view */
  15512. defaultViewMatrix: Matrix;
  15513. /** Gets or sets a boolean indicating that ramp gradients must be used
  15514. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15515. */
  15516. get useRampGradients(): boolean;
  15517. set useRampGradients(value: boolean);
  15518. /**
  15519. * 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.
  15520. * 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: [])
  15521. */
  15522. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15523. private _subEmitters;
  15524. /**
  15525. * @hidden
  15526. * If the particle systems emitter should be disposed when the particle system is disposed
  15527. */
  15528. _disposeEmitterOnDispose: boolean;
  15529. /**
  15530. * The current active Sub-systems, this property is used by the root particle system only.
  15531. */
  15532. activeSubSystems: Array<ParticleSystem>;
  15533. /**
  15534. * Specifies if the particles are updated in emitter local space or world space
  15535. */
  15536. isLocal: boolean;
  15537. private _rootParticleSystem;
  15538. /**
  15539. * Gets the current list of active particles
  15540. */
  15541. get particles(): Particle[];
  15542. /**
  15543. * Gets the number of particles active at the same time.
  15544. * @returns The number of active particles.
  15545. */
  15546. getActiveCount(): number;
  15547. /**
  15548. * Returns the string "ParticleSystem"
  15549. * @returns a string containing the class name
  15550. */
  15551. getClassName(): string;
  15552. /**
  15553. * Gets a boolean indicating that the system is stopping
  15554. * @returns true if the system is currently stopping
  15555. */
  15556. isStopping(): boolean;
  15557. /**
  15558. * Gets the custom effect used to render the particles
  15559. * @param blendMode Blend mode for which the effect should be retrieved
  15560. * @returns The effect
  15561. */
  15562. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15563. /**
  15564. * Sets the custom effect used to render the particles
  15565. * @param effect The effect to set
  15566. * @param blendMode Blend mode for which the effect should be set
  15567. */
  15568. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15569. /** @hidden */
  15570. private _onBeforeDrawParticlesObservable;
  15571. /**
  15572. * Observable that will be called just before the particles are drawn
  15573. */
  15574. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15575. /**
  15576. * Gets the name of the particle vertex shader
  15577. */
  15578. get vertexShaderName(): string;
  15579. /**
  15580. * Instantiates a particle system.
  15581. * 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.
  15582. * @param name The name of the particle system
  15583. * @param capacity The max number of particles alive at the same time
  15584. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15585. * @param customEffect a custom effect used to change the way particles are rendered by default
  15586. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15587. * @param epsilon Offset used to render the particles
  15588. */
  15589. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15590. private _addFactorGradient;
  15591. private _removeFactorGradient;
  15592. /**
  15593. * Adds a new life time gradient
  15594. * @param gradient defines the gradient to use (between 0 and 1)
  15595. * @param factor defines the life time factor to affect to the specified gradient
  15596. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15597. * @returns the current particle system
  15598. */
  15599. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15600. /**
  15601. * Remove a specific life time gradient
  15602. * @param gradient defines the gradient to remove
  15603. * @returns the current particle system
  15604. */
  15605. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15606. /**
  15607. * Adds a new size gradient
  15608. * @param gradient defines the gradient to use (between 0 and 1)
  15609. * @param factor defines the size factor to affect to the specified gradient
  15610. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15611. * @returns the current particle system
  15612. */
  15613. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15614. /**
  15615. * Remove a specific size gradient
  15616. * @param gradient defines the gradient to remove
  15617. * @returns the current particle system
  15618. */
  15619. removeSizeGradient(gradient: number): IParticleSystem;
  15620. /**
  15621. * Adds a new color remap gradient
  15622. * @param gradient defines the gradient to use (between 0 and 1)
  15623. * @param min defines the color remap minimal range
  15624. * @param max defines the color remap maximal range
  15625. * @returns the current particle system
  15626. */
  15627. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15628. /**
  15629. * Remove a specific color remap gradient
  15630. * @param gradient defines the gradient to remove
  15631. * @returns the current particle system
  15632. */
  15633. removeColorRemapGradient(gradient: number): IParticleSystem;
  15634. /**
  15635. * Adds a new alpha remap gradient
  15636. * @param gradient defines the gradient to use (between 0 and 1)
  15637. * @param min defines the alpha remap minimal range
  15638. * @param max defines the alpha remap maximal range
  15639. * @returns the current particle system
  15640. */
  15641. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15642. /**
  15643. * Remove a specific alpha remap gradient
  15644. * @param gradient defines the gradient to remove
  15645. * @returns the current particle system
  15646. */
  15647. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15648. /**
  15649. * Adds a new angular speed gradient
  15650. * @param gradient defines the gradient to use (between 0 and 1)
  15651. * @param factor defines the angular speed to affect to the specified gradient
  15652. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15653. * @returns the current particle system
  15654. */
  15655. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15656. /**
  15657. * Remove a specific angular speed gradient
  15658. * @param gradient defines the gradient to remove
  15659. * @returns the current particle system
  15660. */
  15661. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15662. /**
  15663. * Adds a new velocity gradient
  15664. * @param gradient defines the gradient to use (between 0 and 1)
  15665. * @param factor defines the velocity to affect to the specified gradient
  15666. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15667. * @returns the current particle system
  15668. */
  15669. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15670. /**
  15671. * Remove a specific velocity gradient
  15672. * @param gradient defines the gradient to remove
  15673. * @returns the current particle system
  15674. */
  15675. removeVelocityGradient(gradient: number): IParticleSystem;
  15676. /**
  15677. * Adds a new limit velocity gradient
  15678. * @param gradient defines the gradient to use (between 0 and 1)
  15679. * @param factor defines the limit velocity value to affect to the specified gradient
  15680. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15681. * @returns the current particle system
  15682. */
  15683. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15684. /**
  15685. * Remove a specific limit velocity gradient
  15686. * @param gradient defines the gradient to remove
  15687. * @returns the current particle system
  15688. */
  15689. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15690. /**
  15691. * Adds a new drag gradient
  15692. * @param gradient defines the gradient to use (between 0 and 1)
  15693. * @param factor defines the drag value to affect to the specified gradient
  15694. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15695. * @returns the current particle system
  15696. */
  15697. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15698. /**
  15699. * Remove a specific drag gradient
  15700. * @param gradient defines the gradient to remove
  15701. * @returns the current particle system
  15702. */
  15703. removeDragGradient(gradient: number): IParticleSystem;
  15704. /**
  15705. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15706. * @param gradient defines the gradient to use (between 0 and 1)
  15707. * @param factor defines the emit rate value to affect to the specified gradient
  15708. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15709. * @returns the current particle system
  15710. */
  15711. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15712. /**
  15713. * Remove a specific emit rate gradient
  15714. * @param gradient defines the gradient to remove
  15715. * @returns the current particle system
  15716. */
  15717. removeEmitRateGradient(gradient: number): IParticleSystem;
  15718. /**
  15719. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15720. * @param gradient defines the gradient to use (between 0 and 1)
  15721. * @param factor defines the start size value to affect to the specified gradient
  15722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15723. * @returns the current particle system
  15724. */
  15725. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15726. /**
  15727. * Remove a specific start size gradient
  15728. * @param gradient defines the gradient to remove
  15729. * @returns the current particle system
  15730. */
  15731. removeStartSizeGradient(gradient: number): IParticleSystem;
  15732. private _createRampGradientTexture;
  15733. /**
  15734. * Gets the current list of ramp gradients.
  15735. * You must use addRampGradient and removeRampGradient to udpate this list
  15736. * @returns the list of ramp gradients
  15737. */
  15738. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15739. /** Force the system to rebuild all gradients that need to be resync */
  15740. forceRefreshGradients(): void;
  15741. private _syncRampGradientTexture;
  15742. /**
  15743. * Adds a new ramp gradient used to remap particle colors
  15744. * @param gradient defines the gradient to use (between 0 and 1)
  15745. * @param color defines the color to affect to the specified gradient
  15746. * @returns the current particle system
  15747. */
  15748. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15749. /**
  15750. * Remove a specific ramp gradient
  15751. * @param gradient defines the gradient to remove
  15752. * @returns the current particle system
  15753. */
  15754. removeRampGradient(gradient: number): ParticleSystem;
  15755. /**
  15756. * Adds a new color gradient
  15757. * @param gradient defines the gradient to use (between 0 and 1)
  15758. * @param color1 defines the color to affect to the specified gradient
  15759. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15760. * @returns this particle system
  15761. */
  15762. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15763. /**
  15764. * Remove a specific color gradient
  15765. * @param gradient defines the gradient to remove
  15766. * @returns this particle system
  15767. */
  15768. removeColorGradient(gradient: number): IParticleSystem;
  15769. private _fetchR;
  15770. protected _reset(): void;
  15771. private _resetEffect;
  15772. private _createVertexBuffers;
  15773. private _createIndexBuffer;
  15774. /**
  15775. * Gets the maximum number of particles active at the same time.
  15776. * @returns The max number of active particles.
  15777. */
  15778. getCapacity(): number;
  15779. /**
  15780. * Gets whether there are still active particles in the system.
  15781. * @returns True if it is alive, otherwise false.
  15782. */
  15783. isAlive(): boolean;
  15784. /**
  15785. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15786. * @returns True if it has been started, otherwise false.
  15787. */
  15788. isStarted(): boolean;
  15789. private _prepareSubEmitterInternalArray;
  15790. /**
  15791. * Starts the particle system and begins to emit
  15792. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15793. */
  15794. start(delay?: number): void;
  15795. /**
  15796. * Stops the particle system.
  15797. * @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.
  15798. */
  15799. stop(stopSubEmitters?: boolean): void;
  15800. /**
  15801. * Remove all active particles
  15802. */
  15803. reset(): void;
  15804. /**
  15805. * @hidden (for internal use only)
  15806. */
  15807. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15808. /**
  15809. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15810. * Its lifetime will start back at 0.
  15811. */
  15812. recycleParticle: (particle: Particle) => void;
  15813. private _stopSubEmitters;
  15814. private _createParticle;
  15815. private _removeFromRoot;
  15816. private _emitFromParticle;
  15817. private _update;
  15818. /** @hidden */
  15819. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15820. /** @hidden */
  15821. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15822. /**
  15823. * Fill the defines array according to the current settings of the particle system
  15824. * @param defines Array to be updated
  15825. * @param blendMode blend mode to take into account when updating the array
  15826. */
  15827. fillDefines(defines: Array<string>, blendMode: number): void;
  15828. /**
  15829. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15830. * @param uniforms Uniforms array to fill
  15831. * @param attributes Attributes array to fill
  15832. * @param samplers Samplers array to fill
  15833. */
  15834. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15835. /** @hidden */
  15836. private _getEffect;
  15837. /**
  15838. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15839. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15840. */
  15841. animate(preWarmOnly?: boolean): void;
  15842. private _appendParticleVertices;
  15843. /**
  15844. * Rebuilds the particle system.
  15845. */
  15846. rebuild(): void;
  15847. /**
  15848. * Is this system ready to be used/rendered
  15849. * @return true if the system is ready
  15850. */
  15851. isReady(): boolean;
  15852. private _render;
  15853. /**
  15854. * Renders the particle system in its current state.
  15855. * @returns the current number of particles
  15856. */
  15857. render(): number;
  15858. /**
  15859. * Disposes the particle system and free the associated resources
  15860. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15861. */
  15862. dispose(disposeTexture?: boolean): void;
  15863. /**
  15864. * Clones the particle system.
  15865. * @param name The name of the cloned object
  15866. * @param newEmitter The new emitter to use
  15867. * @returns the cloned particle system
  15868. */
  15869. clone(name: string, newEmitter: any): ParticleSystem;
  15870. /**
  15871. * Serializes the particle system to a JSON object
  15872. * @param serializeTexture defines if the texture must be serialized as well
  15873. * @returns the JSON object
  15874. */
  15875. serialize(serializeTexture?: boolean): any;
  15876. /** @hidden */
  15877. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  15878. /** @hidden */
  15879. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  15880. /**
  15881. * Parses a JSON object to create a particle system.
  15882. * @param parsedParticleSystem The JSON object to parse
  15883. * @param sceneOrEngine The scene or the engine to create the particle system in
  15884. * @param rootUrl The root url to use to load external dependencies like texture
  15885. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15886. * @returns the Parsed particle system
  15887. */
  15888. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15889. }
  15890. }
  15891. declare module "babylonjs/Particles/particle" {
  15892. import { Nullable } from "babylonjs/types";
  15893. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  15894. import { Color4 } from "babylonjs/Maths/math.color";
  15895. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15896. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15897. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  15898. /**
  15899. * A particle represents one of the element emitted by a particle system.
  15900. * This is mainly define by its coordinates, direction, velocity and age.
  15901. */
  15902. export class Particle {
  15903. /**
  15904. * The particle system the particle belongs to.
  15905. */
  15906. particleSystem: ParticleSystem;
  15907. private static _Count;
  15908. /**
  15909. * Unique ID of the particle
  15910. */
  15911. id: number;
  15912. /**
  15913. * The world position of the particle in the scene.
  15914. */
  15915. position: Vector3;
  15916. /**
  15917. * The world direction of the particle in the scene.
  15918. */
  15919. direction: Vector3;
  15920. /**
  15921. * The color of the particle.
  15922. */
  15923. color: Color4;
  15924. /**
  15925. * The color change of the particle per step.
  15926. */
  15927. colorStep: Color4;
  15928. /**
  15929. * Defines how long will the life of the particle be.
  15930. */
  15931. lifeTime: number;
  15932. /**
  15933. * The current age of the particle.
  15934. */
  15935. age: number;
  15936. /**
  15937. * The current size of the particle.
  15938. */
  15939. size: number;
  15940. /**
  15941. * The current scale of the particle.
  15942. */
  15943. scale: Vector2;
  15944. /**
  15945. * The current angle of the particle.
  15946. */
  15947. angle: number;
  15948. /**
  15949. * Defines how fast is the angle changing.
  15950. */
  15951. angularSpeed: number;
  15952. /**
  15953. * Defines the cell index used by the particle to be rendered from a sprite.
  15954. */
  15955. cellIndex: number;
  15956. /**
  15957. * The information required to support color remapping
  15958. */
  15959. remapData: Vector4;
  15960. /** @hidden */
  15961. _randomCellOffset?: number;
  15962. /** @hidden */
  15963. _initialDirection: Nullable<Vector3>;
  15964. /** @hidden */
  15965. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15966. /** @hidden */
  15967. _initialStartSpriteCellID: number;
  15968. /** @hidden */
  15969. _initialEndSpriteCellID: number;
  15970. /** @hidden */
  15971. _currentColorGradient: Nullable<ColorGradient>;
  15972. /** @hidden */
  15973. _currentColor1: Color4;
  15974. /** @hidden */
  15975. _currentColor2: Color4;
  15976. /** @hidden */
  15977. _currentSizeGradient: Nullable<FactorGradient>;
  15978. /** @hidden */
  15979. _currentSize1: number;
  15980. /** @hidden */
  15981. _currentSize2: number;
  15982. /** @hidden */
  15983. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15984. /** @hidden */
  15985. _currentAngularSpeed1: number;
  15986. /** @hidden */
  15987. _currentAngularSpeed2: number;
  15988. /** @hidden */
  15989. _currentVelocityGradient: Nullable<FactorGradient>;
  15990. /** @hidden */
  15991. _currentVelocity1: number;
  15992. /** @hidden */
  15993. _currentVelocity2: number;
  15994. /** @hidden */
  15995. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15996. /** @hidden */
  15997. _currentLimitVelocity1: number;
  15998. /** @hidden */
  15999. _currentLimitVelocity2: number;
  16000. /** @hidden */
  16001. _currentDragGradient: Nullable<FactorGradient>;
  16002. /** @hidden */
  16003. _currentDrag1: number;
  16004. /** @hidden */
  16005. _currentDrag2: number;
  16006. /** @hidden */
  16007. _randomNoiseCoordinates1: Vector3;
  16008. /** @hidden */
  16009. _randomNoiseCoordinates2: Vector3;
  16010. /** @hidden */
  16011. _localPosition?: Vector3;
  16012. /**
  16013. * Creates a new instance Particle
  16014. * @param particleSystem the particle system the particle belongs to
  16015. */
  16016. constructor(
  16017. /**
  16018. * The particle system the particle belongs to.
  16019. */
  16020. particleSystem: ParticleSystem);
  16021. private updateCellInfoFromSystem;
  16022. /**
  16023. * Defines how the sprite cell index is updated for the particle
  16024. */
  16025. updateCellIndex(): void;
  16026. /** @hidden */
  16027. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16028. /** @hidden */
  16029. _inheritParticleInfoToSubEmitters(): void;
  16030. /** @hidden */
  16031. _reset(): void;
  16032. /**
  16033. * Copy the properties of particle to another one.
  16034. * @param other the particle to copy the information to.
  16035. */
  16036. copyTo(other: Particle): void;
  16037. }
  16038. }
  16039. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  16040. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16041. import { Effect } from "babylonjs/Materials/effect";
  16042. import { Particle } from "babylonjs/Particles/particle";
  16043. import { Nullable } from "babylonjs/types";
  16044. import { Scene } from "babylonjs/scene";
  16045. /**
  16046. * Particle emitter represents a volume emitting particles.
  16047. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16048. */
  16049. export interface IParticleEmitterType {
  16050. /**
  16051. * Called by the particle System when the direction is computed for the created particle.
  16052. * @param worldMatrix is the world matrix of the particle system
  16053. * @param directionToUpdate is the direction vector to update with the result
  16054. * @param particle is the particle we are computed the direction for
  16055. * @param isLocal defines if the direction should be set in local space
  16056. */
  16057. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16058. /**
  16059. * Called by the particle System when the position is computed for the created particle.
  16060. * @param worldMatrix is the world matrix of the particle system
  16061. * @param positionToUpdate is the position vector to update with the result
  16062. * @param particle is the particle we are computed the position for
  16063. * @param isLocal defines if the position should be set in local space
  16064. */
  16065. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16066. /**
  16067. * Clones the current emitter and returns a copy of it
  16068. * @returns the new emitter
  16069. */
  16070. clone(): IParticleEmitterType;
  16071. /**
  16072. * Called by the GPUParticleSystem to setup the update shader
  16073. * @param effect defines the update shader
  16074. */
  16075. applyToShader(effect: Effect): void;
  16076. /**
  16077. * Returns a string to use to update the GPU particles update shader
  16078. * @returns the effect defines string
  16079. */
  16080. getEffectDefines(): string;
  16081. /**
  16082. * Returns a string representing the class name
  16083. * @returns a string containing the class name
  16084. */
  16085. getClassName(): string;
  16086. /**
  16087. * Serializes the particle system to a JSON object.
  16088. * @returns the JSON object
  16089. */
  16090. serialize(): any;
  16091. /**
  16092. * Parse properties from a JSON object
  16093. * @param serializationObject defines the JSON object
  16094. * @param scene defines the hosting scene
  16095. */
  16096. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16097. }
  16098. }
  16099. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  16100. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16101. import { Effect } from "babylonjs/Materials/effect";
  16102. import { Particle } from "babylonjs/Particles/particle";
  16103. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16104. /**
  16105. * Particle emitter emitting particles from the inside of a box.
  16106. * It emits the particles randomly between 2 given directions.
  16107. */
  16108. export class BoxParticleEmitter implements IParticleEmitterType {
  16109. /**
  16110. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16111. */
  16112. direction1: Vector3;
  16113. /**
  16114. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16115. */
  16116. direction2: Vector3;
  16117. /**
  16118. * 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.
  16119. */
  16120. minEmitBox: Vector3;
  16121. /**
  16122. * 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.
  16123. */
  16124. maxEmitBox: Vector3;
  16125. /**
  16126. * Creates a new instance BoxParticleEmitter
  16127. */
  16128. constructor();
  16129. /**
  16130. * Called by the particle System when the direction is computed for the created particle.
  16131. * @param worldMatrix is the world matrix of the particle system
  16132. * @param directionToUpdate is the direction vector to update with the result
  16133. * @param particle is the particle we are computed the direction for
  16134. * @param isLocal defines if the direction should be set in local space
  16135. */
  16136. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16137. /**
  16138. * Called by the particle System when the position is computed for the created particle.
  16139. * @param worldMatrix is the world matrix of the particle system
  16140. * @param positionToUpdate is the position vector to update with the result
  16141. * @param particle is the particle we are computed the position for
  16142. * @param isLocal defines if the position should be set in local space
  16143. */
  16144. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16145. /**
  16146. * Clones the current emitter and returns a copy of it
  16147. * @returns the new emitter
  16148. */
  16149. clone(): BoxParticleEmitter;
  16150. /**
  16151. * Called by the GPUParticleSystem to setup the update shader
  16152. * @param effect defines the update shader
  16153. */
  16154. applyToShader(effect: Effect): void;
  16155. /**
  16156. * Returns a string to use to update the GPU particles update shader
  16157. * @returns a string containng the defines string
  16158. */
  16159. getEffectDefines(): string;
  16160. /**
  16161. * Returns the string "BoxParticleEmitter"
  16162. * @returns a string containing the class name
  16163. */
  16164. getClassName(): string;
  16165. /**
  16166. * Serializes the particle system to a JSON object.
  16167. * @returns the JSON object
  16168. */
  16169. serialize(): any;
  16170. /**
  16171. * Parse properties from a JSON object
  16172. * @param serializationObject defines the JSON object
  16173. */
  16174. parse(serializationObject: any): void;
  16175. }
  16176. }
  16177. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16178. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16179. import { Effect } from "babylonjs/Materials/effect";
  16180. import { Particle } from "babylonjs/Particles/particle";
  16181. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16182. /**
  16183. * Particle emitter emitting particles from the inside of a cone.
  16184. * It emits the particles alongside the cone volume from the base to the particle.
  16185. * The emission direction might be randomized.
  16186. */
  16187. export class ConeParticleEmitter implements IParticleEmitterType {
  16188. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16189. directionRandomizer: number;
  16190. private _radius;
  16191. private _angle;
  16192. private _height;
  16193. /**
  16194. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16195. */
  16196. radiusRange: number;
  16197. /**
  16198. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16199. */
  16200. heightRange: number;
  16201. /**
  16202. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16203. */
  16204. emitFromSpawnPointOnly: boolean;
  16205. /**
  16206. * Gets or sets the radius of the emission cone
  16207. */
  16208. get radius(): number;
  16209. set radius(value: number);
  16210. /**
  16211. * Gets or sets the angle of the emission cone
  16212. */
  16213. get angle(): number;
  16214. set angle(value: number);
  16215. private _buildHeight;
  16216. /**
  16217. * Creates a new instance ConeParticleEmitter
  16218. * @param radius the radius of the emission cone (1 by default)
  16219. * @param angle the cone base angle (PI by default)
  16220. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16221. */
  16222. constructor(radius?: number, angle?: number,
  16223. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16224. directionRandomizer?: number);
  16225. /**
  16226. * Called by the particle System when the direction is computed for the created particle.
  16227. * @param worldMatrix is the world matrix of the particle system
  16228. * @param directionToUpdate is the direction vector to update with the result
  16229. * @param particle is the particle we are computed the direction for
  16230. * @param isLocal defines if the direction should be set in local space
  16231. */
  16232. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16233. /**
  16234. * Called by the particle System when the position is computed for the created particle.
  16235. * @param worldMatrix is the world matrix of the particle system
  16236. * @param positionToUpdate is the position vector to update with the result
  16237. * @param particle is the particle we are computed the position for
  16238. * @param isLocal defines if the position should be set in local space
  16239. */
  16240. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16241. /**
  16242. * Clones the current emitter and returns a copy of it
  16243. * @returns the new emitter
  16244. */
  16245. clone(): ConeParticleEmitter;
  16246. /**
  16247. * Called by the GPUParticleSystem to setup the update shader
  16248. * @param effect defines the update shader
  16249. */
  16250. applyToShader(effect: Effect): void;
  16251. /**
  16252. * Returns a string to use to update the GPU particles update shader
  16253. * @returns a string containng the defines string
  16254. */
  16255. getEffectDefines(): string;
  16256. /**
  16257. * Returns the string "ConeParticleEmitter"
  16258. * @returns a string containing the class name
  16259. */
  16260. getClassName(): string;
  16261. /**
  16262. * Serializes the particle system to a JSON object.
  16263. * @returns the JSON object
  16264. */
  16265. serialize(): any;
  16266. /**
  16267. * Parse properties from a JSON object
  16268. * @param serializationObject defines the JSON object
  16269. */
  16270. parse(serializationObject: any): void;
  16271. }
  16272. }
  16273. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16274. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16275. import { Effect } from "babylonjs/Materials/effect";
  16276. import { Particle } from "babylonjs/Particles/particle";
  16277. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16278. /**
  16279. * Particle emitter emitting particles from the inside of a cylinder.
  16280. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16281. */
  16282. export class CylinderParticleEmitter implements IParticleEmitterType {
  16283. /**
  16284. * The radius of the emission cylinder.
  16285. */
  16286. radius: number;
  16287. /**
  16288. * The height of the emission cylinder.
  16289. */
  16290. height: number;
  16291. /**
  16292. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16293. */
  16294. radiusRange: number;
  16295. /**
  16296. * How much to randomize the particle direction [0-1].
  16297. */
  16298. directionRandomizer: number;
  16299. /**
  16300. * Creates a new instance CylinderParticleEmitter
  16301. * @param radius the radius of the emission cylinder (1 by default)
  16302. * @param height the height of the emission cylinder (1 by default)
  16303. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16304. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16305. */
  16306. constructor(
  16307. /**
  16308. * The radius of the emission cylinder.
  16309. */
  16310. radius?: number,
  16311. /**
  16312. * The height of the emission cylinder.
  16313. */
  16314. height?: number,
  16315. /**
  16316. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16317. */
  16318. radiusRange?: number,
  16319. /**
  16320. * How much to randomize the particle direction [0-1].
  16321. */
  16322. directionRandomizer?: number);
  16323. /**
  16324. * Called by the particle System when the direction is computed for the created particle.
  16325. * @param worldMatrix is the world matrix of the particle system
  16326. * @param directionToUpdate is the direction vector to update with the result
  16327. * @param particle is the particle we are computed the direction for
  16328. * @param isLocal defines if the direction should be set in local space
  16329. */
  16330. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16331. /**
  16332. * Called by the particle System when the position is computed for the created particle.
  16333. * @param worldMatrix is the world matrix of the particle system
  16334. * @param positionToUpdate is the position vector to update with the result
  16335. * @param particle is the particle we are computed the position for
  16336. * @param isLocal defines if the position should be set in local space
  16337. */
  16338. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16339. /**
  16340. * Clones the current emitter and returns a copy of it
  16341. * @returns the new emitter
  16342. */
  16343. clone(): CylinderParticleEmitter;
  16344. /**
  16345. * Called by the GPUParticleSystem to setup the update shader
  16346. * @param effect defines the update shader
  16347. */
  16348. applyToShader(effect: Effect): void;
  16349. /**
  16350. * Returns a string to use to update the GPU particles update shader
  16351. * @returns a string containng the defines string
  16352. */
  16353. getEffectDefines(): string;
  16354. /**
  16355. * Returns the string "CylinderParticleEmitter"
  16356. * @returns a string containing the class name
  16357. */
  16358. getClassName(): string;
  16359. /**
  16360. * Serializes the particle system to a JSON object.
  16361. * @returns the JSON object
  16362. */
  16363. serialize(): any;
  16364. /**
  16365. * Parse properties from a JSON object
  16366. * @param serializationObject defines the JSON object
  16367. */
  16368. parse(serializationObject: any): void;
  16369. }
  16370. /**
  16371. * Particle emitter emitting particles from the inside of a cylinder.
  16372. * It emits the particles randomly between two vectors.
  16373. */
  16374. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16375. /**
  16376. * The min limit of the emission direction.
  16377. */
  16378. direction1: Vector3;
  16379. /**
  16380. * The max limit of the emission direction.
  16381. */
  16382. direction2: Vector3;
  16383. /**
  16384. * Creates a new instance CylinderDirectedParticleEmitter
  16385. * @param radius the radius of the emission cylinder (1 by default)
  16386. * @param height the height of the emission cylinder (1 by default)
  16387. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16388. * @param direction1 the min limit of the emission direction (up vector by default)
  16389. * @param direction2 the max limit of the emission direction (up vector by default)
  16390. */
  16391. constructor(radius?: number, height?: number, radiusRange?: number,
  16392. /**
  16393. * The min limit of the emission direction.
  16394. */
  16395. direction1?: Vector3,
  16396. /**
  16397. * The max limit of the emission direction.
  16398. */
  16399. direction2?: Vector3);
  16400. /**
  16401. * Called by the particle System when the direction is computed for the created particle.
  16402. * @param worldMatrix is the world matrix of the particle system
  16403. * @param directionToUpdate is the direction vector to update with the result
  16404. * @param particle is the particle we are computed the direction for
  16405. */
  16406. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16407. /**
  16408. * Clones the current emitter and returns a copy of it
  16409. * @returns the new emitter
  16410. */
  16411. clone(): CylinderDirectedParticleEmitter;
  16412. /**
  16413. * Called by the GPUParticleSystem to setup the update shader
  16414. * @param effect defines the update shader
  16415. */
  16416. applyToShader(effect: Effect): void;
  16417. /**
  16418. * Returns a string to use to update the GPU particles update shader
  16419. * @returns a string containng the defines string
  16420. */
  16421. getEffectDefines(): string;
  16422. /**
  16423. * Returns the string "CylinderDirectedParticleEmitter"
  16424. * @returns a string containing the class name
  16425. */
  16426. getClassName(): string;
  16427. /**
  16428. * Serializes the particle system to a JSON object.
  16429. * @returns the JSON object
  16430. */
  16431. serialize(): any;
  16432. /**
  16433. * Parse properties from a JSON object
  16434. * @param serializationObject defines the JSON object
  16435. */
  16436. parse(serializationObject: any): void;
  16437. }
  16438. }
  16439. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16440. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16441. import { Effect } from "babylonjs/Materials/effect";
  16442. import { Particle } from "babylonjs/Particles/particle";
  16443. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16444. /**
  16445. * Particle emitter emitting particles from the inside of a hemisphere.
  16446. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16447. */
  16448. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16449. /**
  16450. * The radius of the emission hemisphere.
  16451. */
  16452. radius: number;
  16453. /**
  16454. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16455. */
  16456. radiusRange: number;
  16457. /**
  16458. * How much to randomize the particle direction [0-1].
  16459. */
  16460. directionRandomizer: number;
  16461. /**
  16462. * Creates a new instance HemisphericParticleEmitter
  16463. * @param radius the radius of the emission hemisphere (1 by default)
  16464. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16465. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16466. */
  16467. constructor(
  16468. /**
  16469. * The radius of the emission hemisphere.
  16470. */
  16471. radius?: number,
  16472. /**
  16473. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16474. */
  16475. radiusRange?: number,
  16476. /**
  16477. * How much to randomize the particle direction [0-1].
  16478. */
  16479. directionRandomizer?: number);
  16480. /**
  16481. * Called by the particle System when the direction is computed for the created particle.
  16482. * @param worldMatrix is the world matrix of the particle system
  16483. * @param directionToUpdate is the direction vector to update with the result
  16484. * @param particle is the particle we are computed the direction for
  16485. * @param isLocal defines if the direction should be set in local space
  16486. */
  16487. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16488. /**
  16489. * Called by the particle System when the position is computed for the created particle.
  16490. * @param worldMatrix is the world matrix of the particle system
  16491. * @param positionToUpdate is the position vector to update with the result
  16492. * @param particle is the particle we are computed the position for
  16493. * @param isLocal defines if the position should be set in local space
  16494. */
  16495. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16496. /**
  16497. * Clones the current emitter and returns a copy of it
  16498. * @returns the new emitter
  16499. */
  16500. clone(): HemisphericParticleEmitter;
  16501. /**
  16502. * Called by the GPUParticleSystem to setup the update shader
  16503. * @param effect defines the update shader
  16504. */
  16505. applyToShader(effect: Effect): void;
  16506. /**
  16507. * Returns a string to use to update the GPU particles update shader
  16508. * @returns a string containng the defines string
  16509. */
  16510. getEffectDefines(): string;
  16511. /**
  16512. * Returns the string "HemisphericParticleEmitter"
  16513. * @returns a string containing the class name
  16514. */
  16515. getClassName(): string;
  16516. /**
  16517. * Serializes the particle system to a JSON object.
  16518. * @returns the JSON object
  16519. */
  16520. serialize(): any;
  16521. /**
  16522. * Parse properties from a JSON object
  16523. * @param serializationObject defines the JSON object
  16524. */
  16525. parse(serializationObject: any): void;
  16526. }
  16527. }
  16528. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16529. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16530. import { Effect } from "babylonjs/Materials/effect";
  16531. import { Particle } from "babylonjs/Particles/particle";
  16532. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16533. /**
  16534. * Particle emitter emitting particles from a point.
  16535. * It emits the particles randomly between 2 given directions.
  16536. */
  16537. export class PointParticleEmitter implements IParticleEmitterType {
  16538. /**
  16539. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16540. */
  16541. direction1: Vector3;
  16542. /**
  16543. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16544. */
  16545. direction2: Vector3;
  16546. /**
  16547. * Creates a new instance PointParticleEmitter
  16548. */
  16549. constructor();
  16550. /**
  16551. * Called by the particle System when the direction is computed for the created particle.
  16552. * @param worldMatrix is the world matrix of the particle system
  16553. * @param directionToUpdate is the direction vector to update with the result
  16554. * @param particle is the particle we are computed the direction for
  16555. * @param isLocal defines if the direction should be set in local space
  16556. */
  16557. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16558. /**
  16559. * Called by the particle System when the position is computed for the created particle.
  16560. * @param worldMatrix is the world matrix of the particle system
  16561. * @param positionToUpdate is the position vector to update with the result
  16562. * @param particle is the particle we are computed the position for
  16563. * @param isLocal defines if the position should be set in local space
  16564. */
  16565. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16566. /**
  16567. * Clones the current emitter and returns a copy of it
  16568. * @returns the new emitter
  16569. */
  16570. clone(): PointParticleEmitter;
  16571. /**
  16572. * Called by the GPUParticleSystem to setup the update shader
  16573. * @param effect defines the update shader
  16574. */
  16575. applyToShader(effect: Effect): void;
  16576. /**
  16577. * Returns a string to use to update the GPU particles update shader
  16578. * @returns a string containng the defines string
  16579. */
  16580. getEffectDefines(): string;
  16581. /**
  16582. * Returns the string "PointParticleEmitter"
  16583. * @returns a string containing the class name
  16584. */
  16585. getClassName(): string;
  16586. /**
  16587. * Serializes the particle system to a JSON object.
  16588. * @returns the JSON object
  16589. */
  16590. serialize(): any;
  16591. /**
  16592. * Parse properties from a JSON object
  16593. * @param serializationObject defines the JSON object
  16594. */
  16595. parse(serializationObject: any): void;
  16596. }
  16597. }
  16598. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16599. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16600. import { Effect } from "babylonjs/Materials/effect";
  16601. import { Particle } from "babylonjs/Particles/particle";
  16602. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16603. /**
  16604. * Particle emitter emitting particles from the inside of a sphere.
  16605. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16606. */
  16607. export class SphereParticleEmitter implements IParticleEmitterType {
  16608. /**
  16609. * The radius of the emission sphere.
  16610. */
  16611. radius: number;
  16612. /**
  16613. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16614. */
  16615. radiusRange: number;
  16616. /**
  16617. * How much to randomize the particle direction [0-1].
  16618. */
  16619. directionRandomizer: number;
  16620. /**
  16621. * Creates a new instance SphereParticleEmitter
  16622. * @param radius the radius of the emission sphere (1 by default)
  16623. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16624. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16625. */
  16626. constructor(
  16627. /**
  16628. * The radius of the emission sphere.
  16629. */
  16630. radius?: number,
  16631. /**
  16632. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16633. */
  16634. radiusRange?: number,
  16635. /**
  16636. * How much to randomize the particle direction [0-1].
  16637. */
  16638. directionRandomizer?: number);
  16639. /**
  16640. * Called by the particle System when the direction is computed for the created particle.
  16641. * @param worldMatrix is the world matrix of the particle system
  16642. * @param directionToUpdate is the direction vector to update with the result
  16643. * @param particle is the particle we are computed the direction for
  16644. * @param isLocal defines if the direction should be set in local space
  16645. */
  16646. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16647. /**
  16648. * Called by the particle System when the position is computed for the created particle.
  16649. * @param worldMatrix is the world matrix of the particle system
  16650. * @param positionToUpdate is the position vector to update with the result
  16651. * @param particle is the particle we are computed the position for
  16652. * @param isLocal defines if the position should be set in local space
  16653. */
  16654. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16655. /**
  16656. * Clones the current emitter and returns a copy of it
  16657. * @returns the new emitter
  16658. */
  16659. clone(): SphereParticleEmitter;
  16660. /**
  16661. * Called by the GPUParticleSystem to setup the update shader
  16662. * @param effect defines the update shader
  16663. */
  16664. applyToShader(effect: Effect): void;
  16665. /**
  16666. * Returns a string to use to update the GPU particles update shader
  16667. * @returns a string containng the defines string
  16668. */
  16669. getEffectDefines(): string;
  16670. /**
  16671. * Returns the string "SphereParticleEmitter"
  16672. * @returns a string containing the class name
  16673. */
  16674. getClassName(): string;
  16675. /**
  16676. * Serializes the particle system to a JSON object.
  16677. * @returns the JSON object
  16678. */
  16679. serialize(): any;
  16680. /**
  16681. * Parse properties from a JSON object
  16682. * @param serializationObject defines the JSON object
  16683. */
  16684. parse(serializationObject: any): void;
  16685. }
  16686. /**
  16687. * Particle emitter emitting particles from the inside of a sphere.
  16688. * It emits the particles randomly between two vectors.
  16689. */
  16690. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16691. /**
  16692. * The min limit of the emission direction.
  16693. */
  16694. direction1: Vector3;
  16695. /**
  16696. * The max limit of the emission direction.
  16697. */
  16698. direction2: Vector3;
  16699. /**
  16700. * Creates a new instance SphereDirectedParticleEmitter
  16701. * @param radius the radius of the emission sphere (1 by default)
  16702. * @param direction1 the min limit of the emission direction (up vector by default)
  16703. * @param direction2 the max limit of the emission direction (up vector by default)
  16704. */
  16705. constructor(radius?: number,
  16706. /**
  16707. * The min limit of the emission direction.
  16708. */
  16709. direction1?: Vector3,
  16710. /**
  16711. * The max limit of the emission direction.
  16712. */
  16713. direction2?: Vector3);
  16714. /**
  16715. * Called by the particle System when the direction is computed for the created particle.
  16716. * @param worldMatrix is the world matrix of the particle system
  16717. * @param directionToUpdate is the direction vector to update with the result
  16718. * @param particle is the particle we are computed the direction for
  16719. */
  16720. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16721. /**
  16722. * Clones the current emitter and returns a copy of it
  16723. * @returns the new emitter
  16724. */
  16725. clone(): SphereDirectedParticleEmitter;
  16726. /**
  16727. * Called by the GPUParticleSystem to setup the update shader
  16728. * @param effect defines the update shader
  16729. */
  16730. applyToShader(effect: Effect): void;
  16731. /**
  16732. * Returns a string to use to update the GPU particles update shader
  16733. * @returns a string containng the defines string
  16734. */
  16735. getEffectDefines(): string;
  16736. /**
  16737. * Returns the string "SphereDirectedParticleEmitter"
  16738. * @returns a string containing the class name
  16739. */
  16740. getClassName(): string;
  16741. /**
  16742. * Serializes the particle system to a JSON object.
  16743. * @returns the JSON object
  16744. */
  16745. serialize(): any;
  16746. /**
  16747. * Parse properties from a JSON object
  16748. * @param serializationObject defines the JSON object
  16749. */
  16750. parse(serializationObject: any): void;
  16751. }
  16752. }
  16753. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  16754. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16755. import { Effect } from "babylonjs/Materials/effect";
  16756. import { Particle } from "babylonjs/Particles/particle";
  16757. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16758. import { Nullable } from "babylonjs/types";
  16759. /**
  16760. * Particle emitter emitting particles from a custom list of positions.
  16761. */
  16762. export class CustomParticleEmitter implements IParticleEmitterType {
  16763. /**
  16764. * Gets or sets the position generator that will create the inital position of each particle.
  16765. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16766. */
  16767. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16768. /**
  16769. * Gets or sets the destination generator that will create the final destination of each particle.
  16770. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16771. */
  16772. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16773. /**
  16774. * Creates a new instance CustomParticleEmitter
  16775. */
  16776. constructor();
  16777. /**
  16778. * Called by the particle System when the direction is computed for the created particle.
  16779. * @param worldMatrix is the world matrix of the particle system
  16780. * @param directionToUpdate is the direction vector to update with the result
  16781. * @param particle is the particle we are computed the direction for
  16782. * @param isLocal defines if the direction should be set in local space
  16783. */
  16784. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16785. /**
  16786. * Called by the particle System when the position is computed for the created particle.
  16787. * @param worldMatrix is the world matrix of the particle system
  16788. * @param positionToUpdate is the position vector to update with the result
  16789. * @param particle is the particle we are computed the position for
  16790. * @param isLocal defines if the position should be set in local space
  16791. */
  16792. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16793. /**
  16794. * Clones the current emitter and returns a copy of it
  16795. * @returns the new emitter
  16796. */
  16797. clone(): CustomParticleEmitter;
  16798. /**
  16799. * Called by the GPUParticleSystem to setup the update shader
  16800. * @param effect defines the update shader
  16801. */
  16802. applyToShader(effect: Effect): void;
  16803. /**
  16804. * Returns a string to use to update the GPU particles update shader
  16805. * @returns a string containng the defines string
  16806. */
  16807. getEffectDefines(): string;
  16808. /**
  16809. * Returns the string "PointParticleEmitter"
  16810. * @returns a string containing the class name
  16811. */
  16812. getClassName(): string;
  16813. /**
  16814. * Serializes the particle system to a JSON object.
  16815. * @returns the JSON object
  16816. */
  16817. serialize(): any;
  16818. /**
  16819. * Parse properties from a JSON object
  16820. * @param serializationObject defines the JSON object
  16821. */
  16822. parse(serializationObject: any): void;
  16823. }
  16824. }
  16825. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  16826. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16827. import { Effect } from "babylonjs/Materials/effect";
  16828. import { Particle } from "babylonjs/Particles/particle";
  16829. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16830. import { Nullable } from "babylonjs/types";
  16831. import { Scene } from "babylonjs/scene";
  16832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16833. /**
  16834. * Particle emitter emitting particles from the inside of a box.
  16835. * It emits the particles randomly between 2 given directions.
  16836. */
  16837. export class MeshParticleEmitter implements IParticleEmitterType {
  16838. private _indices;
  16839. private _positions;
  16840. private _normals;
  16841. private _storedNormal;
  16842. private _mesh;
  16843. /**
  16844. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16845. */
  16846. direction1: Vector3;
  16847. /**
  16848. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16849. */
  16850. direction2: Vector3;
  16851. /**
  16852. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16853. */
  16854. useMeshNormalsForDirection: boolean;
  16855. /** Defines the mesh to use as source */
  16856. get mesh(): Nullable<AbstractMesh>;
  16857. set mesh(value: Nullable<AbstractMesh>);
  16858. /**
  16859. * Creates a new instance MeshParticleEmitter
  16860. * @param mesh defines the mesh to use as source
  16861. */
  16862. constructor(mesh?: Nullable<AbstractMesh>);
  16863. /**
  16864. * Called by the particle System when the direction is computed for the created particle.
  16865. * @param worldMatrix is the world matrix of the particle system
  16866. * @param directionToUpdate is the direction vector to update with the result
  16867. * @param particle is the particle we are computed the direction for
  16868. * @param isLocal defines if the direction should be set in local space
  16869. */
  16870. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16871. /**
  16872. * Called by the particle System when the position is computed for the created particle.
  16873. * @param worldMatrix is the world matrix of the particle system
  16874. * @param positionToUpdate is the position vector to update with the result
  16875. * @param particle is the particle we are computed the position for
  16876. * @param isLocal defines if the position should be set in local space
  16877. */
  16878. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16879. /**
  16880. * Clones the current emitter and returns a copy of it
  16881. * @returns the new emitter
  16882. */
  16883. clone(): MeshParticleEmitter;
  16884. /**
  16885. * Called by the GPUParticleSystem to setup the update shader
  16886. * @param effect defines the update shader
  16887. */
  16888. applyToShader(effect: Effect): void;
  16889. /**
  16890. * Returns a string to use to update the GPU particles update shader
  16891. * @returns a string containng the defines string
  16892. */
  16893. getEffectDefines(): string;
  16894. /**
  16895. * Returns the string "BoxParticleEmitter"
  16896. * @returns a string containing the class name
  16897. */
  16898. getClassName(): string;
  16899. /**
  16900. * Serializes the particle system to a JSON object.
  16901. * @returns the JSON object
  16902. */
  16903. serialize(): any;
  16904. /**
  16905. * Parse properties from a JSON object
  16906. * @param serializationObject defines the JSON object
  16907. * @param scene defines the hosting scene
  16908. */
  16909. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16910. }
  16911. }
  16912. declare module "babylonjs/Particles/EmitterTypes/index" {
  16913. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16914. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16915. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16916. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16917. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16918. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16919. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16920. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  16921. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  16922. }
  16923. declare module "babylonjs/Particles/IParticleSystem" {
  16924. import { Nullable } from "babylonjs/types";
  16925. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16926. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16928. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16929. import { Scene } from "babylonjs/scene";
  16930. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  16931. import { Effect } from "babylonjs/Materials/effect";
  16932. import { Observable } from "babylonjs/Misc/observable";
  16933. import { Animation } from "babylonjs/Animations/animation";
  16934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16935. /**
  16936. * Interface representing a particle system in Babylon.js.
  16937. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16938. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16939. */
  16940. export interface IParticleSystem {
  16941. /**
  16942. * List of animations used by the particle system.
  16943. */
  16944. animations: Animation[];
  16945. /**
  16946. * The id of the Particle system.
  16947. */
  16948. id: string;
  16949. /**
  16950. * The name of the Particle system.
  16951. */
  16952. name: string;
  16953. /**
  16954. * The emitter represents the Mesh or position we are attaching the particle system to.
  16955. */
  16956. emitter: Nullable<AbstractMesh | Vector3>;
  16957. /**
  16958. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16959. */
  16960. isBillboardBased: boolean;
  16961. /**
  16962. * The rendering group used by the Particle system to chose when to render.
  16963. */
  16964. renderingGroupId: number;
  16965. /**
  16966. * The layer mask we are rendering the particles through.
  16967. */
  16968. layerMask: number;
  16969. /**
  16970. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16971. */
  16972. updateSpeed: number;
  16973. /**
  16974. * The amount of time the particle system is running (depends of the overall update speed).
  16975. */
  16976. targetStopDuration: number;
  16977. /**
  16978. * The texture used to render each particle. (this can be a spritesheet)
  16979. */
  16980. particleTexture: Nullable<BaseTexture>;
  16981. /**
  16982. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16983. */
  16984. blendMode: number;
  16985. /**
  16986. * Minimum life time of emitting particles.
  16987. */
  16988. minLifeTime: number;
  16989. /**
  16990. * Maximum life time of emitting particles.
  16991. */
  16992. maxLifeTime: number;
  16993. /**
  16994. * Minimum Size of emitting particles.
  16995. */
  16996. minSize: number;
  16997. /**
  16998. * Maximum Size of emitting particles.
  16999. */
  17000. maxSize: number;
  17001. /**
  17002. * Minimum scale of emitting particles on X axis.
  17003. */
  17004. minScaleX: number;
  17005. /**
  17006. * Maximum scale of emitting particles on X axis.
  17007. */
  17008. maxScaleX: number;
  17009. /**
  17010. * Minimum scale of emitting particles on Y axis.
  17011. */
  17012. minScaleY: number;
  17013. /**
  17014. * Maximum scale of emitting particles on Y axis.
  17015. */
  17016. maxScaleY: number;
  17017. /**
  17018. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17019. */
  17020. color1: Color4;
  17021. /**
  17022. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17023. */
  17024. color2: Color4;
  17025. /**
  17026. * Color the particle will have at the end of its lifetime.
  17027. */
  17028. colorDead: Color4;
  17029. /**
  17030. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17031. */
  17032. emitRate: number;
  17033. /**
  17034. * You can use gravity if you want to give an orientation to your particles.
  17035. */
  17036. gravity: Vector3;
  17037. /**
  17038. * Minimum power of emitting particles.
  17039. */
  17040. minEmitPower: number;
  17041. /**
  17042. * Maximum power of emitting particles.
  17043. */
  17044. maxEmitPower: number;
  17045. /**
  17046. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17047. */
  17048. minAngularSpeed: number;
  17049. /**
  17050. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17051. */
  17052. maxAngularSpeed: number;
  17053. /**
  17054. * Gets or sets the minimal initial rotation in radians.
  17055. */
  17056. minInitialRotation: number;
  17057. /**
  17058. * Gets or sets the maximal initial rotation in radians.
  17059. */
  17060. maxInitialRotation: number;
  17061. /**
  17062. * The particle emitter type defines the emitter used by the particle system.
  17063. * It can be for example box, sphere, or cone...
  17064. */
  17065. particleEmitterType: Nullable<IParticleEmitterType>;
  17066. /**
  17067. * Defines the delay in milliseconds before starting the system (0 by default)
  17068. */
  17069. startDelay: number;
  17070. /**
  17071. * 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
  17072. */
  17073. preWarmCycles: number;
  17074. /**
  17075. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17076. */
  17077. preWarmStepOffset: number;
  17078. /**
  17079. * 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)
  17080. */
  17081. spriteCellChangeSpeed: number;
  17082. /**
  17083. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17084. */
  17085. startSpriteCellID: number;
  17086. /**
  17087. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17088. */
  17089. endSpriteCellID: number;
  17090. /**
  17091. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17092. */
  17093. spriteCellWidth: number;
  17094. /**
  17095. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17096. */
  17097. spriteCellHeight: number;
  17098. /**
  17099. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17100. */
  17101. spriteRandomStartCell: boolean;
  17102. /**
  17103. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17104. */
  17105. isAnimationSheetEnabled: boolean;
  17106. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17107. translationPivot: Vector2;
  17108. /**
  17109. * Gets or sets a texture used to add random noise to particle positions
  17110. */
  17111. noiseTexture: Nullable<BaseTexture>;
  17112. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17113. noiseStrength: Vector3;
  17114. /**
  17115. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17116. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17117. */
  17118. billboardMode: number;
  17119. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17120. limitVelocityDamping: number;
  17121. /**
  17122. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17123. */
  17124. beginAnimationOnStart: boolean;
  17125. /**
  17126. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17127. */
  17128. beginAnimationFrom: number;
  17129. /**
  17130. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17131. */
  17132. beginAnimationTo: number;
  17133. /**
  17134. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17135. */
  17136. beginAnimationLoop: boolean;
  17137. /**
  17138. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17139. */
  17140. disposeOnStop: boolean;
  17141. /**
  17142. * Specifies if the particles are updated in emitter local space or world space
  17143. */
  17144. isLocal: boolean;
  17145. /** Snippet ID if the particle system was created from the snippet server */
  17146. snippetId: string;
  17147. /** Gets or sets a matrix to use to compute projection */
  17148. defaultProjectionMatrix: Matrix;
  17149. /**
  17150. * Gets the maximum number of particles active at the same time.
  17151. * @returns The max number of active particles.
  17152. */
  17153. getCapacity(): number;
  17154. /**
  17155. * Gets the number of particles active at the same time.
  17156. * @returns The number of active particles.
  17157. */
  17158. getActiveCount(): number;
  17159. /**
  17160. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17161. * @returns True if it has been started, otherwise false.
  17162. */
  17163. isStarted(): boolean;
  17164. /**
  17165. * Animates the particle system for this frame.
  17166. */
  17167. animate(): void;
  17168. /**
  17169. * Renders the particle system in its current state.
  17170. * @returns the current number of particles
  17171. */
  17172. render(): number;
  17173. /**
  17174. * Dispose the particle system and frees its associated resources.
  17175. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17176. */
  17177. dispose(disposeTexture?: boolean): void;
  17178. /**
  17179. * An event triggered when the system is disposed
  17180. */
  17181. onDisposeObservable: Observable<IParticleSystem>;
  17182. /**
  17183. * An event triggered when the system is stopped
  17184. */
  17185. onStoppedObservable: Observable<IParticleSystem>;
  17186. /**
  17187. * Clones the particle system.
  17188. * @param name The name of the cloned object
  17189. * @param newEmitter The new emitter to use
  17190. * @returns the cloned particle system
  17191. */
  17192. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17193. /**
  17194. * Serializes the particle system to a JSON object
  17195. * @param serializeTexture defines if the texture must be serialized as well
  17196. * @returns the JSON object
  17197. */
  17198. serialize(serializeTexture: boolean): any;
  17199. /**
  17200. * Rebuild the particle system
  17201. */
  17202. rebuild(): void;
  17203. /** Force the system to rebuild all gradients that need to be resync */
  17204. forceRefreshGradients(): void;
  17205. /**
  17206. * Starts the particle system and begins to emit
  17207. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17208. */
  17209. start(delay?: number): void;
  17210. /**
  17211. * Stops the particle system.
  17212. */
  17213. stop(): void;
  17214. /**
  17215. * Remove all active particles
  17216. */
  17217. reset(): void;
  17218. /**
  17219. * Gets a boolean indicating that the system is stopping
  17220. * @returns true if the system is currently stopping
  17221. */
  17222. isStopping(): boolean;
  17223. /**
  17224. * Is this system ready to be used/rendered
  17225. * @return true if the system is ready
  17226. */
  17227. isReady(): boolean;
  17228. /**
  17229. * Returns the string "ParticleSystem"
  17230. * @returns a string containing the class name
  17231. */
  17232. getClassName(): string;
  17233. /**
  17234. * Gets the custom effect used to render the particles
  17235. * @param blendMode Blend mode for which the effect should be retrieved
  17236. * @returns The effect
  17237. */
  17238. getCustomEffect(blendMode: number): Nullable<Effect>;
  17239. /**
  17240. * Sets the custom effect used to render the particles
  17241. * @param effect The effect to set
  17242. * @param blendMode Blend mode for which the effect should be set
  17243. */
  17244. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17245. /**
  17246. * Fill the defines array according to the current settings of the particle system
  17247. * @param defines Array to be updated
  17248. * @param blendMode blend mode to take into account when updating the array
  17249. */
  17250. fillDefines(defines: Array<string>, blendMode: number): void;
  17251. /**
  17252. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17253. * @param uniforms Uniforms array to fill
  17254. * @param attributes Attributes array to fill
  17255. * @param samplers Samplers array to fill
  17256. */
  17257. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17258. /**
  17259. * Observable that will be called just before the particles are drawn
  17260. */
  17261. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17262. /**
  17263. * Gets the name of the particle vertex shader
  17264. */
  17265. vertexShaderName: string;
  17266. /**
  17267. * Adds a new color gradient
  17268. * @param gradient defines the gradient to use (between 0 and 1)
  17269. * @param color1 defines the color to affect to the specified gradient
  17270. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17271. * @returns the current particle system
  17272. */
  17273. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17274. /**
  17275. * Remove a specific color gradient
  17276. * @param gradient defines the gradient to remove
  17277. * @returns the current particle system
  17278. */
  17279. removeColorGradient(gradient: number): IParticleSystem;
  17280. /**
  17281. * Adds a new size gradient
  17282. * @param gradient defines the gradient to use (between 0 and 1)
  17283. * @param factor defines the size factor to affect to the specified gradient
  17284. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17285. * @returns the current particle system
  17286. */
  17287. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17288. /**
  17289. * Remove a specific size gradient
  17290. * @param gradient defines the gradient to remove
  17291. * @returns the current particle system
  17292. */
  17293. removeSizeGradient(gradient: number): IParticleSystem;
  17294. /**
  17295. * Gets the current list of color gradients.
  17296. * You must use addColorGradient and removeColorGradient to udpate this list
  17297. * @returns the list of color gradients
  17298. */
  17299. getColorGradients(): Nullable<Array<ColorGradient>>;
  17300. /**
  17301. * Gets the current list of size gradients.
  17302. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17303. * @returns the list of size gradients
  17304. */
  17305. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17306. /**
  17307. * Gets the current list of angular speed gradients.
  17308. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17309. * @returns the list of angular speed gradients
  17310. */
  17311. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17312. /**
  17313. * Adds a new angular speed gradient
  17314. * @param gradient defines the gradient to use (between 0 and 1)
  17315. * @param factor defines the angular speed to affect to the specified gradient
  17316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17317. * @returns the current particle system
  17318. */
  17319. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17320. /**
  17321. * Remove a specific angular speed gradient
  17322. * @param gradient defines the gradient to remove
  17323. * @returns the current particle system
  17324. */
  17325. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17326. /**
  17327. * Gets the current list of velocity gradients.
  17328. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17329. * @returns the list of velocity gradients
  17330. */
  17331. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17332. /**
  17333. * Adds a new velocity gradient
  17334. * @param gradient defines the gradient to use (between 0 and 1)
  17335. * @param factor defines the velocity to affect to the specified gradient
  17336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17337. * @returns the current particle system
  17338. */
  17339. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17340. /**
  17341. * Remove a specific velocity gradient
  17342. * @param gradient defines the gradient to remove
  17343. * @returns the current particle system
  17344. */
  17345. removeVelocityGradient(gradient: number): IParticleSystem;
  17346. /**
  17347. * Gets the current list of limit velocity gradients.
  17348. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17349. * @returns the list of limit velocity gradients
  17350. */
  17351. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17352. /**
  17353. * Adds a new limit velocity gradient
  17354. * @param gradient defines the gradient to use (between 0 and 1)
  17355. * @param factor defines the limit velocity to affect to the specified gradient
  17356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17357. * @returns the current particle system
  17358. */
  17359. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17360. /**
  17361. * Remove a specific limit velocity gradient
  17362. * @param gradient defines the gradient to remove
  17363. * @returns the current particle system
  17364. */
  17365. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17366. /**
  17367. * Adds a new drag gradient
  17368. * @param gradient defines the gradient to use (between 0 and 1)
  17369. * @param factor defines the drag to affect to the specified gradient
  17370. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17371. * @returns the current particle system
  17372. */
  17373. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17374. /**
  17375. * Remove a specific drag gradient
  17376. * @param gradient defines the gradient to remove
  17377. * @returns the current particle system
  17378. */
  17379. removeDragGradient(gradient: number): IParticleSystem;
  17380. /**
  17381. * Gets the current list of drag gradients.
  17382. * You must use addDragGradient and removeDragGradient to udpate this list
  17383. * @returns the list of drag gradients
  17384. */
  17385. getDragGradients(): Nullable<Array<FactorGradient>>;
  17386. /**
  17387. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17388. * @param gradient defines the gradient to use (between 0 and 1)
  17389. * @param factor defines the emit rate to affect to the specified gradient
  17390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17391. * @returns the current particle system
  17392. */
  17393. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17394. /**
  17395. * Remove a specific emit rate gradient
  17396. * @param gradient defines the gradient to remove
  17397. * @returns the current particle system
  17398. */
  17399. removeEmitRateGradient(gradient: number): IParticleSystem;
  17400. /**
  17401. * Gets the current list of emit rate gradients.
  17402. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17403. * @returns the list of emit rate gradients
  17404. */
  17405. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17406. /**
  17407. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17408. * @param gradient defines the gradient to use (between 0 and 1)
  17409. * @param factor defines the start size to affect to the specified gradient
  17410. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17411. * @returns the current particle system
  17412. */
  17413. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17414. /**
  17415. * Remove a specific start size gradient
  17416. * @param gradient defines the gradient to remove
  17417. * @returns the current particle system
  17418. */
  17419. removeStartSizeGradient(gradient: number): IParticleSystem;
  17420. /**
  17421. * Gets the current list of start size gradients.
  17422. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17423. * @returns the list of start size gradients
  17424. */
  17425. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17426. /**
  17427. * Adds a new life time gradient
  17428. * @param gradient defines the gradient to use (between 0 and 1)
  17429. * @param factor defines the life time factor to affect to the specified gradient
  17430. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17431. * @returns the current particle system
  17432. */
  17433. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17434. /**
  17435. * Remove a specific life time gradient
  17436. * @param gradient defines the gradient to remove
  17437. * @returns the current particle system
  17438. */
  17439. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17440. /**
  17441. * Gets the current list of life time gradients.
  17442. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17443. * @returns the list of life time gradients
  17444. */
  17445. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17446. /**
  17447. * Gets the current list of color gradients.
  17448. * You must use addColorGradient and removeColorGradient to udpate this list
  17449. * @returns the list of color gradients
  17450. */
  17451. getColorGradients(): Nullable<Array<ColorGradient>>;
  17452. /**
  17453. * Adds a new ramp gradient used to remap particle colors
  17454. * @param gradient defines the gradient to use (between 0 and 1)
  17455. * @param color defines the color to affect to the specified gradient
  17456. * @returns the current particle system
  17457. */
  17458. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17459. /**
  17460. * Gets the current list of ramp gradients.
  17461. * You must use addRampGradient and removeRampGradient to udpate this list
  17462. * @returns the list of ramp gradients
  17463. */
  17464. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17465. /** Gets or sets a boolean indicating that ramp gradients must be used
  17466. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17467. */
  17468. useRampGradients: boolean;
  17469. /**
  17470. * Adds a new color remap gradient
  17471. * @param gradient defines the gradient to use (between 0 and 1)
  17472. * @param min defines the color remap minimal range
  17473. * @param max defines the color remap maximal range
  17474. * @returns the current particle system
  17475. */
  17476. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17477. /**
  17478. * Gets the current list of color remap gradients.
  17479. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17480. * @returns the list of color remap gradients
  17481. */
  17482. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17483. /**
  17484. * Adds a new alpha remap gradient
  17485. * @param gradient defines the gradient to use (between 0 and 1)
  17486. * @param min defines the alpha remap minimal range
  17487. * @param max defines the alpha remap maximal range
  17488. * @returns the current particle system
  17489. */
  17490. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17491. /**
  17492. * Gets the current list of alpha remap gradients.
  17493. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17494. * @returns the list of alpha remap gradients
  17495. */
  17496. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17497. /**
  17498. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17499. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17500. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17501. * @returns the emitter
  17502. */
  17503. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17504. /**
  17505. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17506. * @param radius The radius of the hemisphere to emit from
  17507. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17508. * @returns the emitter
  17509. */
  17510. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17511. /**
  17512. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17513. * @param radius The radius of the sphere to emit from
  17514. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17515. * @returns the emitter
  17516. */
  17517. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17518. /**
  17519. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17520. * @param radius The radius of the sphere to emit from
  17521. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17522. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17523. * @returns the emitter
  17524. */
  17525. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17526. /**
  17527. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17528. * @param radius The radius of the emission cylinder
  17529. * @param height The height of the emission cylinder
  17530. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17531. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17532. * @returns the emitter
  17533. */
  17534. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17535. /**
  17536. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17537. * @param radius The radius of the cylinder to emit from
  17538. * @param height The height of the emission cylinder
  17539. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17540. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17541. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17542. * @returns the emitter
  17543. */
  17544. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17545. /**
  17546. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17547. * @param radius The radius of the cone to emit from
  17548. * @param angle The base angle of the cone
  17549. * @returns the emitter
  17550. */
  17551. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17552. /**
  17553. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17554. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17555. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17556. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17557. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17558. * @returns the emitter
  17559. */
  17560. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17561. /**
  17562. * Get hosting scene
  17563. * @returns the scene
  17564. */
  17565. getScene(): Nullable<Scene>;
  17566. }
  17567. }
  17568. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  17569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  17571. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  17572. /**
  17573. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17574. */
  17575. export class ColorSplitterBlock extends NodeMaterialBlock {
  17576. /**
  17577. * Create a new ColorSplitterBlock
  17578. * @param name defines the block name
  17579. */
  17580. constructor(name: string);
  17581. /**
  17582. * Gets the current class name
  17583. * @returns the class name
  17584. */
  17585. getClassName(): string;
  17586. /**
  17587. * Gets the rgba component (input)
  17588. */
  17589. get rgba(): NodeMaterialConnectionPoint;
  17590. /**
  17591. * Gets the rgb component (input)
  17592. */
  17593. get rgbIn(): NodeMaterialConnectionPoint;
  17594. /**
  17595. * Gets the rgb component (output)
  17596. */
  17597. get rgbOut(): NodeMaterialConnectionPoint;
  17598. /**
  17599. * Gets the r component (output)
  17600. */
  17601. get r(): NodeMaterialConnectionPoint;
  17602. /**
  17603. * Gets the g component (output)
  17604. */
  17605. get g(): NodeMaterialConnectionPoint;
  17606. /**
  17607. * Gets the b component (output)
  17608. */
  17609. get b(): NodeMaterialConnectionPoint;
  17610. /**
  17611. * Gets the a component (output)
  17612. */
  17613. get a(): NodeMaterialConnectionPoint;
  17614. protected _inputRename(name: string): string;
  17615. protected _outputRename(name: string): string;
  17616. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17617. }
  17618. }
  17619. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  17620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  17622. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  17623. import { Scene } from "babylonjs/scene";
  17624. /**
  17625. * Operations supported by the Trigonometry block
  17626. */
  17627. export enum TrigonometryBlockOperations {
  17628. /** Cos */
  17629. Cos = 0,
  17630. /** Sin */
  17631. Sin = 1,
  17632. /** Abs */
  17633. Abs = 2,
  17634. /** Exp */
  17635. Exp = 3,
  17636. /** Exp2 */
  17637. Exp2 = 4,
  17638. /** Round */
  17639. Round = 5,
  17640. /** Floor */
  17641. Floor = 6,
  17642. /** Ceiling */
  17643. Ceiling = 7,
  17644. /** Square root */
  17645. Sqrt = 8,
  17646. /** Log */
  17647. Log = 9,
  17648. /** Tangent */
  17649. Tan = 10,
  17650. /** Arc tangent */
  17651. ArcTan = 11,
  17652. /** Arc cosinus */
  17653. ArcCos = 12,
  17654. /** Arc sinus */
  17655. ArcSin = 13,
  17656. /** Fraction */
  17657. Fract = 14,
  17658. /** Sign */
  17659. Sign = 15,
  17660. /** To radians (from degrees) */
  17661. Radians = 16,
  17662. /** To degrees (from radians) */
  17663. Degrees = 17
  17664. }
  17665. /**
  17666. * Block used to apply trigonometry operation to floats
  17667. */
  17668. export class TrigonometryBlock extends NodeMaterialBlock {
  17669. /**
  17670. * Gets or sets the operation applied by the block
  17671. */
  17672. operation: TrigonometryBlockOperations;
  17673. /**
  17674. * Creates a new TrigonometryBlock
  17675. * @param name defines the block name
  17676. */
  17677. constructor(name: string);
  17678. /**
  17679. * Gets the current class name
  17680. * @returns the class name
  17681. */
  17682. getClassName(): string;
  17683. /**
  17684. * Gets the input component
  17685. */
  17686. get input(): NodeMaterialConnectionPoint;
  17687. /**
  17688. * Gets the output component
  17689. */
  17690. get output(): NodeMaterialConnectionPoint;
  17691. protected _buildBlock(state: NodeMaterialBuildState): this;
  17692. serialize(): any;
  17693. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17694. protected _dumpPropertiesCode(): string;
  17695. }
  17696. }
  17697. declare module "babylonjs/Materials/Node/nodeMaterial" {
  17698. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17699. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  17700. import { Scene } from "babylonjs/scene";
  17701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17702. import { Matrix } from "babylonjs/Maths/math.vector";
  17703. import { Mesh } from "babylonjs/Meshes/mesh";
  17704. import { Engine } from "babylonjs/Engines/engine";
  17705. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17706. import { Observable } from "babylonjs/Misc/observable";
  17707. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17708. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17709. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  17710. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17711. import { Nullable } from "babylonjs/types";
  17712. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  17713. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  17714. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  17715. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  17716. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  17717. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  17718. import { Effect } from "babylonjs/Materials/effect";
  17719. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  17720. import { Camera } from "babylonjs/Cameras/camera";
  17721. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  17722. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17723. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17724. /**
  17725. * Interface used to configure the node material editor
  17726. */
  17727. export interface INodeMaterialEditorOptions {
  17728. /** Define the URl to load node editor script */
  17729. editorURL?: string;
  17730. }
  17731. /** @hidden */
  17732. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17733. NORMAL: boolean;
  17734. TANGENT: boolean;
  17735. UV1: boolean;
  17736. /** BONES */
  17737. NUM_BONE_INFLUENCERS: number;
  17738. BonesPerMesh: number;
  17739. BONETEXTURE: boolean;
  17740. /** MORPH TARGETS */
  17741. MORPHTARGETS: boolean;
  17742. MORPHTARGETS_NORMAL: boolean;
  17743. MORPHTARGETS_TANGENT: boolean;
  17744. MORPHTARGETS_UV: boolean;
  17745. NUM_MORPH_INFLUENCERS: number;
  17746. /** IMAGE PROCESSING */
  17747. IMAGEPROCESSING: boolean;
  17748. VIGNETTE: boolean;
  17749. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17750. VIGNETTEBLENDMODEOPAQUE: boolean;
  17751. TONEMAPPING: boolean;
  17752. TONEMAPPING_ACES: boolean;
  17753. CONTRAST: boolean;
  17754. EXPOSURE: boolean;
  17755. COLORCURVES: boolean;
  17756. COLORGRADING: boolean;
  17757. COLORGRADING3D: boolean;
  17758. SAMPLER3DGREENDEPTH: boolean;
  17759. SAMPLER3DBGRMAP: boolean;
  17760. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17761. /** MISC. */
  17762. BUMPDIRECTUV: number;
  17763. constructor();
  17764. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17765. }
  17766. /**
  17767. * Class used to configure NodeMaterial
  17768. */
  17769. export interface INodeMaterialOptions {
  17770. /**
  17771. * Defines if blocks should emit comments
  17772. */
  17773. emitComments: boolean;
  17774. }
  17775. /**
  17776. * Class used to create a node based material built by assembling shader blocks
  17777. */
  17778. export class NodeMaterial extends PushMaterial {
  17779. private static _BuildIdGenerator;
  17780. private _options;
  17781. private _vertexCompilationState;
  17782. private _fragmentCompilationState;
  17783. private _sharedData;
  17784. private _buildId;
  17785. private _buildWasSuccessful;
  17786. private _cachedWorldViewMatrix;
  17787. private _cachedWorldViewProjectionMatrix;
  17788. private _optimizers;
  17789. private _animationFrame;
  17790. /** Define the Url to load node editor script */
  17791. static EditorURL: string;
  17792. /** Define the Url to load snippets */
  17793. static SnippetUrl: string;
  17794. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17795. static IgnoreTexturesAtLoadTime: boolean;
  17796. private BJSNODEMATERIALEDITOR;
  17797. /** Get the inspector from bundle or global */
  17798. private _getGlobalNodeMaterialEditor;
  17799. /**
  17800. * Snippet ID if the material was created from the snippet server
  17801. */
  17802. snippetId: string;
  17803. /**
  17804. * Gets or sets data used by visual editor
  17805. * @see https://nme.babylonjs.com
  17806. */
  17807. editorData: any;
  17808. /**
  17809. * 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)
  17810. */
  17811. ignoreAlpha: boolean;
  17812. /**
  17813. * Defines the maximum number of lights that can be used in the material
  17814. */
  17815. maxSimultaneousLights: number;
  17816. /**
  17817. * Observable raised when the material is built
  17818. */
  17819. onBuildObservable: Observable<NodeMaterial>;
  17820. /**
  17821. * Gets or sets the root nodes of the material vertex shader
  17822. */
  17823. _vertexOutputNodes: NodeMaterialBlock[];
  17824. /**
  17825. * Gets or sets the root nodes of the material fragment (pixel) shader
  17826. */
  17827. _fragmentOutputNodes: NodeMaterialBlock[];
  17828. /** Gets or sets options to control the node material overall behavior */
  17829. get options(): INodeMaterialOptions;
  17830. set options(options: INodeMaterialOptions);
  17831. /**
  17832. * Default configuration related to image processing available in the standard Material.
  17833. */
  17834. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17835. /**
  17836. * Gets the image processing configuration used either in this material.
  17837. */
  17838. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17839. /**
  17840. * Sets the Default image processing configuration used either in the this material.
  17841. *
  17842. * If sets to null, the scene one is in use.
  17843. */
  17844. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17845. /**
  17846. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17847. */
  17848. attachedBlocks: NodeMaterialBlock[];
  17849. /**
  17850. * Specifies the mode of the node material
  17851. * @hidden
  17852. */
  17853. _mode: NodeMaterialModes;
  17854. /**
  17855. * Gets the mode property
  17856. */
  17857. get mode(): NodeMaterialModes;
  17858. /**
  17859. * A free comment about the material
  17860. */
  17861. comment: string;
  17862. /**
  17863. * Create a new node based material
  17864. * @param name defines the material name
  17865. * @param scene defines the hosting scene
  17866. * @param options defines creation option
  17867. */
  17868. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17869. /**
  17870. * Gets the current class name of the material e.g. "NodeMaterial"
  17871. * @returns the class name
  17872. */
  17873. getClassName(): string;
  17874. /**
  17875. * Keep track of the image processing observer to allow dispose and replace.
  17876. */
  17877. private _imageProcessingObserver;
  17878. /**
  17879. * Attaches a new image processing configuration to the Standard Material.
  17880. * @param configuration
  17881. */
  17882. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17883. /**
  17884. * Get a block by its name
  17885. * @param name defines the name of the block to retrieve
  17886. * @returns the required block or null if not found
  17887. */
  17888. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17889. /**
  17890. * Get a block by its name
  17891. * @param predicate defines the predicate used to find the good candidate
  17892. * @returns the required block or null if not found
  17893. */
  17894. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17895. /**
  17896. * Get an input block by its name
  17897. * @param predicate defines the predicate used to find the good candidate
  17898. * @returns the required input block or null if not found
  17899. */
  17900. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17901. /**
  17902. * Gets the list of input blocks attached to this material
  17903. * @returns an array of InputBlocks
  17904. */
  17905. getInputBlocks(): InputBlock[];
  17906. /**
  17907. * Adds a new optimizer to the list of optimizers
  17908. * @param optimizer defines the optimizers to add
  17909. * @returns the current material
  17910. */
  17911. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17912. /**
  17913. * Remove an optimizer from the list of optimizers
  17914. * @param optimizer defines the optimizers to remove
  17915. * @returns the current material
  17916. */
  17917. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17918. /**
  17919. * Add a new block to the list of output nodes
  17920. * @param node defines the node to add
  17921. * @returns the current material
  17922. */
  17923. addOutputNode(node: NodeMaterialBlock): this;
  17924. /**
  17925. * Remove a block from the list of root nodes
  17926. * @param node defines the node to remove
  17927. * @returns the current material
  17928. */
  17929. removeOutputNode(node: NodeMaterialBlock): this;
  17930. private _addVertexOutputNode;
  17931. private _removeVertexOutputNode;
  17932. private _addFragmentOutputNode;
  17933. private _removeFragmentOutputNode;
  17934. /**
  17935. * Specifies if the material will require alpha blending
  17936. * @returns a boolean specifying if alpha blending is needed
  17937. */
  17938. needAlphaBlending(): boolean;
  17939. /**
  17940. * Specifies if this material should be rendered in alpha test mode
  17941. * @returns a boolean specifying if an alpha test is needed.
  17942. */
  17943. needAlphaTesting(): boolean;
  17944. private _initializeBlock;
  17945. private _resetDualBlocks;
  17946. /**
  17947. * Remove a block from the current node material
  17948. * @param block defines the block to remove
  17949. */
  17950. removeBlock(block: NodeMaterialBlock): void;
  17951. /**
  17952. * Build the material and generates the inner effect
  17953. * @param verbose defines if the build should log activity
  17954. */
  17955. build(verbose?: boolean): void;
  17956. /**
  17957. * Runs an otpimization phase to try to improve the shader code
  17958. */
  17959. optimize(): void;
  17960. private _prepareDefinesForAttributes;
  17961. /**
  17962. * Create a post process from the material
  17963. * @param camera The camera to apply the render pass to.
  17964. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17966. * @param engine The engine which the post process will be applied. (default: current engine)
  17967. * @param reusable If the post process can be reused on the same frame. (default: false)
  17968. * @param textureType Type of textures used when performing the post process. (default: 0)
  17969. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  17970. * @returns the post process created
  17971. */
  17972. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  17973. /**
  17974. * Create the post process effect from the material
  17975. * @param postProcess The post process to create the effect for
  17976. */
  17977. createEffectForPostProcess(postProcess: PostProcess): void;
  17978. private _createEffectForPostProcess;
  17979. /**
  17980. * Create a new procedural texture based on this node material
  17981. * @param size defines the size of the texture
  17982. * @param scene defines the hosting scene
  17983. * @returns the new procedural texture attached to this node material
  17984. */
  17985. createProceduralTexture(size: number | {
  17986. width: number;
  17987. height: number;
  17988. layers?: number;
  17989. }, scene: Scene): Nullable<ProceduralTexture>;
  17990. private _createEffectForParticles;
  17991. private _checkInternals;
  17992. /**
  17993. * Create the effect to be used as the custom effect for a particle system
  17994. * @param particleSystem Particle system to create the effect for
  17995. * @param onCompiled defines a function to call when the effect creation is successful
  17996. * @param onError defines a function to call when the effect creation has failed
  17997. */
  17998. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  17999. private _processDefines;
  18000. /**
  18001. * Get if the submesh is ready to be used and all its information available.
  18002. * Child classes can use it to update shaders
  18003. * @param mesh defines the mesh to check
  18004. * @param subMesh defines which submesh to check
  18005. * @param useInstances specifies that instances should be used
  18006. * @returns a boolean indicating that the submesh is ready or not
  18007. */
  18008. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18009. /**
  18010. * Get a string representing the shaders built by the current node graph
  18011. */
  18012. get compiledShaders(): string;
  18013. /**
  18014. * Binds the world matrix to the material
  18015. * @param world defines the world transformation matrix
  18016. */
  18017. bindOnlyWorldMatrix(world: Matrix): void;
  18018. /**
  18019. * Binds the submesh to this material by preparing the effect and shader to draw
  18020. * @param world defines the world transformation matrix
  18021. * @param mesh defines the mesh containing the submesh
  18022. * @param subMesh defines the submesh to bind the material to
  18023. */
  18024. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18025. /**
  18026. * Gets the active textures from the material
  18027. * @returns an array of textures
  18028. */
  18029. getActiveTextures(): BaseTexture[];
  18030. /**
  18031. * Gets the list of texture blocks
  18032. * @returns an array of texture blocks
  18033. */
  18034. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18035. /**
  18036. * Specifies if the material uses a texture
  18037. * @param texture defines the texture to check against the material
  18038. * @returns a boolean specifying if the material uses the texture
  18039. */
  18040. hasTexture(texture: BaseTexture): boolean;
  18041. /**
  18042. * Disposes the material
  18043. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18044. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18045. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18046. */
  18047. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18048. /** Creates the node editor window. */
  18049. private _createNodeEditor;
  18050. /**
  18051. * Launch the node material editor
  18052. * @param config Define the configuration of the editor
  18053. * @return a promise fulfilled when the node editor is visible
  18054. */
  18055. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18056. /**
  18057. * Clear the current material
  18058. */
  18059. clear(): void;
  18060. /**
  18061. * Clear the current material and set it to a default state
  18062. */
  18063. setToDefault(): void;
  18064. /**
  18065. * Clear the current material and set it to a default state for post process
  18066. */
  18067. setToDefaultPostProcess(): void;
  18068. /**
  18069. * Clear the current material and set it to a default state for procedural texture
  18070. */
  18071. setToDefaultProceduralTexture(): void;
  18072. /**
  18073. * Clear the current material and set it to a default state for particle
  18074. */
  18075. setToDefaultParticle(): void;
  18076. /**
  18077. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18078. * @param url defines the url to load from
  18079. * @returns a promise that will fullfil when the material is fully loaded
  18080. */
  18081. loadAsync(url: string): Promise<void>;
  18082. private _gatherBlocks;
  18083. /**
  18084. * Generate a string containing the code declaration required to create an equivalent of this material
  18085. * @returns a string
  18086. */
  18087. generateCode(): string;
  18088. /**
  18089. * Serializes this material in a JSON representation
  18090. * @returns the serialized material object
  18091. */
  18092. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18093. private _restoreConnections;
  18094. /**
  18095. * Clear the current graph and load a new one from a serialization object
  18096. * @param source defines the JSON representation of the material
  18097. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18098. * @param merge defines whether or not the source must be merged or replace the current content
  18099. */
  18100. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18101. /**
  18102. * Makes a duplicate of the current material.
  18103. * @param name - name to use for the new material.
  18104. */
  18105. clone(name: string): NodeMaterial;
  18106. /**
  18107. * Creates a node material from parsed material data
  18108. * @param source defines the JSON representation of the material
  18109. * @param scene defines the hosting scene
  18110. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18111. * @returns a new node material
  18112. */
  18113. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18114. /**
  18115. * Creates a node material from a snippet saved in a remote file
  18116. * @param name defines the name of the material to create
  18117. * @param url defines the url to load from
  18118. * @param scene defines the hosting scene
  18119. * @returns a promise that will resolve to the new node material
  18120. */
  18121. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18122. /**
  18123. * Creates a node material from a snippet saved by the node material editor
  18124. * @param snippetId defines the snippet to load
  18125. * @param scene defines the hosting scene
  18126. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18127. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18128. * @returns a promise that will resolve to the new node material
  18129. */
  18130. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18131. /**
  18132. * Creates a new node material set to default basic configuration
  18133. * @param name defines the name of the material
  18134. * @param scene defines the hosting scene
  18135. * @returns a new NodeMaterial
  18136. */
  18137. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18138. }
  18139. }
  18140. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  18141. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18142. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  18143. import { Nullable } from "babylonjs/types";
  18144. module "babylonjs/Engines/thinEngine" {
  18145. interface ThinEngine {
  18146. /**
  18147. * Unbind a list of render target textures from the webGL context
  18148. * This is used only when drawBuffer extension or webGL2 are active
  18149. * @param textures defines the render target textures to unbind
  18150. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18151. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18152. */
  18153. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18154. /**
  18155. * Create a multi render target texture
  18156. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18157. * @param size defines the size of the texture
  18158. * @param options defines the creation options
  18159. * @returns the cube texture as an InternalTexture
  18160. */
  18161. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18162. /**
  18163. * Update the sample count for a given multiple render target texture
  18164. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18165. * @param textures defines the textures to update
  18166. * @param samples defines the sample count to set
  18167. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18168. */
  18169. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18170. /**
  18171. * Select a subsets of attachments to draw to.
  18172. * @param attachments gl attachments
  18173. */
  18174. bindAttachments(attachments: number[]): void;
  18175. /**
  18176. * Creates a layout object to draw/clear on specific textures in a MRT
  18177. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18178. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18179. */
  18180. buildTextureLayout(textureStatus: boolean[]): number[];
  18181. /**
  18182. * Restores the webgl state to only draw on the main color attachment
  18183. */
  18184. restoreSingleAttachment(): void;
  18185. }
  18186. }
  18187. }
  18188. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  18189. import { Scene } from "babylonjs/scene";
  18190. import { Engine } from "babylonjs/Engines/engine";
  18191. import { Texture } from "babylonjs/Materials/Textures/texture";
  18192. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18193. import "babylonjs/Engines/Extensions/engine.multiRender";
  18194. /**
  18195. * Creation options of the multi render target texture.
  18196. */
  18197. export interface IMultiRenderTargetOptions {
  18198. /**
  18199. * Define if the texture needs to create mip maps after render.
  18200. */
  18201. generateMipMaps?: boolean;
  18202. /**
  18203. * Define the types of all the draw buffers we want to create
  18204. */
  18205. types?: number[];
  18206. /**
  18207. * Define the sampling modes of all the draw buffers we want to create
  18208. */
  18209. samplingModes?: number[];
  18210. /**
  18211. * Define if a depth buffer is required
  18212. */
  18213. generateDepthBuffer?: boolean;
  18214. /**
  18215. * Define if a stencil buffer is required
  18216. */
  18217. generateStencilBuffer?: boolean;
  18218. /**
  18219. * Define if a depth texture is required instead of a depth buffer
  18220. */
  18221. generateDepthTexture?: boolean;
  18222. /**
  18223. * Define the number of desired draw buffers
  18224. */
  18225. textureCount?: number;
  18226. /**
  18227. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18228. */
  18229. doNotChangeAspectRatio?: boolean;
  18230. /**
  18231. * Define the default type of the buffers we are creating
  18232. */
  18233. defaultType?: number;
  18234. }
  18235. /**
  18236. * A multi render target, like a render target provides the ability to render to a texture.
  18237. * Unlike the render target, it can render to several draw buffers in one draw.
  18238. * This is specially interesting in deferred rendering or for any effects requiring more than
  18239. * just one color from a single pass.
  18240. */
  18241. export class MultiRenderTarget extends RenderTargetTexture {
  18242. private _internalTextures;
  18243. private _textures;
  18244. private _multiRenderTargetOptions;
  18245. private _count;
  18246. /**
  18247. * Get if draw buffers are currently supported by the used hardware and browser.
  18248. */
  18249. get isSupported(): boolean;
  18250. /**
  18251. * Get the list of textures generated by the multi render target.
  18252. */
  18253. get textures(): Texture[];
  18254. /**
  18255. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18256. */
  18257. get count(): number;
  18258. /**
  18259. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18260. */
  18261. get depthTexture(): Texture;
  18262. /**
  18263. * Set the wrapping mode on U of all the textures we are rendering to.
  18264. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18265. */
  18266. set wrapU(wrap: number);
  18267. /**
  18268. * Set the wrapping mode on V of all the textures we are rendering to.
  18269. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18270. */
  18271. set wrapV(wrap: number);
  18272. /**
  18273. * Instantiate a new multi render target texture.
  18274. * A multi render target, like a render target provides the ability to render to a texture.
  18275. * Unlike the render target, it can render to several draw buffers in one draw.
  18276. * This is specially interesting in deferred rendering or for any effects requiring more than
  18277. * just one color from a single pass.
  18278. * @param name Define the name of the texture
  18279. * @param size Define the size of the buffers to render to
  18280. * @param count Define the number of target we are rendering into
  18281. * @param scene Define the scene the texture belongs to
  18282. * @param options Define the options used to create the multi render target
  18283. */
  18284. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18285. private _initTypes;
  18286. /** @hidden */
  18287. _rebuild(forceFullRebuild?: boolean): void;
  18288. private _createInternalTextures;
  18289. private _createTextures;
  18290. /**
  18291. * Replaces a texture within the MRT.
  18292. * @param texture The new texture to insert in the MRT
  18293. * @param index The index of the texture to replace
  18294. */
  18295. replaceTexture(texture: Texture, index: number): void;
  18296. /**
  18297. * Define the number of samples used if MSAA is enabled.
  18298. */
  18299. get samples(): number;
  18300. set samples(value: number);
  18301. /**
  18302. * Resize all the textures in the multi render target.
  18303. * Be careful as it will recreate all the data in the new texture.
  18304. * @param size Define the new size
  18305. */
  18306. resize(size: any): void;
  18307. /**
  18308. * Changes the number of render targets in this MRT
  18309. * Be careful as it will recreate all the data in the new texture.
  18310. * @param count new texture count
  18311. * @param options Specifies texture types and sampling modes for new textures
  18312. */
  18313. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18314. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18315. /**
  18316. * Dispose the render targets and their associated resources
  18317. */
  18318. dispose(): void;
  18319. /**
  18320. * Release all the underlying texture used as draw buffers.
  18321. */
  18322. releaseInternalTextures(): void;
  18323. }
  18324. }
  18325. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  18326. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  18327. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  18328. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  18329. /** @hidden */
  18330. export var imageProcessingPixelShader: {
  18331. name: string;
  18332. shader: string;
  18333. };
  18334. }
  18335. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  18336. import { Nullable } from "babylonjs/types";
  18337. import { Color4 } from "babylonjs/Maths/math.color";
  18338. import { Camera } from "babylonjs/Cameras/camera";
  18339. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18340. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  18341. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  18342. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18343. import { Engine } from "babylonjs/Engines/engine";
  18344. import "babylonjs/Shaders/imageProcessing.fragment";
  18345. import "babylonjs/Shaders/postprocess.vertex";
  18346. /**
  18347. * ImageProcessingPostProcess
  18348. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18349. */
  18350. export class ImageProcessingPostProcess extends PostProcess {
  18351. /**
  18352. * Default configuration related to image processing available in the PBR Material.
  18353. */
  18354. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18355. /**
  18356. * Gets the image processing configuration used either in this material.
  18357. */
  18358. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18359. /**
  18360. * Sets the Default image processing configuration used either in the this material.
  18361. *
  18362. * If sets to null, the scene one is in use.
  18363. */
  18364. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18365. /**
  18366. * Keep track of the image processing observer to allow dispose and replace.
  18367. */
  18368. private _imageProcessingObserver;
  18369. /**
  18370. * Attaches a new image processing configuration to the PBR Material.
  18371. * @param configuration
  18372. */
  18373. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18374. /**
  18375. * If the post process is supported.
  18376. */
  18377. get isSupported(): boolean;
  18378. /**
  18379. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18380. */
  18381. get colorCurves(): Nullable<ColorCurves>;
  18382. /**
  18383. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18384. */
  18385. set colorCurves(value: Nullable<ColorCurves>);
  18386. /**
  18387. * Gets wether the color curves effect is enabled.
  18388. */
  18389. get colorCurvesEnabled(): boolean;
  18390. /**
  18391. * Sets wether the color curves effect is enabled.
  18392. */
  18393. set colorCurvesEnabled(value: boolean);
  18394. /**
  18395. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18396. */
  18397. get colorGradingTexture(): Nullable<BaseTexture>;
  18398. /**
  18399. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18400. */
  18401. set colorGradingTexture(value: Nullable<BaseTexture>);
  18402. /**
  18403. * Gets wether the color grading effect is enabled.
  18404. */
  18405. get colorGradingEnabled(): boolean;
  18406. /**
  18407. * Gets wether the color grading effect is enabled.
  18408. */
  18409. set colorGradingEnabled(value: boolean);
  18410. /**
  18411. * Gets exposure used in the effect.
  18412. */
  18413. get exposure(): number;
  18414. /**
  18415. * Sets exposure used in the effect.
  18416. */
  18417. set exposure(value: number);
  18418. /**
  18419. * Gets wether tonemapping is enabled or not.
  18420. */
  18421. get toneMappingEnabled(): boolean;
  18422. /**
  18423. * Sets wether tonemapping is enabled or not
  18424. */
  18425. set toneMappingEnabled(value: boolean);
  18426. /**
  18427. * Gets the type of tone mapping effect.
  18428. */
  18429. get toneMappingType(): number;
  18430. /**
  18431. * Sets the type of tone mapping effect.
  18432. */
  18433. set toneMappingType(value: number);
  18434. /**
  18435. * Gets contrast used in the effect.
  18436. */
  18437. get contrast(): number;
  18438. /**
  18439. * Sets contrast used in the effect.
  18440. */
  18441. set contrast(value: number);
  18442. /**
  18443. * Gets Vignette stretch size.
  18444. */
  18445. get vignetteStretch(): number;
  18446. /**
  18447. * Sets Vignette stretch size.
  18448. */
  18449. set vignetteStretch(value: number);
  18450. /**
  18451. * Gets Vignette centre X Offset.
  18452. */
  18453. get vignetteCentreX(): number;
  18454. /**
  18455. * Sets Vignette centre X Offset.
  18456. */
  18457. set vignetteCentreX(value: number);
  18458. /**
  18459. * Gets Vignette centre Y Offset.
  18460. */
  18461. get vignetteCentreY(): number;
  18462. /**
  18463. * Sets Vignette centre Y Offset.
  18464. */
  18465. set vignetteCentreY(value: number);
  18466. /**
  18467. * Gets Vignette weight or intensity of the vignette effect.
  18468. */
  18469. get vignetteWeight(): number;
  18470. /**
  18471. * Sets Vignette weight or intensity of the vignette effect.
  18472. */
  18473. set vignetteWeight(value: number);
  18474. /**
  18475. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18476. * if vignetteEnabled is set to true.
  18477. */
  18478. get vignetteColor(): Color4;
  18479. /**
  18480. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18481. * if vignetteEnabled is set to true.
  18482. */
  18483. set vignetteColor(value: Color4);
  18484. /**
  18485. * Gets Camera field of view used by the Vignette effect.
  18486. */
  18487. get vignetteCameraFov(): number;
  18488. /**
  18489. * Sets Camera field of view used by the Vignette effect.
  18490. */
  18491. set vignetteCameraFov(value: number);
  18492. /**
  18493. * Gets the vignette blend mode allowing different kind of effect.
  18494. */
  18495. get vignetteBlendMode(): number;
  18496. /**
  18497. * Sets the vignette blend mode allowing different kind of effect.
  18498. */
  18499. set vignetteBlendMode(value: number);
  18500. /**
  18501. * Gets wether the vignette effect is enabled.
  18502. */
  18503. get vignetteEnabled(): boolean;
  18504. /**
  18505. * Sets wether the vignette effect is enabled.
  18506. */
  18507. set vignetteEnabled(value: boolean);
  18508. private _fromLinearSpace;
  18509. /**
  18510. * Gets wether the input of the processing is in Gamma or Linear Space.
  18511. */
  18512. get fromLinearSpace(): boolean;
  18513. /**
  18514. * Sets wether the input of the processing is in Gamma or Linear Space.
  18515. */
  18516. set fromLinearSpace(value: boolean);
  18517. /**
  18518. * Defines cache preventing GC.
  18519. */
  18520. private _defines;
  18521. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18522. /**
  18523. * "ImageProcessingPostProcess"
  18524. * @returns "ImageProcessingPostProcess"
  18525. */
  18526. getClassName(): string;
  18527. /**
  18528. * @hidden
  18529. */
  18530. _updateParameters(): void;
  18531. dispose(camera?: Camera): void;
  18532. }
  18533. }
  18534. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  18535. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18536. /**
  18537. * Interface for defining prepass effects in the prepass post-process pipeline
  18538. */
  18539. export interface PrePassEffectConfiguration {
  18540. /**
  18541. * Name of the effect
  18542. */
  18543. name: string;
  18544. /**
  18545. * Post process to attach for this effect
  18546. */
  18547. postProcess?: PostProcess;
  18548. /**
  18549. * Textures required in the MRT
  18550. */
  18551. texturesRequired: number[];
  18552. /**
  18553. * Is the effect enabled
  18554. */
  18555. enabled: boolean;
  18556. /**
  18557. * Disposes the effect configuration
  18558. */
  18559. dispose?: () => void;
  18560. /**
  18561. * Creates the associated post process
  18562. */
  18563. createPostProcess?: () => PostProcess;
  18564. }
  18565. }
  18566. declare module "babylonjs/Materials/fresnelParameters" {
  18567. import { DeepImmutable } from "babylonjs/types";
  18568. import { Color3 } from "babylonjs/Maths/math.color";
  18569. /**
  18570. * Options to be used when creating a FresnelParameters.
  18571. */
  18572. export type IFresnelParametersCreationOptions = {
  18573. /**
  18574. * Define the color used on edges (grazing angle)
  18575. */
  18576. leftColor?: Color3;
  18577. /**
  18578. * Define the color used on center
  18579. */
  18580. rightColor?: Color3;
  18581. /**
  18582. * Define bias applied to computed fresnel term
  18583. */
  18584. bias?: number;
  18585. /**
  18586. * Defined the power exponent applied to fresnel term
  18587. */
  18588. power?: number;
  18589. /**
  18590. * Define if the fresnel effect is enable or not.
  18591. */
  18592. isEnabled?: boolean;
  18593. };
  18594. /**
  18595. * Serialized format for FresnelParameters.
  18596. */
  18597. export type IFresnelParametersSerialized = {
  18598. /**
  18599. * Define the color used on edges (grazing angle) [as an array]
  18600. */
  18601. leftColor: number[];
  18602. /**
  18603. * Define the color used on center [as an array]
  18604. */
  18605. rightColor: number[];
  18606. /**
  18607. * Define bias applied to computed fresnel term
  18608. */
  18609. bias: number;
  18610. /**
  18611. * Defined the power exponent applied to fresnel term
  18612. */
  18613. power?: number;
  18614. /**
  18615. * Define if the fresnel effect is enable or not.
  18616. */
  18617. isEnabled: boolean;
  18618. };
  18619. /**
  18620. * This represents all the required information to add a fresnel effect on a material:
  18621. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18622. */
  18623. export class FresnelParameters {
  18624. private _isEnabled;
  18625. /**
  18626. * Define if the fresnel effect is enable or not.
  18627. */
  18628. get isEnabled(): boolean;
  18629. set isEnabled(value: boolean);
  18630. /**
  18631. * Define the color used on edges (grazing angle)
  18632. */
  18633. leftColor: Color3;
  18634. /**
  18635. * Define the color used on center
  18636. */
  18637. rightColor: Color3;
  18638. /**
  18639. * Define bias applied to computed fresnel term
  18640. */
  18641. bias: number;
  18642. /**
  18643. * Defined the power exponent applied to fresnel term
  18644. */
  18645. power: number;
  18646. /**
  18647. * Creates a new FresnelParameters object.
  18648. *
  18649. * @param options provide your own settings to optionally to override defaults
  18650. */
  18651. constructor(options?: IFresnelParametersCreationOptions);
  18652. /**
  18653. * Clones the current fresnel and its valuues
  18654. * @returns a clone fresnel configuration
  18655. */
  18656. clone(): FresnelParameters;
  18657. /**
  18658. * Determines equality between FresnelParameters objects
  18659. * @param otherFresnelParameters defines the second operand
  18660. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18661. */
  18662. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18663. /**
  18664. * Serializes the current fresnel parameters to a JSON representation.
  18665. * @return the JSON serialization
  18666. */
  18667. serialize(): IFresnelParametersSerialized;
  18668. /**
  18669. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18670. * @param parsedFresnelParameters Define the JSON representation
  18671. * @returns the parsed parameters
  18672. */
  18673. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18674. }
  18675. }
  18676. declare module "babylonjs/Materials/materialFlags" {
  18677. /**
  18678. * This groups all the flags used to control the materials channel.
  18679. */
  18680. export class MaterialFlags {
  18681. private static _DiffuseTextureEnabled;
  18682. /**
  18683. * Are diffuse textures enabled in the application.
  18684. */
  18685. static get DiffuseTextureEnabled(): boolean;
  18686. static set DiffuseTextureEnabled(value: boolean);
  18687. private static _DetailTextureEnabled;
  18688. /**
  18689. * Are detail textures enabled in the application.
  18690. */
  18691. static get DetailTextureEnabled(): boolean;
  18692. static set DetailTextureEnabled(value: boolean);
  18693. private static _AmbientTextureEnabled;
  18694. /**
  18695. * Are ambient textures enabled in the application.
  18696. */
  18697. static get AmbientTextureEnabled(): boolean;
  18698. static set AmbientTextureEnabled(value: boolean);
  18699. private static _OpacityTextureEnabled;
  18700. /**
  18701. * Are opacity textures enabled in the application.
  18702. */
  18703. static get OpacityTextureEnabled(): boolean;
  18704. static set OpacityTextureEnabled(value: boolean);
  18705. private static _ReflectionTextureEnabled;
  18706. /**
  18707. * Are reflection textures enabled in the application.
  18708. */
  18709. static get ReflectionTextureEnabled(): boolean;
  18710. static set ReflectionTextureEnabled(value: boolean);
  18711. private static _EmissiveTextureEnabled;
  18712. /**
  18713. * Are emissive textures enabled in the application.
  18714. */
  18715. static get EmissiveTextureEnabled(): boolean;
  18716. static set EmissiveTextureEnabled(value: boolean);
  18717. private static _SpecularTextureEnabled;
  18718. /**
  18719. * Are specular textures enabled in the application.
  18720. */
  18721. static get SpecularTextureEnabled(): boolean;
  18722. static set SpecularTextureEnabled(value: boolean);
  18723. private static _BumpTextureEnabled;
  18724. /**
  18725. * Are bump textures enabled in the application.
  18726. */
  18727. static get BumpTextureEnabled(): boolean;
  18728. static set BumpTextureEnabled(value: boolean);
  18729. private static _LightmapTextureEnabled;
  18730. /**
  18731. * Are lightmap textures enabled in the application.
  18732. */
  18733. static get LightmapTextureEnabled(): boolean;
  18734. static set LightmapTextureEnabled(value: boolean);
  18735. private static _RefractionTextureEnabled;
  18736. /**
  18737. * Are refraction textures enabled in the application.
  18738. */
  18739. static get RefractionTextureEnabled(): boolean;
  18740. static set RefractionTextureEnabled(value: boolean);
  18741. private static _ColorGradingTextureEnabled;
  18742. /**
  18743. * Are color grading textures enabled in the application.
  18744. */
  18745. static get ColorGradingTextureEnabled(): boolean;
  18746. static set ColorGradingTextureEnabled(value: boolean);
  18747. private static _FresnelEnabled;
  18748. /**
  18749. * Are fresnels enabled in the application.
  18750. */
  18751. static get FresnelEnabled(): boolean;
  18752. static set FresnelEnabled(value: boolean);
  18753. private static _ClearCoatTextureEnabled;
  18754. /**
  18755. * Are clear coat textures enabled in the application.
  18756. */
  18757. static get ClearCoatTextureEnabled(): boolean;
  18758. static set ClearCoatTextureEnabled(value: boolean);
  18759. private static _ClearCoatBumpTextureEnabled;
  18760. /**
  18761. * Are clear coat bump textures enabled in the application.
  18762. */
  18763. static get ClearCoatBumpTextureEnabled(): boolean;
  18764. static set ClearCoatBumpTextureEnabled(value: boolean);
  18765. private static _ClearCoatTintTextureEnabled;
  18766. /**
  18767. * Are clear coat tint textures enabled in the application.
  18768. */
  18769. static get ClearCoatTintTextureEnabled(): boolean;
  18770. static set ClearCoatTintTextureEnabled(value: boolean);
  18771. private static _SheenTextureEnabled;
  18772. /**
  18773. * Are sheen textures enabled in the application.
  18774. */
  18775. static get SheenTextureEnabled(): boolean;
  18776. static set SheenTextureEnabled(value: boolean);
  18777. private static _AnisotropicTextureEnabled;
  18778. /**
  18779. * Are anisotropic textures enabled in the application.
  18780. */
  18781. static get AnisotropicTextureEnabled(): boolean;
  18782. static set AnisotropicTextureEnabled(value: boolean);
  18783. private static _ThicknessTextureEnabled;
  18784. /**
  18785. * Are thickness textures enabled in the application.
  18786. */
  18787. static get ThicknessTextureEnabled(): boolean;
  18788. static set ThicknessTextureEnabled(value: boolean);
  18789. }
  18790. }
  18791. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  18792. /** @hidden */
  18793. export var defaultFragmentDeclaration: {
  18794. name: string;
  18795. shader: string;
  18796. };
  18797. }
  18798. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  18799. /** @hidden */
  18800. export var defaultUboDeclaration: {
  18801. name: string;
  18802. shader: string;
  18803. };
  18804. }
  18805. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  18806. /** @hidden */
  18807. export var prePassDeclaration: {
  18808. name: string;
  18809. shader: string;
  18810. };
  18811. }
  18812. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  18813. /** @hidden */
  18814. export var lightFragmentDeclaration: {
  18815. name: string;
  18816. shader: string;
  18817. };
  18818. }
  18819. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  18820. /** @hidden */
  18821. export var lightUboDeclaration: {
  18822. name: string;
  18823. shader: string;
  18824. };
  18825. }
  18826. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  18827. /** @hidden */
  18828. export var lightsFragmentFunctions: {
  18829. name: string;
  18830. shader: string;
  18831. };
  18832. }
  18833. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  18834. /** @hidden */
  18835. export var shadowsFragmentFunctions: {
  18836. name: string;
  18837. shader: string;
  18838. };
  18839. }
  18840. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  18841. /** @hidden */
  18842. export var fresnelFunction: {
  18843. name: string;
  18844. shader: string;
  18845. };
  18846. }
  18847. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  18848. /** @hidden */
  18849. export var bumpFragmentMainFunctions: {
  18850. name: string;
  18851. shader: string;
  18852. };
  18853. }
  18854. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  18855. /** @hidden */
  18856. export var bumpFragmentFunctions: {
  18857. name: string;
  18858. shader: string;
  18859. };
  18860. }
  18861. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  18862. /** @hidden */
  18863. export var logDepthDeclaration: {
  18864. name: string;
  18865. shader: string;
  18866. };
  18867. }
  18868. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  18869. /** @hidden */
  18870. export var fogFragmentDeclaration: {
  18871. name: string;
  18872. shader: string;
  18873. };
  18874. }
  18875. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  18876. /** @hidden */
  18877. export var bumpFragment: {
  18878. name: string;
  18879. shader: string;
  18880. };
  18881. }
  18882. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  18883. /** @hidden */
  18884. export var depthPrePass: {
  18885. name: string;
  18886. shader: string;
  18887. };
  18888. }
  18889. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  18890. /** @hidden */
  18891. export var lightFragment: {
  18892. name: string;
  18893. shader: string;
  18894. };
  18895. }
  18896. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  18897. /** @hidden */
  18898. export var logDepthFragment: {
  18899. name: string;
  18900. shader: string;
  18901. };
  18902. }
  18903. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  18904. /** @hidden */
  18905. export var fogFragment: {
  18906. name: string;
  18907. shader: string;
  18908. };
  18909. }
  18910. declare module "babylonjs/Shaders/default.fragment" {
  18911. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  18912. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  18913. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  18914. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  18915. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  18916. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  18917. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  18918. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  18919. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  18920. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  18921. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  18922. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  18923. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  18924. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  18925. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  18926. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  18927. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  18928. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  18929. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  18930. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  18931. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  18932. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  18933. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  18934. /** @hidden */
  18935. export var defaultPixelShader: {
  18936. name: string;
  18937. shader: string;
  18938. };
  18939. }
  18940. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  18941. /** @hidden */
  18942. export var defaultVertexDeclaration: {
  18943. name: string;
  18944. shader: string;
  18945. };
  18946. }
  18947. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  18948. /** @hidden */
  18949. export var bonesDeclaration: {
  18950. name: string;
  18951. shader: string;
  18952. };
  18953. }
  18954. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  18955. /** @hidden */
  18956. export var instancesDeclaration: {
  18957. name: string;
  18958. shader: string;
  18959. };
  18960. }
  18961. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  18962. /** @hidden */
  18963. export var prePassVertexDeclaration: {
  18964. name: string;
  18965. shader: string;
  18966. };
  18967. }
  18968. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  18969. /** @hidden */
  18970. export var bumpVertexDeclaration: {
  18971. name: string;
  18972. shader: string;
  18973. };
  18974. }
  18975. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  18976. /** @hidden */
  18977. export var fogVertexDeclaration: {
  18978. name: string;
  18979. shader: string;
  18980. };
  18981. }
  18982. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  18983. /** @hidden */
  18984. export var morphTargetsVertexGlobalDeclaration: {
  18985. name: string;
  18986. shader: string;
  18987. };
  18988. }
  18989. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  18990. /** @hidden */
  18991. export var morphTargetsVertexDeclaration: {
  18992. name: string;
  18993. shader: string;
  18994. };
  18995. }
  18996. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  18997. /** @hidden */
  18998. export var morphTargetsVertex: {
  18999. name: string;
  19000. shader: string;
  19001. };
  19002. }
  19003. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  19004. /** @hidden */
  19005. export var instancesVertex: {
  19006. name: string;
  19007. shader: string;
  19008. };
  19009. }
  19010. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  19011. /** @hidden */
  19012. export var bonesVertex: {
  19013. name: string;
  19014. shader: string;
  19015. };
  19016. }
  19017. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  19018. /** @hidden */
  19019. export var prePassVertex: {
  19020. name: string;
  19021. shader: string;
  19022. };
  19023. }
  19024. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  19025. /** @hidden */
  19026. export var bumpVertex: {
  19027. name: string;
  19028. shader: string;
  19029. };
  19030. }
  19031. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  19032. /** @hidden */
  19033. export var fogVertex: {
  19034. name: string;
  19035. shader: string;
  19036. };
  19037. }
  19038. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  19039. /** @hidden */
  19040. export var shadowsVertex: {
  19041. name: string;
  19042. shader: string;
  19043. };
  19044. }
  19045. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  19046. /** @hidden */
  19047. export var pointCloudVertex: {
  19048. name: string;
  19049. shader: string;
  19050. };
  19051. }
  19052. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  19053. /** @hidden */
  19054. export var logDepthVertex: {
  19055. name: string;
  19056. shader: string;
  19057. };
  19058. }
  19059. declare module "babylonjs/Shaders/default.vertex" {
  19060. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  19061. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19062. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19063. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19064. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19065. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  19066. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  19067. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19068. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  19069. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  19070. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  19071. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  19072. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  19073. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19074. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  19075. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19076. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19077. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  19078. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  19079. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19080. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  19081. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  19082. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  19083. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  19084. /** @hidden */
  19085. export var defaultVertexShader: {
  19086. name: string;
  19087. shader: string;
  19088. };
  19089. }
  19090. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  19091. import { Nullable } from "babylonjs/types";
  19092. import { Scene } from "babylonjs/scene";
  19093. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19094. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19095. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19096. /**
  19097. * @hidden
  19098. */
  19099. export interface IMaterialDetailMapDefines {
  19100. DETAIL: boolean;
  19101. DETAILDIRECTUV: number;
  19102. DETAIL_NORMALBLENDMETHOD: number;
  19103. /** @hidden */
  19104. _areTexturesDirty: boolean;
  19105. }
  19106. /**
  19107. * Define the code related to the detail map parameters of a material
  19108. *
  19109. * Inspired from:
  19110. * 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
  19111. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19112. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19113. */
  19114. export class DetailMapConfiguration {
  19115. private _texture;
  19116. /**
  19117. * The detail texture of the material.
  19118. */
  19119. texture: Nullable<BaseTexture>;
  19120. /**
  19121. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19122. * Bigger values mean stronger blending
  19123. */
  19124. diffuseBlendLevel: number;
  19125. /**
  19126. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19127. * Bigger values mean stronger blending. Only used with PBR materials
  19128. */
  19129. roughnessBlendLevel: number;
  19130. /**
  19131. * Defines how strong the bump effect from the detail map is
  19132. * Bigger values mean stronger effect
  19133. */
  19134. bumpLevel: number;
  19135. private _normalBlendMethod;
  19136. /**
  19137. * The method used to blend the bump and detail normals together
  19138. */
  19139. normalBlendMethod: number;
  19140. private _isEnabled;
  19141. /**
  19142. * Enable or disable the detail map on this material
  19143. */
  19144. isEnabled: boolean;
  19145. /** @hidden */
  19146. private _internalMarkAllSubMeshesAsTexturesDirty;
  19147. /** @hidden */
  19148. _markAllSubMeshesAsTexturesDirty(): void;
  19149. /**
  19150. * Instantiate a new detail map
  19151. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19152. */
  19153. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19154. /**
  19155. * Gets whether the submesh is ready to be used or not.
  19156. * @param defines the list of "defines" to update.
  19157. * @param scene defines the scene the material belongs to.
  19158. * @returns - boolean indicating that the submesh is ready or not.
  19159. */
  19160. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19161. /**
  19162. * Update the defines for detail map usage
  19163. * @param defines the list of "defines" to update.
  19164. * @param scene defines the scene the material belongs to.
  19165. */
  19166. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19167. /**
  19168. * Binds the material data.
  19169. * @param uniformBuffer defines the Uniform buffer to fill in.
  19170. * @param scene defines the scene the material belongs to.
  19171. * @param isFrozen defines whether the material is frozen or not.
  19172. */
  19173. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19174. /**
  19175. * Checks to see if a texture is used in the material.
  19176. * @param texture - Base texture to use.
  19177. * @returns - Boolean specifying if a texture is used in the material.
  19178. */
  19179. hasTexture(texture: BaseTexture): boolean;
  19180. /**
  19181. * Returns an array of the actively used textures.
  19182. * @param activeTextures Array of BaseTextures
  19183. */
  19184. getActiveTextures(activeTextures: BaseTexture[]): void;
  19185. /**
  19186. * Returns the animatable textures.
  19187. * @param animatables Array of animatable textures.
  19188. */
  19189. getAnimatables(animatables: IAnimatable[]): void;
  19190. /**
  19191. * Disposes the resources of the material.
  19192. * @param forceDisposeTextures - Forces the disposal of all textures.
  19193. */
  19194. dispose(forceDisposeTextures?: boolean): void;
  19195. /**
  19196. * Get the current class name useful for serialization or dynamic coding.
  19197. * @returns "DetailMap"
  19198. */
  19199. getClassName(): string;
  19200. /**
  19201. * Add the required uniforms to the current list.
  19202. * @param uniforms defines the current uniform list.
  19203. */
  19204. static AddUniforms(uniforms: string[]): void;
  19205. /**
  19206. * Add the required samplers to the current list.
  19207. * @param samplers defines the current sampler list.
  19208. */
  19209. static AddSamplers(samplers: string[]): void;
  19210. /**
  19211. * Add the required uniforms to the current buffer.
  19212. * @param uniformBuffer defines the current uniform buffer.
  19213. */
  19214. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19215. /**
  19216. * Makes a duplicate of the current instance into another one.
  19217. * @param detailMap define the instance where to copy the info
  19218. */
  19219. copyTo(detailMap: DetailMapConfiguration): void;
  19220. /**
  19221. * Serializes this detail map instance
  19222. * @returns - An object with the serialized instance.
  19223. */
  19224. serialize(): any;
  19225. /**
  19226. * Parses a detail map setting from a serialized object.
  19227. * @param source - Serialized object.
  19228. * @param scene Defines the scene we are parsing for
  19229. * @param rootUrl Defines the rootUrl to load from
  19230. */
  19231. parse(source: any, scene: Scene, rootUrl: string): void;
  19232. }
  19233. }
  19234. declare module "babylonjs/Materials/standardMaterial" {
  19235. import { SmartArray } from "babylonjs/Misc/smartArray";
  19236. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19237. import { Nullable } from "babylonjs/types";
  19238. import { Scene } from "babylonjs/scene";
  19239. import { Matrix } from "babylonjs/Maths/math.vector";
  19240. import { Color3 } from "babylonjs/Maths/math.color";
  19241. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19243. import { Mesh } from "babylonjs/Meshes/mesh";
  19244. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  19245. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19246. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  19247. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  19248. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  19249. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  19250. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19251. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19252. import "babylonjs/Shaders/default.fragment";
  19253. import "babylonjs/Shaders/default.vertex";
  19254. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  19255. /** @hidden */
  19256. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19257. MAINUV1: boolean;
  19258. MAINUV2: boolean;
  19259. DIFFUSE: boolean;
  19260. DIFFUSEDIRECTUV: number;
  19261. DETAIL: boolean;
  19262. DETAILDIRECTUV: number;
  19263. DETAIL_NORMALBLENDMETHOD: number;
  19264. AMBIENT: boolean;
  19265. AMBIENTDIRECTUV: number;
  19266. OPACITY: boolean;
  19267. OPACITYDIRECTUV: number;
  19268. OPACITYRGB: boolean;
  19269. REFLECTION: boolean;
  19270. EMISSIVE: boolean;
  19271. EMISSIVEDIRECTUV: number;
  19272. SPECULAR: boolean;
  19273. SPECULARDIRECTUV: number;
  19274. BUMP: boolean;
  19275. BUMPDIRECTUV: number;
  19276. PARALLAX: boolean;
  19277. PARALLAXOCCLUSION: boolean;
  19278. SPECULAROVERALPHA: boolean;
  19279. CLIPPLANE: boolean;
  19280. CLIPPLANE2: boolean;
  19281. CLIPPLANE3: boolean;
  19282. CLIPPLANE4: boolean;
  19283. CLIPPLANE5: boolean;
  19284. CLIPPLANE6: boolean;
  19285. ALPHATEST: boolean;
  19286. DEPTHPREPASS: boolean;
  19287. ALPHAFROMDIFFUSE: boolean;
  19288. POINTSIZE: boolean;
  19289. FOG: boolean;
  19290. SPECULARTERM: boolean;
  19291. DIFFUSEFRESNEL: boolean;
  19292. OPACITYFRESNEL: boolean;
  19293. REFLECTIONFRESNEL: boolean;
  19294. REFRACTIONFRESNEL: boolean;
  19295. EMISSIVEFRESNEL: boolean;
  19296. FRESNEL: boolean;
  19297. NORMAL: boolean;
  19298. UV1: boolean;
  19299. UV2: boolean;
  19300. VERTEXCOLOR: boolean;
  19301. VERTEXALPHA: boolean;
  19302. NUM_BONE_INFLUENCERS: number;
  19303. BonesPerMesh: number;
  19304. BONETEXTURE: boolean;
  19305. BONES_VELOCITY_ENABLED: boolean;
  19306. INSTANCES: boolean;
  19307. THIN_INSTANCES: boolean;
  19308. GLOSSINESS: boolean;
  19309. ROUGHNESS: boolean;
  19310. EMISSIVEASILLUMINATION: boolean;
  19311. LINKEMISSIVEWITHDIFFUSE: boolean;
  19312. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19313. LIGHTMAP: boolean;
  19314. LIGHTMAPDIRECTUV: number;
  19315. OBJECTSPACE_NORMALMAP: boolean;
  19316. USELIGHTMAPASSHADOWMAP: boolean;
  19317. REFLECTIONMAP_3D: boolean;
  19318. REFLECTIONMAP_SPHERICAL: boolean;
  19319. REFLECTIONMAP_PLANAR: boolean;
  19320. REFLECTIONMAP_CUBIC: boolean;
  19321. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19322. REFLECTIONMAP_PROJECTION: boolean;
  19323. REFLECTIONMAP_SKYBOX: boolean;
  19324. REFLECTIONMAP_EXPLICIT: boolean;
  19325. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19326. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19327. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19328. INVERTCUBICMAP: boolean;
  19329. LOGARITHMICDEPTH: boolean;
  19330. REFRACTION: boolean;
  19331. REFRACTIONMAP_3D: boolean;
  19332. REFLECTIONOVERALPHA: boolean;
  19333. TWOSIDEDLIGHTING: boolean;
  19334. SHADOWFLOAT: boolean;
  19335. MORPHTARGETS: boolean;
  19336. MORPHTARGETS_NORMAL: boolean;
  19337. MORPHTARGETS_TANGENT: boolean;
  19338. MORPHTARGETS_UV: boolean;
  19339. NUM_MORPH_INFLUENCERS: number;
  19340. NONUNIFORMSCALING: boolean;
  19341. PREMULTIPLYALPHA: boolean;
  19342. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19343. ALPHABLEND: boolean;
  19344. PREPASS: boolean;
  19345. PREPASS_IRRADIANCE: boolean;
  19346. PREPASS_IRRADIANCE_INDEX: number;
  19347. PREPASS_ALBEDO: boolean;
  19348. PREPASS_ALBEDO_INDEX: number;
  19349. PREPASS_DEPTHNORMAL: boolean;
  19350. PREPASS_DEPTHNORMAL_INDEX: number;
  19351. PREPASS_POSITION: boolean;
  19352. PREPASS_POSITION_INDEX: number;
  19353. PREPASS_VELOCITY: boolean;
  19354. PREPASS_VELOCITY_INDEX: number;
  19355. PREPASS_REFLECTIVITY: boolean;
  19356. PREPASS_REFLECTIVITY_INDEX: number;
  19357. SCENE_MRT_COUNT: number;
  19358. RGBDLIGHTMAP: boolean;
  19359. RGBDREFLECTION: boolean;
  19360. RGBDREFRACTION: boolean;
  19361. IMAGEPROCESSING: boolean;
  19362. VIGNETTE: boolean;
  19363. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19364. VIGNETTEBLENDMODEOPAQUE: boolean;
  19365. TONEMAPPING: boolean;
  19366. TONEMAPPING_ACES: boolean;
  19367. CONTRAST: boolean;
  19368. COLORCURVES: boolean;
  19369. COLORGRADING: boolean;
  19370. COLORGRADING3D: boolean;
  19371. SAMPLER3DGREENDEPTH: boolean;
  19372. SAMPLER3DBGRMAP: boolean;
  19373. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19374. MULTIVIEW: boolean;
  19375. /**
  19376. * If the reflection texture on this material is in linear color space
  19377. * @hidden
  19378. */
  19379. IS_REFLECTION_LINEAR: boolean;
  19380. /**
  19381. * If the refraction texture on this material is in linear color space
  19382. * @hidden
  19383. */
  19384. IS_REFRACTION_LINEAR: boolean;
  19385. EXPOSURE: boolean;
  19386. constructor();
  19387. setReflectionMode(modeToEnable: string): void;
  19388. }
  19389. /**
  19390. * This is the default material used in Babylon. It is the best trade off between quality
  19391. * and performances.
  19392. * @see https://doc.babylonjs.com/babylon101/materials
  19393. */
  19394. export class StandardMaterial extends PushMaterial {
  19395. private _diffuseTexture;
  19396. /**
  19397. * The basic texture of the material as viewed under a light.
  19398. */
  19399. diffuseTexture: Nullable<BaseTexture>;
  19400. private _ambientTexture;
  19401. /**
  19402. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19403. */
  19404. ambientTexture: Nullable<BaseTexture>;
  19405. private _opacityTexture;
  19406. /**
  19407. * Define the transparency of the material from a texture.
  19408. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19409. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19410. */
  19411. opacityTexture: Nullable<BaseTexture>;
  19412. private _reflectionTexture;
  19413. /**
  19414. * Define the texture used to display the reflection.
  19415. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19416. */
  19417. reflectionTexture: Nullable<BaseTexture>;
  19418. private _emissiveTexture;
  19419. /**
  19420. * Define texture of the material as if self lit.
  19421. * This will be mixed in the final result even in the absence of light.
  19422. */
  19423. emissiveTexture: Nullable<BaseTexture>;
  19424. private _specularTexture;
  19425. /**
  19426. * Define how the color and intensity of the highlight given by the light in the material.
  19427. */
  19428. specularTexture: Nullable<BaseTexture>;
  19429. private _bumpTexture;
  19430. /**
  19431. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19432. * 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.
  19433. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19434. */
  19435. bumpTexture: Nullable<BaseTexture>;
  19436. private _lightmapTexture;
  19437. /**
  19438. * Complex lighting can be computationally expensive to compute at runtime.
  19439. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19440. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19441. */
  19442. lightmapTexture: Nullable<BaseTexture>;
  19443. private _refractionTexture;
  19444. /**
  19445. * Define the texture used to display the refraction.
  19446. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19447. */
  19448. refractionTexture: Nullable<BaseTexture>;
  19449. /**
  19450. * The color of the material lit by the environmental background lighting.
  19451. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19452. */
  19453. ambientColor: Color3;
  19454. /**
  19455. * The basic color of the material as viewed under a light.
  19456. */
  19457. diffuseColor: Color3;
  19458. /**
  19459. * Define how the color and intensity of the highlight given by the light in the material.
  19460. */
  19461. specularColor: Color3;
  19462. /**
  19463. * Define the color of the material as if self lit.
  19464. * This will be mixed in the final result even in the absence of light.
  19465. */
  19466. emissiveColor: Color3;
  19467. /**
  19468. * Defines how sharp are the highlights in the material.
  19469. * The bigger the value the sharper giving a more glossy feeling to the result.
  19470. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19471. */
  19472. specularPower: number;
  19473. private _useAlphaFromDiffuseTexture;
  19474. /**
  19475. * Does the transparency come from the diffuse texture alpha channel.
  19476. */
  19477. useAlphaFromDiffuseTexture: boolean;
  19478. private _useEmissiveAsIllumination;
  19479. /**
  19480. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19481. */
  19482. useEmissiveAsIllumination: boolean;
  19483. private _linkEmissiveWithDiffuse;
  19484. /**
  19485. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19486. * the emissive level when the final color is close to one.
  19487. */
  19488. linkEmissiveWithDiffuse: boolean;
  19489. private _useSpecularOverAlpha;
  19490. /**
  19491. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19492. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19493. */
  19494. useSpecularOverAlpha: boolean;
  19495. private _useReflectionOverAlpha;
  19496. /**
  19497. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19498. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19499. */
  19500. useReflectionOverAlpha: boolean;
  19501. private _disableLighting;
  19502. /**
  19503. * Does lights from the scene impacts this material.
  19504. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19505. */
  19506. disableLighting: boolean;
  19507. private _useObjectSpaceNormalMap;
  19508. /**
  19509. * Allows using an object space normal map (instead of tangent space).
  19510. */
  19511. useObjectSpaceNormalMap: boolean;
  19512. private _useParallax;
  19513. /**
  19514. * Is parallax enabled or not.
  19515. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19516. */
  19517. useParallax: boolean;
  19518. private _useParallaxOcclusion;
  19519. /**
  19520. * Is parallax occlusion enabled or not.
  19521. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19522. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19523. */
  19524. useParallaxOcclusion: boolean;
  19525. /**
  19526. * 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.
  19527. */
  19528. parallaxScaleBias: number;
  19529. private _roughness;
  19530. /**
  19531. * Helps to define how blurry the reflections should appears in the material.
  19532. */
  19533. roughness: number;
  19534. /**
  19535. * In case of refraction, define the value of the index of refraction.
  19536. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19537. */
  19538. indexOfRefraction: number;
  19539. /**
  19540. * Invert the refraction texture alongside the y axis.
  19541. * It can be useful with procedural textures or probe for instance.
  19542. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19543. */
  19544. invertRefractionY: boolean;
  19545. /**
  19546. * Defines the alpha limits in alpha test mode.
  19547. */
  19548. alphaCutOff: number;
  19549. private _useLightmapAsShadowmap;
  19550. /**
  19551. * In case of light mapping, define whether the map contains light or shadow informations.
  19552. */
  19553. useLightmapAsShadowmap: boolean;
  19554. private _diffuseFresnelParameters;
  19555. /**
  19556. * Define the diffuse fresnel parameters of the material.
  19557. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19558. */
  19559. diffuseFresnelParameters: FresnelParameters;
  19560. private _opacityFresnelParameters;
  19561. /**
  19562. * Define the opacity fresnel parameters of the material.
  19563. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19564. */
  19565. opacityFresnelParameters: FresnelParameters;
  19566. private _reflectionFresnelParameters;
  19567. /**
  19568. * Define the reflection fresnel parameters of the material.
  19569. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19570. */
  19571. reflectionFresnelParameters: FresnelParameters;
  19572. private _refractionFresnelParameters;
  19573. /**
  19574. * Define the refraction fresnel parameters of the material.
  19575. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19576. */
  19577. refractionFresnelParameters: FresnelParameters;
  19578. private _emissiveFresnelParameters;
  19579. /**
  19580. * Define the emissive fresnel parameters of the material.
  19581. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19582. */
  19583. emissiveFresnelParameters: FresnelParameters;
  19584. private _useReflectionFresnelFromSpecular;
  19585. /**
  19586. * If true automatically deducts the fresnels values from the material specularity.
  19587. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19588. */
  19589. useReflectionFresnelFromSpecular: boolean;
  19590. private _useGlossinessFromSpecularMapAlpha;
  19591. /**
  19592. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19593. */
  19594. useGlossinessFromSpecularMapAlpha: boolean;
  19595. private _maxSimultaneousLights;
  19596. /**
  19597. * Defines the maximum number of lights that can be used in the material
  19598. */
  19599. maxSimultaneousLights: number;
  19600. private _invertNormalMapX;
  19601. /**
  19602. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19603. */
  19604. invertNormalMapX: boolean;
  19605. private _invertNormalMapY;
  19606. /**
  19607. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19608. */
  19609. invertNormalMapY: boolean;
  19610. private _twoSidedLighting;
  19611. /**
  19612. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19613. */
  19614. twoSidedLighting: boolean;
  19615. /**
  19616. * Default configuration related to image processing available in the standard Material.
  19617. */
  19618. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19619. /**
  19620. * Gets the image processing configuration used either in this material.
  19621. */
  19622. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19623. /**
  19624. * Sets the Default image processing configuration used either in the this material.
  19625. *
  19626. * If sets to null, the scene one is in use.
  19627. */
  19628. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19629. /**
  19630. * Keep track of the image processing observer to allow dispose and replace.
  19631. */
  19632. private _imageProcessingObserver;
  19633. /**
  19634. * Attaches a new image processing configuration to the Standard Material.
  19635. * @param configuration
  19636. */
  19637. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19638. /**
  19639. * Defines additionnal PrePass parameters for the material.
  19640. */
  19641. readonly prePassConfiguration: PrePassConfiguration;
  19642. /**
  19643. * Gets wether the color curves effect is enabled.
  19644. */
  19645. get cameraColorCurvesEnabled(): boolean;
  19646. /**
  19647. * Sets wether the color curves effect is enabled.
  19648. */
  19649. set cameraColorCurvesEnabled(value: boolean);
  19650. /**
  19651. * Gets wether the color grading effect is enabled.
  19652. */
  19653. get cameraColorGradingEnabled(): boolean;
  19654. /**
  19655. * Gets wether the color grading effect is enabled.
  19656. */
  19657. set cameraColorGradingEnabled(value: boolean);
  19658. /**
  19659. * Gets wether tonemapping is enabled or not.
  19660. */
  19661. get cameraToneMappingEnabled(): boolean;
  19662. /**
  19663. * Sets wether tonemapping is enabled or not
  19664. */
  19665. set cameraToneMappingEnabled(value: boolean);
  19666. /**
  19667. * The camera exposure used on this material.
  19668. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19669. * This corresponds to a photographic exposure.
  19670. */
  19671. get cameraExposure(): number;
  19672. /**
  19673. * The camera exposure used on this material.
  19674. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19675. * This corresponds to a photographic exposure.
  19676. */
  19677. set cameraExposure(value: number);
  19678. /**
  19679. * Gets The camera contrast used on this material.
  19680. */
  19681. get cameraContrast(): number;
  19682. /**
  19683. * Sets The camera contrast used on this material.
  19684. */
  19685. set cameraContrast(value: number);
  19686. /**
  19687. * Gets the Color Grading 2D Lookup Texture.
  19688. */
  19689. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19690. /**
  19691. * Sets the Color Grading 2D Lookup Texture.
  19692. */
  19693. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19694. /**
  19695. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19696. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19697. * 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;
  19698. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19699. */
  19700. get cameraColorCurves(): Nullable<ColorCurves>;
  19701. /**
  19702. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19703. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19704. * 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;
  19705. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19706. */
  19707. set cameraColorCurves(value: Nullable<ColorCurves>);
  19708. /**
  19709. * Can this material render to several textures at once
  19710. */
  19711. get canRenderToMRT(): boolean;
  19712. /**
  19713. * Defines the detail map parameters for the material.
  19714. */
  19715. readonly detailMap: DetailMapConfiguration;
  19716. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19717. protected _worldViewProjectionMatrix: Matrix;
  19718. protected _globalAmbientColor: Color3;
  19719. protected _useLogarithmicDepth: boolean;
  19720. protected _rebuildInParallel: boolean;
  19721. /**
  19722. * Instantiates a new standard material.
  19723. * This is the default material used in Babylon. It is the best trade off between quality
  19724. * and performances.
  19725. * @see https://doc.babylonjs.com/babylon101/materials
  19726. * @param name Define the name of the material in the scene
  19727. * @param scene Define the scene the material belong to
  19728. */
  19729. constructor(name: string, scene: Scene);
  19730. /**
  19731. * Gets a boolean indicating that current material needs to register RTT
  19732. */
  19733. get hasRenderTargetTextures(): boolean;
  19734. /**
  19735. * Gets the current class name of the material e.g. "StandardMaterial"
  19736. * Mainly use in serialization.
  19737. * @returns the class name
  19738. */
  19739. getClassName(): string;
  19740. /**
  19741. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19742. * You can try switching to logarithmic depth.
  19743. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19744. */
  19745. get useLogarithmicDepth(): boolean;
  19746. set useLogarithmicDepth(value: boolean);
  19747. /**
  19748. * Specifies if the material will require alpha blending
  19749. * @returns a boolean specifying if alpha blending is needed
  19750. */
  19751. needAlphaBlending(): boolean;
  19752. /**
  19753. * Specifies if this material should be rendered in alpha test mode
  19754. * @returns a boolean specifying if an alpha test is needed.
  19755. */
  19756. needAlphaTesting(): boolean;
  19757. /**
  19758. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19759. */
  19760. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19761. /**
  19762. * Specifies whether or not there is a usable alpha channel for transparency.
  19763. */
  19764. protected _hasAlphaChannel(): boolean;
  19765. /**
  19766. * Get the texture used for alpha test purpose.
  19767. * @returns the diffuse texture in case of the standard material.
  19768. */
  19769. getAlphaTestTexture(): Nullable<BaseTexture>;
  19770. /**
  19771. * Get if the submesh is ready to be used and all its information available.
  19772. * Child classes can use it to update shaders
  19773. * @param mesh defines the mesh to check
  19774. * @param subMesh defines which submesh to check
  19775. * @param useInstances specifies that instances should be used
  19776. * @returns a boolean indicating that the submesh is ready or not
  19777. */
  19778. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19779. /**
  19780. * Builds the material UBO layouts.
  19781. * Used internally during the effect preparation.
  19782. */
  19783. buildUniformLayout(): void;
  19784. /**
  19785. * Unbinds the material from the mesh
  19786. */
  19787. unbind(): void;
  19788. /**
  19789. * Binds the submesh to this material by preparing the effect and shader to draw
  19790. * @param world defines the world transformation matrix
  19791. * @param mesh defines the mesh containing the submesh
  19792. * @param subMesh defines the submesh to bind the material to
  19793. */
  19794. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19795. /**
  19796. * Get the list of animatables in the material.
  19797. * @returns the list of animatables object used in the material
  19798. */
  19799. getAnimatables(): IAnimatable[];
  19800. /**
  19801. * Gets the active textures from the material
  19802. * @returns an array of textures
  19803. */
  19804. getActiveTextures(): BaseTexture[];
  19805. /**
  19806. * Specifies if the material uses a texture
  19807. * @param texture defines the texture to check against the material
  19808. * @returns a boolean specifying if the material uses the texture
  19809. */
  19810. hasTexture(texture: BaseTexture): boolean;
  19811. /**
  19812. * Disposes the material
  19813. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19814. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19815. */
  19816. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19817. /**
  19818. * Makes a duplicate of the material, and gives it a new name
  19819. * @param name defines the new name for the duplicated material
  19820. * @returns the cloned material
  19821. */
  19822. clone(name: string): StandardMaterial;
  19823. /**
  19824. * Serializes this material in a JSON representation
  19825. * @returns the serialized material object
  19826. */
  19827. serialize(): any;
  19828. /**
  19829. * Creates a standard material from parsed material data
  19830. * @param source defines the JSON representation of the material
  19831. * @param scene defines the hosting scene
  19832. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19833. * @returns a new standard material
  19834. */
  19835. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19836. /**
  19837. * Are diffuse textures enabled in the application.
  19838. */
  19839. static get DiffuseTextureEnabled(): boolean;
  19840. static set DiffuseTextureEnabled(value: boolean);
  19841. /**
  19842. * Are detail textures enabled in the application.
  19843. */
  19844. static get DetailTextureEnabled(): boolean;
  19845. static set DetailTextureEnabled(value: boolean);
  19846. /**
  19847. * Are ambient textures enabled in the application.
  19848. */
  19849. static get AmbientTextureEnabled(): boolean;
  19850. static set AmbientTextureEnabled(value: boolean);
  19851. /**
  19852. * Are opacity textures enabled in the application.
  19853. */
  19854. static get OpacityTextureEnabled(): boolean;
  19855. static set OpacityTextureEnabled(value: boolean);
  19856. /**
  19857. * Are reflection textures enabled in the application.
  19858. */
  19859. static get ReflectionTextureEnabled(): boolean;
  19860. static set ReflectionTextureEnabled(value: boolean);
  19861. /**
  19862. * Are emissive textures enabled in the application.
  19863. */
  19864. static get EmissiveTextureEnabled(): boolean;
  19865. static set EmissiveTextureEnabled(value: boolean);
  19866. /**
  19867. * Are specular textures enabled in the application.
  19868. */
  19869. static get SpecularTextureEnabled(): boolean;
  19870. static set SpecularTextureEnabled(value: boolean);
  19871. /**
  19872. * Are bump textures enabled in the application.
  19873. */
  19874. static get BumpTextureEnabled(): boolean;
  19875. static set BumpTextureEnabled(value: boolean);
  19876. /**
  19877. * Are lightmap textures enabled in the application.
  19878. */
  19879. static get LightmapTextureEnabled(): boolean;
  19880. static set LightmapTextureEnabled(value: boolean);
  19881. /**
  19882. * Are refraction textures enabled in the application.
  19883. */
  19884. static get RefractionTextureEnabled(): boolean;
  19885. static set RefractionTextureEnabled(value: boolean);
  19886. /**
  19887. * Are color grading textures enabled in the application.
  19888. */
  19889. static get ColorGradingTextureEnabled(): boolean;
  19890. static set ColorGradingTextureEnabled(value: boolean);
  19891. /**
  19892. * Are fresnels enabled in the application.
  19893. */
  19894. static get FresnelEnabled(): boolean;
  19895. static set FresnelEnabled(value: boolean);
  19896. }
  19897. }
  19898. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  19899. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19900. /** @hidden */
  19901. export var rgbdDecodePixelShader: {
  19902. name: string;
  19903. shader: string;
  19904. };
  19905. }
  19906. declare module "babylonjs/Misc/rgbdTextureTools" {
  19907. import "babylonjs/Shaders/rgbdDecode.fragment";
  19908. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19909. import { Texture } from "babylonjs/Materials/Textures/texture";
  19910. /**
  19911. * Class used to host RGBD texture specific utilities
  19912. */
  19913. export class RGBDTextureTools {
  19914. /**
  19915. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19916. * @param texture the texture to expand.
  19917. */
  19918. static ExpandRGBDTexture(texture: Texture): void;
  19919. }
  19920. }
  19921. declare module "babylonjs/Misc/brdfTextureTools" {
  19922. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19923. import { Scene } from "babylonjs/scene";
  19924. /**
  19925. * Class used to host texture specific utilities
  19926. */
  19927. export class BRDFTextureTools {
  19928. /**
  19929. * Prevents texture cache collision
  19930. */
  19931. private static _instanceNumber;
  19932. /**
  19933. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  19934. * @param scene defines the hosting scene
  19935. * @returns the environment BRDF texture
  19936. */
  19937. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  19938. private static _environmentBRDFBase64Texture;
  19939. }
  19940. }
  19941. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  19942. import { Nullable } from "babylonjs/types";
  19943. import { Color3 } from "babylonjs/Maths/math.color";
  19944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19945. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19946. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19947. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  19948. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19949. import { Engine } from "babylonjs/Engines/engine";
  19950. import { Scene } from "babylonjs/scene";
  19951. /**
  19952. * @hidden
  19953. */
  19954. export interface IMaterialClearCoatDefines {
  19955. CLEARCOAT: boolean;
  19956. CLEARCOAT_DEFAULTIOR: boolean;
  19957. CLEARCOAT_TEXTURE: boolean;
  19958. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  19959. CLEARCOAT_TEXTUREDIRECTUV: number;
  19960. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  19961. CLEARCOAT_BUMP: boolean;
  19962. CLEARCOAT_BUMPDIRECTUV: number;
  19963. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19964. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19965. CLEARCOAT_REMAP_F0: boolean;
  19966. CLEARCOAT_TINT: boolean;
  19967. CLEARCOAT_TINT_TEXTURE: boolean;
  19968. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  19969. /** @hidden */
  19970. _areTexturesDirty: boolean;
  19971. }
  19972. /**
  19973. * Define the code related to the clear coat parameters of the pbr material.
  19974. */
  19975. export class PBRClearCoatConfiguration {
  19976. /**
  19977. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19978. * The default fits with a polyurethane material.
  19979. * @hidden
  19980. */
  19981. static readonly _DefaultIndexOfRefraction: number;
  19982. private _isEnabled;
  19983. /**
  19984. * Defines if the clear coat is enabled in the material.
  19985. */
  19986. isEnabled: boolean;
  19987. /**
  19988. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  19989. */
  19990. intensity: number;
  19991. /**
  19992. * Defines the clear coat layer roughness.
  19993. */
  19994. roughness: number;
  19995. private _indexOfRefraction;
  19996. /**
  19997. * Defines the index of refraction of the clear coat.
  19998. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19999. * The default fits with a polyurethane material.
  20000. * Changing the default value is more performance intensive.
  20001. */
  20002. indexOfRefraction: number;
  20003. private _texture;
  20004. /**
  20005. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20006. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20007. * if textureRoughness is not empty, else no texture roughness is used
  20008. */
  20009. texture: Nullable<BaseTexture>;
  20010. private _useRoughnessFromMainTexture;
  20011. /**
  20012. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20013. * If false, the green channel from textureRoughness is used for roughness
  20014. */
  20015. useRoughnessFromMainTexture: boolean;
  20016. private _textureRoughness;
  20017. /**
  20018. * Stores the clear coat roughness in a texture (green channel)
  20019. * Not used if useRoughnessFromMainTexture is true
  20020. */
  20021. textureRoughness: Nullable<BaseTexture>;
  20022. private _remapF0OnInterfaceChange;
  20023. /**
  20024. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20025. */
  20026. remapF0OnInterfaceChange: boolean;
  20027. private _bumpTexture;
  20028. /**
  20029. * Define the clear coat specific bump texture.
  20030. */
  20031. bumpTexture: Nullable<BaseTexture>;
  20032. private _isTintEnabled;
  20033. /**
  20034. * Defines if the clear coat tint is enabled in the material.
  20035. */
  20036. isTintEnabled: boolean;
  20037. /**
  20038. * Defines the clear coat tint of the material.
  20039. * This is only use if tint is enabled
  20040. */
  20041. tintColor: Color3;
  20042. /**
  20043. * Defines the distance at which the tint color should be found in the
  20044. * clear coat media.
  20045. * This is only use if tint is enabled
  20046. */
  20047. tintColorAtDistance: number;
  20048. /**
  20049. * Defines the clear coat layer thickness.
  20050. * This is only use if tint is enabled
  20051. */
  20052. tintThickness: number;
  20053. private _tintTexture;
  20054. /**
  20055. * Stores the clear tint values in a texture.
  20056. * rgb is tint
  20057. * a is a thickness factor
  20058. */
  20059. tintTexture: Nullable<BaseTexture>;
  20060. /** @hidden */
  20061. private _internalMarkAllSubMeshesAsTexturesDirty;
  20062. /** @hidden */
  20063. _markAllSubMeshesAsTexturesDirty(): void;
  20064. /**
  20065. * Instantiate a new istance of clear coat configuration.
  20066. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20067. */
  20068. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20069. /**
  20070. * Gets wehter the submesh is ready to be used or not.
  20071. * @param defines the list of "defines" to update.
  20072. * @param scene defines the scene the material belongs to.
  20073. * @param engine defines the engine the material belongs to.
  20074. * @param disableBumpMap defines wether the material disables bump or not.
  20075. * @returns - boolean indicating that the submesh is ready or not.
  20076. */
  20077. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20078. /**
  20079. * Checks to see if a texture is used in the material.
  20080. * @param defines the list of "defines" to update.
  20081. * @param scene defines the scene to the material belongs to.
  20082. */
  20083. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20084. /**
  20085. * Binds the material data.
  20086. * @param uniformBuffer defines the Uniform buffer to fill in.
  20087. * @param scene defines the scene the material belongs to.
  20088. * @param engine defines the engine the material belongs to.
  20089. * @param disableBumpMap defines wether the material disables bump or not.
  20090. * @param isFrozen defines wether the material is frozen or not.
  20091. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20092. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20093. * @param subMesh the submesh to bind data for
  20094. */
  20095. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20096. /**
  20097. * Checks to see if a texture is used in the material.
  20098. * @param texture - Base texture to use.
  20099. * @returns - Boolean specifying if a texture is used in the material.
  20100. */
  20101. hasTexture(texture: BaseTexture): boolean;
  20102. /**
  20103. * Returns an array of the actively used textures.
  20104. * @param activeTextures Array of BaseTextures
  20105. */
  20106. getActiveTextures(activeTextures: BaseTexture[]): void;
  20107. /**
  20108. * Returns the animatable textures.
  20109. * @param animatables Array of animatable textures.
  20110. */
  20111. getAnimatables(animatables: IAnimatable[]): void;
  20112. /**
  20113. * Disposes the resources of the material.
  20114. * @param forceDisposeTextures - Forces the disposal of all textures.
  20115. */
  20116. dispose(forceDisposeTextures?: boolean): void;
  20117. /**
  20118. * Get the current class name of the texture useful for serialization or dynamic coding.
  20119. * @returns "PBRClearCoatConfiguration"
  20120. */
  20121. getClassName(): string;
  20122. /**
  20123. * Add fallbacks to the effect fallbacks list.
  20124. * @param defines defines the Base texture to use.
  20125. * @param fallbacks defines the current fallback list.
  20126. * @param currentRank defines the current fallback rank.
  20127. * @returns the new fallback rank.
  20128. */
  20129. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20130. /**
  20131. * Add the required uniforms to the current list.
  20132. * @param uniforms defines the current uniform list.
  20133. */
  20134. static AddUniforms(uniforms: string[]): void;
  20135. /**
  20136. * Add the required samplers to the current list.
  20137. * @param samplers defines the current sampler list.
  20138. */
  20139. static AddSamplers(samplers: string[]): void;
  20140. /**
  20141. * Add the required uniforms to the current buffer.
  20142. * @param uniformBuffer defines the current uniform buffer.
  20143. */
  20144. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20145. /**
  20146. * Makes a duplicate of the current configuration into another one.
  20147. * @param clearCoatConfiguration define the config where to copy the info
  20148. */
  20149. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20150. /**
  20151. * Serializes this clear coat configuration.
  20152. * @returns - An object with the serialized config.
  20153. */
  20154. serialize(): any;
  20155. /**
  20156. * Parses a anisotropy Configuration from a serialized object.
  20157. * @param source - Serialized object.
  20158. * @param scene Defines the scene we are parsing for
  20159. * @param rootUrl Defines the rootUrl to load from
  20160. */
  20161. parse(source: any, scene: Scene, rootUrl: string): void;
  20162. }
  20163. }
  20164. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  20165. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20167. import { Vector2 } from "babylonjs/Maths/math.vector";
  20168. import { Scene } from "babylonjs/scene";
  20169. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20170. import { Nullable } from "babylonjs/types";
  20171. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20172. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20173. /**
  20174. * @hidden
  20175. */
  20176. export interface IMaterialAnisotropicDefines {
  20177. ANISOTROPIC: boolean;
  20178. ANISOTROPIC_TEXTURE: boolean;
  20179. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20180. MAINUV1: boolean;
  20181. _areTexturesDirty: boolean;
  20182. _needUVs: boolean;
  20183. }
  20184. /**
  20185. * Define the code related to the anisotropic parameters of the pbr material.
  20186. */
  20187. export class PBRAnisotropicConfiguration {
  20188. private _isEnabled;
  20189. /**
  20190. * Defines if the anisotropy is enabled in the material.
  20191. */
  20192. isEnabled: boolean;
  20193. /**
  20194. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20195. */
  20196. intensity: number;
  20197. /**
  20198. * Defines if the effect is along the tangents, bitangents or in between.
  20199. * By default, the effect is "strectching" the highlights along the tangents.
  20200. */
  20201. direction: Vector2;
  20202. private _texture;
  20203. /**
  20204. * Stores the anisotropy values in a texture.
  20205. * rg is direction (like normal from -1 to 1)
  20206. * b is a intensity
  20207. */
  20208. texture: Nullable<BaseTexture>;
  20209. /** @hidden */
  20210. private _internalMarkAllSubMeshesAsTexturesDirty;
  20211. /** @hidden */
  20212. _markAllSubMeshesAsTexturesDirty(): void;
  20213. /**
  20214. * Instantiate a new istance of anisotropy configuration.
  20215. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20216. */
  20217. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20218. /**
  20219. * Specifies that the submesh is ready to be used.
  20220. * @param defines the list of "defines" to update.
  20221. * @param scene defines the scene the material belongs to.
  20222. * @returns - boolean indicating that the submesh is ready or not.
  20223. */
  20224. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20225. /**
  20226. * Checks to see if a texture is used in the material.
  20227. * @param defines the list of "defines" to update.
  20228. * @param mesh the mesh we are preparing the defines for.
  20229. * @param scene defines the scene the material belongs to.
  20230. */
  20231. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20232. /**
  20233. * Binds the material data.
  20234. * @param uniformBuffer defines the Uniform buffer to fill in.
  20235. * @param scene defines the scene the material belongs to.
  20236. * @param isFrozen defines wether the material is frozen or not.
  20237. */
  20238. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20239. /**
  20240. * Checks to see if a texture is used in the material.
  20241. * @param texture - Base texture to use.
  20242. * @returns - Boolean specifying if a texture is used in the material.
  20243. */
  20244. hasTexture(texture: BaseTexture): boolean;
  20245. /**
  20246. * Returns an array of the actively used textures.
  20247. * @param activeTextures Array of BaseTextures
  20248. */
  20249. getActiveTextures(activeTextures: BaseTexture[]): void;
  20250. /**
  20251. * Returns the animatable textures.
  20252. * @param animatables Array of animatable textures.
  20253. */
  20254. getAnimatables(animatables: IAnimatable[]): void;
  20255. /**
  20256. * Disposes the resources of the material.
  20257. * @param forceDisposeTextures - Forces the disposal of all textures.
  20258. */
  20259. dispose(forceDisposeTextures?: boolean): void;
  20260. /**
  20261. * Get the current class name of the texture useful for serialization or dynamic coding.
  20262. * @returns "PBRAnisotropicConfiguration"
  20263. */
  20264. getClassName(): string;
  20265. /**
  20266. * Add fallbacks to the effect fallbacks list.
  20267. * @param defines defines the Base texture to use.
  20268. * @param fallbacks defines the current fallback list.
  20269. * @param currentRank defines the current fallback rank.
  20270. * @returns the new fallback rank.
  20271. */
  20272. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20273. /**
  20274. * Add the required uniforms to the current list.
  20275. * @param uniforms defines the current uniform list.
  20276. */
  20277. static AddUniforms(uniforms: string[]): void;
  20278. /**
  20279. * Add the required uniforms to the current buffer.
  20280. * @param uniformBuffer defines the current uniform buffer.
  20281. */
  20282. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20283. /**
  20284. * Add the required samplers to the current list.
  20285. * @param samplers defines the current sampler list.
  20286. */
  20287. static AddSamplers(samplers: string[]): void;
  20288. /**
  20289. * Makes a duplicate of the current configuration into another one.
  20290. * @param anisotropicConfiguration define the config where to copy the info
  20291. */
  20292. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20293. /**
  20294. * Serializes this anisotropy configuration.
  20295. * @returns - An object with the serialized config.
  20296. */
  20297. serialize(): any;
  20298. /**
  20299. * Parses a anisotropy Configuration from a serialized object.
  20300. * @param source - Serialized object.
  20301. * @param scene Defines the scene we are parsing for
  20302. * @param rootUrl Defines the rootUrl to load from
  20303. */
  20304. parse(source: any, scene: Scene, rootUrl: string): void;
  20305. }
  20306. }
  20307. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  20308. import { Scene } from "babylonjs/scene";
  20309. /**
  20310. * @hidden
  20311. */
  20312. export interface IMaterialBRDFDefines {
  20313. BRDF_V_HEIGHT_CORRELATED: boolean;
  20314. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20315. SPHERICAL_HARMONICS: boolean;
  20316. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20317. /** @hidden */
  20318. _areMiscDirty: boolean;
  20319. }
  20320. /**
  20321. * Define the code related to the BRDF parameters of the pbr material.
  20322. */
  20323. export class PBRBRDFConfiguration {
  20324. /**
  20325. * Default value used for the energy conservation.
  20326. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20327. */
  20328. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20329. /**
  20330. * Default value used for the Smith Visibility Height Correlated mode.
  20331. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20332. */
  20333. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20334. /**
  20335. * Default value used for the IBL diffuse part.
  20336. * This can help switching back to the polynomials mode globally which is a tiny bit
  20337. * less GPU intensive at the drawback of a lower quality.
  20338. */
  20339. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20340. /**
  20341. * Default value used for activating energy conservation for the specular workflow.
  20342. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20343. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20344. */
  20345. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20346. private _useEnergyConservation;
  20347. /**
  20348. * Defines if the material uses energy conservation.
  20349. */
  20350. useEnergyConservation: boolean;
  20351. private _useSmithVisibilityHeightCorrelated;
  20352. /**
  20353. * LEGACY Mode set to false
  20354. * Defines if the material uses height smith correlated visibility term.
  20355. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20356. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20357. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20358. * Not relying on height correlated will also disable energy conservation.
  20359. */
  20360. useSmithVisibilityHeightCorrelated: boolean;
  20361. private _useSphericalHarmonics;
  20362. /**
  20363. * LEGACY Mode set to false
  20364. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20365. * diffuse part of the IBL.
  20366. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20367. * to the ground truth.
  20368. */
  20369. useSphericalHarmonics: boolean;
  20370. private _useSpecularGlossinessInputEnergyConservation;
  20371. /**
  20372. * Defines if the material uses energy conservation, when the specular workflow is active.
  20373. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20374. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20375. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20376. */
  20377. useSpecularGlossinessInputEnergyConservation: boolean;
  20378. /** @hidden */
  20379. private _internalMarkAllSubMeshesAsMiscDirty;
  20380. /** @hidden */
  20381. _markAllSubMeshesAsMiscDirty(): void;
  20382. /**
  20383. * Instantiate a new istance of clear coat configuration.
  20384. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20385. */
  20386. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20387. /**
  20388. * Checks to see if a texture is used in the material.
  20389. * @param defines the list of "defines" to update.
  20390. */
  20391. prepareDefines(defines: IMaterialBRDFDefines): void;
  20392. /**
  20393. * Get the current class name of the texture useful for serialization or dynamic coding.
  20394. * @returns "PBRClearCoatConfiguration"
  20395. */
  20396. getClassName(): string;
  20397. /**
  20398. * Makes a duplicate of the current configuration into another one.
  20399. * @param brdfConfiguration define the config where to copy the info
  20400. */
  20401. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20402. /**
  20403. * Serializes this BRDF configuration.
  20404. * @returns - An object with the serialized config.
  20405. */
  20406. serialize(): any;
  20407. /**
  20408. * Parses a anisotropy Configuration from a serialized object.
  20409. * @param source - Serialized object.
  20410. * @param scene Defines the scene we are parsing for
  20411. * @param rootUrl Defines the rootUrl to load from
  20412. */
  20413. parse(source: any, scene: Scene, rootUrl: string): void;
  20414. }
  20415. }
  20416. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  20417. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20418. import { Color3 } from "babylonjs/Maths/math.color";
  20419. import { Scene } from "babylonjs/scene";
  20420. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20421. import { Nullable } from "babylonjs/types";
  20422. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20423. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20424. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20425. /**
  20426. * @hidden
  20427. */
  20428. export interface IMaterialSheenDefines {
  20429. SHEEN: boolean;
  20430. SHEEN_TEXTURE: boolean;
  20431. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20432. SHEEN_TEXTUREDIRECTUV: number;
  20433. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20434. SHEEN_LINKWITHALBEDO: boolean;
  20435. SHEEN_ROUGHNESS: boolean;
  20436. SHEEN_ALBEDOSCALING: boolean;
  20437. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20438. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20439. /** @hidden */
  20440. _areTexturesDirty: boolean;
  20441. }
  20442. /**
  20443. * Define the code related to the Sheen parameters of the pbr material.
  20444. */
  20445. export class PBRSheenConfiguration {
  20446. private _isEnabled;
  20447. /**
  20448. * Defines if the material uses sheen.
  20449. */
  20450. isEnabled: boolean;
  20451. private _linkSheenWithAlbedo;
  20452. /**
  20453. * Defines if the sheen is linked to the sheen color.
  20454. */
  20455. linkSheenWithAlbedo: boolean;
  20456. /**
  20457. * Defines the sheen intensity.
  20458. */
  20459. intensity: number;
  20460. /**
  20461. * Defines the sheen color.
  20462. */
  20463. color: Color3;
  20464. private _texture;
  20465. /**
  20466. * Stores the sheen tint values in a texture.
  20467. * rgb is tint
  20468. * 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)
  20469. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20470. */
  20471. texture: Nullable<BaseTexture>;
  20472. private _useRoughnessFromMainTexture;
  20473. /**
  20474. * Indicates that the alpha channel of the texture property will be used for roughness.
  20475. * Has no effect if the roughness (and texture!) property is not defined
  20476. */
  20477. useRoughnessFromMainTexture: boolean;
  20478. private _roughness;
  20479. /**
  20480. * Defines the sheen roughness.
  20481. * It is not taken into account if linkSheenWithAlbedo is true.
  20482. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20483. */
  20484. roughness: Nullable<number>;
  20485. private _textureRoughness;
  20486. /**
  20487. * Stores the sheen roughness in a texture.
  20488. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20489. */
  20490. textureRoughness: Nullable<BaseTexture>;
  20491. private _albedoScaling;
  20492. /**
  20493. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20494. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20495. * making it easier to setup and tweak the effect
  20496. */
  20497. albedoScaling: boolean;
  20498. /** @hidden */
  20499. private _internalMarkAllSubMeshesAsTexturesDirty;
  20500. /** @hidden */
  20501. _markAllSubMeshesAsTexturesDirty(): void;
  20502. /**
  20503. * Instantiate a new istance of clear coat configuration.
  20504. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20505. */
  20506. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20507. /**
  20508. * Specifies that the submesh is ready to be used.
  20509. * @param defines the list of "defines" to update.
  20510. * @param scene defines the scene the material belongs to.
  20511. * @returns - boolean indicating that the submesh is ready or not.
  20512. */
  20513. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20514. /**
  20515. * Checks to see if a texture is used in the material.
  20516. * @param defines the list of "defines" to update.
  20517. * @param scene defines the scene the material belongs to.
  20518. */
  20519. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20520. /**
  20521. * Binds the material data.
  20522. * @param uniformBuffer defines the Uniform buffer to fill in.
  20523. * @param scene defines the scene the material belongs to.
  20524. * @param isFrozen defines wether the material is frozen or not.
  20525. * @param subMesh the submesh to bind data for
  20526. */
  20527. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20528. /**
  20529. * Checks to see if a texture is used in the material.
  20530. * @param texture - Base texture to use.
  20531. * @returns - Boolean specifying if a texture is used in the material.
  20532. */
  20533. hasTexture(texture: BaseTexture): boolean;
  20534. /**
  20535. * Returns an array of the actively used textures.
  20536. * @param activeTextures Array of BaseTextures
  20537. */
  20538. getActiveTextures(activeTextures: BaseTexture[]): void;
  20539. /**
  20540. * Returns the animatable textures.
  20541. * @param animatables Array of animatable textures.
  20542. */
  20543. getAnimatables(animatables: IAnimatable[]): void;
  20544. /**
  20545. * Disposes the resources of the material.
  20546. * @param forceDisposeTextures - Forces the disposal of all textures.
  20547. */
  20548. dispose(forceDisposeTextures?: boolean): void;
  20549. /**
  20550. * Get the current class name of the texture useful for serialization or dynamic coding.
  20551. * @returns "PBRSheenConfiguration"
  20552. */
  20553. getClassName(): string;
  20554. /**
  20555. * Add fallbacks to the effect fallbacks list.
  20556. * @param defines defines the Base texture to use.
  20557. * @param fallbacks defines the current fallback list.
  20558. * @param currentRank defines the current fallback rank.
  20559. * @returns the new fallback rank.
  20560. */
  20561. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20562. /**
  20563. * Add the required uniforms to the current list.
  20564. * @param uniforms defines the current uniform list.
  20565. */
  20566. static AddUniforms(uniforms: string[]): void;
  20567. /**
  20568. * Add the required uniforms to the current buffer.
  20569. * @param uniformBuffer defines the current uniform buffer.
  20570. */
  20571. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20572. /**
  20573. * Add the required samplers to the current list.
  20574. * @param samplers defines the current sampler list.
  20575. */
  20576. static AddSamplers(samplers: string[]): void;
  20577. /**
  20578. * Makes a duplicate of the current configuration into another one.
  20579. * @param sheenConfiguration define the config where to copy the info
  20580. */
  20581. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20582. /**
  20583. * Serializes this BRDF configuration.
  20584. * @returns - An object with the serialized config.
  20585. */
  20586. serialize(): any;
  20587. /**
  20588. * Parses a anisotropy Configuration from a serialized object.
  20589. * @param source - Serialized object.
  20590. * @param scene Defines the scene we are parsing for
  20591. * @param rootUrl Defines the rootUrl to load from
  20592. */
  20593. parse(source: any, scene: Scene, rootUrl: string): void;
  20594. }
  20595. }
  20596. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  20597. import { Nullable } from "babylonjs/types";
  20598. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20599. import { Color3 } from "babylonjs/Maths/math.color";
  20600. import { SmartArray } from "babylonjs/Misc/smartArray";
  20601. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20602. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20603. import { Effect } from "babylonjs/Materials/effect";
  20604. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20605. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20606. import { Engine } from "babylonjs/Engines/engine";
  20607. import { Scene } from "babylonjs/scene";
  20608. /**
  20609. * @hidden
  20610. */
  20611. export interface IMaterialSubSurfaceDefines {
  20612. SUBSURFACE: boolean;
  20613. SS_REFRACTION: boolean;
  20614. SS_TRANSLUCENCY: boolean;
  20615. SS_SCATTERING: boolean;
  20616. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20617. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20618. SS_REFRACTIONMAP_3D: boolean;
  20619. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20620. SS_LODINREFRACTIONALPHA: boolean;
  20621. SS_GAMMAREFRACTION: boolean;
  20622. SS_RGBDREFRACTION: boolean;
  20623. SS_LINEARSPECULARREFRACTION: boolean;
  20624. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20625. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20626. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20627. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20628. /** @hidden */
  20629. _areTexturesDirty: boolean;
  20630. }
  20631. /**
  20632. * Define the code related to the sub surface parameters of the pbr material.
  20633. */
  20634. export class PBRSubSurfaceConfiguration {
  20635. private _isRefractionEnabled;
  20636. /**
  20637. * Defines if the refraction is enabled in the material.
  20638. */
  20639. isRefractionEnabled: boolean;
  20640. private _isTranslucencyEnabled;
  20641. /**
  20642. * Defines if the translucency is enabled in the material.
  20643. */
  20644. isTranslucencyEnabled: boolean;
  20645. private _isScatteringEnabled;
  20646. /**
  20647. * Defines if the sub surface scattering is enabled in the material.
  20648. */
  20649. isScatteringEnabled: boolean;
  20650. private _scatteringDiffusionProfileIndex;
  20651. /**
  20652. * Diffusion profile for subsurface scattering.
  20653. * Useful for better scattering in the skins or foliages.
  20654. */
  20655. get scatteringDiffusionProfile(): Nullable<Color3>;
  20656. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20657. /**
  20658. * Defines the refraction intensity of the material.
  20659. * The refraction when enabled replaces the Diffuse part of the material.
  20660. * The intensity helps transitionning between diffuse and refraction.
  20661. */
  20662. refractionIntensity: number;
  20663. /**
  20664. * Defines the translucency intensity of the material.
  20665. * When translucency has been enabled, this defines how much of the "translucency"
  20666. * is addded to the diffuse part of the material.
  20667. */
  20668. translucencyIntensity: number;
  20669. /**
  20670. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20671. */
  20672. useAlbedoToTintRefraction: boolean;
  20673. private _thicknessTexture;
  20674. /**
  20675. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20676. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20677. * 0 would mean minimumThickness
  20678. * 1 would mean maximumThickness
  20679. * The other channels might be use as a mask to vary the different effects intensity.
  20680. */
  20681. thicknessTexture: Nullable<BaseTexture>;
  20682. private _refractionTexture;
  20683. /**
  20684. * Defines the texture to use for refraction.
  20685. */
  20686. refractionTexture: Nullable<BaseTexture>;
  20687. private _indexOfRefraction;
  20688. /**
  20689. * Index of refraction of the material base layer.
  20690. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20691. *
  20692. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20693. *
  20694. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20695. */
  20696. indexOfRefraction: number;
  20697. private _volumeIndexOfRefraction;
  20698. /**
  20699. * Index of refraction of the material's volume.
  20700. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20701. *
  20702. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20703. * the volume will use the same IOR as the surface.
  20704. */
  20705. get volumeIndexOfRefraction(): number;
  20706. set volumeIndexOfRefraction(value: number);
  20707. private _invertRefractionY;
  20708. /**
  20709. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20710. */
  20711. invertRefractionY: boolean;
  20712. private _linkRefractionWithTransparency;
  20713. /**
  20714. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20715. * Materials half opaque for instance using refraction could benefit from this control.
  20716. */
  20717. linkRefractionWithTransparency: boolean;
  20718. /**
  20719. * Defines the minimum thickness stored in the thickness map.
  20720. * If no thickness map is defined, this value will be used to simulate thickness.
  20721. */
  20722. minimumThickness: number;
  20723. /**
  20724. * Defines the maximum thickness stored in the thickness map.
  20725. */
  20726. maximumThickness: number;
  20727. /**
  20728. * Defines the volume tint of the material.
  20729. * This is used for both translucency and scattering.
  20730. */
  20731. tintColor: Color3;
  20732. /**
  20733. * Defines the distance at which the tint color should be found in the media.
  20734. * This is used for refraction only.
  20735. */
  20736. tintColorAtDistance: number;
  20737. /**
  20738. * Defines how far each channel transmit through the media.
  20739. * It is defined as a color to simplify it selection.
  20740. */
  20741. diffusionDistance: Color3;
  20742. private _useMaskFromThicknessTexture;
  20743. /**
  20744. * Stores the intensity of the different subsurface effects in the thickness texture.
  20745. * * the green channel is the translucency intensity.
  20746. * * the blue channel is the scattering intensity.
  20747. * * the alpha channel is the refraction intensity.
  20748. */
  20749. useMaskFromThicknessTexture: boolean;
  20750. private _scene;
  20751. private _useMaskFromThicknessTextureGltf;
  20752. /**
  20753. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20754. * matches the channel-packing that is used by glTF.
  20755. * * the red channel is the transmission/translucency intensity.
  20756. * * the green channel is the thickness.
  20757. */
  20758. useMaskFromThicknessTextureGltf: boolean;
  20759. /** @hidden */
  20760. private _internalMarkAllSubMeshesAsTexturesDirty;
  20761. private _internalMarkScenePrePassDirty;
  20762. /** @hidden */
  20763. _markAllSubMeshesAsTexturesDirty(): void;
  20764. /** @hidden */
  20765. _markScenePrePassDirty(): void;
  20766. /**
  20767. * Instantiate a new istance of sub surface configuration.
  20768. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20769. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20770. * @param scene The scene
  20771. */
  20772. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20773. /**
  20774. * Gets wehter the submesh is ready to be used or not.
  20775. * @param defines the list of "defines" to update.
  20776. * @param scene defines the scene the material belongs to.
  20777. * @returns - boolean indicating that the submesh is ready or not.
  20778. */
  20779. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20780. /**
  20781. * Checks to see if a texture is used in the material.
  20782. * @param defines the list of "defines" to update.
  20783. * @param scene defines the scene to the material belongs to.
  20784. */
  20785. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20786. /**
  20787. * Binds the material data.
  20788. * @param uniformBuffer defines the Uniform buffer to fill in.
  20789. * @param scene defines the scene the material belongs to.
  20790. * @param engine defines the engine the material belongs to.
  20791. * @param isFrozen defines whether the material is frozen or not.
  20792. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20793. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20794. */
  20795. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20796. /**
  20797. * Unbinds the material from the mesh.
  20798. * @param activeEffect defines the effect that should be unbound from.
  20799. * @returns true if unbound, otherwise false
  20800. */
  20801. unbind(activeEffect: Effect): boolean;
  20802. /**
  20803. * Returns the texture used for refraction or null if none is used.
  20804. * @param scene defines the scene the material belongs to.
  20805. * @returns - Refraction texture if present. If no refraction texture and refraction
  20806. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20807. */
  20808. private _getRefractionTexture;
  20809. /**
  20810. * Returns true if alpha blending should be disabled.
  20811. */
  20812. get disableAlphaBlending(): boolean;
  20813. /**
  20814. * Fills the list of render target textures.
  20815. * @param renderTargets the list of render targets to update
  20816. */
  20817. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20818. /**
  20819. * Checks to see if a texture is used in the material.
  20820. * @param texture - Base texture to use.
  20821. * @returns - Boolean specifying if a texture is used in the material.
  20822. */
  20823. hasTexture(texture: BaseTexture): boolean;
  20824. /**
  20825. * Gets a boolean indicating that current material needs to register RTT
  20826. * @returns true if this uses a render target otherwise false.
  20827. */
  20828. hasRenderTargetTextures(): boolean;
  20829. /**
  20830. * Returns an array of the actively used textures.
  20831. * @param activeTextures Array of BaseTextures
  20832. */
  20833. getActiveTextures(activeTextures: BaseTexture[]): void;
  20834. /**
  20835. * Returns the animatable textures.
  20836. * @param animatables Array of animatable textures.
  20837. */
  20838. getAnimatables(animatables: IAnimatable[]): void;
  20839. /**
  20840. * Disposes the resources of the material.
  20841. * @param forceDisposeTextures - Forces the disposal of all textures.
  20842. */
  20843. dispose(forceDisposeTextures?: boolean): void;
  20844. /**
  20845. * Get the current class name of the texture useful for serialization or dynamic coding.
  20846. * @returns "PBRSubSurfaceConfiguration"
  20847. */
  20848. getClassName(): string;
  20849. /**
  20850. * Add fallbacks to the effect fallbacks list.
  20851. * @param defines defines the Base texture to use.
  20852. * @param fallbacks defines the current fallback list.
  20853. * @param currentRank defines the current fallback rank.
  20854. * @returns the new fallback rank.
  20855. */
  20856. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20857. /**
  20858. * Add the required uniforms to the current list.
  20859. * @param uniforms defines the current uniform list.
  20860. */
  20861. static AddUniforms(uniforms: string[]): void;
  20862. /**
  20863. * Add the required samplers to the current list.
  20864. * @param samplers defines the current sampler list.
  20865. */
  20866. static AddSamplers(samplers: string[]): void;
  20867. /**
  20868. * Add the required uniforms to the current buffer.
  20869. * @param uniformBuffer defines the current uniform buffer.
  20870. */
  20871. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20872. /**
  20873. * Makes a duplicate of the current configuration into another one.
  20874. * @param configuration define the config where to copy the info
  20875. */
  20876. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20877. /**
  20878. * Serializes this Sub Surface configuration.
  20879. * @returns - An object with the serialized config.
  20880. */
  20881. serialize(): any;
  20882. /**
  20883. * Parses a anisotropy Configuration from a serialized object.
  20884. * @param source - Serialized object.
  20885. * @param scene Defines the scene we are parsing for
  20886. * @param rootUrl Defines the rootUrl to load from
  20887. */
  20888. parse(source: any, scene: Scene, rootUrl: string): void;
  20889. }
  20890. }
  20891. declare module "babylonjs/Maths/sphericalPolynomial" {
  20892. import { Vector3 } from "babylonjs/Maths/math.vector";
  20893. import { Color3 } from "babylonjs/Maths/math.color";
  20894. /**
  20895. * Class representing spherical harmonics coefficients to the 3rd degree
  20896. */
  20897. export class SphericalHarmonics {
  20898. /**
  20899. * Defines whether or not the harmonics have been prescaled for rendering.
  20900. */
  20901. preScaled: boolean;
  20902. /**
  20903. * The l0,0 coefficients of the spherical harmonics
  20904. */
  20905. l00: Vector3;
  20906. /**
  20907. * The l1,-1 coefficients of the spherical harmonics
  20908. */
  20909. l1_1: Vector3;
  20910. /**
  20911. * The l1,0 coefficients of the spherical harmonics
  20912. */
  20913. l10: Vector3;
  20914. /**
  20915. * The l1,1 coefficients of the spherical harmonics
  20916. */
  20917. l11: Vector3;
  20918. /**
  20919. * The l2,-2 coefficients of the spherical harmonics
  20920. */
  20921. l2_2: Vector3;
  20922. /**
  20923. * The l2,-1 coefficients of the spherical harmonics
  20924. */
  20925. l2_1: Vector3;
  20926. /**
  20927. * The l2,0 coefficients of the spherical harmonics
  20928. */
  20929. l20: Vector3;
  20930. /**
  20931. * The l2,1 coefficients of the spherical harmonics
  20932. */
  20933. l21: Vector3;
  20934. /**
  20935. * The l2,2 coefficients of the spherical harmonics
  20936. */
  20937. l22: Vector3;
  20938. /**
  20939. * Adds a light to the spherical harmonics
  20940. * @param direction the direction of the light
  20941. * @param color the color of the light
  20942. * @param deltaSolidAngle the delta solid angle of the light
  20943. */
  20944. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20945. /**
  20946. * Scales the spherical harmonics by the given amount
  20947. * @param scale the amount to scale
  20948. */
  20949. scaleInPlace(scale: number): void;
  20950. /**
  20951. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20952. *
  20953. * ```
  20954. * E_lm = A_l * L_lm
  20955. * ```
  20956. *
  20957. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20958. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20959. * the scaling factors are given in equation 9.
  20960. */
  20961. convertIncidentRadianceToIrradiance(): void;
  20962. /**
  20963. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20964. *
  20965. * ```
  20966. * L = (1/pi) * E * rho
  20967. * ```
  20968. *
  20969. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20970. */
  20971. convertIrradianceToLambertianRadiance(): void;
  20972. /**
  20973. * Integrates the reconstruction coefficients directly in to the SH preventing further
  20974. * required operations at run time.
  20975. *
  20976. * This is simply done by scaling back the SH with Ylm constants parameter.
  20977. * The trigonometric part being applied by the shader at run time.
  20978. */
  20979. preScaleForRendering(): void;
  20980. /**
  20981. * Constructs a spherical harmonics from an array.
  20982. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20983. * @returns the spherical harmonics
  20984. */
  20985. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20986. /**
  20987. * Gets the spherical harmonics from polynomial
  20988. * @param polynomial the spherical polynomial
  20989. * @returns the spherical harmonics
  20990. */
  20991. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20992. }
  20993. /**
  20994. * Class representing spherical polynomial coefficients to the 3rd degree
  20995. */
  20996. export class SphericalPolynomial {
  20997. private _harmonics;
  20998. /**
  20999. * The spherical harmonics used to create the polynomials.
  21000. */
  21001. get preScaledHarmonics(): SphericalHarmonics;
  21002. /**
  21003. * The x coefficients of the spherical polynomial
  21004. */
  21005. x: Vector3;
  21006. /**
  21007. * The y coefficients of the spherical polynomial
  21008. */
  21009. y: Vector3;
  21010. /**
  21011. * The z coefficients of the spherical polynomial
  21012. */
  21013. z: Vector3;
  21014. /**
  21015. * The xx coefficients of the spherical polynomial
  21016. */
  21017. xx: Vector3;
  21018. /**
  21019. * The yy coefficients of the spherical polynomial
  21020. */
  21021. yy: Vector3;
  21022. /**
  21023. * The zz coefficients of the spherical polynomial
  21024. */
  21025. zz: Vector3;
  21026. /**
  21027. * The xy coefficients of the spherical polynomial
  21028. */
  21029. xy: Vector3;
  21030. /**
  21031. * The yz coefficients of the spherical polynomial
  21032. */
  21033. yz: Vector3;
  21034. /**
  21035. * The zx coefficients of the spherical polynomial
  21036. */
  21037. zx: Vector3;
  21038. /**
  21039. * Adds an ambient color to the spherical polynomial
  21040. * @param color the color to add
  21041. */
  21042. addAmbient(color: Color3): void;
  21043. /**
  21044. * Scales the spherical polynomial by the given amount
  21045. * @param scale the amount to scale
  21046. */
  21047. scaleInPlace(scale: number): void;
  21048. /**
  21049. * Gets the spherical polynomial from harmonics
  21050. * @param harmonics the spherical harmonics
  21051. * @returns the spherical polynomial
  21052. */
  21053. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21054. /**
  21055. * Constructs a spherical polynomial from an array.
  21056. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21057. * @returns the spherical polynomial
  21058. */
  21059. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21060. }
  21061. }
  21062. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  21063. import { Nullable } from "babylonjs/types";
  21064. /**
  21065. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21066. */
  21067. export interface CubeMapInfo {
  21068. /**
  21069. * The pixel array for the front face.
  21070. * This is stored in format, left to right, up to down format.
  21071. */
  21072. front: Nullable<ArrayBufferView>;
  21073. /**
  21074. * The pixel array for the back face.
  21075. * This is stored in format, left to right, up to down format.
  21076. */
  21077. back: Nullable<ArrayBufferView>;
  21078. /**
  21079. * The pixel array for the left face.
  21080. * This is stored in format, left to right, up to down format.
  21081. */
  21082. left: Nullable<ArrayBufferView>;
  21083. /**
  21084. * The pixel array for the right face.
  21085. * This is stored in format, left to right, up to down format.
  21086. */
  21087. right: Nullable<ArrayBufferView>;
  21088. /**
  21089. * The pixel array for the up face.
  21090. * This is stored in format, left to right, up to down format.
  21091. */
  21092. up: Nullable<ArrayBufferView>;
  21093. /**
  21094. * The pixel array for the down face.
  21095. * This is stored in format, left to right, up to down format.
  21096. */
  21097. down: Nullable<ArrayBufferView>;
  21098. /**
  21099. * The size of the cubemap stored.
  21100. *
  21101. * Each faces will be size * size pixels.
  21102. */
  21103. size: number;
  21104. /**
  21105. * The format of the texture.
  21106. *
  21107. * RGBA, RGB.
  21108. */
  21109. format: number;
  21110. /**
  21111. * The type of the texture data.
  21112. *
  21113. * UNSIGNED_INT, FLOAT.
  21114. */
  21115. type: number;
  21116. /**
  21117. * Specifies whether the texture is in gamma space.
  21118. */
  21119. gammaSpace: boolean;
  21120. }
  21121. /**
  21122. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21123. */
  21124. export class PanoramaToCubeMapTools {
  21125. private static FACE_LEFT;
  21126. private static FACE_RIGHT;
  21127. private static FACE_FRONT;
  21128. private static FACE_BACK;
  21129. private static FACE_DOWN;
  21130. private static FACE_UP;
  21131. /**
  21132. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21133. *
  21134. * @param float32Array The source data.
  21135. * @param inputWidth The width of the input panorama.
  21136. * @param inputHeight The height of the input panorama.
  21137. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21138. * @return The cubemap data
  21139. */
  21140. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21141. private static CreateCubemapTexture;
  21142. private static CalcProjectionSpherical;
  21143. }
  21144. }
  21145. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  21146. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21147. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21148. import { Nullable } from "babylonjs/types";
  21149. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  21150. /**
  21151. * Helper class dealing with the extraction of spherical polynomial dataArray
  21152. * from a cube map.
  21153. */
  21154. export class CubeMapToSphericalPolynomialTools {
  21155. private static FileFaces;
  21156. /**
  21157. * Converts a texture to the according Spherical Polynomial data.
  21158. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21159. *
  21160. * @param texture The texture to extract the information from.
  21161. * @return The Spherical Polynomial data.
  21162. */
  21163. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  21164. /**
  21165. * Converts a cubemap to the according Spherical Polynomial data.
  21166. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21167. *
  21168. * @param cubeInfo The Cube map to extract the information from.
  21169. * @return The Spherical Polynomial data.
  21170. */
  21171. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21172. }
  21173. }
  21174. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  21175. import { Nullable } from "babylonjs/types";
  21176. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21177. module "babylonjs/Materials/Textures/baseTexture" {
  21178. interface BaseTexture {
  21179. /**
  21180. * Get the polynomial representation of the texture data.
  21181. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21182. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21183. */
  21184. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21185. }
  21186. }
  21187. }
  21188. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  21189. /** @hidden */
  21190. export var pbrFragmentDeclaration: {
  21191. name: string;
  21192. shader: string;
  21193. };
  21194. }
  21195. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  21196. /** @hidden */
  21197. export var pbrUboDeclaration: {
  21198. name: string;
  21199. shader: string;
  21200. };
  21201. }
  21202. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  21203. /** @hidden */
  21204. export var pbrFragmentExtraDeclaration: {
  21205. name: string;
  21206. shader: string;
  21207. };
  21208. }
  21209. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  21210. /** @hidden */
  21211. export var pbrFragmentSamplersDeclaration: {
  21212. name: string;
  21213. shader: string;
  21214. };
  21215. }
  21216. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  21217. /** @hidden */
  21218. export var subSurfaceScatteringFunctions: {
  21219. name: string;
  21220. shader: string;
  21221. };
  21222. }
  21223. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  21224. /** @hidden */
  21225. export var importanceSampling: {
  21226. name: string;
  21227. shader: string;
  21228. };
  21229. }
  21230. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  21231. /** @hidden */
  21232. export var pbrHelperFunctions: {
  21233. name: string;
  21234. shader: string;
  21235. };
  21236. }
  21237. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  21238. /** @hidden */
  21239. export var harmonicsFunctions: {
  21240. name: string;
  21241. shader: string;
  21242. };
  21243. }
  21244. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  21245. /** @hidden */
  21246. export var pbrDirectLightingSetupFunctions: {
  21247. name: string;
  21248. shader: string;
  21249. };
  21250. }
  21251. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  21252. /** @hidden */
  21253. export var pbrDirectLightingFalloffFunctions: {
  21254. name: string;
  21255. shader: string;
  21256. };
  21257. }
  21258. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  21259. /** @hidden */
  21260. export var pbrBRDFFunctions: {
  21261. name: string;
  21262. shader: string;
  21263. };
  21264. }
  21265. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  21266. /** @hidden */
  21267. export var hdrFilteringFunctions: {
  21268. name: string;
  21269. shader: string;
  21270. };
  21271. }
  21272. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  21273. /** @hidden */
  21274. export var pbrDirectLightingFunctions: {
  21275. name: string;
  21276. shader: string;
  21277. };
  21278. }
  21279. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  21280. /** @hidden */
  21281. export var pbrIBLFunctions: {
  21282. name: string;
  21283. shader: string;
  21284. };
  21285. }
  21286. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  21287. /** @hidden */
  21288. export var pbrBlockAlbedoOpacity: {
  21289. name: string;
  21290. shader: string;
  21291. };
  21292. }
  21293. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  21294. /** @hidden */
  21295. export var pbrBlockReflectivity: {
  21296. name: string;
  21297. shader: string;
  21298. };
  21299. }
  21300. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  21301. /** @hidden */
  21302. export var pbrBlockAmbientOcclusion: {
  21303. name: string;
  21304. shader: string;
  21305. };
  21306. }
  21307. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  21308. /** @hidden */
  21309. export var pbrBlockAlphaFresnel: {
  21310. name: string;
  21311. shader: string;
  21312. };
  21313. }
  21314. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  21315. /** @hidden */
  21316. export var pbrBlockAnisotropic: {
  21317. name: string;
  21318. shader: string;
  21319. };
  21320. }
  21321. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  21322. /** @hidden */
  21323. export var pbrBlockReflection: {
  21324. name: string;
  21325. shader: string;
  21326. };
  21327. }
  21328. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  21329. /** @hidden */
  21330. export var pbrBlockSheen: {
  21331. name: string;
  21332. shader: string;
  21333. };
  21334. }
  21335. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  21336. /** @hidden */
  21337. export var pbrBlockClearcoat: {
  21338. name: string;
  21339. shader: string;
  21340. };
  21341. }
  21342. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  21343. /** @hidden */
  21344. export var pbrBlockSubSurface: {
  21345. name: string;
  21346. shader: string;
  21347. };
  21348. }
  21349. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  21350. /** @hidden */
  21351. export var pbrBlockNormalGeometric: {
  21352. name: string;
  21353. shader: string;
  21354. };
  21355. }
  21356. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  21357. /** @hidden */
  21358. export var pbrBlockNormalFinal: {
  21359. name: string;
  21360. shader: string;
  21361. };
  21362. }
  21363. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  21364. /** @hidden */
  21365. export var pbrBlockLightmapInit: {
  21366. name: string;
  21367. shader: string;
  21368. };
  21369. }
  21370. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  21371. /** @hidden */
  21372. export var pbrBlockGeometryInfo: {
  21373. name: string;
  21374. shader: string;
  21375. };
  21376. }
  21377. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  21378. /** @hidden */
  21379. export var pbrBlockReflectance0: {
  21380. name: string;
  21381. shader: string;
  21382. };
  21383. }
  21384. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  21385. /** @hidden */
  21386. export var pbrBlockReflectance: {
  21387. name: string;
  21388. shader: string;
  21389. };
  21390. }
  21391. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  21392. /** @hidden */
  21393. export var pbrBlockDirectLighting: {
  21394. name: string;
  21395. shader: string;
  21396. };
  21397. }
  21398. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  21399. /** @hidden */
  21400. export var pbrBlockFinalLitComponents: {
  21401. name: string;
  21402. shader: string;
  21403. };
  21404. }
  21405. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  21406. /** @hidden */
  21407. export var pbrBlockFinalUnlitComponents: {
  21408. name: string;
  21409. shader: string;
  21410. };
  21411. }
  21412. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  21413. /** @hidden */
  21414. export var pbrBlockFinalColorComposition: {
  21415. name: string;
  21416. shader: string;
  21417. };
  21418. }
  21419. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  21420. /** @hidden */
  21421. export var pbrBlockImageProcessing: {
  21422. name: string;
  21423. shader: string;
  21424. };
  21425. }
  21426. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  21427. /** @hidden */
  21428. export var pbrDebug: {
  21429. name: string;
  21430. shader: string;
  21431. };
  21432. }
  21433. declare module "babylonjs/Shaders/pbr.fragment" {
  21434. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  21435. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  21436. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  21437. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  21438. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  21439. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  21440. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  21441. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  21442. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  21443. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  21444. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  21445. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21446. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  21447. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  21448. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  21449. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  21450. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  21451. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  21452. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  21453. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  21454. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  21455. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  21456. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  21457. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  21458. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  21459. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  21460. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21461. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  21462. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  21463. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  21464. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  21465. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  21466. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  21467. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  21468. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  21469. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  21470. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  21471. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  21472. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  21473. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  21474. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  21475. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  21476. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  21477. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  21478. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  21479. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  21480. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  21481. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  21482. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  21483. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  21484. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  21485. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  21486. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  21487. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  21488. /** @hidden */
  21489. export var pbrPixelShader: {
  21490. name: string;
  21491. shader: string;
  21492. };
  21493. }
  21494. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  21495. /** @hidden */
  21496. export var pbrVertexDeclaration: {
  21497. name: string;
  21498. shader: string;
  21499. };
  21500. }
  21501. declare module "babylonjs/Shaders/pbr.vertex" {
  21502. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  21503. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  21504. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21505. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  21506. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  21507. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  21508. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  21509. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  21510. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  21511. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  21512. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  21513. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  21514. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  21515. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  21516. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  21517. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  21518. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  21519. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  21520. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  21521. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  21522. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  21523. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  21524. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  21525. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  21526. /** @hidden */
  21527. export var pbrVertexShader: {
  21528. name: string;
  21529. shader: string;
  21530. };
  21531. }
  21532. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  21533. import { Nullable } from "babylonjs/types";
  21534. import { Scene } from "babylonjs/scene";
  21535. import { Matrix } from "babylonjs/Maths/math.vector";
  21536. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21538. import { Mesh } from "babylonjs/Meshes/mesh";
  21539. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  21540. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  21541. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  21542. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  21543. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  21544. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  21545. import { Color3 } from "babylonjs/Maths/math.color";
  21546. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  21547. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  21548. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21549. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  21550. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21551. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21552. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  21553. import "babylonjs/Shaders/pbr.fragment";
  21554. import "babylonjs/Shaders/pbr.vertex";
  21555. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  21556. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  21557. /**
  21558. * Manages the defines for the PBR Material.
  21559. * @hidden
  21560. */
  21561. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21562. PBR: boolean;
  21563. NUM_SAMPLES: string;
  21564. REALTIME_FILTERING: boolean;
  21565. MAINUV1: boolean;
  21566. MAINUV2: boolean;
  21567. UV1: boolean;
  21568. UV2: boolean;
  21569. ALBEDO: boolean;
  21570. GAMMAALBEDO: boolean;
  21571. ALBEDODIRECTUV: number;
  21572. VERTEXCOLOR: boolean;
  21573. DETAIL: boolean;
  21574. DETAILDIRECTUV: number;
  21575. DETAIL_NORMALBLENDMETHOD: number;
  21576. AMBIENT: boolean;
  21577. AMBIENTDIRECTUV: number;
  21578. AMBIENTINGRAYSCALE: boolean;
  21579. OPACITY: boolean;
  21580. VERTEXALPHA: boolean;
  21581. OPACITYDIRECTUV: number;
  21582. OPACITYRGB: boolean;
  21583. ALPHATEST: boolean;
  21584. DEPTHPREPASS: boolean;
  21585. ALPHABLEND: boolean;
  21586. ALPHAFROMALBEDO: boolean;
  21587. ALPHATESTVALUE: string;
  21588. SPECULAROVERALPHA: boolean;
  21589. RADIANCEOVERALPHA: boolean;
  21590. ALPHAFRESNEL: boolean;
  21591. LINEARALPHAFRESNEL: boolean;
  21592. PREMULTIPLYALPHA: boolean;
  21593. EMISSIVE: boolean;
  21594. EMISSIVEDIRECTUV: number;
  21595. REFLECTIVITY: boolean;
  21596. REFLECTIVITYDIRECTUV: number;
  21597. SPECULARTERM: boolean;
  21598. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21599. MICROSURFACEAUTOMATIC: boolean;
  21600. LODBASEDMICROSFURACE: boolean;
  21601. MICROSURFACEMAP: boolean;
  21602. MICROSURFACEMAPDIRECTUV: number;
  21603. METALLICWORKFLOW: boolean;
  21604. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21605. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21606. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21607. AOSTOREINMETALMAPRED: boolean;
  21608. METALLIC_REFLECTANCE: boolean;
  21609. METALLIC_REFLECTANCEDIRECTUV: number;
  21610. ENVIRONMENTBRDF: boolean;
  21611. ENVIRONMENTBRDF_RGBD: boolean;
  21612. NORMAL: boolean;
  21613. TANGENT: boolean;
  21614. BUMP: boolean;
  21615. BUMPDIRECTUV: number;
  21616. OBJECTSPACE_NORMALMAP: boolean;
  21617. PARALLAX: boolean;
  21618. PARALLAXOCCLUSION: boolean;
  21619. NORMALXYSCALE: boolean;
  21620. LIGHTMAP: boolean;
  21621. LIGHTMAPDIRECTUV: number;
  21622. USELIGHTMAPASSHADOWMAP: boolean;
  21623. GAMMALIGHTMAP: boolean;
  21624. RGBDLIGHTMAP: boolean;
  21625. REFLECTION: boolean;
  21626. REFLECTIONMAP_3D: boolean;
  21627. REFLECTIONMAP_SPHERICAL: boolean;
  21628. REFLECTIONMAP_PLANAR: boolean;
  21629. REFLECTIONMAP_CUBIC: boolean;
  21630. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21631. REFLECTIONMAP_PROJECTION: boolean;
  21632. REFLECTIONMAP_SKYBOX: boolean;
  21633. REFLECTIONMAP_EXPLICIT: boolean;
  21634. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21635. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21636. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21637. INVERTCUBICMAP: boolean;
  21638. USESPHERICALFROMREFLECTIONMAP: boolean;
  21639. USEIRRADIANCEMAP: boolean;
  21640. SPHERICAL_HARMONICS: boolean;
  21641. USESPHERICALINVERTEX: boolean;
  21642. REFLECTIONMAP_OPPOSITEZ: boolean;
  21643. LODINREFLECTIONALPHA: boolean;
  21644. GAMMAREFLECTION: boolean;
  21645. RGBDREFLECTION: boolean;
  21646. LINEARSPECULARREFLECTION: boolean;
  21647. RADIANCEOCCLUSION: boolean;
  21648. HORIZONOCCLUSION: boolean;
  21649. INSTANCES: boolean;
  21650. THIN_INSTANCES: boolean;
  21651. PREPASS: boolean;
  21652. PREPASS_IRRADIANCE: boolean;
  21653. PREPASS_IRRADIANCE_INDEX: number;
  21654. PREPASS_ALBEDO: boolean;
  21655. PREPASS_ALBEDO_INDEX: number;
  21656. PREPASS_DEPTHNORMAL: boolean;
  21657. PREPASS_DEPTHNORMAL_INDEX: number;
  21658. PREPASS_POSITION: boolean;
  21659. PREPASS_POSITION_INDEX: number;
  21660. PREPASS_VELOCITY: boolean;
  21661. PREPASS_VELOCITY_INDEX: number;
  21662. PREPASS_REFLECTIVITY: boolean;
  21663. PREPASS_REFLECTIVITY_INDEX: number;
  21664. SCENE_MRT_COUNT: number;
  21665. NUM_BONE_INFLUENCERS: number;
  21666. BonesPerMesh: number;
  21667. BONETEXTURE: boolean;
  21668. BONES_VELOCITY_ENABLED: boolean;
  21669. NONUNIFORMSCALING: boolean;
  21670. MORPHTARGETS: boolean;
  21671. MORPHTARGETS_NORMAL: boolean;
  21672. MORPHTARGETS_TANGENT: boolean;
  21673. MORPHTARGETS_UV: boolean;
  21674. NUM_MORPH_INFLUENCERS: number;
  21675. IMAGEPROCESSING: boolean;
  21676. VIGNETTE: boolean;
  21677. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21678. VIGNETTEBLENDMODEOPAQUE: boolean;
  21679. TONEMAPPING: boolean;
  21680. TONEMAPPING_ACES: boolean;
  21681. CONTRAST: boolean;
  21682. COLORCURVES: boolean;
  21683. COLORGRADING: boolean;
  21684. COLORGRADING3D: boolean;
  21685. SAMPLER3DGREENDEPTH: boolean;
  21686. SAMPLER3DBGRMAP: boolean;
  21687. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21688. EXPOSURE: boolean;
  21689. MULTIVIEW: boolean;
  21690. USEPHYSICALLIGHTFALLOFF: boolean;
  21691. USEGLTFLIGHTFALLOFF: boolean;
  21692. TWOSIDEDLIGHTING: boolean;
  21693. SHADOWFLOAT: boolean;
  21694. CLIPPLANE: boolean;
  21695. CLIPPLANE2: boolean;
  21696. CLIPPLANE3: boolean;
  21697. CLIPPLANE4: boolean;
  21698. CLIPPLANE5: boolean;
  21699. CLIPPLANE6: boolean;
  21700. POINTSIZE: boolean;
  21701. FOG: boolean;
  21702. LOGARITHMICDEPTH: boolean;
  21703. FORCENORMALFORWARD: boolean;
  21704. SPECULARAA: boolean;
  21705. CLEARCOAT: boolean;
  21706. CLEARCOAT_DEFAULTIOR: boolean;
  21707. CLEARCOAT_TEXTURE: boolean;
  21708. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21709. CLEARCOAT_TEXTUREDIRECTUV: number;
  21710. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21711. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21712. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21713. CLEARCOAT_BUMP: boolean;
  21714. CLEARCOAT_BUMPDIRECTUV: number;
  21715. CLEARCOAT_REMAP_F0: boolean;
  21716. CLEARCOAT_TINT: boolean;
  21717. CLEARCOAT_TINT_TEXTURE: boolean;
  21718. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21719. ANISOTROPIC: boolean;
  21720. ANISOTROPIC_TEXTURE: boolean;
  21721. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21722. BRDF_V_HEIGHT_CORRELATED: boolean;
  21723. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21724. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21725. SHEEN: boolean;
  21726. SHEEN_TEXTURE: boolean;
  21727. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21728. SHEEN_TEXTUREDIRECTUV: number;
  21729. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21730. SHEEN_LINKWITHALBEDO: boolean;
  21731. SHEEN_ROUGHNESS: boolean;
  21732. SHEEN_ALBEDOSCALING: boolean;
  21733. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21734. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21735. SUBSURFACE: boolean;
  21736. SS_REFRACTION: boolean;
  21737. SS_TRANSLUCENCY: boolean;
  21738. SS_SCATTERING: boolean;
  21739. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21740. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21741. SS_REFRACTIONMAP_3D: boolean;
  21742. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21743. SS_LODINREFRACTIONALPHA: boolean;
  21744. SS_GAMMAREFRACTION: boolean;
  21745. SS_RGBDREFRACTION: boolean;
  21746. SS_LINEARSPECULARREFRACTION: boolean;
  21747. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21748. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21749. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21750. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21751. UNLIT: boolean;
  21752. DEBUGMODE: number;
  21753. /**
  21754. * Initializes the PBR Material defines.
  21755. */
  21756. constructor();
  21757. /**
  21758. * Resets the PBR Material defines.
  21759. */
  21760. reset(): void;
  21761. }
  21762. /**
  21763. * The Physically based material base class of BJS.
  21764. *
  21765. * This offers the main features of a standard PBR material.
  21766. * For more information, please refer to the documentation :
  21767. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21768. */
  21769. export abstract class PBRBaseMaterial extends PushMaterial {
  21770. /**
  21771. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21772. */
  21773. static readonly PBRMATERIAL_OPAQUE: number;
  21774. /**
  21775. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21776. */
  21777. static readonly PBRMATERIAL_ALPHATEST: number;
  21778. /**
  21779. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21780. */
  21781. static readonly PBRMATERIAL_ALPHABLEND: number;
  21782. /**
  21783. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21784. * They are also discarded below the alpha cutoff threshold to improve performances.
  21785. */
  21786. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21787. /**
  21788. * Defines the default value of how much AO map is occluding the analytical lights
  21789. * (point spot...).
  21790. */
  21791. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21792. /**
  21793. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21794. */
  21795. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21796. /**
  21797. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21798. * to enhance interoperability with other engines.
  21799. */
  21800. static readonly LIGHTFALLOFF_GLTF: number;
  21801. /**
  21802. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21803. * to enhance interoperability with other materials.
  21804. */
  21805. static readonly LIGHTFALLOFF_STANDARD: number;
  21806. /**
  21807. * Intensity of the direct lights e.g. the four lights available in your scene.
  21808. * This impacts both the direct diffuse and specular highlights.
  21809. */
  21810. protected _directIntensity: number;
  21811. /**
  21812. * Intensity of the emissive part of the material.
  21813. * This helps controlling the emissive effect without modifying the emissive color.
  21814. */
  21815. protected _emissiveIntensity: number;
  21816. /**
  21817. * Intensity of the environment e.g. how much the environment will light the object
  21818. * either through harmonics for rough material or through the refelction for shiny ones.
  21819. */
  21820. protected _environmentIntensity: number;
  21821. /**
  21822. * This is a special control allowing the reduction of the specular highlights coming from the
  21823. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21824. */
  21825. protected _specularIntensity: number;
  21826. /**
  21827. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21828. */
  21829. private _lightingInfos;
  21830. /**
  21831. * Debug Control allowing disabling the bump map on this material.
  21832. */
  21833. protected _disableBumpMap: boolean;
  21834. /**
  21835. * AKA Diffuse Texture in standard nomenclature.
  21836. */
  21837. protected _albedoTexture: Nullable<BaseTexture>;
  21838. /**
  21839. * AKA Occlusion Texture in other nomenclature.
  21840. */
  21841. protected _ambientTexture: Nullable<BaseTexture>;
  21842. /**
  21843. * AKA Occlusion Texture Intensity in other nomenclature.
  21844. */
  21845. protected _ambientTextureStrength: number;
  21846. /**
  21847. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21848. * 1 means it completely occludes it
  21849. * 0 mean it has no impact
  21850. */
  21851. protected _ambientTextureImpactOnAnalyticalLights: number;
  21852. /**
  21853. * Stores the alpha values in a texture.
  21854. */
  21855. protected _opacityTexture: Nullable<BaseTexture>;
  21856. /**
  21857. * Stores the reflection values in a texture.
  21858. */
  21859. protected _reflectionTexture: Nullable<BaseTexture>;
  21860. /**
  21861. * Stores the emissive values in a texture.
  21862. */
  21863. protected _emissiveTexture: Nullable<BaseTexture>;
  21864. /**
  21865. * AKA Specular texture in other nomenclature.
  21866. */
  21867. protected _reflectivityTexture: Nullable<BaseTexture>;
  21868. /**
  21869. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21870. */
  21871. protected _metallicTexture: Nullable<BaseTexture>;
  21872. /**
  21873. * Specifies the metallic scalar of the metallic/roughness workflow.
  21874. * Can also be used to scale the metalness values of the metallic texture.
  21875. */
  21876. protected _metallic: Nullable<number>;
  21877. /**
  21878. * Specifies the roughness scalar of the metallic/roughness workflow.
  21879. * Can also be used to scale the roughness values of the metallic texture.
  21880. */
  21881. protected _roughness: Nullable<number>;
  21882. /**
  21883. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21884. * By default the indexOfrefraction is used to compute F0;
  21885. *
  21886. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21887. *
  21888. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21889. * F90 = metallicReflectanceColor;
  21890. */
  21891. protected _metallicF0Factor: number;
  21892. /**
  21893. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21894. * By default the F90 is always 1;
  21895. *
  21896. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21897. *
  21898. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21899. * F90 = metallicReflectanceColor;
  21900. */
  21901. protected _metallicReflectanceColor: Color3;
  21902. /**
  21903. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21904. * This is multiply against the scalar values defined in the material.
  21905. */
  21906. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21907. /**
  21908. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21909. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21910. */
  21911. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21912. /**
  21913. * Stores surface normal data used to displace a mesh in a texture.
  21914. */
  21915. protected _bumpTexture: Nullable<BaseTexture>;
  21916. /**
  21917. * Stores the pre-calculated light information of a mesh in a texture.
  21918. */
  21919. protected _lightmapTexture: Nullable<BaseTexture>;
  21920. /**
  21921. * The color of a material in ambient lighting.
  21922. */
  21923. protected _ambientColor: Color3;
  21924. /**
  21925. * AKA Diffuse Color in other nomenclature.
  21926. */
  21927. protected _albedoColor: Color3;
  21928. /**
  21929. * AKA Specular Color in other nomenclature.
  21930. */
  21931. protected _reflectivityColor: Color3;
  21932. /**
  21933. * The color applied when light is reflected from a material.
  21934. */
  21935. protected _reflectionColor: Color3;
  21936. /**
  21937. * The color applied when light is emitted from a material.
  21938. */
  21939. protected _emissiveColor: Color3;
  21940. /**
  21941. * AKA Glossiness in other nomenclature.
  21942. */
  21943. protected _microSurface: number;
  21944. /**
  21945. * Specifies that the material will use the light map as a show map.
  21946. */
  21947. protected _useLightmapAsShadowmap: boolean;
  21948. /**
  21949. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21950. * makes the reflect vector face the model (under horizon).
  21951. */
  21952. protected _useHorizonOcclusion: boolean;
  21953. /**
  21954. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21955. * too much the area relying on ambient texture to define their ambient occlusion.
  21956. */
  21957. protected _useRadianceOcclusion: boolean;
  21958. /**
  21959. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21960. */
  21961. protected _useAlphaFromAlbedoTexture: boolean;
  21962. /**
  21963. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21964. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21965. */
  21966. protected _useSpecularOverAlpha: boolean;
  21967. /**
  21968. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21969. */
  21970. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21971. /**
  21972. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21973. */
  21974. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21975. /**
  21976. * Specifies if the metallic texture contains the roughness information in its green channel.
  21977. */
  21978. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21979. /**
  21980. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21981. */
  21982. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21983. /**
  21984. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21985. */
  21986. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21987. /**
  21988. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21989. */
  21990. protected _useAmbientInGrayScale: boolean;
  21991. /**
  21992. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21993. * The material will try to infer what glossiness each pixel should be.
  21994. */
  21995. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21996. /**
  21997. * Defines the falloff type used in this material.
  21998. * It by default is Physical.
  21999. */
  22000. protected _lightFalloff: number;
  22001. /**
  22002. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22003. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22004. */
  22005. protected _useRadianceOverAlpha: boolean;
  22006. /**
  22007. * Allows using an object space normal map (instead of tangent space).
  22008. */
  22009. protected _useObjectSpaceNormalMap: boolean;
  22010. /**
  22011. * Allows using the bump map in parallax mode.
  22012. */
  22013. protected _useParallax: boolean;
  22014. /**
  22015. * Allows using the bump map in parallax occlusion mode.
  22016. */
  22017. protected _useParallaxOcclusion: boolean;
  22018. /**
  22019. * Controls the scale bias of the parallax mode.
  22020. */
  22021. protected _parallaxScaleBias: number;
  22022. /**
  22023. * If sets to true, disables all the lights affecting the material.
  22024. */
  22025. protected _disableLighting: boolean;
  22026. /**
  22027. * Number of Simultaneous lights allowed on the material.
  22028. */
  22029. protected _maxSimultaneousLights: number;
  22030. /**
  22031. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22032. */
  22033. protected _invertNormalMapX: boolean;
  22034. /**
  22035. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22036. */
  22037. protected _invertNormalMapY: boolean;
  22038. /**
  22039. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22040. */
  22041. protected _twoSidedLighting: boolean;
  22042. /**
  22043. * Defines the alpha limits in alpha test mode.
  22044. */
  22045. protected _alphaCutOff: number;
  22046. /**
  22047. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22048. */
  22049. protected _forceAlphaTest: boolean;
  22050. /**
  22051. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22052. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22053. */
  22054. protected _useAlphaFresnel: boolean;
  22055. /**
  22056. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22057. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22058. */
  22059. protected _useLinearAlphaFresnel: boolean;
  22060. /**
  22061. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  22062. * from cos thetav and roughness:
  22063. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22064. */
  22065. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22066. /**
  22067. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22068. */
  22069. protected _forceIrradianceInFragment: boolean;
  22070. private _realTimeFiltering;
  22071. /**
  22072. * Enables realtime filtering on the texture.
  22073. */
  22074. get realTimeFiltering(): boolean;
  22075. set realTimeFiltering(b: boolean);
  22076. private _realTimeFilteringQuality;
  22077. /**
  22078. * Quality switch for realtime filtering
  22079. */
  22080. get realTimeFilteringQuality(): number;
  22081. set realTimeFilteringQuality(n: number);
  22082. /**
  22083. * Can this material render to several textures at once
  22084. */
  22085. get canRenderToMRT(): boolean;
  22086. /**
  22087. * Force normal to face away from face.
  22088. */
  22089. protected _forceNormalForward: boolean;
  22090. /**
  22091. * Enables specular anti aliasing in the PBR shader.
  22092. * It will both interacts on the Geometry for analytical and IBL lighting.
  22093. * It also prefilter the roughness map based on the bump values.
  22094. */
  22095. protected _enableSpecularAntiAliasing: boolean;
  22096. /**
  22097. * Default configuration related to image processing available in the PBR Material.
  22098. */
  22099. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22100. /**
  22101. * Keep track of the image processing observer to allow dispose and replace.
  22102. */
  22103. private _imageProcessingObserver;
  22104. /**
  22105. * Attaches a new image processing configuration to the PBR Material.
  22106. * @param configuration
  22107. */
  22108. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22109. /**
  22110. * Stores the available render targets.
  22111. */
  22112. private _renderTargets;
  22113. /**
  22114. * Sets the global ambient color for the material used in lighting calculations.
  22115. */
  22116. private _globalAmbientColor;
  22117. /**
  22118. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22119. */
  22120. private _useLogarithmicDepth;
  22121. /**
  22122. * If set to true, no lighting calculations will be applied.
  22123. */
  22124. private _unlit;
  22125. private _debugMode;
  22126. /**
  22127. * @hidden
  22128. * This is reserved for the inspector.
  22129. * Defines the material debug mode.
  22130. * It helps seeing only some components of the material while troubleshooting.
  22131. */
  22132. debugMode: number;
  22133. /**
  22134. * @hidden
  22135. * This is reserved for the inspector.
  22136. * Specify from where on screen the debug mode should start.
  22137. * The value goes from -1 (full screen) to 1 (not visible)
  22138. * It helps with side by side comparison against the final render
  22139. * This defaults to -1
  22140. */
  22141. private debugLimit;
  22142. /**
  22143. * @hidden
  22144. * This is reserved for the inspector.
  22145. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22146. * You can use the factor to better multiply the final value.
  22147. */
  22148. private debugFactor;
  22149. /**
  22150. * Defines the clear coat layer parameters for the material.
  22151. */
  22152. readonly clearCoat: PBRClearCoatConfiguration;
  22153. /**
  22154. * Defines the anisotropic parameters for the material.
  22155. */
  22156. readonly anisotropy: PBRAnisotropicConfiguration;
  22157. /**
  22158. * Defines the BRDF parameters for the material.
  22159. */
  22160. readonly brdf: PBRBRDFConfiguration;
  22161. /**
  22162. * Defines the Sheen parameters for the material.
  22163. */
  22164. readonly sheen: PBRSheenConfiguration;
  22165. /**
  22166. * Defines the SubSurface parameters for the material.
  22167. */
  22168. readonly subSurface: PBRSubSurfaceConfiguration;
  22169. /**
  22170. * Defines additionnal PrePass parameters for the material.
  22171. */
  22172. readonly prePassConfiguration: PrePassConfiguration;
  22173. /**
  22174. * Defines the detail map parameters for the material.
  22175. */
  22176. readonly detailMap: DetailMapConfiguration;
  22177. protected _rebuildInParallel: boolean;
  22178. /**
  22179. * Instantiates a new PBRMaterial instance.
  22180. *
  22181. * @param name The material name
  22182. * @param scene The scene the material will be use in.
  22183. */
  22184. constructor(name: string, scene: Scene);
  22185. /**
  22186. * Gets a boolean indicating that current material needs to register RTT
  22187. */
  22188. get hasRenderTargetTextures(): boolean;
  22189. /**
  22190. * Gets the name of the material class.
  22191. */
  22192. getClassName(): string;
  22193. /**
  22194. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22195. */
  22196. get useLogarithmicDepth(): boolean;
  22197. /**
  22198. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22199. */
  22200. set useLogarithmicDepth(value: boolean);
  22201. /**
  22202. * Returns true if alpha blending should be disabled.
  22203. */
  22204. protected get _disableAlphaBlending(): boolean;
  22205. /**
  22206. * Specifies whether or not this material should be rendered in alpha blend mode.
  22207. */
  22208. needAlphaBlending(): boolean;
  22209. /**
  22210. * Specifies whether or not this material should be rendered in alpha test mode.
  22211. */
  22212. needAlphaTesting(): boolean;
  22213. /**
  22214. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22215. */
  22216. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22217. /**
  22218. * Specifies whether or not there is a usable alpha channel for transparency.
  22219. */
  22220. protected _hasAlphaChannel(): boolean;
  22221. /**
  22222. * Gets the texture used for the alpha test.
  22223. */
  22224. getAlphaTestTexture(): Nullable<BaseTexture>;
  22225. /**
  22226. * Specifies that the submesh is ready to be used.
  22227. * @param mesh - BJS mesh.
  22228. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22229. * @param useInstances - Specifies that instances should be used.
  22230. * @returns - boolean indicating that the submesh is ready or not.
  22231. */
  22232. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22233. /**
  22234. * Specifies if the material uses metallic roughness workflow.
  22235. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22236. */
  22237. isMetallicWorkflow(): boolean;
  22238. private _prepareEffect;
  22239. private _prepareDefines;
  22240. /**
  22241. * Force shader compilation
  22242. */
  22243. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22244. /**
  22245. * Initializes the uniform buffer layout for the shader.
  22246. */
  22247. buildUniformLayout(): void;
  22248. /**
  22249. * Unbinds the material from the mesh
  22250. */
  22251. unbind(): void;
  22252. /**
  22253. * Binds the submesh data.
  22254. * @param world - The world matrix.
  22255. * @param mesh - The BJS mesh.
  22256. * @param subMesh - A submesh of the BJS mesh.
  22257. */
  22258. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22259. /**
  22260. * Returns the animatable textures.
  22261. * @returns - Array of animatable textures.
  22262. */
  22263. getAnimatables(): IAnimatable[];
  22264. /**
  22265. * Returns the texture used for reflections.
  22266. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22267. */
  22268. private _getReflectionTexture;
  22269. /**
  22270. * Returns an array of the actively used textures.
  22271. * @returns - Array of BaseTextures
  22272. */
  22273. getActiveTextures(): BaseTexture[];
  22274. /**
  22275. * Checks to see if a texture is used in the material.
  22276. * @param texture - Base texture to use.
  22277. * @returns - Boolean specifying if a texture is used in the material.
  22278. */
  22279. hasTexture(texture: BaseTexture): boolean;
  22280. /**
  22281. * Sets the required values to the prepass renderer.
  22282. * @param prePassRenderer defines the prepass renderer to setup
  22283. */
  22284. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22285. /**
  22286. * Disposes the resources of the material.
  22287. * @param forceDisposeEffect - Forces the disposal of effects.
  22288. * @param forceDisposeTextures - Forces the disposal of all textures.
  22289. */
  22290. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22291. }
  22292. }
  22293. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  22294. import { Nullable } from "babylonjs/types";
  22295. import { Scene } from "babylonjs/scene";
  22296. import { Color3 } from "babylonjs/Maths/math.color";
  22297. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  22298. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  22299. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22300. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  22301. /**
  22302. * The Physically based material of BJS.
  22303. *
  22304. * This offers the main features of a standard PBR material.
  22305. * For more information, please refer to the documentation :
  22306. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22307. */
  22308. export class PBRMaterial extends PBRBaseMaterial {
  22309. /**
  22310. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22311. */
  22312. static readonly PBRMATERIAL_OPAQUE: number;
  22313. /**
  22314. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22315. */
  22316. static readonly PBRMATERIAL_ALPHATEST: number;
  22317. /**
  22318. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22319. */
  22320. static readonly PBRMATERIAL_ALPHABLEND: number;
  22321. /**
  22322. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22323. * They are also discarded below the alpha cutoff threshold to improve performances.
  22324. */
  22325. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22326. /**
  22327. * Defines the default value of how much AO map is occluding the analytical lights
  22328. * (point spot...).
  22329. */
  22330. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22331. /**
  22332. * Intensity of the direct lights e.g. the four lights available in your scene.
  22333. * This impacts both the direct diffuse and specular highlights.
  22334. */
  22335. directIntensity: number;
  22336. /**
  22337. * Intensity of the emissive part of the material.
  22338. * This helps controlling the emissive effect without modifying the emissive color.
  22339. */
  22340. emissiveIntensity: number;
  22341. /**
  22342. * Intensity of the environment e.g. how much the environment will light the object
  22343. * either through harmonics for rough material or through the refelction for shiny ones.
  22344. */
  22345. environmentIntensity: number;
  22346. /**
  22347. * This is a special control allowing the reduction of the specular highlights coming from the
  22348. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22349. */
  22350. specularIntensity: number;
  22351. /**
  22352. * Debug Control allowing disabling the bump map on this material.
  22353. */
  22354. disableBumpMap: boolean;
  22355. /**
  22356. * AKA Diffuse Texture in standard nomenclature.
  22357. */
  22358. albedoTexture: BaseTexture;
  22359. /**
  22360. * AKA Occlusion Texture in other nomenclature.
  22361. */
  22362. ambientTexture: BaseTexture;
  22363. /**
  22364. * AKA Occlusion Texture Intensity in other nomenclature.
  22365. */
  22366. ambientTextureStrength: number;
  22367. /**
  22368. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22369. * 1 means it completely occludes it
  22370. * 0 mean it has no impact
  22371. */
  22372. ambientTextureImpactOnAnalyticalLights: number;
  22373. /**
  22374. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22375. */
  22376. opacityTexture: BaseTexture;
  22377. /**
  22378. * Stores the reflection values in a texture.
  22379. */
  22380. reflectionTexture: Nullable<BaseTexture>;
  22381. /**
  22382. * Stores the emissive values in a texture.
  22383. */
  22384. emissiveTexture: BaseTexture;
  22385. /**
  22386. * AKA Specular texture in other nomenclature.
  22387. */
  22388. reflectivityTexture: BaseTexture;
  22389. /**
  22390. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22391. */
  22392. metallicTexture: BaseTexture;
  22393. /**
  22394. * Specifies the metallic scalar of the metallic/roughness workflow.
  22395. * Can also be used to scale the metalness values of the metallic texture.
  22396. */
  22397. metallic: Nullable<number>;
  22398. /**
  22399. * Specifies the roughness scalar of the metallic/roughness workflow.
  22400. * Can also be used to scale the roughness values of the metallic texture.
  22401. */
  22402. roughness: Nullable<number>;
  22403. /**
  22404. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22405. * By default the indexOfrefraction is used to compute F0;
  22406. *
  22407. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22408. *
  22409. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22410. * F90 = metallicReflectanceColor;
  22411. */
  22412. metallicF0Factor: number;
  22413. /**
  22414. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22415. * By default the F90 is always 1;
  22416. *
  22417. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22418. *
  22419. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22420. * F90 = metallicReflectanceColor;
  22421. */
  22422. metallicReflectanceColor: Color3;
  22423. /**
  22424. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22425. * This is multiply against the scalar values defined in the material.
  22426. */
  22427. metallicReflectanceTexture: Nullable<BaseTexture>;
  22428. /**
  22429. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22430. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22431. */
  22432. microSurfaceTexture: BaseTexture;
  22433. /**
  22434. * Stores surface normal data used to displace a mesh in a texture.
  22435. */
  22436. bumpTexture: BaseTexture;
  22437. /**
  22438. * Stores the pre-calculated light information of a mesh in a texture.
  22439. */
  22440. lightmapTexture: BaseTexture;
  22441. /**
  22442. * Stores the refracted light information in a texture.
  22443. */
  22444. get refractionTexture(): Nullable<BaseTexture>;
  22445. set refractionTexture(value: Nullable<BaseTexture>);
  22446. /**
  22447. * The color of a material in ambient lighting.
  22448. */
  22449. ambientColor: Color3;
  22450. /**
  22451. * AKA Diffuse Color in other nomenclature.
  22452. */
  22453. albedoColor: Color3;
  22454. /**
  22455. * AKA Specular Color in other nomenclature.
  22456. */
  22457. reflectivityColor: Color3;
  22458. /**
  22459. * The color reflected from the material.
  22460. */
  22461. reflectionColor: Color3;
  22462. /**
  22463. * The color emitted from the material.
  22464. */
  22465. emissiveColor: Color3;
  22466. /**
  22467. * AKA Glossiness in other nomenclature.
  22468. */
  22469. microSurface: number;
  22470. /**
  22471. * Index of refraction of the material base layer.
  22472. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22473. *
  22474. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22475. *
  22476. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22477. */
  22478. get indexOfRefraction(): number;
  22479. set indexOfRefraction(value: number);
  22480. /**
  22481. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22482. */
  22483. get invertRefractionY(): boolean;
  22484. set invertRefractionY(value: boolean);
  22485. /**
  22486. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22487. * Materials half opaque for instance using refraction could benefit from this control.
  22488. */
  22489. get linkRefractionWithTransparency(): boolean;
  22490. set linkRefractionWithTransparency(value: boolean);
  22491. /**
  22492. * If true, the light map contains occlusion information instead of lighting info.
  22493. */
  22494. useLightmapAsShadowmap: boolean;
  22495. /**
  22496. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22497. */
  22498. useAlphaFromAlbedoTexture: boolean;
  22499. /**
  22500. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22501. */
  22502. forceAlphaTest: boolean;
  22503. /**
  22504. * Defines the alpha limits in alpha test mode.
  22505. */
  22506. alphaCutOff: number;
  22507. /**
  22508. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  22509. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22510. */
  22511. useSpecularOverAlpha: boolean;
  22512. /**
  22513. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22514. */
  22515. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22516. /**
  22517. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22518. */
  22519. useRoughnessFromMetallicTextureAlpha: boolean;
  22520. /**
  22521. * Specifies if the metallic texture contains the roughness information in its green channel.
  22522. */
  22523. useRoughnessFromMetallicTextureGreen: boolean;
  22524. /**
  22525. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22526. */
  22527. useMetallnessFromMetallicTextureBlue: boolean;
  22528. /**
  22529. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22530. */
  22531. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22532. /**
  22533. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22534. */
  22535. useAmbientInGrayScale: boolean;
  22536. /**
  22537. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22538. * The material will try to infer what glossiness each pixel should be.
  22539. */
  22540. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22541. /**
  22542. * BJS is using an harcoded light falloff based on a manually sets up range.
  22543. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22544. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22545. */
  22546. get usePhysicalLightFalloff(): boolean;
  22547. /**
  22548. * BJS is using an harcoded light falloff based on a manually sets up range.
  22549. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22550. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22551. */
  22552. set usePhysicalLightFalloff(value: boolean);
  22553. /**
  22554. * In order to support the falloff compatibility with gltf, a special mode has been added
  22555. * to reproduce the gltf light falloff.
  22556. */
  22557. get useGLTFLightFalloff(): boolean;
  22558. /**
  22559. * In order to support the falloff compatibility with gltf, a special mode has been added
  22560. * to reproduce the gltf light falloff.
  22561. */
  22562. set useGLTFLightFalloff(value: boolean);
  22563. /**
  22564. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22565. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22566. */
  22567. useRadianceOverAlpha: boolean;
  22568. /**
  22569. * Allows using an object space normal map (instead of tangent space).
  22570. */
  22571. useObjectSpaceNormalMap: boolean;
  22572. /**
  22573. * Allows using the bump map in parallax mode.
  22574. */
  22575. useParallax: boolean;
  22576. /**
  22577. * Allows using the bump map in parallax occlusion mode.
  22578. */
  22579. useParallaxOcclusion: boolean;
  22580. /**
  22581. * Controls the scale bias of the parallax mode.
  22582. */
  22583. parallaxScaleBias: number;
  22584. /**
  22585. * If sets to true, disables all the lights affecting the material.
  22586. */
  22587. disableLighting: boolean;
  22588. /**
  22589. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22590. */
  22591. forceIrradianceInFragment: boolean;
  22592. /**
  22593. * Number of Simultaneous lights allowed on the material.
  22594. */
  22595. maxSimultaneousLights: number;
  22596. /**
  22597. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22598. */
  22599. invertNormalMapX: boolean;
  22600. /**
  22601. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22602. */
  22603. invertNormalMapY: boolean;
  22604. /**
  22605. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22606. */
  22607. twoSidedLighting: boolean;
  22608. /**
  22609. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22610. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22611. */
  22612. useAlphaFresnel: boolean;
  22613. /**
  22614. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22615. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22616. */
  22617. useLinearAlphaFresnel: boolean;
  22618. /**
  22619. * Let user defines the brdf lookup texture used for IBL.
  22620. * A default 8bit version is embedded but you could point at :
  22621. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22622. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22623. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22624. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22625. */
  22626. environmentBRDFTexture: Nullable<BaseTexture>;
  22627. /**
  22628. * Force normal to face away from face.
  22629. */
  22630. forceNormalForward: boolean;
  22631. /**
  22632. * Enables specular anti aliasing in the PBR shader.
  22633. * It will both interacts on the Geometry for analytical and IBL lighting.
  22634. * It also prefilter the roughness map based on the bump values.
  22635. */
  22636. enableSpecularAntiAliasing: boolean;
  22637. /**
  22638. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22639. * makes the reflect vector face the model (under horizon).
  22640. */
  22641. useHorizonOcclusion: boolean;
  22642. /**
  22643. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22644. * too much the area relying on ambient texture to define their ambient occlusion.
  22645. */
  22646. useRadianceOcclusion: boolean;
  22647. /**
  22648. * If set to true, no lighting calculations will be applied.
  22649. */
  22650. unlit: boolean;
  22651. /**
  22652. * Gets the image processing configuration used either in this material.
  22653. */
  22654. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22655. /**
  22656. * Sets the Default image processing configuration used either in the this material.
  22657. *
  22658. * If sets to null, the scene one is in use.
  22659. */
  22660. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22661. /**
  22662. * Gets wether the color curves effect is enabled.
  22663. */
  22664. get cameraColorCurvesEnabled(): boolean;
  22665. /**
  22666. * Sets wether the color curves effect is enabled.
  22667. */
  22668. set cameraColorCurvesEnabled(value: boolean);
  22669. /**
  22670. * Gets wether the color grading effect is enabled.
  22671. */
  22672. get cameraColorGradingEnabled(): boolean;
  22673. /**
  22674. * Gets wether the color grading effect is enabled.
  22675. */
  22676. set cameraColorGradingEnabled(value: boolean);
  22677. /**
  22678. * Gets wether tonemapping is enabled or not.
  22679. */
  22680. get cameraToneMappingEnabled(): boolean;
  22681. /**
  22682. * Sets wether tonemapping is enabled or not
  22683. */
  22684. set cameraToneMappingEnabled(value: boolean);
  22685. /**
  22686. * The camera exposure used on this material.
  22687. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22688. * This corresponds to a photographic exposure.
  22689. */
  22690. get cameraExposure(): number;
  22691. /**
  22692. * The camera exposure used on this material.
  22693. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22694. * This corresponds to a photographic exposure.
  22695. */
  22696. set cameraExposure(value: number);
  22697. /**
  22698. * Gets The camera contrast used on this material.
  22699. */
  22700. get cameraContrast(): number;
  22701. /**
  22702. * Sets The camera contrast used on this material.
  22703. */
  22704. set cameraContrast(value: number);
  22705. /**
  22706. * Gets the Color Grading 2D Lookup Texture.
  22707. */
  22708. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22709. /**
  22710. * Sets the Color Grading 2D Lookup Texture.
  22711. */
  22712. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22713. /**
  22714. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22715. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22716. * 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;
  22717. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22718. */
  22719. get cameraColorCurves(): Nullable<ColorCurves>;
  22720. /**
  22721. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22722. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22723. * 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;
  22724. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22725. */
  22726. set cameraColorCurves(value: Nullable<ColorCurves>);
  22727. /**
  22728. * Instantiates a new PBRMaterial instance.
  22729. *
  22730. * @param name The material name
  22731. * @param scene The scene the material will be use in.
  22732. */
  22733. constructor(name: string, scene: Scene);
  22734. /**
  22735. * Returns the name of this material class.
  22736. */
  22737. getClassName(): string;
  22738. /**
  22739. * Makes a duplicate of the current material.
  22740. * @param name - name to use for the new material.
  22741. */
  22742. clone(name: string): PBRMaterial;
  22743. /**
  22744. * Serializes this PBR Material.
  22745. * @returns - An object with the serialized material.
  22746. */
  22747. serialize(): any;
  22748. /**
  22749. * Parses a PBR Material from a serialized object.
  22750. * @param source - Serialized object.
  22751. * @param scene - BJS scene instance.
  22752. * @param rootUrl - url for the scene object
  22753. * @returns - PBRMaterial
  22754. */
  22755. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22756. }
  22757. }
  22758. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  22759. /** @hidden */
  22760. export var mrtFragmentDeclaration: {
  22761. name: string;
  22762. shader: string;
  22763. };
  22764. }
  22765. declare module "babylonjs/Shaders/geometry.fragment" {
  22766. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  22767. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  22768. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  22769. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  22770. /** @hidden */
  22771. export var geometryPixelShader: {
  22772. name: string;
  22773. shader: string;
  22774. };
  22775. }
  22776. declare module "babylonjs/Shaders/geometry.vertex" {
  22777. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  22778. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  22779. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  22780. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  22781. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  22782. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  22783. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  22784. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  22785. /** @hidden */
  22786. export var geometryVertexShader: {
  22787. name: string;
  22788. shader: string;
  22789. };
  22790. }
  22791. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  22792. import { Matrix } from "babylonjs/Maths/math.vector";
  22793. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22794. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22795. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  22796. import { Effect } from "babylonjs/Materials/effect";
  22797. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  22798. import { Scene } from "babylonjs/scene";
  22799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22800. import { Nullable } from "babylonjs/types";
  22801. import "babylonjs/Shaders/geometry.fragment";
  22802. import "babylonjs/Shaders/geometry.vertex";
  22803. /** @hidden */
  22804. interface ISavedTransformationMatrix {
  22805. world: Matrix;
  22806. viewProjection: Matrix;
  22807. }
  22808. /**
  22809. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22810. */
  22811. export class GeometryBufferRenderer {
  22812. /**
  22813. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22814. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22815. */
  22816. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22817. /**
  22818. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22819. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22820. */
  22821. static readonly POSITION_TEXTURE_TYPE: number;
  22822. /**
  22823. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22824. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22825. */
  22826. static readonly VELOCITY_TEXTURE_TYPE: number;
  22827. /**
  22828. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22829. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22830. */
  22831. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22832. /**
  22833. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22834. * in order to compute objects velocities when enableVelocity is set to "true"
  22835. * @hidden
  22836. */
  22837. _previousTransformationMatrices: {
  22838. [index: number]: ISavedTransformationMatrix;
  22839. };
  22840. /**
  22841. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22842. * in order to compute objects velocities when enableVelocity is set to "true"
  22843. * @hidden
  22844. */
  22845. _previousBonesTransformationMatrices: {
  22846. [index: number]: Float32Array;
  22847. };
  22848. /**
  22849. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22850. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22851. */
  22852. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22853. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22854. renderTransparentMeshes: boolean;
  22855. private _scene;
  22856. private _resizeObserver;
  22857. private _multiRenderTarget;
  22858. private _ratio;
  22859. private _enablePosition;
  22860. private _enableVelocity;
  22861. private _enableReflectivity;
  22862. private _positionIndex;
  22863. private _velocityIndex;
  22864. private _reflectivityIndex;
  22865. private _depthNormalIndex;
  22866. private _linkedWithPrePass;
  22867. private _prePassRenderer;
  22868. private _attachments;
  22869. protected _effect: Effect;
  22870. protected _cachedDefines: string;
  22871. /**
  22872. * @hidden
  22873. * Sets up internal structures to share outputs with PrePassRenderer
  22874. * This method should only be called by the PrePassRenderer itself
  22875. */
  22876. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22877. /**
  22878. * @hidden
  22879. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22880. * This method should only be called by the PrePassRenderer itself
  22881. */
  22882. _unlinkPrePassRenderer(): void;
  22883. /**
  22884. * @hidden
  22885. * Resets the geometry buffer layout
  22886. */
  22887. _resetLayout(): void;
  22888. /**
  22889. * @hidden
  22890. * Replaces a texture in the geometry buffer renderer
  22891. * Useful when linking textures of the prepass renderer
  22892. */
  22893. _forceTextureType(geometryBufferType: number, index: number): void;
  22894. /**
  22895. * @hidden
  22896. * Sets texture attachments
  22897. * Useful when linking textures of the prepass renderer
  22898. */
  22899. _setAttachments(attachments: number[]): void;
  22900. /**
  22901. * @hidden
  22902. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22903. * Useful when linking textures of the prepass renderer
  22904. */
  22905. _linkInternalTexture(internalTexture: InternalTexture): void;
  22906. /**
  22907. * Gets the render list (meshes to be rendered) used in the G buffer.
  22908. */
  22909. get renderList(): Nullable<AbstractMesh[]>;
  22910. /**
  22911. * Set the render list (meshes to be rendered) used in the G buffer.
  22912. */
  22913. set renderList(meshes: Nullable<AbstractMesh[]>);
  22914. /**
  22915. * Gets wether or not G buffer are supported by the running hardware.
  22916. * This requires draw buffer supports
  22917. */
  22918. get isSupported(): boolean;
  22919. /**
  22920. * Returns the index of the given texture type in the G-Buffer textures array
  22921. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22922. * @returns the index of the given texture type in the G-Buffer textures array
  22923. */
  22924. getTextureIndex(textureType: number): number;
  22925. /**
  22926. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22927. */
  22928. get enablePosition(): boolean;
  22929. /**
  22930. * Sets whether or not objects positions are enabled for the G buffer.
  22931. */
  22932. set enablePosition(enable: boolean);
  22933. /**
  22934. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22935. */
  22936. get enableVelocity(): boolean;
  22937. /**
  22938. * Sets wether or not objects velocities are enabled for the G buffer.
  22939. */
  22940. set enableVelocity(enable: boolean);
  22941. /**
  22942. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22943. */
  22944. get enableReflectivity(): boolean;
  22945. /**
  22946. * Sets wether or not objects roughness are enabled for the G buffer.
  22947. */
  22948. set enableReflectivity(enable: boolean);
  22949. /**
  22950. * Gets the scene associated with the buffer.
  22951. */
  22952. get scene(): Scene;
  22953. /**
  22954. * Gets the ratio used by the buffer during its creation.
  22955. * How big is the buffer related to the main canvas.
  22956. */
  22957. get ratio(): number;
  22958. /** @hidden */
  22959. static _SceneComponentInitialization: (scene: Scene) => void;
  22960. /**
  22961. * Creates a new G Buffer for the scene
  22962. * @param scene The scene the buffer belongs to
  22963. * @param ratio How big is the buffer related to the main canvas.
  22964. */
  22965. constructor(scene: Scene, ratio?: number);
  22966. /**
  22967. * Checks wether everything is ready to render a submesh to the G buffer.
  22968. * @param subMesh the submesh to check readiness for
  22969. * @param useInstances is the mesh drawn using instance or not
  22970. * @returns true if ready otherwise false
  22971. */
  22972. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22973. /**
  22974. * Gets the current underlying G Buffer.
  22975. * @returns the buffer
  22976. */
  22977. getGBuffer(): MultiRenderTarget;
  22978. /**
  22979. * Gets the number of samples used to render the buffer (anti aliasing).
  22980. */
  22981. get samples(): number;
  22982. /**
  22983. * Sets the number of samples used to render the buffer (anti aliasing).
  22984. */
  22985. set samples(value: number);
  22986. /**
  22987. * Disposes the renderer and frees up associated resources.
  22988. */
  22989. dispose(): void;
  22990. private _assignRenderTargetIndices;
  22991. protected _createRenderTargets(): void;
  22992. private _copyBonesTransformationMatrices;
  22993. }
  22994. }
  22995. declare module "babylonjs/Rendering/prePassRenderer" {
  22996. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  22997. import { Scene } from "babylonjs/scene";
  22998. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  22999. import { Effect } from "babylonjs/Materials/effect";
  23000. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23002. import { Material } from "babylonjs/Materials/material";
  23003. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23004. /**
  23005. * Renders a pre pass of the scene
  23006. * This means every mesh in the scene will be rendered to a render target texture
  23007. * And then this texture will be composited to the rendering canvas with post processes
  23008. * It is necessary for effects like subsurface scattering or deferred shading
  23009. */
  23010. export class PrePassRenderer {
  23011. /** @hidden */
  23012. static _SceneComponentInitialization: (scene: Scene) => void;
  23013. private _textureFormats;
  23014. /**
  23015. * To save performance, we can excluded skinned meshes from the prepass
  23016. */
  23017. excludedSkinnedMesh: AbstractMesh[];
  23018. /**
  23019. * Force material to be excluded from the prepass
  23020. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23021. * and you don't want a material to show in the effect.
  23022. */
  23023. excludedMaterials: Material[];
  23024. private _textureIndices;
  23025. private _scene;
  23026. private _engine;
  23027. private _isDirty;
  23028. /**
  23029. * Number of textures in the multi render target texture where the scene is directly rendered
  23030. */
  23031. mrtCount: number;
  23032. /**
  23033. * The render target where the scene is directly rendered
  23034. */
  23035. prePassRT: MultiRenderTarget;
  23036. private _multiRenderAttachments;
  23037. private _defaultAttachments;
  23038. private _clearAttachments;
  23039. private _postProcesses;
  23040. private readonly _clearColor;
  23041. /**
  23042. * Image processing post process for composition
  23043. */
  23044. imageProcessingPostProcess: ImageProcessingPostProcess;
  23045. /**
  23046. * Configuration for prepass effects
  23047. */
  23048. private _effectConfigurations;
  23049. private _mrtFormats;
  23050. private _mrtLayout;
  23051. private _enabled;
  23052. /**
  23053. * Indicates if the prepass is enabled
  23054. */
  23055. get enabled(): boolean;
  23056. /**
  23057. * How many samples are used for MSAA of the scene render target
  23058. */
  23059. get samples(): number;
  23060. set samples(n: number);
  23061. private _geometryBuffer;
  23062. private _useGeometryBufferFallback;
  23063. /**
  23064. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  23065. */
  23066. get useGeometryBufferFallback(): boolean;
  23067. set useGeometryBufferFallback(value: boolean);
  23068. /**
  23069. * Instanciates a prepass renderer
  23070. * @param scene The scene
  23071. */
  23072. constructor(scene: Scene);
  23073. private _initializeAttachments;
  23074. private _createCompositionEffect;
  23075. /**
  23076. * Indicates if rendering a prepass is supported
  23077. */
  23078. get isSupported(): boolean;
  23079. /**
  23080. * Sets the proper output textures to draw in the engine.
  23081. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23082. * @param subMesh Submesh on which the effect is applied
  23083. */
  23084. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23085. /**
  23086. * @hidden
  23087. */
  23088. _beforeCameraDraw(): void;
  23089. /**
  23090. * @hidden
  23091. */
  23092. _afterCameraDraw(): void;
  23093. private _checkRTSize;
  23094. private _bindFrameBuffer;
  23095. /**
  23096. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23097. */
  23098. clear(): void;
  23099. private _setState;
  23100. private _updateGeometryBufferLayout;
  23101. /**
  23102. * Adds an effect configuration to the prepass.
  23103. * If an effect has already been added, it won't add it twice and will return the configuration
  23104. * already present.
  23105. * @param cfg the effect configuration
  23106. * @return the effect configuration now used by the prepass
  23107. */
  23108. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23109. /**
  23110. * Returns the index of a texture in the multi render target texture array.
  23111. * @param type Texture type
  23112. * @return The index
  23113. */
  23114. getIndex(type: number): number;
  23115. private _enable;
  23116. private _disable;
  23117. private _resetLayout;
  23118. private _resetPostProcessChain;
  23119. private _bindPostProcessChain;
  23120. /**
  23121. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23122. */
  23123. markAsDirty(): void;
  23124. /**
  23125. * Enables a texture on the MultiRenderTarget for prepass
  23126. */
  23127. private _enableTextures;
  23128. private _update;
  23129. private _markAllMaterialsAsPrePassDirty;
  23130. /**
  23131. * Disposes the prepass renderer.
  23132. */
  23133. dispose(): void;
  23134. }
  23135. }
  23136. declare module "babylonjs/PostProcesses/postProcess" {
  23137. import { Nullable } from "babylonjs/types";
  23138. import { SmartArray } from "babylonjs/Misc/smartArray";
  23139. import { Observable } from "babylonjs/Misc/observable";
  23140. import { Vector2 } from "babylonjs/Maths/math.vector";
  23141. import { Camera } from "babylonjs/Cameras/camera";
  23142. import { Effect } from "babylonjs/Materials/effect";
  23143. import "babylonjs/Shaders/postprocess.vertex";
  23144. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23145. import { Engine } from "babylonjs/Engines/engine";
  23146. import { Color4 } from "babylonjs/Maths/math.color";
  23147. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23148. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23149. import { Scene } from "babylonjs/scene";
  23150. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23151. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  23152. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23153. /**
  23154. * Size options for a post process
  23155. */
  23156. export type PostProcessOptions = {
  23157. width: number;
  23158. height: number;
  23159. };
  23160. /**
  23161. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23162. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23163. */
  23164. export class PostProcess {
  23165. /**
  23166. * Gets or sets the unique id of the post process
  23167. */
  23168. uniqueId: number;
  23169. /** Name of the PostProcess. */
  23170. name: string;
  23171. /**
  23172. * Width of the texture to apply the post process on
  23173. */
  23174. width: number;
  23175. /**
  23176. * Height of the texture to apply the post process on
  23177. */
  23178. height: number;
  23179. /**
  23180. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23181. */
  23182. nodeMaterialSource: Nullable<NodeMaterial>;
  23183. /**
  23184. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23185. * @hidden
  23186. */
  23187. _outputTexture: Nullable<InternalTexture>;
  23188. /**
  23189. * Sampling mode used by the shader
  23190. * See https://doc.babylonjs.com/classes/3.1/texture
  23191. */
  23192. renderTargetSamplingMode: number;
  23193. /**
  23194. * Clear color to use when screen clearing
  23195. */
  23196. clearColor: Color4;
  23197. /**
  23198. * If the buffer needs to be cleared before applying the post process. (default: true)
  23199. * Should be set to false if shader will overwrite all previous pixels.
  23200. */
  23201. autoClear: boolean;
  23202. /**
  23203. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23204. */
  23205. alphaMode: number;
  23206. /**
  23207. * Sets the setAlphaBlendConstants of the babylon engine
  23208. */
  23209. alphaConstants: Color4;
  23210. /**
  23211. * Animations to be used for the post processing
  23212. */
  23213. animations: import("babylonjs/Animations/animation").Animation[];
  23214. /**
  23215. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23216. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23217. */
  23218. enablePixelPerfectMode: boolean;
  23219. /**
  23220. * Force the postprocess to be applied without taking in account viewport
  23221. */
  23222. forceFullscreenViewport: boolean;
  23223. /**
  23224. * List of inspectable custom properties (used by the Inspector)
  23225. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23226. */
  23227. inspectableCustomProperties: IInspectable[];
  23228. /**
  23229. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23230. *
  23231. * | Value | Type | Description |
  23232. * | ----- | ----------------------------------- | ----------- |
  23233. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23234. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23235. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23236. *
  23237. */
  23238. scaleMode: number;
  23239. /**
  23240. * Force textures to be a power of two (default: false)
  23241. */
  23242. alwaysForcePOT: boolean;
  23243. private _samples;
  23244. /**
  23245. * Number of sample textures (default: 1)
  23246. */
  23247. get samples(): number;
  23248. set samples(n: number);
  23249. /**
  23250. * Modify the scale of the post process to be the same as the viewport (default: false)
  23251. */
  23252. adaptScaleToCurrentViewport: boolean;
  23253. private _camera;
  23254. protected _scene: Scene;
  23255. private _engine;
  23256. private _options;
  23257. private _reusable;
  23258. private _textureType;
  23259. private _textureFormat;
  23260. /**
  23261. * Smart array of input and output textures for the post process.
  23262. * @hidden
  23263. */
  23264. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23265. /**
  23266. * The index in _textures that corresponds to the output texture.
  23267. * @hidden
  23268. */
  23269. _currentRenderTextureInd: number;
  23270. private _effect;
  23271. private _samplers;
  23272. private _fragmentUrl;
  23273. private _vertexUrl;
  23274. private _parameters;
  23275. private _scaleRatio;
  23276. protected _indexParameters: any;
  23277. private _shareOutputWithPostProcess;
  23278. private _texelSize;
  23279. private _forcedOutputTexture;
  23280. /**
  23281. * Prepass configuration in case this post process needs a texture from prepass
  23282. * @hidden
  23283. */
  23284. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23285. /**
  23286. * Returns the fragment url or shader name used in the post process.
  23287. * @returns the fragment url or name in the shader store.
  23288. */
  23289. getEffectName(): string;
  23290. /**
  23291. * An event triggered when the postprocess is activated.
  23292. */
  23293. onActivateObservable: Observable<Camera>;
  23294. private _onActivateObserver;
  23295. /**
  23296. * A function that is added to the onActivateObservable
  23297. */
  23298. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23299. /**
  23300. * An event triggered when the postprocess changes its size.
  23301. */
  23302. onSizeChangedObservable: Observable<PostProcess>;
  23303. private _onSizeChangedObserver;
  23304. /**
  23305. * A function that is added to the onSizeChangedObservable
  23306. */
  23307. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23308. /**
  23309. * An event triggered when the postprocess applies its effect.
  23310. */
  23311. onApplyObservable: Observable<Effect>;
  23312. private _onApplyObserver;
  23313. /**
  23314. * A function that is added to the onApplyObservable
  23315. */
  23316. set onApply(callback: (effect: Effect) => void);
  23317. /**
  23318. * An event triggered before rendering the postprocess
  23319. */
  23320. onBeforeRenderObservable: Observable<Effect>;
  23321. private _onBeforeRenderObserver;
  23322. /**
  23323. * A function that is added to the onBeforeRenderObservable
  23324. */
  23325. set onBeforeRender(callback: (effect: Effect) => void);
  23326. /**
  23327. * An event triggered after rendering the postprocess
  23328. */
  23329. onAfterRenderObservable: Observable<Effect>;
  23330. private _onAfterRenderObserver;
  23331. /**
  23332. * A function that is added to the onAfterRenderObservable
  23333. */
  23334. set onAfterRender(callback: (efect: Effect) => void);
  23335. /**
  23336. * 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
  23337. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23338. */
  23339. get inputTexture(): InternalTexture;
  23340. set inputTexture(value: InternalTexture);
  23341. /**
  23342. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23343. * the only way to unset it is to use this function to restore its internal state
  23344. */
  23345. restoreDefaultInputTexture(): void;
  23346. /**
  23347. * Gets the camera which post process is applied to.
  23348. * @returns The camera the post process is applied to.
  23349. */
  23350. getCamera(): Camera;
  23351. /**
  23352. * Gets the texel size of the postprocess.
  23353. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23354. */
  23355. get texelSize(): Vector2;
  23356. /**
  23357. * Creates a new instance PostProcess
  23358. * @param name The name of the PostProcess.
  23359. * @param fragmentUrl The url of the fragment shader to be used.
  23360. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23361. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23362. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23363. * @param camera The camera to apply the render pass to.
  23364. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23365. * @param engine The engine which the post process will be applied. (default: current engine)
  23366. * @param reusable If the post process can be reused on the same frame. (default: false)
  23367. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23368. * @param textureType Type of textures used when performing the post process. (default: 0)
  23369. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23370. * @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
  23371. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23372. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23373. */
  23374. 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);
  23375. /**
  23376. * Gets a string identifying the name of the class
  23377. * @returns "PostProcess" string
  23378. */
  23379. getClassName(): string;
  23380. /**
  23381. * Gets the engine which this post process belongs to.
  23382. * @returns The engine the post process was enabled with.
  23383. */
  23384. getEngine(): Engine;
  23385. /**
  23386. * The effect that is created when initializing the post process.
  23387. * @returns The created effect corresponding the the postprocess.
  23388. */
  23389. getEffect(): Effect;
  23390. /**
  23391. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23392. * @param postProcess The post process to share the output with.
  23393. * @returns This post process.
  23394. */
  23395. shareOutputWith(postProcess: PostProcess): PostProcess;
  23396. /**
  23397. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23398. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23399. */
  23400. useOwnOutput(): void;
  23401. /**
  23402. * Updates the effect with the current post process compile time values and recompiles the shader.
  23403. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23404. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23405. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23406. * @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
  23407. * @param onCompiled Called when the shader has been compiled.
  23408. * @param onError Called if there is an error when compiling a shader.
  23409. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23410. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23411. */
  23412. 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;
  23413. /**
  23414. * The post process is reusable if it can be used multiple times within one frame.
  23415. * @returns If the post process is reusable
  23416. */
  23417. isReusable(): boolean;
  23418. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23419. markTextureDirty(): void;
  23420. /**
  23421. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23422. * 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.
  23423. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23424. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23425. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23426. * @returns The target texture that was bound to be written to.
  23427. */
  23428. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23429. /**
  23430. * If the post process is supported.
  23431. */
  23432. get isSupported(): boolean;
  23433. /**
  23434. * The aspect ratio of the output texture.
  23435. */
  23436. get aspectRatio(): number;
  23437. /**
  23438. * Get a value indicating if the post-process is ready to be used
  23439. * @returns true if the post-process is ready (shader is compiled)
  23440. */
  23441. isReady(): boolean;
  23442. /**
  23443. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23444. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23445. */
  23446. apply(): Nullable<Effect>;
  23447. private _disposeTextures;
  23448. /**
  23449. * Sets the required values to the prepass renderer.
  23450. * @param prePassRenderer defines the prepass renderer to setup.
  23451. * @returns true if the pre pass is needed.
  23452. */
  23453. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23454. /**
  23455. * Disposes the post process.
  23456. * @param camera The camera to dispose the post process on.
  23457. */
  23458. dispose(camera?: Camera): void;
  23459. /**
  23460. * Serializes the particle system to a JSON object
  23461. * @returns the JSON object
  23462. */
  23463. serialize(): any;
  23464. /**
  23465. * Creates a material from parsed material data
  23466. * @param parsedPostProcess defines parsed post process data
  23467. * @param scene defines the hosting scene
  23468. * @param rootUrl defines the root URL to use to load textures
  23469. * @returns a new post process
  23470. */
  23471. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23472. }
  23473. }
  23474. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23475. /** @hidden */
  23476. export var kernelBlurVaryingDeclaration: {
  23477. name: string;
  23478. shader: string;
  23479. };
  23480. }
  23481. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  23482. /** @hidden */
  23483. export var packingFunctions: {
  23484. name: string;
  23485. shader: string;
  23486. };
  23487. }
  23488. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23489. /** @hidden */
  23490. export var kernelBlurFragment: {
  23491. name: string;
  23492. shader: string;
  23493. };
  23494. }
  23495. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23496. /** @hidden */
  23497. export var kernelBlurFragment2: {
  23498. name: string;
  23499. shader: string;
  23500. };
  23501. }
  23502. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23503. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23504. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23505. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23506. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23507. /** @hidden */
  23508. export var kernelBlurPixelShader: {
  23509. name: string;
  23510. shader: string;
  23511. };
  23512. }
  23513. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23514. /** @hidden */
  23515. export var kernelBlurVertex: {
  23516. name: string;
  23517. shader: string;
  23518. };
  23519. }
  23520. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23521. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23522. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23523. /** @hidden */
  23524. export var kernelBlurVertexShader: {
  23525. name: string;
  23526. shader: string;
  23527. };
  23528. }
  23529. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23530. import { Vector2 } from "babylonjs/Maths/math.vector";
  23531. import { Nullable } from "babylonjs/types";
  23532. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23533. import { Camera } from "babylonjs/Cameras/camera";
  23534. import { Effect } from "babylonjs/Materials/effect";
  23535. import { Engine } from "babylonjs/Engines/engine";
  23536. import "babylonjs/Shaders/kernelBlur.fragment";
  23537. import "babylonjs/Shaders/kernelBlur.vertex";
  23538. import { Scene } from "babylonjs/scene";
  23539. /**
  23540. * The Blur Post Process which blurs an image based on a kernel and direction.
  23541. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23542. */
  23543. export class BlurPostProcess extends PostProcess {
  23544. private blockCompilation;
  23545. protected _kernel: number;
  23546. protected _idealKernel: number;
  23547. protected _packedFloat: boolean;
  23548. private _staticDefines;
  23549. /** The direction in which to blur the image. */
  23550. direction: Vector2;
  23551. /**
  23552. * Sets the length in pixels of the blur sample region
  23553. */
  23554. set kernel(v: number);
  23555. /**
  23556. * Gets the length in pixels of the blur sample region
  23557. */
  23558. get kernel(): number;
  23559. /**
  23560. * Sets wether or not the blur needs to unpack/repack floats
  23561. */
  23562. set packedFloat(v: boolean);
  23563. /**
  23564. * Gets wether or not the blur is unpacking/repacking floats
  23565. */
  23566. get packedFloat(): boolean;
  23567. /**
  23568. * Gets a string identifying the name of the class
  23569. * @returns "BlurPostProcess" string
  23570. */
  23571. getClassName(): string;
  23572. /**
  23573. * Creates a new instance BlurPostProcess
  23574. * @param name The name of the effect.
  23575. * @param direction The direction in which to blur the image.
  23576. * @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.
  23577. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23578. * @param camera The camera to apply the render pass to.
  23579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23580. * @param engine The engine which the post process will be applied. (default: current engine)
  23581. * @param reusable If the post process can be reused on the same frame. (default: false)
  23582. * @param textureType Type of textures used when performing the post process. (default: 0)
  23583. * @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)
  23584. */
  23585. 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);
  23586. /**
  23587. * Updates the effect with the current post process compile time values and recompiles the shader.
  23588. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23589. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23590. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23591. * @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
  23592. * @param onCompiled Called when the shader has been compiled.
  23593. * @param onError Called if there is an error when compiling a shader.
  23594. */
  23595. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23596. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23597. /**
  23598. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23599. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23600. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23601. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23602. * The gaps between physical kernels are compensated for in the weighting of the samples
  23603. * @param idealKernel Ideal blur kernel.
  23604. * @return Nearest best kernel.
  23605. */
  23606. protected _nearestBestKernel(idealKernel: number): number;
  23607. /**
  23608. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23609. * @param x The point on the Gaussian distribution to sample.
  23610. * @return the value of the Gaussian function at x.
  23611. */
  23612. protected _gaussianWeight(x: number): number;
  23613. /**
  23614. * Generates a string that can be used as a floating point number in GLSL.
  23615. * @param x Value to print.
  23616. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23617. * @return GLSL float string.
  23618. */
  23619. protected _glslFloat(x: number, decimalFigures?: number): string;
  23620. /** @hidden */
  23621. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23622. }
  23623. }
  23624. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23625. import { Scene } from "babylonjs/scene";
  23626. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23627. import { Plane } from "babylonjs/Maths/math.plane";
  23628. /**
  23629. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23630. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23631. * You can then easily use it as a reflectionTexture on a flat surface.
  23632. * In case the surface is not a plane, please consider relying on reflection probes.
  23633. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23634. */
  23635. export class MirrorTexture extends RenderTargetTexture {
  23636. private scene;
  23637. /**
  23638. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23639. * 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.
  23640. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23641. */
  23642. mirrorPlane: Plane;
  23643. /**
  23644. * Define the blur ratio used to blur the reflection if needed.
  23645. */
  23646. set blurRatio(value: number);
  23647. get blurRatio(): number;
  23648. /**
  23649. * Define the adaptive blur kernel used to blur the reflection if needed.
  23650. * This will autocompute the closest best match for the `blurKernel`
  23651. */
  23652. set adaptiveBlurKernel(value: number);
  23653. /**
  23654. * Define the blur kernel used to blur the reflection if needed.
  23655. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23656. */
  23657. set blurKernel(value: number);
  23658. /**
  23659. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23660. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23661. */
  23662. set blurKernelX(value: number);
  23663. get blurKernelX(): number;
  23664. /**
  23665. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23666. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23667. */
  23668. set blurKernelY(value: number);
  23669. get blurKernelY(): number;
  23670. private _autoComputeBlurKernel;
  23671. protected _onRatioRescale(): void;
  23672. private _updateGammaSpace;
  23673. private _imageProcessingConfigChangeObserver;
  23674. private _transformMatrix;
  23675. private _mirrorMatrix;
  23676. private _savedViewMatrix;
  23677. private _blurX;
  23678. private _blurY;
  23679. private _adaptiveBlurKernel;
  23680. private _blurKernelX;
  23681. private _blurKernelY;
  23682. private _blurRatio;
  23683. /**
  23684. * Instantiates a Mirror Texture.
  23685. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23686. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23687. * You can then easily use it as a reflectionTexture on a flat surface.
  23688. * In case the surface is not a plane, please consider relying on reflection probes.
  23689. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23690. * @param name
  23691. * @param size
  23692. * @param scene
  23693. * @param generateMipMaps
  23694. * @param type
  23695. * @param samplingMode
  23696. * @param generateDepthBuffer
  23697. */
  23698. constructor(name: string, size: number | {
  23699. width: number;
  23700. height: number;
  23701. } | {
  23702. ratio: number;
  23703. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23704. private _preparePostProcesses;
  23705. /**
  23706. * Clone the mirror texture.
  23707. * @returns the cloned texture
  23708. */
  23709. clone(): MirrorTexture;
  23710. /**
  23711. * Serialize the texture to a JSON representation you could use in Parse later on
  23712. * @returns the serialized JSON representation
  23713. */
  23714. serialize(): any;
  23715. /**
  23716. * Dispose the texture and release its associated resources.
  23717. */
  23718. dispose(): void;
  23719. }
  23720. }
  23721. declare module "babylonjs/Materials/Textures/texture" {
  23722. import { Observable } from "babylonjs/Misc/observable";
  23723. import { Nullable } from "babylonjs/types";
  23724. import { Matrix } from "babylonjs/Maths/math.vector";
  23725. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23726. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23727. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23728. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23729. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23730. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23731. import { Scene } from "babylonjs/scene";
  23732. /**
  23733. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23734. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23735. */
  23736. export class Texture extends BaseTexture {
  23737. /**
  23738. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23739. */
  23740. static SerializeBuffers: boolean;
  23741. /**
  23742. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23743. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23744. */
  23745. static ForceSerializeBuffers: boolean;
  23746. /** @hidden */
  23747. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23748. /** @hidden */
  23749. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23750. /** @hidden */
  23751. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23752. /** nearest is mag = nearest and min = nearest and mip = linear */
  23753. static readonly NEAREST_SAMPLINGMODE: number;
  23754. /** nearest is mag = nearest and min = nearest and mip = linear */
  23755. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23756. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23757. static readonly BILINEAR_SAMPLINGMODE: number;
  23758. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23759. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23760. /** Trilinear is mag = linear and min = linear and mip = linear */
  23761. static readonly TRILINEAR_SAMPLINGMODE: number;
  23762. /** Trilinear is mag = linear and min = linear and mip = linear */
  23763. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23764. /** mag = nearest and min = nearest and mip = nearest */
  23765. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23766. /** mag = nearest and min = linear and mip = nearest */
  23767. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23768. /** mag = nearest and min = linear and mip = linear */
  23769. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23770. /** mag = nearest and min = linear and mip = none */
  23771. static readonly NEAREST_LINEAR: number;
  23772. /** mag = nearest and min = nearest and mip = none */
  23773. static readonly NEAREST_NEAREST: number;
  23774. /** mag = linear and min = nearest and mip = nearest */
  23775. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23776. /** mag = linear and min = nearest and mip = linear */
  23777. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23778. /** mag = linear and min = linear and mip = none */
  23779. static readonly LINEAR_LINEAR: number;
  23780. /** mag = linear and min = nearest and mip = none */
  23781. static readonly LINEAR_NEAREST: number;
  23782. /** Explicit coordinates mode */
  23783. static readonly EXPLICIT_MODE: number;
  23784. /** Spherical coordinates mode */
  23785. static readonly SPHERICAL_MODE: number;
  23786. /** Planar coordinates mode */
  23787. static readonly PLANAR_MODE: number;
  23788. /** Cubic coordinates mode */
  23789. static readonly CUBIC_MODE: number;
  23790. /** Projection coordinates mode */
  23791. static readonly PROJECTION_MODE: number;
  23792. /** Inverse Cubic coordinates mode */
  23793. static readonly SKYBOX_MODE: number;
  23794. /** Inverse Cubic coordinates mode */
  23795. static readonly INVCUBIC_MODE: number;
  23796. /** Equirectangular coordinates mode */
  23797. static readonly EQUIRECTANGULAR_MODE: number;
  23798. /** Equirectangular Fixed coordinates mode */
  23799. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23800. /** Equirectangular Fixed Mirrored coordinates mode */
  23801. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23802. /** Texture is not repeating outside of 0..1 UVs */
  23803. static readonly CLAMP_ADDRESSMODE: number;
  23804. /** Texture is repeating outside of 0..1 UVs */
  23805. static readonly WRAP_ADDRESSMODE: number;
  23806. /** Texture is repeating and mirrored */
  23807. static readonly MIRROR_ADDRESSMODE: number;
  23808. /**
  23809. * 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
  23810. */
  23811. static UseSerializedUrlIfAny: boolean;
  23812. /**
  23813. * Define the url of the texture.
  23814. */
  23815. url: Nullable<string>;
  23816. /**
  23817. * Define an offset on the texture to offset the u coordinates of the UVs
  23818. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23819. */
  23820. uOffset: number;
  23821. /**
  23822. * Define an offset on the texture to offset the v coordinates of the UVs
  23823. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23824. */
  23825. vOffset: number;
  23826. /**
  23827. * Define an offset on the texture to scale the u coordinates of the UVs
  23828. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23829. */
  23830. uScale: number;
  23831. /**
  23832. * Define an offset on the texture to scale the v coordinates of the UVs
  23833. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23834. */
  23835. vScale: number;
  23836. /**
  23837. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23838. * @see https://doc.babylonjs.com/how_to/more_materials
  23839. */
  23840. uAng: number;
  23841. /**
  23842. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23843. * @see https://doc.babylonjs.com/how_to/more_materials
  23844. */
  23845. vAng: number;
  23846. /**
  23847. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23848. * @see https://doc.babylonjs.com/how_to/more_materials
  23849. */
  23850. wAng: number;
  23851. /**
  23852. * Defines the center of rotation (U)
  23853. */
  23854. uRotationCenter: number;
  23855. /**
  23856. * Defines the center of rotation (V)
  23857. */
  23858. vRotationCenter: number;
  23859. /**
  23860. * Defines the center of rotation (W)
  23861. */
  23862. wRotationCenter: number;
  23863. /**
  23864. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23865. */
  23866. homogeneousRotationInUVTransform: boolean;
  23867. /**
  23868. * Are mip maps generated for this texture or not.
  23869. */
  23870. get noMipmap(): boolean;
  23871. /**
  23872. * List of inspectable custom properties (used by the Inspector)
  23873. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23874. */
  23875. inspectableCustomProperties: Nullable<IInspectable[]>;
  23876. private _noMipmap;
  23877. /** @hidden */
  23878. _invertY: boolean;
  23879. private _rowGenerationMatrix;
  23880. private _cachedTextureMatrix;
  23881. private _projectionModeMatrix;
  23882. private _t0;
  23883. private _t1;
  23884. private _t2;
  23885. private _cachedUOffset;
  23886. private _cachedVOffset;
  23887. private _cachedUScale;
  23888. private _cachedVScale;
  23889. private _cachedUAng;
  23890. private _cachedVAng;
  23891. private _cachedWAng;
  23892. private _cachedProjectionMatrixId;
  23893. private _cachedURotationCenter;
  23894. private _cachedVRotationCenter;
  23895. private _cachedWRotationCenter;
  23896. private _cachedHomogeneousRotationInUVTransform;
  23897. private _cachedCoordinatesMode;
  23898. /** @hidden */
  23899. protected _initialSamplingMode: number;
  23900. /** @hidden */
  23901. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23902. private _deleteBuffer;
  23903. protected _format: Nullable<number>;
  23904. private _delayedOnLoad;
  23905. private _delayedOnError;
  23906. private _mimeType?;
  23907. private _loaderOptions?;
  23908. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23909. get mimeType(): string | undefined;
  23910. /**
  23911. * Observable triggered once the texture has been loaded.
  23912. */
  23913. onLoadObservable: Observable<Texture>;
  23914. protected _isBlocking: boolean;
  23915. /**
  23916. * Is the texture preventing material to render while loading.
  23917. * If false, a default texture will be used instead of the loading one during the preparation step.
  23918. */
  23919. set isBlocking(value: boolean);
  23920. get isBlocking(): boolean;
  23921. /**
  23922. * Get the current sampling mode associated with the texture.
  23923. */
  23924. get samplingMode(): number;
  23925. /**
  23926. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23927. */
  23928. get invertY(): boolean;
  23929. /**
  23930. * Instantiates a new texture.
  23931. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23932. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23933. * @param url defines the url of the picture to load as a texture
  23934. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23935. * @param noMipmap defines if the texture will require mip maps or not
  23936. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23937. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23938. * @param onLoad defines a callback triggered when the texture has been loaded
  23939. * @param onError defines a callback triggered when an error occurred during the loading session
  23940. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23941. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23942. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23943. * @param mimeType defines an optional mime type information
  23944. * @param loaderOptions options to be passed to the loader
  23945. */
  23946. 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);
  23947. /**
  23948. * Update the url (and optional buffer) of this texture if url was null during construction.
  23949. * @param url the url of the texture
  23950. * @param buffer the buffer of the texture (defaults to null)
  23951. * @param onLoad callback called when the texture is loaded (defaults to null)
  23952. */
  23953. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23954. /**
  23955. * Finish the loading sequence of a texture flagged as delayed load.
  23956. * @hidden
  23957. */
  23958. delayLoad(): void;
  23959. private _prepareRowForTextureGeneration;
  23960. /**
  23961. * Checks if the texture has the same transform matrix than another texture
  23962. * @param texture texture to check against
  23963. * @returns true if the transforms are the same, else false
  23964. */
  23965. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23966. /**
  23967. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23968. * @returns the transform matrix of the texture.
  23969. */
  23970. getTextureMatrix(uBase?: number): Matrix;
  23971. /**
  23972. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23973. * @returns The reflection texture transform
  23974. */
  23975. getReflectionTextureMatrix(): Matrix;
  23976. /**
  23977. * Clones the texture.
  23978. * @returns the cloned texture
  23979. */
  23980. clone(): Texture;
  23981. /**
  23982. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23983. * @returns The JSON representation of the texture
  23984. */
  23985. serialize(): any;
  23986. /**
  23987. * Get the current class name of the texture useful for serialization or dynamic coding.
  23988. * @returns "Texture"
  23989. */
  23990. getClassName(): string;
  23991. /**
  23992. * Dispose the texture and release its associated resources.
  23993. */
  23994. dispose(): void;
  23995. /**
  23996. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23997. * @param parsedTexture Define the JSON representation of the texture
  23998. * @param scene Define the scene the parsed texture should be instantiated in
  23999. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24000. * @returns The parsed texture if successful
  24001. */
  24002. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24003. /**
  24004. * Creates a texture from its base 64 representation.
  24005. * @param data Define the base64 payload without the data: prefix
  24006. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24007. * @param scene Define the scene the texture should belong to
  24008. * @param noMipmap Forces the texture to not create mip map information if true
  24009. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24010. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24011. * @param onLoad define a callback triggered when the texture has been loaded
  24012. * @param onError define a callback triggered when an error occurred during the loading session
  24013. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24014. * @returns the created texture
  24015. */
  24016. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24017. /**
  24018. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24019. * @param data Define the base64 payload without the data: prefix
  24020. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24021. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24022. * @param scene Define the scene the texture should belong to
  24023. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24024. * @param noMipmap Forces the texture to not create mip map information if true
  24025. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24026. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24027. * @param onLoad define a callback triggered when the texture has been loaded
  24028. * @param onError define a callback triggered when an error occurred during the loading session
  24029. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24030. * @returns the created texture
  24031. */
  24032. 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;
  24033. }
  24034. }
  24035. declare module "babylonjs/Sprites/thinSprite" {
  24036. import { IVector3Like, IColor4Like } from "babylonjs/Maths/math.like";
  24037. import { Nullable } from "babylonjs/types";
  24038. /**
  24039. * ThinSprite Class used to represent a thin sprite
  24040. * This is the base class for sprites but can also directly be used with ThinEngine
  24041. * @see https://doc.babylonjs.com/babylon101/sprites
  24042. */
  24043. export class ThinSprite {
  24044. /** Gets or sets the cell index in the sprite sheet */
  24045. cellIndex: number;
  24046. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24047. cellRef: string;
  24048. /** Gets or sets the current world position */
  24049. position: IVector3Like;
  24050. /** Gets or sets the main color */
  24051. color: IColor4Like;
  24052. /** Gets or sets the width */
  24053. width: number;
  24054. /** Gets or sets the height */
  24055. height: number;
  24056. /** Gets or sets rotation angle */
  24057. angle: number;
  24058. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24059. invertU: boolean;
  24060. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24061. invertV: boolean;
  24062. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24063. isVisible: boolean;
  24064. /**
  24065. * Returns a boolean indicating if the animation is started
  24066. */
  24067. get animationStarted(): boolean;
  24068. /** Gets the initial key for the animation (setting it will restart the animation) */
  24069. get fromIndex(): number;
  24070. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24071. get toIndex(): number;
  24072. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24073. get loopAnimation(): boolean;
  24074. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24075. get delay(): number;
  24076. /** @hidden */
  24077. _xOffset: number;
  24078. /** @hidden */
  24079. _yOffset: number;
  24080. /** @hidden */
  24081. _xSize: number;
  24082. /** @hidden */
  24083. _ySize: number;
  24084. private _animationStarted;
  24085. protected _loopAnimation: boolean;
  24086. protected _fromIndex: number;
  24087. protected _toIndex: number;
  24088. protected _delay: number;
  24089. private _direction;
  24090. private _time;
  24091. private _onBaseAnimationEnd;
  24092. /**
  24093. * Creates a new Thin Sprite
  24094. */
  24095. constructor();
  24096. /**
  24097. * Starts an animation
  24098. * @param from defines the initial key
  24099. * @param to defines the end key
  24100. * @param loop defines if the animation must loop
  24101. * @param delay defines the start delay (in ms)
  24102. * @param onAnimationEnd defines a callback for when the animation ends
  24103. */
  24104. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24105. /** Stops current animation (if any) */
  24106. stopAnimation(): void;
  24107. /** @hidden */
  24108. _animate(deltaTime: number): void;
  24109. }
  24110. }
  24111. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  24112. /** @hidden */
  24113. export var imageProcessingCompatibility: {
  24114. name: string;
  24115. shader: string;
  24116. };
  24117. }
  24118. declare module "babylonjs/Shaders/sprites.fragment" {
  24119. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24120. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24121. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  24122. /** @hidden */
  24123. export var spritesPixelShader: {
  24124. name: string;
  24125. shader: string;
  24126. };
  24127. }
  24128. declare module "babylonjs/Shaders/sprites.vertex" {
  24129. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24130. /** @hidden */
  24131. export var spritesVertexShader: {
  24132. name: string;
  24133. shader: string;
  24134. };
  24135. }
  24136. declare module "babylonjs/Sprites/spriteRenderer" {
  24137. import { Nullable } from "babylonjs/types";
  24138. import { IMatrixLike } from "babylonjs/Maths/math.like";
  24139. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24140. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  24141. import { ISize } from "babylonjs/Maths/math.size";
  24142. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  24143. import { Scene } from "babylonjs/scene";
  24144. import "babylonjs/Engines/Extensions/engine.alpha";
  24145. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  24146. import "babylonjs/Shaders/sprites.fragment";
  24147. import "babylonjs/Shaders/sprites.vertex";
  24148. /**
  24149. * Class used to render sprites.
  24150. *
  24151. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24152. */
  24153. export class SpriteRenderer {
  24154. /**
  24155. * Defines the texture of the spritesheet
  24156. */
  24157. texture: Nullable<ThinTexture>;
  24158. /**
  24159. * Defines the default width of a cell in the spritesheet
  24160. */
  24161. cellWidth: number;
  24162. /**
  24163. * Defines the default height of a cell in the spritesheet
  24164. */
  24165. cellHeight: number;
  24166. /**
  24167. * Blend mode use to render the particle, it can be any of
  24168. * the static Constants.ALPHA_x properties provided in this class.
  24169. * Default value is Constants.ALPHA_COMBINE
  24170. */
  24171. blendMode: number;
  24172. /**
  24173. * Gets or sets a boolean indicating if alpha mode is automatically
  24174. * reset.
  24175. */
  24176. autoResetAlpha: boolean;
  24177. /**
  24178. * Disables writing to the depth buffer when rendering the sprites.
  24179. * It can be handy to disable depth writing when using textures without alpha channel
  24180. * and setting some specific blend modes.
  24181. */
  24182. disableDepthWrite: boolean;
  24183. /**
  24184. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24185. */
  24186. fogEnabled: boolean;
  24187. /**
  24188. * Gets the capacity of the manager
  24189. */
  24190. get capacity(): number;
  24191. private readonly _engine;
  24192. private readonly _useVAO;
  24193. private readonly _useInstancing;
  24194. private readonly _scene;
  24195. private readonly _capacity;
  24196. private readonly _epsilon;
  24197. private _vertexBufferSize;
  24198. private _vertexData;
  24199. private _buffer;
  24200. private _vertexBuffers;
  24201. private _spriteBuffer;
  24202. private _indexBuffer;
  24203. private _effectBase;
  24204. private _effectFog;
  24205. private _vertexArrayObject;
  24206. /**
  24207. * Creates a new sprite Renderer
  24208. * @param engine defines the engine the renderer works with
  24209. * @param capacity defines the maximum allowed number of sprites
  24210. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24211. * @param scene defines the hosting scene
  24212. */
  24213. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24214. /**
  24215. * Render all child sprites
  24216. * @param sprites defines the list of sprites to render
  24217. * @param deltaTime defines the time since last frame
  24218. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24219. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24220. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24221. */
  24222. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24223. private _appendSpriteVertex;
  24224. /**
  24225. * Release associated resources
  24226. */
  24227. dispose(): void;
  24228. }
  24229. }
  24230. declare module "babylonjs/Sprites/spriteManager" {
  24231. import { IDisposable, Scene } from "babylonjs/scene";
  24232. import { Nullable } from "babylonjs/types";
  24233. import { Observable } from "babylonjs/Misc/observable";
  24234. import { Sprite } from "babylonjs/Sprites/sprite";
  24235. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24236. import { Camera } from "babylonjs/Cameras/camera";
  24237. import { Texture } from "babylonjs/Materials/Textures/texture";
  24238. import { Ray } from "babylonjs/Culling/ray";
  24239. /**
  24240. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24241. */
  24242. export interface ISpriteManager extends IDisposable {
  24243. /**
  24244. * Gets manager's name
  24245. */
  24246. name: string;
  24247. /**
  24248. * Restricts the camera to viewing objects with the same layerMask.
  24249. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24250. */
  24251. layerMask: number;
  24252. /**
  24253. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24254. */
  24255. isPickable: boolean;
  24256. /**
  24257. * Gets the hosting scene
  24258. */
  24259. scene: Scene;
  24260. /**
  24261. * Specifies the rendering group id for this mesh (0 by default)
  24262. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24263. */
  24264. renderingGroupId: number;
  24265. /**
  24266. * Defines the list of sprites managed by the manager.
  24267. */
  24268. sprites: Array<Sprite>;
  24269. /**
  24270. * Gets or sets the spritesheet texture
  24271. */
  24272. texture: Texture;
  24273. /** Defines the default width of a cell in the spritesheet */
  24274. cellWidth: number;
  24275. /** Defines the default height of a cell in the spritesheet */
  24276. cellHeight: number;
  24277. /**
  24278. * Tests the intersection of a sprite with a specific ray.
  24279. * @param ray The ray we are sending to test the collision
  24280. * @param camera The camera space we are sending rays in
  24281. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24282. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24283. * @returns picking info or null.
  24284. */
  24285. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24286. /**
  24287. * Intersects the sprites with a ray
  24288. * @param ray defines the ray to intersect with
  24289. * @param camera defines the current active camera
  24290. * @param predicate defines a predicate used to select candidate sprites
  24291. * @returns null if no hit or a PickingInfo array
  24292. */
  24293. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24294. /**
  24295. * Renders the list of sprites on screen.
  24296. */
  24297. render(): void;
  24298. }
  24299. /**
  24300. * Class used to manage multiple sprites on the same spritesheet
  24301. * @see https://doc.babylonjs.com/babylon101/sprites
  24302. */
  24303. export class SpriteManager implements ISpriteManager {
  24304. /** defines the manager's name */
  24305. name: string;
  24306. /** Define the Url to load snippets */
  24307. static SnippetUrl: string;
  24308. /** Snippet ID if the manager was created from the snippet server */
  24309. snippetId: string;
  24310. /** Gets the list of sprites */
  24311. sprites: Sprite[];
  24312. /** Gets or sets the rendering group id (0 by default) */
  24313. renderingGroupId: number;
  24314. /** Gets or sets camera layer mask */
  24315. layerMask: number;
  24316. /** Gets or sets a boolean indicating if the sprites are pickable */
  24317. isPickable: boolean;
  24318. /**
  24319. * An event triggered when the manager is disposed.
  24320. */
  24321. onDisposeObservable: Observable<SpriteManager>;
  24322. /**
  24323. * Callback called when the manager is disposed
  24324. */
  24325. set onDispose(callback: () => void);
  24326. /**
  24327. * Gets or sets the unique id of the sprite
  24328. */
  24329. uniqueId: number;
  24330. /**
  24331. * Gets the array of sprites
  24332. */
  24333. get children(): Sprite[];
  24334. /**
  24335. * Gets the hosting scene
  24336. */
  24337. get scene(): Scene;
  24338. /**
  24339. * Gets the capacity of the manager
  24340. */
  24341. get capacity(): number;
  24342. /**
  24343. * Gets or sets the spritesheet texture
  24344. */
  24345. get texture(): Texture;
  24346. set texture(value: Texture);
  24347. /** Defines the default width of a cell in the spritesheet */
  24348. get cellWidth(): number;
  24349. set cellWidth(value: number);
  24350. /** Defines the default height of a cell in the spritesheet */
  24351. get cellHeight(): number;
  24352. set cellHeight(value: number);
  24353. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24354. get fogEnabled(): boolean;
  24355. set fogEnabled(value: boolean);
  24356. /**
  24357. * Blend mode use to render the particle, it can be any of
  24358. * the static Constants.ALPHA_x properties provided in this class.
  24359. * Default value is Constants.ALPHA_COMBINE
  24360. */
  24361. get blendMode(): number;
  24362. set blendMode(blendMode: number);
  24363. /** Disables writing to the depth buffer when rendering the sprites.
  24364. * It can be handy to disable depth writing when using textures without alpha channel
  24365. * and setting some specific blend modes.
  24366. */
  24367. disableDepthWrite: boolean;
  24368. private _spriteRenderer;
  24369. /** Associative array from JSON sprite data file */
  24370. private _cellData;
  24371. /** Array of sprite names from JSON sprite data file */
  24372. private _spriteMap;
  24373. /** True when packed cell data from JSON file is ready*/
  24374. private _packedAndReady;
  24375. private _textureContent;
  24376. private _onDisposeObserver;
  24377. private _fromPacked;
  24378. private _scene;
  24379. /**
  24380. * Creates a new sprite manager
  24381. * @param name defines the manager's name
  24382. * @param imgUrl defines the sprite sheet url
  24383. * @param capacity defines the maximum allowed number of sprites
  24384. * @param cellSize defines the size of a sprite cell
  24385. * @param scene defines the hosting scene
  24386. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24387. * @param samplingMode defines the smapling mode to use with spritesheet
  24388. * @param fromPacked set to false; do not alter
  24389. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24390. */
  24391. constructor(
  24392. /** defines the manager's name */
  24393. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24394. /**
  24395. * Returns the string "SpriteManager"
  24396. * @returns "SpriteManager"
  24397. */
  24398. getClassName(): string;
  24399. private _makePacked;
  24400. private _checkTextureAlpha;
  24401. /**
  24402. * Intersects the sprites with a ray
  24403. * @param ray defines the ray to intersect with
  24404. * @param camera defines the current active camera
  24405. * @param predicate defines a predicate used to select candidate sprites
  24406. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24407. * @returns null if no hit or a PickingInfo
  24408. */
  24409. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24410. /**
  24411. * Intersects the sprites with a ray
  24412. * @param ray defines the ray to intersect with
  24413. * @param camera defines the current active camera
  24414. * @param predicate defines a predicate used to select candidate sprites
  24415. * @returns null if no hit or a PickingInfo array
  24416. */
  24417. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24418. /**
  24419. * Render all child sprites
  24420. */
  24421. render(): void;
  24422. private _customUpdate;
  24423. /**
  24424. * Release associated resources
  24425. */
  24426. dispose(): void;
  24427. /**
  24428. * Serializes the sprite manager to a JSON object
  24429. * @param serializeTexture defines if the texture must be serialized as well
  24430. * @returns the JSON object
  24431. */
  24432. serialize(serializeTexture?: boolean): any;
  24433. /**
  24434. * Parses a JSON object to create a new sprite manager.
  24435. * @param parsedManager The JSON object to parse
  24436. * @param scene The scene to create the sprite managerin
  24437. * @param rootUrl The root url to use to load external dependencies like texture
  24438. * @returns the new sprite manager
  24439. */
  24440. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24441. /**
  24442. * Creates a sprite manager from a snippet saved in a remote file
  24443. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24444. * @param url defines the url to load from
  24445. * @param scene defines the hosting scene
  24446. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24447. * @returns a promise that will resolve to the new sprite manager
  24448. */
  24449. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24450. /**
  24451. * Creates a sprite manager from a snippet saved by the sprite editor
  24452. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24453. * @param scene defines the hosting scene
  24454. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24455. * @returns a promise that will resolve to the new sprite manager
  24456. */
  24457. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24458. }
  24459. }
  24460. declare module "babylonjs/Sprites/sprite" {
  24461. import { Vector3 } from "babylonjs/Maths/math.vector";
  24462. import { Nullable } from "babylonjs/types";
  24463. import { ActionManager } from "babylonjs/Actions/actionManager";
  24464. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  24465. import { Color4 } from "babylonjs/Maths/math.color";
  24466. import { Observable } from "babylonjs/Misc/observable";
  24467. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24468. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  24469. import { Animation } from "babylonjs/Animations/animation";
  24470. /**
  24471. * Class used to represent a sprite
  24472. * @see https://doc.babylonjs.com/babylon101/sprites
  24473. */
  24474. export class Sprite extends ThinSprite implements IAnimatable {
  24475. /** defines the name */
  24476. name: string;
  24477. /** Gets or sets the current world position */
  24478. position: Vector3;
  24479. /** Gets or sets the main color */
  24480. color: Color4;
  24481. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24482. disposeWhenFinishedAnimating: boolean;
  24483. /** Gets the list of attached animations */
  24484. animations: Nullable<Array<Animation>>;
  24485. /** Gets or sets a boolean indicating if the sprite can be picked */
  24486. isPickable: boolean;
  24487. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24488. useAlphaForPicking: boolean;
  24489. /**
  24490. * Gets or sets the associated action manager
  24491. */
  24492. actionManager: Nullable<ActionManager>;
  24493. /**
  24494. * An event triggered when the control has been disposed
  24495. */
  24496. onDisposeObservable: Observable<Sprite>;
  24497. private _manager;
  24498. private _onAnimationEnd;
  24499. /**
  24500. * Gets or sets the sprite size
  24501. */
  24502. get size(): number;
  24503. set size(value: number);
  24504. /**
  24505. * Gets or sets the unique id of the sprite
  24506. */
  24507. uniqueId: number;
  24508. /**
  24509. * Gets the manager of this sprite
  24510. */
  24511. get manager(): ISpriteManager;
  24512. /**
  24513. * Creates a new Sprite
  24514. * @param name defines the name
  24515. * @param manager defines the manager
  24516. */
  24517. constructor(
  24518. /** defines the name */
  24519. name: string, manager: ISpriteManager);
  24520. /**
  24521. * Returns the string "Sprite"
  24522. * @returns "Sprite"
  24523. */
  24524. getClassName(): string;
  24525. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24526. get fromIndex(): number;
  24527. set fromIndex(value: number);
  24528. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24529. get toIndex(): number;
  24530. set toIndex(value: number);
  24531. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24532. get loopAnimation(): boolean;
  24533. set loopAnimation(value: boolean);
  24534. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24535. get delay(): number;
  24536. set delay(value: number);
  24537. /**
  24538. * Starts an animation
  24539. * @param from defines the initial key
  24540. * @param to defines the end key
  24541. * @param loop defines if the animation must loop
  24542. * @param delay defines the start delay (in ms)
  24543. * @param onAnimationEnd defines a callback to call when animation ends
  24544. */
  24545. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24546. private _endAnimation;
  24547. /** Release associated resources */
  24548. dispose(): void;
  24549. /**
  24550. * Serializes the sprite to a JSON object
  24551. * @returns the JSON object
  24552. */
  24553. serialize(): any;
  24554. /**
  24555. * Parses a JSON object to create a new sprite
  24556. * @param parsedSprite The JSON object to parse
  24557. * @param manager defines the hosting manager
  24558. * @returns the new sprite
  24559. */
  24560. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24561. }
  24562. }
  24563. declare module "babylonjs/Collisions/pickingInfo" {
  24564. import { Nullable } from "babylonjs/types";
  24565. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  24566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24567. import { Sprite } from "babylonjs/Sprites/sprite";
  24568. import { Ray } from "babylonjs/Culling/ray";
  24569. /**
  24570. * Information about the result of picking within a scene
  24571. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24572. */
  24573. export class PickingInfo {
  24574. /** @hidden */
  24575. _pickingUnavailable: boolean;
  24576. /**
  24577. * If the pick collided with an object
  24578. */
  24579. hit: boolean;
  24580. /**
  24581. * Distance away where the pick collided
  24582. */
  24583. distance: number;
  24584. /**
  24585. * The location of pick collision
  24586. */
  24587. pickedPoint: Nullable<Vector3>;
  24588. /**
  24589. * The mesh corresponding the the pick collision
  24590. */
  24591. pickedMesh: Nullable<AbstractMesh>;
  24592. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24593. bu: number;
  24594. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24595. bv: number;
  24596. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24597. faceId: number;
  24598. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24599. subMeshFaceId: number;
  24600. /** Id of the the submesh that was picked */
  24601. subMeshId: number;
  24602. /** If a sprite was picked, this will be the sprite the pick collided with */
  24603. pickedSprite: Nullable<Sprite>;
  24604. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  24605. thinInstanceIndex: number;
  24606. /**
  24607. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24608. */
  24609. originMesh: Nullable<AbstractMesh>;
  24610. /**
  24611. * The ray that was used to perform the picking.
  24612. */
  24613. ray: Nullable<Ray>;
  24614. /**
  24615. * Gets the normal correspodning to the face the pick collided with
  24616. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24617. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24618. * @returns The normal correspodning to the face the pick collided with
  24619. */
  24620. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24621. /**
  24622. * Gets the texture coordinates of where the pick occured
  24623. * @returns the vector containing the coordnates of the texture
  24624. */
  24625. getTextureCoordinates(): Nullable<Vector2>;
  24626. }
  24627. }
  24628. declare module "babylonjs/Events/pointerEvents" {
  24629. import { Nullable } from "babylonjs/types";
  24630. import { Vector2 } from "babylonjs/Maths/math.vector";
  24631. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24632. import { Ray } from "babylonjs/Culling/ray";
  24633. /**
  24634. * Gather the list of pointer event types as constants.
  24635. */
  24636. export class PointerEventTypes {
  24637. /**
  24638. * 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.
  24639. */
  24640. static readonly POINTERDOWN: number;
  24641. /**
  24642. * The pointerup event is fired when a pointer is no longer active.
  24643. */
  24644. static readonly POINTERUP: number;
  24645. /**
  24646. * The pointermove event is fired when a pointer changes coordinates.
  24647. */
  24648. static readonly POINTERMOVE: number;
  24649. /**
  24650. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24651. */
  24652. static readonly POINTERWHEEL: number;
  24653. /**
  24654. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24655. */
  24656. static readonly POINTERPICK: number;
  24657. /**
  24658. * The pointertap event is fired when a the object has been touched and released without drag.
  24659. */
  24660. static readonly POINTERTAP: number;
  24661. /**
  24662. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24663. */
  24664. static readonly POINTERDOUBLETAP: number;
  24665. }
  24666. /**
  24667. * Base class of pointer info types.
  24668. */
  24669. export class PointerInfoBase {
  24670. /**
  24671. * Defines the type of event (PointerEventTypes)
  24672. */
  24673. type: number;
  24674. /**
  24675. * Defines the related dom event
  24676. */
  24677. event: PointerEvent | MouseWheelEvent;
  24678. /**
  24679. * Instantiates the base class of pointers info.
  24680. * @param type Defines the type of event (PointerEventTypes)
  24681. * @param event Defines the related dom event
  24682. */
  24683. constructor(
  24684. /**
  24685. * Defines the type of event (PointerEventTypes)
  24686. */
  24687. type: number,
  24688. /**
  24689. * Defines the related dom event
  24690. */
  24691. event: PointerEvent | MouseWheelEvent);
  24692. }
  24693. /**
  24694. * This class is used to store pointer related info for the onPrePointerObservable event.
  24695. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24696. */
  24697. export class PointerInfoPre extends PointerInfoBase {
  24698. /**
  24699. * Ray from a pointer if availible (eg. 6dof controller)
  24700. */
  24701. ray: Nullable<Ray>;
  24702. /**
  24703. * Defines the local position of the pointer on the canvas.
  24704. */
  24705. localPosition: Vector2;
  24706. /**
  24707. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24708. */
  24709. skipOnPointerObservable: boolean;
  24710. /**
  24711. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24712. * @param type Defines the type of event (PointerEventTypes)
  24713. * @param event Defines the related dom event
  24714. * @param localX Defines the local x coordinates of the pointer when the event occured
  24715. * @param localY Defines the local y coordinates of the pointer when the event occured
  24716. */
  24717. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24718. }
  24719. /**
  24720. * This type contains all the data related to a pointer event in Babylon.js.
  24721. * 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.
  24722. */
  24723. export class PointerInfo extends PointerInfoBase {
  24724. /**
  24725. * Defines the picking info associated to the info (if any)\
  24726. */
  24727. pickInfo: Nullable<PickingInfo>;
  24728. /**
  24729. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24730. * @param type Defines the type of event (PointerEventTypes)
  24731. * @param event Defines the related dom event
  24732. * @param pickInfo Defines the picking info associated to the info (if any)\
  24733. */
  24734. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24735. /**
  24736. * Defines the picking info associated to the info (if any)\
  24737. */
  24738. pickInfo: Nullable<PickingInfo>);
  24739. }
  24740. /**
  24741. * Data relating to a touch event on the screen.
  24742. */
  24743. export interface PointerTouch {
  24744. /**
  24745. * X coordinate of touch.
  24746. */
  24747. x: number;
  24748. /**
  24749. * Y coordinate of touch.
  24750. */
  24751. y: number;
  24752. /**
  24753. * Id of touch. Unique for each finger.
  24754. */
  24755. pointerId: number;
  24756. /**
  24757. * Event type passed from DOM.
  24758. */
  24759. type: any;
  24760. }
  24761. }
  24762. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  24763. import { Observable } from "babylonjs/Misc/observable";
  24764. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  24765. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  24766. /**
  24767. * Manage the mouse inputs to control the movement of a free camera.
  24768. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24769. */
  24770. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24771. /**
  24772. * Define if touch is enabled in the mouse input
  24773. */
  24774. touchEnabled: boolean;
  24775. /**
  24776. * Defines the camera the input is attached to.
  24777. */
  24778. camera: FreeCamera;
  24779. /**
  24780. * Defines the buttons associated with the input to handle camera move.
  24781. */
  24782. buttons: number[];
  24783. /**
  24784. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24785. */
  24786. angularSensibility: number;
  24787. private _pointerInput;
  24788. private _onMouseMove;
  24789. private _observer;
  24790. private previousPosition;
  24791. /**
  24792. * Observable for when a pointer move event occurs containing the move offset
  24793. */
  24794. onPointerMovedObservable: Observable<{
  24795. offsetX: number;
  24796. offsetY: number;
  24797. }>;
  24798. /**
  24799. * @hidden
  24800. * If the camera should be rotated automatically based on pointer movement
  24801. */
  24802. _allowCameraRotation: boolean;
  24803. /**
  24804. * Manage the mouse inputs to control the movement of a free camera.
  24805. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24806. * @param touchEnabled Defines if touch is enabled or not
  24807. */
  24808. constructor(
  24809. /**
  24810. * Define if touch is enabled in the mouse input
  24811. */
  24812. touchEnabled?: boolean);
  24813. /**
  24814. * Attach the input controls to a specific dom element to get the input from.
  24815. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24816. */
  24817. attachControl(noPreventDefault?: boolean): void;
  24818. /**
  24819. * Called on JS contextmenu event.
  24820. * Override this method to provide functionality.
  24821. */
  24822. protected onContextMenu(evt: PointerEvent): void;
  24823. /**
  24824. * Detach the current controls from the specified dom element.
  24825. */
  24826. detachControl(): void;
  24827. /**
  24828. * Gets the class name of the current intput.
  24829. * @returns the class name
  24830. */
  24831. getClassName(): string;
  24832. /**
  24833. * Get the friendly name associated with the input class.
  24834. * @returns the input friendly name
  24835. */
  24836. getSimpleName(): string;
  24837. }
  24838. }
  24839. declare module "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput" {
  24840. import { Observable } from "babylonjs/Misc/observable";
  24841. import { Camera } from "babylonjs/Cameras/camera";
  24842. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  24843. /**
  24844. * Base class for mouse wheel input..
  24845. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24846. * for example usage.
  24847. */
  24848. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24849. /**
  24850. * Defines the camera the input is attached to.
  24851. */
  24852. abstract camera: Camera;
  24853. /**
  24854. * How fast is the camera moves in relation to X axis mouseWheel events.
  24855. * Use negative value to reverse direction.
  24856. */
  24857. wheelPrecisionX: number;
  24858. /**
  24859. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24860. * Use negative value to reverse direction.
  24861. */
  24862. wheelPrecisionY: number;
  24863. /**
  24864. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24865. * Use negative value to reverse direction.
  24866. */
  24867. wheelPrecisionZ: number;
  24868. /**
  24869. * Observable for when a mouse wheel move event occurs.
  24870. */
  24871. onChangedObservable: Observable<{
  24872. wheelDeltaX: number;
  24873. wheelDeltaY: number;
  24874. wheelDeltaZ: number;
  24875. }>;
  24876. private _wheel;
  24877. private _observer;
  24878. /**
  24879. * Attach the input controls to a specific dom element to get the input from.
  24880. * @param noPreventDefault Defines whether event caught by the controls
  24881. * should call preventdefault().
  24882. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24883. */
  24884. attachControl(noPreventDefault?: boolean): void;
  24885. /**
  24886. * Detach the current controls from the specified dom element.
  24887. */
  24888. detachControl(): void;
  24889. /**
  24890. * Called for each rendered frame.
  24891. */
  24892. checkInputs(): void;
  24893. /**
  24894. * Gets the class name of the current intput.
  24895. * @returns the class name
  24896. */
  24897. getClassName(): string;
  24898. /**
  24899. * Get the friendly name associated with the input class.
  24900. * @returns the input friendly name
  24901. */
  24902. getSimpleName(): string;
  24903. /**
  24904. * Incremental value of multiple mouse wheel movements of the X axis.
  24905. * Should be zero-ed when read.
  24906. */
  24907. protected _wheelDeltaX: number;
  24908. /**
  24909. * Incremental value of multiple mouse wheel movements of the Y axis.
  24910. * Should be zero-ed when read.
  24911. */
  24912. protected _wheelDeltaY: number;
  24913. /**
  24914. * Incremental value of multiple mouse wheel movements of the Z axis.
  24915. * Should be zero-ed when read.
  24916. */
  24917. protected _wheelDeltaZ: number;
  24918. /**
  24919. * Firefox uses a different scheme to report scroll distances to other
  24920. * browsers. Rather than use complicated methods to calculate the exact
  24921. * multiple we need to apply, let's just cheat and use a constant.
  24922. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24923. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24924. */
  24925. private readonly _ffMultiplier;
  24926. /**
  24927. * Different event attributes for wheel data fall into a few set ranges.
  24928. * Some relevant but dated date here:
  24929. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24930. */
  24931. private readonly _normalize;
  24932. }
  24933. }
  24934. declare module "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput" {
  24935. import { Nullable } from "babylonjs/types";
  24936. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  24937. import { BaseCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  24938. import { Coordinate } from "babylonjs/Maths/math.axis";
  24939. /**
  24940. * Manage the mouse wheel inputs to control a free camera.
  24941. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24942. */
  24943. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24944. /**
  24945. * Defines the camera the input is attached to.
  24946. */
  24947. camera: FreeCamera;
  24948. /**
  24949. * Gets the class name of the current input.
  24950. * @returns the class name
  24951. */
  24952. getClassName(): string;
  24953. /**
  24954. * Set which movement axis (relative to camera's orientation) the mouse
  24955. * wheel's X axis controls.
  24956. * @param axis The axis to be moved. Set null to clear.
  24957. */
  24958. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24959. /**
  24960. * Get the configured movement axis (relative to camera's orientation) the
  24961. * mouse wheel's X axis controls.
  24962. * @returns The configured axis or null if none.
  24963. */
  24964. get wheelXMoveRelative(): Nullable<Coordinate>;
  24965. /**
  24966. * Set which movement axis (relative to camera's orientation) the mouse
  24967. * wheel's Y axis controls.
  24968. * @param axis The axis to be moved. Set null to clear.
  24969. */
  24970. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24971. /**
  24972. * Get the configured movement axis (relative to camera's orientation) the
  24973. * mouse wheel's Y axis controls.
  24974. * @returns The configured axis or null if none.
  24975. */
  24976. get wheelYMoveRelative(): Nullable<Coordinate>;
  24977. /**
  24978. * Set which movement axis (relative to camera's orientation) the mouse
  24979. * wheel's Z axis controls.
  24980. * @param axis The axis to be moved. Set null to clear.
  24981. */
  24982. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24983. /**
  24984. * Get the configured movement axis (relative to camera's orientation) the
  24985. * mouse wheel's Z axis controls.
  24986. * @returns The configured axis or null if none.
  24987. */
  24988. get wheelZMoveRelative(): Nullable<Coordinate>;
  24989. /**
  24990. * Set which rotation axis (relative to camera's orientation) the mouse
  24991. * wheel's X axis controls.
  24992. * @param axis The axis to be moved. Set null to clear.
  24993. */
  24994. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24995. /**
  24996. * Get the configured rotation axis (relative to camera's orientation) the
  24997. * mouse wheel's X axis controls.
  24998. * @returns The configured axis or null if none.
  24999. */
  25000. get wheelXRotateRelative(): Nullable<Coordinate>;
  25001. /**
  25002. * Set which rotation axis (relative to camera's orientation) the mouse
  25003. * wheel's Y axis controls.
  25004. * @param axis The axis to be moved. Set null to clear.
  25005. */
  25006. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25007. /**
  25008. * Get the configured rotation axis (relative to camera's orientation) the
  25009. * mouse wheel's Y axis controls.
  25010. * @returns The configured axis or null if none.
  25011. */
  25012. get wheelYRotateRelative(): Nullable<Coordinate>;
  25013. /**
  25014. * Set which rotation axis (relative to camera's orientation) the mouse
  25015. * wheel's Z axis controls.
  25016. * @param axis The axis to be moved. Set null to clear.
  25017. */
  25018. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25019. /**
  25020. * Get the configured rotation axis (relative to camera's orientation) the
  25021. * mouse wheel's Z axis controls.
  25022. * @returns The configured axis or null if none.
  25023. */
  25024. get wheelZRotateRelative(): Nullable<Coordinate>;
  25025. /**
  25026. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25027. * controls.
  25028. * @param axis The axis to be moved. Set null to clear.
  25029. */
  25030. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25031. /**
  25032. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25033. * X axis controls.
  25034. * @returns The configured axis or null if none.
  25035. */
  25036. get wheelXMoveScene(): Nullable<Coordinate>;
  25037. /**
  25038. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25039. * controls.
  25040. * @param axis The axis to be moved. Set null to clear.
  25041. */
  25042. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25043. /**
  25044. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25045. * Y axis controls.
  25046. * @returns The configured axis or null if none.
  25047. */
  25048. get wheelYMoveScene(): Nullable<Coordinate>;
  25049. /**
  25050. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25051. * controls.
  25052. * @param axis The axis to be moved. Set null to clear.
  25053. */
  25054. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25055. /**
  25056. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25057. * Z axis controls.
  25058. * @returns The configured axis or null if none.
  25059. */
  25060. get wheelZMoveScene(): Nullable<Coordinate>;
  25061. /**
  25062. * Called for each rendered frame.
  25063. */
  25064. checkInputs(): void;
  25065. private _moveRelative;
  25066. private _rotateRelative;
  25067. private _moveScene;
  25068. /**
  25069. * These are set to the desired default behaviour.
  25070. */
  25071. private _wheelXAction;
  25072. private _wheelXActionCoordinate;
  25073. private _wheelYAction;
  25074. private _wheelYActionCoordinate;
  25075. private _wheelZAction;
  25076. private _wheelZActionCoordinate;
  25077. /**
  25078. * Update the camera according to any configured properties for the 3
  25079. * mouse-wheel axis.
  25080. */
  25081. private _updateCamera;
  25082. }
  25083. }
  25084. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  25085. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25086. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25087. /**
  25088. * Manage the touch inputs to control the movement of a free camera.
  25089. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25090. */
  25091. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25092. /**
  25093. * Define if mouse events can be treated as touch events
  25094. */
  25095. allowMouse: boolean;
  25096. /**
  25097. * Defines the camera the input is attached to.
  25098. */
  25099. camera: FreeCamera;
  25100. /**
  25101. * Defines the touch sensibility for rotation.
  25102. * The higher the faster.
  25103. */
  25104. touchAngularSensibility: number;
  25105. /**
  25106. * Defines the touch sensibility for move.
  25107. * The higher the faster.
  25108. */
  25109. touchMoveSensibility: number;
  25110. private _offsetX;
  25111. private _offsetY;
  25112. private _pointerPressed;
  25113. private _pointerInput?;
  25114. private _observer;
  25115. private _onLostFocus;
  25116. /**
  25117. * Manage the touch inputs to control the movement of a free camera.
  25118. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25119. * @param allowMouse Defines if mouse events can be treated as touch events
  25120. */
  25121. constructor(
  25122. /**
  25123. * Define if mouse events can be treated as touch events
  25124. */
  25125. allowMouse?: boolean);
  25126. /**
  25127. * Attach the input controls to a specific dom element to get the input from.
  25128. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25129. */
  25130. attachControl(noPreventDefault?: boolean): void;
  25131. /**
  25132. * Detach the current controls from the specified dom element.
  25133. */
  25134. detachControl(): void;
  25135. /**
  25136. * Update the current camera state depending on the inputs that have been used this frame.
  25137. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25138. */
  25139. checkInputs(): void;
  25140. /**
  25141. * Gets the class name of the current intput.
  25142. * @returns the class name
  25143. */
  25144. getClassName(): string;
  25145. /**
  25146. * Get the friendly name associated with the input class.
  25147. * @returns the input friendly name
  25148. */
  25149. getSimpleName(): string;
  25150. }
  25151. }
  25152. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  25153. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25154. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25155. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  25156. import { FreeCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  25157. import { Nullable } from "babylonjs/types";
  25158. /**
  25159. * Default Inputs manager for the FreeCamera.
  25160. * It groups all the default supported inputs for ease of use.
  25161. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25162. */
  25163. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25164. /**
  25165. * @hidden
  25166. */
  25167. _mouseInput: Nullable<FreeCameraMouseInput>;
  25168. /**
  25169. * @hidden
  25170. */
  25171. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25172. /**
  25173. * Instantiates a new FreeCameraInputsManager.
  25174. * @param camera Defines the camera the inputs belong to
  25175. */
  25176. constructor(camera: FreeCamera);
  25177. /**
  25178. * Add keyboard input support to the input manager.
  25179. * @returns the current input manager
  25180. */
  25181. addKeyboard(): FreeCameraInputsManager;
  25182. /**
  25183. * Add mouse input support to the input manager.
  25184. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25185. * @returns the current input manager
  25186. */
  25187. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25188. /**
  25189. * Removes the mouse input support from the manager
  25190. * @returns the current input manager
  25191. */
  25192. removeMouse(): FreeCameraInputsManager;
  25193. /**
  25194. * Add mouse wheel input support to the input manager.
  25195. * @returns the current input manager
  25196. */
  25197. addMouseWheel(): FreeCameraInputsManager;
  25198. /**
  25199. * Removes the mouse wheel input support from the manager
  25200. * @returns the current input manager
  25201. */
  25202. removeMouseWheel(): FreeCameraInputsManager;
  25203. /**
  25204. * Add touch input support to the input manager.
  25205. * @returns the current input manager
  25206. */
  25207. addTouch(): FreeCameraInputsManager;
  25208. /**
  25209. * Remove all attached input methods from a camera
  25210. */
  25211. clear(): void;
  25212. }
  25213. }
  25214. declare module "babylonjs/Cameras/freeCamera" {
  25215. import { Vector3 } from "babylonjs/Maths/math.vector";
  25216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25217. import { Scene } from "babylonjs/scene";
  25218. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  25219. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  25220. /**
  25221. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25222. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25223. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25224. */
  25225. export class FreeCamera extends TargetCamera {
  25226. /**
  25227. * Define the collision ellipsoid of the camera.
  25228. * This is helpful to simulate a camera body like the player body around the camera
  25229. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25230. */
  25231. ellipsoid: Vector3;
  25232. /**
  25233. * Define an offset for the position of the ellipsoid around the camera.
  25234. * This can be helpful to determine the center of the body near the gravity center of the body
  25235. * instead of its head.
  25236. */
  25237. ellipsoidOffset: Vector3;
  25238. /**
  25239. * Enable or disable collisions of the camera with the rest of the scene objects.
  25240. */
  25241. checkCollisions: boolean;
  25242. /**
  25243. * Enable or disable gravity on the camera.
  25244. */
  25245. applyGravity: boolean;
  25246. /**
  25247. * Define the input manager associated to the camera.
  25248. */
  25249. inputs: FreeCameraInputsManager;
  25250. /**
  25251. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25252. * Higher values reduce sensitivity.
  25253. */
  25254. get angularSensibility(): number;
  25255. /**
  25256. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25257. * Higher values reduce sensitivity.
  25258. */
  25259. set angularSensibility(value: number);
  25260. /**
  25261. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25262. */
  25263. get keysUp(): number[];
  25264. set keysUp(value: number[]);
  25265. /**
  25266. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25267. */
  25268. get keysUpward(): number[];
  25269. set keysUpward(value: number[]);
  25270. /**
  25271. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25272. */
  25273. get keysDown(): number[];
  25274. set keysDown(value: number[]);
  25275. /**
  25276. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25277. */
  25278. get keysDownward(): number[];
  25279. set keysDownward(value: number[]);
  25280. /**
  25281. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25282. */
  25283. get keysLeft(): number[];
  25284. set keysLeft(value: number[]);
  25285. /**
  25286. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25287. */
  25288. get keysRight(): number[];
  25289. set keysRight(value: number[]);
  25290. /**
  25291. * Event raised when the camera collide with a mesh in the scene.
  25292. */
  25293. onCollide: (collidedMesh: AbstractMesh) => void;
  25294. private _collider;
  25295. private _needMoveForGravity;
  25296. private _oldPosition;
  25297. private _diffPosition;
  25298. private _newPosition;
  25299. /** @hidden */
  25300. _localDirection: Vector3;
  25301. /** @hidden */
  25302. _transformedDirection: Vector3;
  25303. /**
  25304. * Instantiates a Free Camera.
  25305. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25306. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25307. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25308. * @param name Define the name of the camera in the scene
  25309. * @param position Define the start position of the camera in the scene
  25310. * @param scene Define the scene the camera belongs to
  25311. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  25312. */
  25313. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25314. /**
  25315. * Attach the input controls to a specific dom element to get the input from.
  25316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25317. */
  25318. attachControl(noPreventDefault?: boolean): void;
  25319. /**
  25320. * Attach the input controls to a specific dom element to get the input from.
  25321. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25322. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25323. * BACK COMPAT SIGNATURE ONLY.
  25324. */
  25325. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25326. /**
  25327. * Detach the current controls from the specified dom element.
  25328. */
  25329. detachControl(): void;
  25330. /**
  25331. * Detach the current controls from the specified dom element.
  25332. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25333. */
  25334. detachControl(ignored: any): void;
  25335. private _collisionMask;
  25336. /**
  25337. * Define a collision mask to limit the list of object the camera can collide with
  25338. */
  25339. get collisionMask(): number;
  25340. set collisionMask(mask: number);
  25341. /** @hidden */
  25342. _collideWithWorld(displacement: Vector3): void;
  25343. private _onCollisionPositionChange;
  25344. /** @hidden */
  25345. _checkInputs(): void;
  25346. /** @hidden */
  25347. _decideIfNeedsToMove(): boolean;
  25348. /** @hidden */
  25349. _updatePosition(): void;
  25350. /**
  25351. * Destroy the camera and release the current resources hold by it.
  25352. */
  25353. dispose(): void;
  25354. /**
  25355. * Gets the current object class name.
  25356. * @return the class name
  25357. */
  25358. getClassName(): string;
  25359. }
  25360. }
  25361. declare module "babylonjs/Gamepads/gamepad" {
  25362. import { Observable } from "babylonjs/Misc/observable";
  25363. /**
  25364. * Represents a gamepad control stick position
  25365. */
  25366. export class StickValues {
  25367. /**
  25368. * The x component of the control stick
  25369. */
  25370. x: number;
  25371. /**
  25372. * The y component of the control stick
  25373. */
  25374. y: number;
  25375. /**
  25376. * Initializes the gamepad x and y control stick values
  25377. * @param x The x component of the gamepad control stick value
  25378. * @param y The y component of the gamepad control stick value
  25379. */
  25380. constructor(
  25381. /**
  25382. * The x component of the control stick
  25383. */
  25384. x: number,
  25385. /**
  25386. * The y component of the control stick
  25387. */
  25388. y: number);
  25389. }
  25390. /**
  25391. * An interface which manages callbacks for gamepad button changes
  25392. */
  25393. export interface GamepadButtonChanges {
  25394. /**
  25395. * Called when a gamepad has been changed
  25396. */
  25397. changed: boolean;
  25398. /**
  25399. * Called when a gamepad press event has been triggered
  25400. */
  25401. pressChanged: boolean;
  25402. /**
  25403. * Called when a touch event has been triggered
  25404. */
  25405. touchChanged: boolean;
  25406. /**
  25407. * Called when a value has changed
  25408. */
  25409. valueChanged: boolean;
  25410. }
  25411. /**
  25412. * Represents a gamepad
  25413. */
  25414. export class Gamepad {
  25415. /**
  25416. * The id of the gamepad
  25417. */
  25418. id: string;
  25419. /**
  25420. * The index of the gamepad
  25421. */
  25422. index: number;
  25423. /**
  25424. * The browser gamepad
  25425. */
  25426. browserGamepad: any;
  25427. /**
  25428. * Specifies what type of gamepad this represents
  25429. */
  25430. type: number;
  25431. private _leftStick;
  25432. private _rightStick;
  25433. /** @hidden */
  25434. _isConnected: boolean;
  25435. private _leftStickAxisX;
  25436. private _leftStickAxisY;
  25437. private _rightStickAxisX;
  25438. private _rightStickAxisY;
  25439. /**
  25440. * Triggered when the left control stick has been changed
  25441. */
  25442. private _onleftstickchanged;
  25443. /**
  25444. * Triggered when the right control stick has been changed
  25445. */
  25446. private _onrightstickchanged;
  25447. /**
  25448. * Represents a gamepad controller
  25449. */
  25450. static GAMEPAD: number;
  25451. /**
  25452. * Represents a generic controller
  25453. */
  25454. static GENERIC: number;
  25455. /**
  25456. * Represents an XBox controller
  25457. */
  25458. static XBOX: number;
  25459. /**
  25460. * Represents a pose-enabled controller
  25461. */
  25462. static POSE_ENABLED: number;
  25463. /**
  25464. * Represents an Dual Shock controller
  25465. */
  25466. static DUALSHOCK: number;
  25467. /**
  25468. * Specifies whether the left control stick should be Y-inverted
  25469. */
  25470. protected _invertLeftStickY: boolean;
  25471. /**
  25472. * Specifies if the gamepad has been connected
  25473. */
  25474. get isConnected(): boolean;
  25475. /**
  25476. * Initializes the gamepad
  25477. * @param id The id of the gamepad
  25478. * @param index The index of the gamepad
  25479. * @param browserGamepad The browser gamepad
  25480. * @param leftStickX The x component of the left joystick
  25481. * @param leftStickY The y component of the left joystick
  25482. * @param rightStickX The x component of the right joystick
  25483. * @param rightStickY The y component of the right joystick
  25484. */
  25485. constructor(
  25486. /**
  25487. * The id of the gamepad
  25488. */
  25489. id: string,
  25490. /**
  25491. * The index of the gamepad
  25492. */
  25493. index: number,
  25494. /**
  25495. * The browser gamepad
  25496. */
  25497. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25498. /**
  25499. * Callback triggered when the left joystick has changed
  25500. * @param callback
  25501. */
  25502. onleftstickchanged(callback: (values: StickValues) => void): void;
  25503. /**
  25504. * Callback triggered when the right joystick has changed
  25505. * @param callback
  25506. */
  25507. onrightstickchanged(callback: (values: StickValues) => void): void;
  25508. /**
  25509. * Gets the left joystick
  25510. */
  25511. get leftStick(): StickValues;
  25512. /**
  25513. * Sets the left joystick values
  25514. */
  25515. set leftStick(newValues: StickValues);
  25516. /**
  25517. * Gets the right joystick
  25518. */
  25519. get rightStick(): StickValues;
  25520. /**
  25521. * Sets the right joystick value
  25522. */
  25523. set rightStick(newValues: StickValues);
  25524. /**
  25525. * Updates the gamepad joystick positions
  25526. */
  25527. update(): void;
  25528. /**
  25529. * Disposes the gamepad
  25530. */
  25531. dispose(): void;
  25532. }
  25533. /**
  25534. * Represents a generic gamepad
  25535. */
  25536. export class GenericPad extends Gamepad {
  25537. private _buttons;
  25538. private _onbuttondown;
  25539. private _onbuttonup;
  25540. /**
  25541. * Observable triggered when a button has been pressed
  25542. */
  25543. onButtonDownObservable: Observable<number>;
  25544. /**
  25545. * Observable triggered when a button has been released
  25546. */
  25547. onButtonUpObservable: Observable<number>;
  25548. /**
  25549. * Callback triggered when a button has been pressed
  25550. * @param callback Called when a button has been pressed
  25551. */
  25552. onbuttondown(callback: (buttonPressed: number) => void): void;
  25553. /**
  25554. * Callback triggered when a button has been released
  25555. * @param callback Called when a button has been released
  25556. */
  25557. onbuttonup(callback: (buttonReleased: number) => void): void;
  25558. /**
  25559. * Initializes the generic gamepad
  25560. * @param id The id of the generic gamepad
  25561. * @param index The index of the generic gamepad
  25562. * @param browserGamepad The browser gamepad
  25563. */
  25564. constructor(id: string, index: number, browserGamepad: any);
  25565. private _setButtonValue;
  25566. /**
  25567. * Updates the generic gamepad
  25568. */
  25569. update(): void;
  25570. /**
  25571. * Disposes the generic gamepad
  25572. */
  25573. dispose(): void;
  25574. }
  25575. }
  25576. declare module "babylonjs/Animations/runtimeAnimation" {
  25577. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  25578. import { Animatable } from "babylonjs/Animations/animatable";
  25579. import { Scene } from "babylonjs/scene";
  25580. /**
  25581. * Defines a runtime animation
  25582. */
  25583. export class RuntimeAnimation {
  25584. private _events;
  25585. /**
  25586. * The current frame of the runtime animation
  25587. */
  25588. private _currentFrame;
  25589. /**
  25590. * The animation used by the runtime animation
  25591. */
  25592. private _animation;
  25593. /**
  25594. * The target of the runtime animation
  25595. */
  25596. private _target;
  25597. /**
  25598. * The initiating animatable
  25599. */
  25600. private _host;
  25601. /**
  25602. * The original value of the runtime animation
  25603. */
  25604. private _originalValue;
  25605. /**
  25606. * The original blend value of the runtime animation
  25607. */
  25608. private _originalBlendValue;
  25609. /**
  25610. * The offsets cache of the runtime animation
  25611. */
  25612. private _offsetsCache;
  25613. /**
  25614. * The high limits cache of the runtime animation
  25615. */
  25616. private _highLimitsCache;
  25617. /**
  25618. * Specifies if the runtime animation has been stopped
  25619. */
  25620. private _stopped;
  25621. /**
  25622. * The blending factor of the runtime animation
  25623. */
  25624. private _blendingFactor;
  25625. /**
  25626. * The BabylonJS scene
  25627. */
  25628. private _scene;
  25629. /**
  25630. * The current value of the runtime animation
  25631. */
  25632. private _currentValue;
  25633. /** @hidden */
  25634. _animationState: _IAnimationState;
  25635. /**
  25636. * The active target of the runtime animation
  25637. */
  25638. private _activeTargets;
  25639. private _currentActiveTarget;
  25640. private _directTarget;
  25641. /**
  25642. * The target path of the runtime animation
  25643. */
  25644. private _targetPath;
  25645. /**
  25646. * The weight of the runtime animation
  25647. */
  25648. private _weight;
  25649. /**
  25650. * The ratio offset of the runtime animation
  25651. */
  25652. private _ratioOffset;
  25653. /**
  25654. * The previous delay of the runtime animation
  25655. */
  25656. private _previousDelay;
  25657. /**
  25658. * The previous ratio of the runtime animation
  25659. */
  25660. private _previousRatio;
  25661. private _enableBlending;
  25662. private _keys;
  25663. private _minFrame;
  25664. private _maxFrame;
  25665. private _minValue;
  25666. private _maxValue;
  25667. private _targetIsArray;
  25668. /**
  25669. * Gets the current frame of the runtime animation
  25670. */
  25671. get currentFrame(): number;
  25672. /**
  25673. * Gets the weight of the runtime animation
  25674. */
  25675. get weight(): number;
  25676. /**
  25677. * Gets the current value of the runtime animation
  25678. */
  25679. get currentValue(): any;
  25680. /**
  25681. * Gets the target path of the runtime animation
  25682. */
  25683. get targetPath(): string;
  25684. /**
  25685. * Gets the actual target of the runtime animation
  25686. */
  25687. get target(): any;
  25688. /**
  25689. * Gets the additive state of the runtime animation
  25690. */
  25691. get isAdditive(): boolean;
  25692. /** @hidden */
  25693. _onLoop: () => void;
  25694. /**
  25695. * Create a new RuntimeAnimation object
  25696. * @param target defines the target of the animation
  25697. * @param animation defines the source animation object
  25698. * @param scene defines the hosting scene
  25699. * @param host defines the initiating Animatable
  25700. */
  25701. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25702. private _preparePath;
  25703. /**
  25704. * Gets the animation from the runtime animation
  25705. */
  25706. get animation(): Animation;
  25707. /**
  25708. * Resets the runtime animation to the beginning
  25709. * @param restoreOriginal defines whether to restore the target property to the original value
  25710. */
  25711. reset(restoreOriginal?: boolean): void;
  25712. /**
  25713. * Specifies if the runtime animation is stopped
  25714. * @returns Boolean specifying if the runtime animation is stopped
  25715. */
  25716. isStopped(): boolean;
  25717. /**
  25718. * Disposes of the runtime animation
  25719. */
  25720. dispose(): void;
  25721. /**
  25722. * Apply the interpolated value to the target
  25723. * @param currentValue defines the value computed by the animation
  25724. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25725. */
  25726. setValue(currentValue: any, weight: number): void;
  25727. private _getOriginalValues;
  25728. private _setValue;
  25729. /**
  25730. * Gets the loop pmode of the runtime animation
  25731. * @returns Loop Mode
  25732. */
  25733. private _getCorrectLoopMode;
  25734. /**
  25735. * Move the current animation to a given frame
  25736. * @param frame defines the frame to move to
  25737. */
  25738. goToFrame(frame: number): void;
  25739. /**
  25740. * @hidden Internal use only
  25741. */
  25742. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25743. /**
  25744. * Execute the current animation
  25745. * @param delay defines the delay to add to the current frame
  25746. * @param from defines the lower bound of the animation range
  25747. * @param to defines the upper bound of the animation range
  25748. * @param loop defines if the current animation must loop
  25749. * @param speedRatio defines the current speed ratio
  25750. * @param weight defines the weight of the animation (default is -1 so no weight)
  25751. * @param onLoop optional callback called when animation loops
  25752. * @returns a boolean indicating if the animation is running
  25753. */
  25754. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25755. }
  25756. }
  25757. declare module "babylonjs/Animations/animatable" {
  25758. import { Animation } from "babylonjs/Animations/animation";
  25759. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25760. import { Nullable } from "babylonjs/types";
  25761. import { Observable } from "babylonjs/Misc/observable";
  25762. import { Scene } from "babylonjs/scene";
  25763. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  25764. import { Node } from "babylonjs/node";
  25765. /**
  25766. * Class used to store an actual running animation
  25767. */
  25768. export class Animatable {
  25769. /** defines the target object */
  25770. target: any;
  25771. /** defines the starting frame number (default is 0) */
  25772. fromFrame: number;
  25773. /** defines the ending frame number (default is 100) */
  25774. toFrame: number;
  25775. /** defines if the animation must loop (default is false) */
  25776. loopAnimation: boolean;
  25777. /** defines a callback to call when animation ends if it is not looping */
  25778. onAnimationEnd?: (() => void) | null | undefined;
  25779. /** defines a callback to call when animation loops */
  25780. onAnimationLoop?: (() => void) | null | undefined;
  25781. /** defines whether the animation should be evaluated additively */
  25782. isAdditive: boolean;
  25783. private _localDelayOffset;
  25784. private _pausedDelay;
  25785. private _runtimeAnimations;
  25786. private _paused;
  25787. private _scene;
  25788. private _speedRatio;
  25789. private _weight;
  25790. private _syncRoot;
  25791. /**
  25792. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25793. * This will only apply for non looping animation (default is true)
  25794. */
  25795. disposeOnEnd: boolean;
  25796. /**
  25797. * Gets a boolean indicating if the animation has started
  25798. */
  25799. animationStarted: boolean;
  25800. /**
  25801. * Observer raised when the animation ends
  25802. */
  25803. onAnimationEndObservable: Observable<Animatable>;
  25804. /**
  25805. * Observer raised when the animation loops
  25806. */
  25807. onAnimationLoopObservable: Observable<Animatable>;
  25808. /**
  25809. * Gets the root Animatable used to synchronize and normalize animations
  25810. */
  25811. get syncRoot(): Nullable<Animatable>;
  25812. /**
  25813. * Gets the current frame of the first RuntimeAnimation
  25814. * Used to synchronize Animatables
  25815. */
  25816. get masterFrame(): number;
  25817. /**
  25818. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25819. */
  25820. get weight(): number;
  25821. set weight(value: number);
  25822. /**
  25823. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25824. */
  25825. get speedRatio(): number;
  25826. set speedRatio(value: number);
  25827. /**
  25828. * Creates a new Animatable
  25829. * @param scene defines the hosting scene
  25830. * @param target defines the target object
  25831. * @param fromFrame defines the starting frame number (default is 0)
  25832. * @param toFrame defines the ending frame number (default is 100)
  25833. * @param loopAnimation defines if the animation must loop (default is false)
  25834. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25835. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25836. * @param animations defines a group of animation to add to the new Animatable
  25837. * @param onAnimationLoop defines a callback to call when animation loops
  25838. * @param isAdditive defines whether the animation should be evaluated additively
  25839. */
  25840. constructor(scene: Scene,
  25841. /** defines the target object */
  25842. target: any,
  25843. /** defines the starting frame number (default is 0) */
  25844. fromFrame?: number,
  25845. /** defines the ending frame number (default is 100) */
  25846. toFrame?: number,
  25847. /** defines if the animation must loop (default is false) */
  25848. loopAnimation?: boolean, speedRatio?: number,
  25849. /** defines a callback to call when animation ends if it is not looping */
  25850. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25851. /** defines a callback to call when animation loops */
  25852. onAnimationLoop?: (() => void) | null | undefined,
  25853. /** defines whether the animation should be evaluated additively */
  25854. isAdditive?: boolean);
  25855. /**
  25856. * Synchronize and normalize current Animatable with a source Animatable
  25857. * This is useful when using animation weights and when animations are not of the same length
  25858. * @param root defines the root Animatable to synchronize with
  25859. * @returns the current Animatable
  25860. */
  25861. syncWith(root: Animatable): Animatable;
  25862. /**
  25863. * Gets the list of runtime animations
  25864. * @returns an array of RuntimeAnimation
  25865. */
  25866. getAnimations(): RuntimeAnimation[];
  25867. /**
  25868. * Adds more animations to the current animatable
  25869. * @param target defines the target of the animations
  25870. * @param animations defines the new animations to add
  25871. */
  25872. appendAnimations(target: any, animations: Animation[]): void;
  25873. /**
  25874. * Gets the source animation for a specific property
  25875. * @param property defines the propertyu to look for
  25876. * @returns null or the source animation for the given property
  25877. */
  25878. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25879. /**
  25880. * Gets the runtime animation for a specific property
  25881. * @param property defines the propertyu to look for
  25882. * @returns null or the runtime animation for the given property
  25883. */
  25884. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25885. /**
  25886. * Resets the animatable to its original state
  25887. */
  25888. reset(): void;
  25889. /**
  25890. * Allows the animatable to blend with current running animations
  25891. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25892. * @param blendingSpeed defines the blending speed to use
  25893. */
  25894. enableBlending(blendingSpeed: number): void;
  25895. /**
  25896. * Disable animation blending
  25897. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25898. */
  25899. disableBlending(): void;
  25900. /**
  25901. * Jump directly to a given frame
  25902. * @param frame defines the frame to jump to
  25903. */
  25904. goToFrame(frame: number): void;
  25905. /**
  25906. * Pause the animation
  25907. */
  25908. pause(): void;
  25909. /**
  25910. * Restart the animation
  25911. */
  25912. restart(): void;
  25913. private _raiseOnAnimationEnd;
  25914. /**
  25915. * Stop and delete the current animation
  25916. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25917. * @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)
  25918. */
  25919. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25920. /**
  25921. * Wait asynchronously for the animation to end
  25922. * @returns a promise which will be fullfilled when the animation ends
  25923. */
  25924. waitAsync(): Promise<Animatable>;
  25925. /** @hidden */
  25926. _animate(delay: number): boolean;
  25927. }
  25928. module "babylonjs/scene" {
  25929. interface Scene {
  25930. /** @hidden */
  25931. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25932. /** @hidden */
  25933. _processLateAnimationBindingsForMatrices(holder: {
  25934. totalWeight: number;
  25935. totalAdditiveWeight: number;
  25936. animations: RuntimeAnimation[];
  25937. additiveAnimations: RuntimeAnimation[];
  25938. originalValue: Matrix;
  25939. }): any;
  25940. /** @hidden */
  25941. _processLateAnimationBindingsForQuaternions(holder: {
  25942. totalWeight: number;
  25943. totalAdditiveWeight: number;
  25944. animations: RuntimeAnimation[];
  25945. additiveAnimations: RuntimeAnimation[];
  25946. originalValue: Quaternion;
  25947. }, refQuaternion: Quaternion): Quaternion;
  25948. /** @hidden */
  25949. _processLateAnimationBindings(): void;
  25950. /**
  25951. * Will start the animation sequence of a given target
  25952. * @param target defines the target
  25953. * @param from defines from which frame should animation start
  25954. * @param to defines until which frame should animation run.
  25955. * @param weight defines the weight to apply to the animation (1.0 by default)
  25956. * @param loop defines if the animation loops
  25957. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25958. * @param onAnimationEnd defines the function to be executed when the animation ends
  25959. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25960. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25961. * @param onAnimationLoop defines the callback to call when an animation loops
  25962. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25963. * @returns the animatable object created for this animation
  25964. */
  25965. 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;
  25966. /**
  25967. * Will start the animation sequence of a given target
  25968. * @param target defines the target
  25969. * @param from defines from which frame should animation start
  25970. * @param to defines until which frame should animation run.
  25971. * @param loop defines if the animation loops
  25972. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25973. * @param onAnimationEnd defines the function to be executed when the animation ends
  25974. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25975. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25976. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25977. * @param onAnimationLoop defines the callback to call when an animation loops
  25978. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25979. * @returns the animatable object created for this animation
  25980. */
  25981. 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;
  25982. /**
  25983. * Will start the animation sequence of a given target and its hierarchy
  25984. * @param target defines the target
  25985. * @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.
  25986. * @param from defines from which frame should animation start
  25987. * @param to defines until which frame should animation run.
  25988. * @param loop defines if the animation loops
  25989. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25990. * @param onAnimationEnd defines the function to be executed when the animation ends
  25991. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25992. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25993. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25994. * @param onAnimationLoop defines the callback to call when an animation loops
  25995. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25996. * @returns the list of created animatables
  25997. */
  25998. 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[];
  25999. /**
  26000. * Begin a new animation on a given node
  26001. * @param target defines the target where the animation will take place
  26002. * @param animations defines the list of animations to start
  26003. * @param from defines the initial value
  26004. * @param to defines the final value
  26005. * @param loop defines if you want animation to loop (off by default)
  26006. * @param speedRatio defines the speed ratio to apply to all animations
  26007. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26008. * @param onAnimationLoop defines the callback to call when an animation loops
  26009. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26010. * @returns the list of created animatables
  26011. */
  26012. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26013. /**
  26014. * Begin a new animation on a given node and its hierarchy
  26015. * @param target defines the root node where the animation will take place
  26016. * @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.
  26017. * @param animations defines the list of animations to start
  26018. * @param from defines the initial value
  26019. * @param to defines the final value
  26020. * @param loop defines if you want animation to loop (off by default)
  26021. * @param speedRatio defines the speed ratio to apply to all animations
  26022. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26023. * @param onAnimationLoop defines the callback to call when an animation loops
  26024. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26025. * @returns the list of animatables created for all nodes
  26026. */
  26027. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26028. /**
  26029. * Gets the animatable associated with a specific target
  26030. * @param target defines the target of the animatable
  26031. * @returns the required animatable if found
  26032. */
  26033. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26034. /**
  26035. * Gets all animatables associated with a given target
  26036. * @param target defines the target to look animatables for
  26037. * @returns an array of Animatables
  26038. */
  26039. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26040. /**
  26041. * Stops and removes all animations that have been applied to the scene
  26042. */
  26043. stopAllAnimations(): void;
  26044. /**
  26045. * Gets the current delta time used by animation engine
  26046. */
  26047. deltaTime: number;
  26048. }
  26049. }
  26050. module "babylonjs/Bones/bone" {
  26051. interface Bone {
  26052. /**
  26053. * Copy an animation range from another bone
  26054. * @param source defines the source bone
  26055. * @param rangeName defines the range name to copy
  26056. * @param frameOffset defines the frame offset
  26057. * @param rescaleAsRequired defines if rescaling must be applied if required
  26058. * @param skelDimensionsRatio defines the scaling ratio
  26059. * @returns true if operation was successful
  26060. */
  26061. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26062. }
  26063. }
  26064. }
  26065. declare module "babylonjs/Animations/animationPropertiesOverride" {
  26066. /**
  26067. * Class used to override all child animations of a given target
  26068. */
  26069. export class AnimationPropertiesOverride {
  26070. /**
  26071. * Gets or sets a value indicating if animation blending must be used
  26072. */
  26073. enableBlending: boolean;
  26074. /**
  26075. * Gets or sets the blending speed to use when enableBlending is true
  26076. */
  26077. blendingSpeed: number;
  26078. /**
  26079. * Gets or sets the default loop mode to use
  26080. */
  26081. loopMode: number;
  26082. }
  26083. }
  26084. declare module "babylonjs/Bones/skeleton" {
  26085. import { Bone } from "babylonjs/Bones/bone";
  26086. import { Observable } from "babylonjs/Misc/observable";
  26087. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  26088. import { Scene } from "babylonjs/scene";
  26089. import { Nullable } from "babylonjs/types";
  26090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26091. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26092. import { Animatable } from "babylonjs/Animations/animatable";
  26093. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26094. import { Animation } from "babylonjs/Animations/animation";
  26095. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26096. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26097. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26098. /**
  26099. * Class used to handle skinning animations
  26100. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26101. */
  26102. export class Skeleton implements IAnimatable {
  26103. /** defines the skeleton name */
  26104. name: string;
  26105. /** defines the skeleton Id */
  26106. id: string;
  26107. /**
  26108. * Defines the list of child bones
  26109. */
  26110. bones: Bone[];
  26111. /**
  26112. * Defines an estimate of the dimension of the skeleton at rest
  26113. */
  26114. dimensionsAtRest: Vector3;
  26115. /**
  26116. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26117. */
  26118. needInitialSkinMatrix: boolean;
  26119. /**
  26120. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26121. */
  26122. overrideMesh: Nullable<AbstractMesh>;
  26123. /**
  26124. * Gets the list of animations attached to this skeleton
  26125. */
  26126. animations: Array<Animation>;
  26127. private _scene;
  26128. private _isDirty;
  26129. private _transformMatrices;
  26130. private _transformMatrixTexture;
  26131. private _meshesWithPoseMatrix;
  26132. private _animatables;
  26133. private _identity;
  26134. private _synchronizedWithMesh;
  26135. private _ranges;
  26136. private _lastAbsoluteTransformsUpdateId;
  26137. private _canUseTextureForBones;
  26138. private _uniqueId;
  26139. /** @hidden */
  26140. _numBonesWithLinkedTransformNode: number;
  26141. /** @hidden */
  26142. _hasWaitingData: Nullable<boolean>;
  26143. /** @hidden */
  26144. _waitingOverrideMeshId: Nullable<string>;
  26145. /**
  26146. * Specifies if the skeleton should be serialized
  26147. */
  26148. doNotSerialize: boolean;
  26149. private _useTextureToStoreBoneMatrices;
  26150. /**
  26151. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26152. * Please note that this option is not available if the hardware does not support it
  26153. */
  26154. get useTextureToStoreBoneMatrices(): boolean;
  26155. set useTextureToStoreBoneMatrices(value: boolean);
  26156. private _animationPropertiesOverride;
  26157. /**
  26158. * Gets or sets the animation properties override
  26159. */
  26160. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26161. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26162. /**
  26163. * List of inspectable custom properties (used by the Inspector)
  26164. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26165. */
  26166. inspectableCustomProperties: IInspectable[];
  26167. /**
  26168. * An observable triggered before computing the skeleton's matrices
  26169. */
  26170. onBeforeComputeObservable: Observable<Skeleton>;
  26171. /**
  26172. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26173. */
  26174. get isUsingTextureForMatrices(): boolean;
  26175. /**
  26176. * Gets the unique ID of this skeleton
  26177. */
  26178. get uniqueId(): number;
  26179. /**
  26180. * Creates a new skeleton
  26181. * @param name defines the skeleton name
  26182. * @param id defines the skeleton Id
  26183. * @param scene defines the hosting scene
  26184. */
  26185. constructor(
  26186. /** defines the skeleton name */
  26187. name: string,
  26188. /** defines the skeleton Id */
  26189. id: string, scene: Scene);
  26190. /**
  26191. * Gets the current object class name.
  26192. * @return the class name
  26193. */
  26194. getClassName(): string;
  26195. /**
  26196. * Returns an array containing the root bones
  26197. * @returns an array containing the root bones
  26198. */
  26199. getChildren(): Array<Bone>;
  26200. /**
  26201. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26202. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26203. * @returns a Float32Array containing matrices data
  26204. */
  26205. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26206. /**
  26207. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26208. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26209. * @returns a raw texture containing the data
  26210. */
  26211. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26212. /**
  26213. * Gets the current hosting scene
  26214. * @returns a scene object
  26215. */
  26216. getScene(): Scene;
  26217. /**
  26218. * Gets a string representing the current skeleton data
  26219. * @param fullDetails defines a boolean indicating if we want a verbose version
  26220. * @returns a string representing the current skeleton data
  26221. */
  26222. toString(fullDetails?: boolean): string;
  26223. /**
  26224. * Get bone's index searching by name
  26225. * @param name defines bone's name to search for
  26226. * @return the indice of the bone. Returns -1 if not found
  26227. */
  26228. getBoneIndexByName(name: string): number;
  26229. /**
  26230. * Creater a new animation range
  26231. * @param name defines the name of the range
  26232. * @param from defines the start key
  26233. * @param to defines the end key
  26234. */
  26235. createAnimationRange(name: string, from: number, to: number): void;
  26236. /**
  26237. * Delete a specific animation range
  26238. * @param name defines the name of the range
  26239. * @param deleteFrames defines if frames must be removed as well
  26240. */
  26241. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26242. /**
  26243. * Gets a specific animation range
  26244. * @param name defines the name of the range to look for
  26245. * @returns the requested animation range or null if not found
  26246. */
  26247. getAnimationRange(name: string): Nullable<AnimationRange>;
  26248. /**
  26249. * Gets the list of all animation ranges defined on this skeleton
  26250. * @returns an array
  26251. */
  26252. getAnimationRanges(): Nullable<AnimationRange>[];
  26253. /**
  26254. * Copy animation range from a source skeleton.
  26255. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26256. * @param source defines the source skeleton
  26257. * @param name defines the name of the range to copy
  26258. * @param rescaleAsRequired defines if rescaling must be applied if required
  26259. * @returns true if operation was successful
  26260. */
  26261. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26262. /**
  26263. * Forces the skeleton to go to rest pose
  26264. */
  26265. returnToRest(): void;
  26266. private _getHighestAnimationFrame;
  26267. /**
  26268. * Begin a specific animation range
  26269. * @param name defines the name of the range to start
  26270. * @param loop defines if looping must be turned on (false by default)
  26271. * @param speedRatio defines the speed ratio to apply (1 by default)
  26272. * @param onAnimationEnd defines a callback which will be called when animation will end
  26273. * @returns a new animatable
  26274. */
  26275. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26276. /**
  26277. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26278. * @param skeleton defines the Skeleton containing the animation range to convert
  26279. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26280. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26281. * @returns the original skeleton
  26282. */
  26283. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26284. /** @hidden */
  26285. _markAsDirty(): void;
  26286. /** @hidden */
  26287. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26288. /** @hidden */
  26289. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26290. private _computeTransformMatrices;
  26291. /**
  26292. * Build all resources required to render a skeleton
  26293. */
  26294. prepare(): void;
  26295. /**
  26296. * Gets the list of animatables currently running for this skeleton
  26297. * @returns an array of animatables
  26298. */
  26299. getAnimatables(): IAnimatable[];
  26300. /**
  26301. * Clone the current skeleton
  26302. * @param name defines the name of the new skeleton
  26303. * @param id defines the id of the new skeleton
  26304. * @returns the new skeleton
  26305. */
  26306. clone(name: string, id?: string): Skeleton;
  26307. /**
  26308. * Enable animation blending for this skeleton
  26309. * @param blendingSpeed defines the blending speed to apply
  26310. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26311. */
  26312. enableBlending(blendingSpeed?: number): void;
  26313. /**
  26314. * Releases all resources associated with the current skeleton
  26315. */
  26316. dispose(): void;
  26317. /**
  26318. * Serialize the skeleton in a JSON object
  26319. * @returns a JSON object
  26320. */
  26321. serialize(): any;
  26322. /**
  26323. * Creates a new skeleton from serialized data
  26324. * @param parsedSkeleton defines the serialized data
  26325. * @param scene defines the hosting scene
  26326. * @returns a new skeleton
  26327. */
  26328. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26329. /**
  26330. * Compute all node absolute transforms
  26331. * @param forceUpdate defines if computation must be done even if cache is up to date
  26332. */
  26333. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26334. /**
  26335. * Gets the root pose matrix
  26336. * @returns a matrix
  26337. */
  26338. getPoseMatrix(): Nullable<Matrix>;
  26339. /**
  26340. * Sorts bones per internal index
  26341. */
  26342. sortBones(): void;
  26343. private _sortBones;
  26344. /**
  26345. * Set the current local matrix as the restPose for all bones in the skeleton.
  26346. */
  26347. setCurrentPoseAsRest(): void;
  26348. }
  26349. }
  26350. declare module "babylonjs/Bones/bone" {
  26351. import { Skeleton } from "babylonjs/Bones/skeleton";
  26352. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  26353. import { Nullable } from "babylonjs/types";
  26354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26355. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26356. import { Node } from "babylonjs/node";
  26357. import { Space } from "babylonjs/Maths/math.axis";
  26358. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26359. /**
  26360. * Class used to store bone information
  26361. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26362. */
  26363. export class Bone extends Node {
  26364. /**
  26365. * defines the bone name
  26366. */
  26367. name: string;
  26368. private static _tmpVecs;
  26369. private static _tmpQuat;
  26370. private static _tmpMats;
  26371. /**
  26372. * Gets the list of child bones
  26373. */
  26374. children: Bone[];
  26375. /** Gets the animations associated with this bone */
  26376. animations: import("babylonjs/Animations/animation").Animation[];
  26377. /**
  26378. * Gets or sets bone length
  26379. */
  26380. length: number;
  26381. /**
  26382. * @hidden Internal only
  26383. * Set this value to map this bone to a different index in the transform matrices
  26384. * Set this value to -1 to exclude the bone from the transform matrices
  26385. */
  26386. _index: Nullable<number>;
  26387. private _skeleton;
  26388. private _localMatrix;
  26389. private _restPose;
  26390. private _bindPose;
  26391. private _baseMatrix;
  26392. private _absoluteTransform;
  26393. private _invertedAbsoluteTransform;
  26394. private _parent;
  26395. private _scalingDeterminant;
  26396. private _worldTransform;
  26397. private _localScaling;
  26398. private _localRotation;
  26399. private _localPosition;
  26400. private _needToDecompose;
  26401. private _needToCompose;
  26402. /** @hidden */
  26403. _linkedTransformNode: Nullable<TransformNode>;
  26404. /** @hidden */
  26405. _waitingTransformNodeId: Nullable<string>;
  26406. /** @hidden */
  26407. get _matrix(): Matrix;
  26408. /** @hidden */
  26409. set _matrix(value: Matrix);
  26410. /**
  26411. * Create a new bone
  26412. * @param name defines the bone name
  26413. * @param skeleton defines the parent skeleton
  26414. * @param parentBone defines the parent (can be null if the bone is the root)
  26415. * @param localMatrix defines the local matrix
  26416. * @param restPose defines the rest pose matrix
  26417. * @param baseMatrix defines the base matrix
  26418. * @param index defines index of the bone in the hiearchy
  26419. */
  26420. constructor(
  26421. /**
  26422. * defines the bone name
  26423. */
  26424. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26425. /**
  26426. * Gets the current object class name.
  26427. * @return the class name
  26428. */
  26429. getClassName(): string;
  26430. /**
  26431. * Gets the parent skeleton
  26432. * @returns a skeleton
  26433. */
  26434. getSkeleton(): Skeleton;
  26435. /**
  26436. * Gets parent bone
  26437. * @returns a bone or null if the bone is the root of the bone hierarchy
  26438. */
  26439. getParent(): Nullable<Bone>;
  26440. /**
  26441. * Returns an array containing the root bones
  26442. * @returns an array containing the root bones
  26443. */
  26444. getChildren(): Array<Bone>;
  26445. /**
  26446. * Gets the node index in matrix array generated for rendering
  26447. * @returns the node index
  26448. */
  26449. getIndex(): number;
  26450. /**
  26451. * Sets the parent bone
  26452. * @param parent defines the parent (can be null if the bone is the root)
  26453. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26454. */
  26455. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26456. /**
  26457. * Gets the local matrix
  26458. * @returns a matrix
  26459. */
  26460. getLocalMatrix(): Matrix;
  26461. /**
  26462. * Gets the base matrix (initial matrix which remains unchanged)
  26463. * @returns a matrix
  26464. */
  26465. getBaseMatrix(): Matrix;
  26466. /**
  26467. * Gets the rest pose matrix
  26468. * @returns a matrix
  26469. */
  26470. getRestPose(): Matrix;
  26471. /**
  26472. * Sets the rest pose matrix
  26473. * @param matrix the local-space rest pose to set for this bone
  26474. */
  26475. setRestPose(matrix: Matrix): void;
  26476. /**
  26477. * Gets the bind pose matrix
  26478. * @returns the bind pose matrix
  26479. */
  26480. getBindPose(): Matrix;
  26481. /**
  26482. * Sets the bind pose matrix
  26483. * @param matrix the local-space bind pose to set for this bone
  26484. */
  26485. setBindPose(matrix: Matrix): void;
  26486. /**
  26487. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26488. */
  26489. getWorldMatrix(): Matrix;
  26490. /**
  26491. * Sets the local matrix to rest pose matrix
  26492. */
  26493. returnToRest(): void;
  26494. /**
  26495. * Gets the inverse of the absolute transform matrix.
  26496. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26497. * @returns a matrix
  26498. */
  26499. getInvertedAbsoluteTransform(): Matrix;
  26500. /**
  26501. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26502. * @returns a matrix
  26503. */
  26504. getAbsoluteTransform(): Matrix;
  26505. /**
  26506. * Links with the given transform node.
  26507. * The local matrix of this bone is copied from the transform node every frame.
  26508. * @param transformNode defines the transform node to link to
  26509. */
  26510. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26511. /**
  26512. * Gets the node used to drive the bone's transformation
  26513. * @returns a transform node or null
  26514. */
  26515. getTransformNode(): Nullable<TransformNode>;
  26516. /** Gets or sets current position (in local space) */
  26517. get position(): Vector3;
  26518. set position(newPosition: Vector3);
  26519. /** Gets or sets current rotation (in local space) */
  26520. get rotation(): Vector3;
  26521. set rotation(newRotation: Vector3);
  26522. /** Gets or sets current rotation quaternion (in local space) */
  26523. get rotationQuaternion(): Quaternion;
  26524. set rotationQuaternion(newRotation: Quaternion);
  26525. /** Gets or sets current scaling (in local space) */
  26526. get scaling(): Vector3;
  26527. set scaling(newScaling: Vector3);
  26528. /**
  26529. * Gets the animation properties override
  26530. */
  26531. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26532. private _decompose;
  26533. private _compose;
  26534. /**
  26535. * Update the base and local matrices
  26536. * @param matrix defines the new base or local matrix
  26537. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26538. * @param updateLocalMatrix defines if the local matrix should be updated
  26539. */
  26540. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26541. /** @hidden */
  26542. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26543. /**
  26544. * Flag the bone as dirty (Forcing it to update everything)
  26545. */
  26546. markAsDirty(): void;
  26547. /** @hidden */
  26548. _markAsDirtyAndCompose(): void;
  26549. private _markAsDirtyAndDecompose;
  26550. /**
  26551. * Translate the bone in local or world space
  26552. * @param vec The amount to translate the bone
  26553. * @param space The space that the translation is in
  26554. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26555. */
  26556. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26557. /**
  26558. * Set the postion of the bone in local or world space
  26559. * @param position The position to set the bone
  26560. * @param space The space that the position is in
  26561. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26562. */
  26563. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26564. /**
  26565. * Set the absolute position of the bone (world space)
  26566. * @param position The position to set the bone
  26567. * @param mesh The mesh that this bone is attached to
  26568. */
  26569. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26570. /**
  26571. * Scale the bone on the x, y and z axes (in local space)
  26572. * @param x The amount to scale the bone on the x axis
  26573. * @param y The amount to scale the bone on the y axis
  26574. * @param z The amount to scale the bone on the z axis
  26575. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26576. */
  26577. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26578. /**
  26579. * Set the bone scaling in local space
  26580. * @param scale defines the scaling vector
  26581. */
  26582. setScale(scale: Vector3): void;
  26583. /**
  26584. * Gets the current scaling in local space
  26585. * @returns the current scaling vector
  26586. */
  26587. getScale(): Vector3;
  26588. /**
  26589. * Gets the current scaling in local space and stores it in a target vector
  26590. * @param result defines the target vector
  26591. */
  26592. getScaleToRef(result: Vector3): void;
  26593. /**
  26594. * Set the yaw, pitch, and roll of the bone in local or world space
  26595. * @param yaw The rotation of the bone on the y axis
  26596. * @param pitch The rotation of the bone on the x axis
  26597. * @param roll The rotation of the bone on the z axis
  26598. * @param space The space that the axes of rotation are in
  26599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26600. */
  26601. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26602. /**
  26603. * Add a rotation to the bone on an axis in local or world space
  26604. * @param axis The axis to rotate the bone on
  26605. * @param amount The amount to rotate the bone
  26606. * @param space The space that the axis is in
  26607. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26608. */
  26609. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26610. /**
  26611. * Set the rotation of the bone to a particular axis angle in local or world space
  26612. * @param axis The axis to rotate the bone on
  26613. * @param angle The angle that the bone should be rotated to
  26614. * @param space The space that the axis is in
  26615. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26616. */
  26617. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26618. /**
  26619. * Set the euler rotation of the bone in local or world space
  26620. * @param rotation The euler rotation that the bone should be set to
  26621. * @param space The space that the rotation is in
  26622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26623. */
  26624. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26625. /**
  26626. * Set the quaternion rotation of the bone in local or world space
  26627. * @param quat The quaternion rotation that the bone should be set to
  26628. * @param space The space that the rotation is in
  26629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26630. */
  26631. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26632. /**
  26633. * Set the rotation matrix of the bone in local or world space
  26634. * @param rotMat The rotation matrix that the bone should be set to
  26635. * @param space The space that the rotation is in
  26636. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26637. */
  26638. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26639. private _rotateWithMatrix;
  26640. private _getNegativeRotationToRef;
  26641. /**
  26642. * Get the position of the bone in local or world space
  26643. * @param space The space that the returned position is in
  26644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26645. * @returns The position of the bone
  26646. */
  26647. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26648. /**
  26649. * Copy the position of the bone to a vector3 in local or world space
  26650. * @param space The space that the returned position is in
  26651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26652. * @param result The vector3 to copy the position to
  26653. */
  26654. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26655. /**
  26656. * Get the absolute position of the bone (world space)
  26657. * @param mesh The mesh that this bone is attached to
  26658. * @returns The absolute position of the bone
  26659. */
  26660. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26661. /**
  26662. * Copy the absolute position of the bone (world space) to the result param
  26663. * @param mesh The mesh that this bone is attached to
  26664. * @param result The vector3 to copy the absolute position to
  26665. */
  26666. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26667. /**
  26668. * Compute the absolute transforms of this bone and its children
  26669. */
  26670. computeAbsoluteTransforms(): void;
  26671. /**
  26672. * Get the world direction from an axis that is in the local space of the bone
  26673. * @param localAxis The local direction that is used to compute the world direction
  26674. * @param mesh The mesh that this bone is attached to
  26675. * @returns The world direction
  26676. */
  26677. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26678. /**
  26679. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26680. * @param localAxis The local direction that is used to compute the world direction
  26681. * @param mesh The mesh that this bone is attached to
  26682. * @param result The vector3 that the world direction will be copied to
  26683. */
  26684. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26685. /**
  26686. * Get the euler rotation of the bone in local or world space
  26687. * @param space The space that the rotation should be in
  26688. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26689. * @returns The euler rotation
  26690. */
  26691. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26692. /**
  26693. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26694. * @param space The space that the rotation should be in
  26695. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26696. * @param result The vector3 that the rotation should be copied to
  26697. */
  26698. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26699. /**
  26700. * Get the quaternion rotation of the bone in either local or world space
  26701. * @param space The space that the rotation should be in
  26702. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26703. * @returns The quaternion rotation
  26704. */
  26705. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26706. /**
  26707. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26708. * @param space The space that the rotation should be in
  26709. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26710. * @param result The quaternion that the rotation should be copied to
  26711. */
  26712. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26713. /**
  26714. * Get the rotation matrix of the bone in local or world space
  26715. * @param space The space that the rotation should be in
  26716. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26717. * @returns The rotation matrix
  26718. */
  26719. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26720. /**
  26721. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26722. * @param space The space that the rotation should be in
  26723. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26724. * @param result The quaternion that the rotation should be copied to
  26725. */
  26726. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26727. /**
  26728. * Get the world position of a point that is in the local space of the bone
  26729. * @param position The local position
  26730. * @param mesh The mesh that this bone is attached to
  26731. * @returns The world position
  26732. */
  26733. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26734. /**
  26735. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26736. * @param position The local position
  26737. * @param mesh The mesh that this bone is attached to
  26738. * @param result The vector3 that the world position should be copied to
  26739. */
  26740. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26741. /**
  26742. * Get the local position of a point that is in world space
  26743. * @param position The world position
  26744. * @param mesh The mesh that this bone is attached to
  26745. * @returns The local position
  26746. */
  26747. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26748. /**
  26749. * Get the local position of a point that is in world space and copy it to the result param
  26750. * @param position The world position
  26751. * @param mesh The mesh that this bone is attached to
  26752. * @param result The vector3 that the local position should be copied to
  26753. */
  26754. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26755. /**
  26756. * Set the current local matrix as the restPose for this bone.
  26757. */
  26758. setCurrentPoseAsRest(): void;
  26759. }
  26760. }
  26761. declare module "babylonjs/Meshes/transformNode" {
  26762. import { DeepImmutable } from "babylonjs/types";
  26763. import { Observable } from "babylonjs/Misc/observable";
  26764. import { Nullable } from "babylonjs/types";
  26765. import { Camera } from "babylonjs/Cameras/camera";
  26766. import { Scene } from "babylonjs/scene";
  26767. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26768. import { Node } from "babylonjs/node";
  26769. import { Bone } from "babylonjs/Bones/bone";
  26770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26771. import { Space } from "babylonjs/Maths/math.axis";
  26772. /**
  26773. * 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.
  26774. * @see https://doc.babylonjs.com/how_to/transformnode
  26775. */
  26776. export class TransformNode extends Node {
  26777. /**
  26778. * Object will not rotate to face the camera
  26779. */
  26780. static BILLBOARDMODE_NONE: number;
  26781. /**
  26782. * Object will rotate to face the camera but only on the x axis
  26783. */
  26784. static BILLBOARDMODE_X: number;
  26785. /**
  26786. * Object will rotate to face the camera but only on the y axis
  26787. */
  26788. static BILLBOARDMODE_Y: number;
  26789. /**
  26790. * Object will rotate to face the camera but only on the z axis
  26791. */
  26792. static BILLBOARDMODE_Z: number;
  26793. /**
  26794. * Object will rotate to face the camera
  26795. */
  26796. static BILLBOARDMODE_ALL: number;
  26797. /**
  26798. * Object will rotate to face the camera's position instead of orientation
  26799. */
  26800. static BILLBOARDMODE_USE_POSITION: number;
  26801. private static _TmpRotation;
  26802. private static _TmpScaling;
  26803. private static _TmpTranslation;
  26804. private _forward;
  26805. private _forwardInverted;
  26806. private _up;
  26807. private _right;
  26808. private _rightInverted;
  26809. private _position;
  26810. private _rotation;
  26811. private _rotationQuaternion;
  26812. protected _scaling: Vector3;
  26813. protected _isDirty: boolean;
  26814. private _transformToBoneReferal;
  26815. private _isAbsoluteSynced;
  26816. private _billboardMode;
  26817. /**
  26818. * Gets or sets the billboard mode. Default is 0.
  26819. *
  26820. * | Value | Type | Description |
  26821. * | --- | --- | --- |
  26822. * | 0 | BILLBOARDMODE_NONE | |
  26823. * | 1 | BILLBOARDMODE_X | |
  26824. * | 2 | BILLBOARDMODE_Y | |
  26825. * | 4 | BILLBOARDMODE_Z | |
  26826. * | 7 | BILLBOARDMODE_ALL | |
  26827. *
  26828. */
  26829. get billboardMode(): number;
  26830. set billboardMode(value: number);
  26831. private _preserveParentRotationForBillboard;
  26832. /**
  26833. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26834. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26835. */
  26836. get preserveParentRotationForBillboard(): boolean;
  26837. set preserveParentRotationForBillboard(value: boolean);
  26838. /**
  26839. * 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
  26840. */
  26841. scalingDeterminant: number;
  26842. private _infiniteDistance;
  26843. /**
  26844. * Gets or sets the distance of the object to max, often used by skybox
  26845. */
  26846. get infiniteDistance(): boolean;
  26847. set infiniteDistance(value: boolean);
  26848. /**
  26849. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26850. * By default the system will update normals to compensate
  26851. */
  26852. ignoreNonUniformScaling: boolean;
  26853. /**
  26854. * 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
  26855. */
  26856. reIntegrateRotationIntoRotationQuaternion: boolean;
  26857. /** @hidden */
  26858. _poseMatrix: Nullable<Matrix>;
  26859. /** @hidden */
  26860. _localMatrix: Matrix;
  26861. private _usePivotMatrix;
  26862. private _absolutePosition;
  26863. private _absoluteScaling;
  26864. private _absoluteRotationQuaternion;
  26865. private _pivotMatrix;
  26866. private _pivotMatrixInverse;
  26867. /** @hidden */
  26868. _postMultiplyPivotMatrix: boolean;
  26869. protected _isWorldMatrixFrozen: boolean;
  26870. /** @hidden */
  26871. _indexInSceneTransformNodesArray: number;
  26872. /**
  26873. * An event triggered after the world matrix is updated
  26874. */
  26875. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26876. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26877. /**
  26878. * Gets a string identifying the name of the class
  26879. * @returns "TransformNode" string
  26880. */
  26881. getClassName(): string;
  26882. /**
  26883. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26884. */
  26885. get position(): Vector3;
  26886. set position(newPosition: Vector3);
  26887. /**
  26888. * 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)).
  26889. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26890. */
  26891. get rotation(): Vector3;
  26892. set rotation(newRotation: Vector3);
  26893. /**
  26894. * 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)).
  26895. */
  26896. get scaling(): Vector3;
  26897. set scaling(newScaling: Vector3);
  26898. /**
  26899. * 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).
  26900. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26901. */
  26902. get rotationQuaternion(): Nullable<Quaternion>;
  26903. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26904. /**
  26905. * The forward direction of that transform in world space.
  26906. */
  26907. get forward(): Vector3;
  26908. /**
  26909. * The up direction of that transform in world space.
  26910. */
  26911. get up(): Vector3;
  26912. /**
  26913. * The right direction of that transform in world space.
  26914. */
  26915. get right(): Vector3;
  26916. /**
  26917. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26918. * @param matrix the matrix to copy the pose from
  26919. * @returns this TransformNode.
  26920. */
  26921. updatePoseMatrix(matrix: Matrix): TransformNode;
  26922. /**
  26923. * Returns the mesh Pose matrix.
  26924. * @returns the pose matrix
  26925. */
  26926. getPoseMatrix(): Matrix;
  26927. /** @hidden */
  26928. _isSynchronized(): boolean;
  26929. /** @hidden */
  26930. _initCache(): void;
  26931. /**
  26932. * Flag the transform node as dirty (Forcing it to update everything)
  26933. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26934. * @returns this transform node
  26935. */
  26936. markAsDirty(property: string): TransformNode;
  26937. /**
  26938. * Returns the current mesh absolute position.
  26939. * Returns a Vector3.
  26940. */
  26941. get absolutePosition(): Vector3;
  26942. /**
  26943. * Returns the current mesh absolute scaling.
  26944. * Returns a Vector3.
  26945. */
  26946. get absoluteScaling(): Vector3;
  26947. /**
  26948. * Returns the current mesh absolute rotation.
  26949. * Returns a Quaternion.
  26950. */
  26951. get absoluteRotationQuaternion(): Quaternion;
  26952. /**
  26953. * Sets a new matrix to apply before all other transformation
  26954. * @param matrix defines the transform matrix
  26955. * @returns the current TransformNode
  26956. */
  26957. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26958. /**
  26959. * Sets a new pivot matrix to the current node
  26960. * @param matrix defines the new pivot matrix to use
  26961. * @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
  26962. * @returns the current TransformNode
  26963. */
  26964. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26965. /**
  26966. * Returns the mesh pivot matrix.
  26967. * Default : Identity.
  26968. * @returns the matrix
  26969. */
  26970. getPivotMatrix(): Matrix;
  26971. /**
  26972. * Instantiate (when possible) or clone that node with its hierarchy
  26973. * @param newParent defines the new parent to use for the instance (or clone)
  26974. * @param options defines options to configure how copy is done
  26975. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26976. * @returns an instance (or a clone) of the current node with its hiearchy
  26977. */
  26978. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26979. doNotInstantiate: boolean;
  26980. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26981. /**
  26982. * Prevents the World matrix to be computed any longer
  26983. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26984. * @returns the TransformNode.
  26985. */
  26986. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26987. /**
  26988. * Allows back the World matrix computation.
  26989. * @returns the TransformNode.
  26990. */
  26991. unfreezeWorldMatrix(): this;
  26992. /**
  26993. * True if the World matrix has been frozen.
  26994. */
  26995. get isWorldMatrixFrozen(): boolean;
  26996. /**
  26997. * Retuns the mesh absolute position in the World.
  26998. * @returns a Vector3.
  26999. */
  27000. getAbsolutePosition(): Vector3;
  27001. /**
  27002. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27003. * @param absolutePosition the absolute position to set
  27004. * @returns the TransformNode.
  27005. */
  27006. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27007. /**
  27008. * Sets the mesh position in its local space.
  27009. * @param vector3 the position to set in localspace
  27010. * @returns the TransformNode.
  27011. */
  27012. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27013. /**
  27014. * Returns the mesh position in the local space from the current World matrix values.
  27015. * @returns a new Vector3.
  27016. */
  27017. getPositionExpressedInLocalSpace(): Vector3;
  27018. /**
  27019. * Translates the mesh along the passed Vector3 in its local space.
  27020. * @param vector3 the distance to translate in localspace
  27021. * @returns the TransformNode.
  27022. */
  27023. locallyTranslate(vector3: Vector3): TransformNode;
  27024. private static _lookAtVectorCache;
  27025. /**
  27026. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27027. * @param targetPoint the position (must be in same space as current mesh) to look at
  27028. * @param yawCor optional yaw (y-axis) correction in radians
  27029. * @param pitchCor optional pitch (x-axis) correction in radians
  27030. * @param rollCor optional roll (z-axis) correction in radians
  27031. * @param space the choosen space of the target
  27032. * @returns the TransformNode.
  27033. */
  27034. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27035. /**
  27036. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27037. * This Vector3 is expressed in the World space.
  27038. * @param localAxis axis to rotate
  27039. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27040. */
  27041. getDirection(localAxis: Vector3): Vector3;
  27042. /**
  27043. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27044. * localAxis is expressed in the mesh local space.
  27045. * result is computed in the Wordl space from the mesh World matrix.
  27046. * @param localAxis axis to rotate
  27047. * @param result the resulting transformnode
  27048. * @returns this TransformNode.
  27049. */
  27050. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27051. /**
  27052. * Sets this transform node rotation to the given local axis.
  27053. * @param localAxis the axis in local space
  27054. * @param yawCor optional yaw (y-axis) correction in radians
  27055. * @param pitchCor optional pitch (x-axis) correction in radians
  27056. * @param rollCor optional roll (z-axis) correction in radians
  27057. * @returns this TransformNode
  27058. */
  27059. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27060. /**
  27061. * Sets a new pivot point to the current node
  27062. * @param point defines the new pivot point to use
  27063. * @param space defines if the point is in world or local space (local by default)
  27064. * @returns the current TransformNode
  27065. */
  27066. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27067. /**
  27068. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27069. * @returns the pivot point
  27070. */
  27071. getPivotPoint(): Vector3;
  27072. /**
  27073. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27074. * @param result the vector3 to store the result
  27075. * @returns this TransformNode.
  27076. */
  27077. getPivotPointToRef(result: Vector3): TransformNode;
  27078. /**
  27079. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27080. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27081. */
  27082. getAbsolutePivotPoint(): Vector3;
  27083. /**
  27084. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27085. * @param result vector3 to store the result
  27086. * @returns this TransformNode.
  27087. */
  27088. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27089. /**
  27090. * Defines the passed node as the parent of the current node.
  27091. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27092. * @see https://doc.babylonjs.com/how_to/parenting
  27093. * @param node the node ot set as the parent
  27094. * @returns this TransformNode.
  27095. */
  27096. setParent(node: Nullable<Node>): TransformNode;
  27097. private _nonUniformScaling;
  27098. /**
  27099. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27100. */
  27101. get nonUniformScaling(): boolean;
  27102. /** @hidden */
  27103. _updateNonUniformScalingState(value: boolean): boolean;
  27104. /**
  27105. * Attach the current TransformNode to another TransformNode associated with a bone
  27106. * @param bone Bone affecting the TransformNode
  27107. * @param affectedTransformNode TransformNode associated with the bone
  27108. * @returns this object
  27109. */
  27110. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27111. /**
  27112. * Detach the transform node if its associated with a bone
  27113. * @returns this object
  27114. */
  27115. detachFromBone(): TransformNode;
  27116. private static _rotationAxisCache;
  27117. /**
  27118. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27119. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27120. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27121. * The passed axis is also normalized.
  27122. * @param axis the axis to rotate around
  27123. * @param amount the amount to rotate in radians
  27124. * @param space Space to rotate in (Default: local)
  27125. * @returns the TransformNode.
  27126. */
  27127. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27128. /**
  27129. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27130. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27131. * The passed axis is also normalized. .
  27132. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27133. * @param point the point to rotate around
  27134. * @param axis the axis to rotate around
  27135. * @param amount the amount to rotate in radians
  27136. * @returns the TransformNode
  27137. */
  27138. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27139. /**
  27140. * Translates the mesh along the axis vector for the passed distance in the given space.
  27141. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27142. * @param axis the axis to translate in
  27143. * @param distance the distance to translate
  27144. * @param space Space to rotate in (Default: local)
  27145. * @returns the TransformNode.
  27146. */
  27147. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27148. /**
  27149. * Adds a rotation step to the mesh current rotation.
  27150. * x, y, z are Euler angles expressed in radians.
  27151. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27152. * This means this rotation is made in the mesh local space only.
  27153. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27154. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27155. * ```javascript
  27156. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27157. * ```
  27158. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27159. * 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.
  27160. * @param x Rotation to add
  27161. * @param y Rotation to add
  27162. * @param z Rotation to add
  27163. * @returns the TransformNode.
  27164. */
  27165. addRotation(x: number, y: number, z: number): TransformNode;
  27166. /**
  27167. * @hidden
  27168. */
  27169. protected _getEffectiveParent(): Nullable<Node>;
  27170. /**
  27171. * Computes the world matrix of the node
  27172. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27173. * @returns the world matrix
  27174. */
  27175. computeWorldMatrix(force?: boolean): Matrix;
  27176. /**
  27177. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27178. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27179. */
  27180. resetLocalMatrix(independentOfChildren?: boolean): void;
  27181. protected _afterComputeWorldMatrix(): void;
  27182. /**
  27183. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27184. * @param func callback function to add
  27185. *
  27186. * @returns the TransformNode.
  27187. */
  27188. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27189. /**
  27190. * Removes a registered callback function.
  27191. * @param func callback function to remove
  27192. * @returns the TransformNode.
  27193. */
  27194. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27195. /**
  27196. * Gets the position of the current mesh in camera space
  27197. * @param camera defines the camera to use
  27198. * @returns a position
  27199. */
  27200. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27201. /**
  27202. * Returns the distance from the mesh to the active camera
  27203. * @param camera defines the camera to use
  27204. * @returns the distance
  27205. */
  27206. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27207. /**
  27208. * Clone the current transform node
  27209. * @param name Name of the new clone
  27210. * @param newParent New parent for the clone
  27211. * @param doNotCloneChildren Do not clone children hierarchy
  27212. * @returns the new transform node
  27213. */
  27214. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27215. /**
  27216. * Serializes the objects information.
  27217. * @param currentSerializationObject defines the object to serialize in
  27218. * @returns the serialized object
  27219. */
  27220. serialize(currentSerializationObject?: any): any;
  27221. /**
  27222. * Returns a new TransformNode object parsed from the source provided.
  27223. * @param parsedTransformNode is the source.
  27224. * @param scene the scne the object belongs to
  27225. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27226. * @returns a new TransformNode object parsed from the source provided.
  27227. */
  27228. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27229. /**
  27230. * Get all child-transformNodes of this node
  27231. * @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
  27232. * @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
  27233. * @returns an array of TransformNode
  27234. */
  27235. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27236. /**
  27237. * Releases resources associated with this transform node.
  27238. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27239. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27240. */
  27241. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27242. /**
  27243. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27244. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27245. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27246. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27247. * @returns the current mesh
  27248. */
  27249. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27250. private _syncAbsoluteScalingAndRotation;
  27251. }
  27252. }
  27253. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  27254. import { Observable } from "babylonjs/Misc/observable";
  27255. import { Nullable } from "babylonjs/types";
  27256. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27257. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27259. import { Ray } from "babylonjs/Culling/ray";
  27260. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  27261. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  27262. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  27263. /**
  27264. * Defines the types of pose enabled controllers that are supported
  27265. */
  27266. export enum PoseEnabledControllerType {
  27267. /**
  27268. * HTC Vive
  27269. */
  27270. VIVE = 0,
  27271. /**
  27272. * Oculus Rift
  27273. */
  27274. OCULUS = 1,
  27275. /**
  27276. * Windows mixed reality
  27277. */
  27278. WINDOWS = 2,
  27279. /**
  27280. * Samsung gear VR
  27281. */
  27282. GEAR_VR = 3,
  27283. /**
  27284. * Google Daydream
  27285. */
  27286. DAYDREAM = 4,
  27287. /**
  27288. * Generic
  27289. */
  27290. GENERIC = 5
  27291. }
  27292. /**
  27293. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27294. */
  27295. export interface MutableGamepadButton {
  27296. /**
  27297. * Value of the button/trigger
  27298. */
  27299. value: number;
  27300. /**
  27301. * If the button/trigger is currently touched
  27302. */
  27303. touched: boolean;
  27304. /**
  27305. * If the button/trigger is currently pressed
  27306. */
  27307. pressed: boolean;
  27308. }
  27309. /**
  27310. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27311. * @hidden
  27312. */
  27313. export interface ExtendedGamepadButton extends GamepadButton {
  27314. /**
  27315. * If the button/trigger is currently pressed
  27316. */
  27317. readonly pressed: boolean;
  27318. /**
  27319. * If the button/trigger is currently touched
  27320. */
  27321. readonly touched: boolean;
  27322. /**
  27323. * Value of the button/trigger
  27324. */
  27325. readonly value: number;
  27326. }
  27327. /** @hidden */
  27328. export interface _GamePadFactory {
  27329. /**
  27330. * Returns whether or not the current gamepad can be created for this type of controller.
  27331. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27332. * @returns true if it can be created, otherwise false
  27333. */
  27334. canCreate(gamepadInfo: any): boolean;
  27335. /**
  27336. * Creates a new instance of the Gamepad.
  27337. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27338. * @returns the new gamepad instance
  27339. */
  27340. create(gamepadInfo: any): Gamepad;
  27341. }
  27342. /**
  27343. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27344. */
  27345. export class PoseEnabledControllerHelper {
  27346. /** @hidden */
  27347. static _ControllerFactories: _GamePadFactory[];
  27348. /** @hidden */
  27349. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27350. /**
  27351. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27352. * @param vrGamepad the gamepad to initialized
  27353. * @returns a vr controller of the type the gamepad identified as
  27354. */
  27355. static InitiateController(vrGamepad: any): Gamepad;
  27356. }
  27357. /**
  27358. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27359. */
  27360. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27361. /**
  27362. * If the controller is used in a webXR session
  27363. */
  27364. isXR: boolean;
  27365. private _deviceRoomPosition;
  27366. private _deviceRoomRotationQuaternion;
  27367. /**
  27368. * The device position in babylon space
  27369. */
  27370. devicePosition: Vector3;
  27371. /**
  27372. * The device rotation in babylon space
  27373. */
  27374. deviceRotationQuaternion: Quaternion;
  27375. /**
  27376. * The scale factor of the device in babylon space
  27377. */
  27378. deviceScaleFactor: number;
  27379. /**
  27380. * (Likely devicePosition should be used instead) The device position in its room space
  27381. */
  27382. position: Vector3;
  27383. /**
  27384. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27385. */
  27386. rotationQuaternion: Quaternion;
  27387. /**
  27388. * The type of controller (Eg. Windows mixed reality)
  27389. */
  27390. controllerType: PoseEnabledControllerType;
  27391. protected _calculatedPosition: Vector3;
  27392. private _calculatedRotation;
  27393. /**
  27394. * The raw pose from the device
  27395. */
  27396. rawPose: DevicePose;
  27397. private _trackPosition;
  27398. private _maxRotationDistFromHeadset;
  27399. private _draggedRoomRotation;
  27400. /**
  27401. * @hidden
  27402. */
  27403. _disableTrackPosition(fixedPosition: Vector3): void;
  27404. /**
  27405. * Internal, the mesh attached to the controller
  27406. * @hidden
  27407. */
  27408. _mesh: Nullable<AbstractMesh>;
  27409. private _poseControlledCamera;
  27410. private _leftHandSystemQuaternion;
  27411. /**
  27412. * Internal, matrix used to convert room space to babylon space
  27413. * @hidden
  27414. */
  27415. _deviceToWorld: Matrix;
  27416. /**
  27417. * Node to be used when casting a ray from the controller
  27418. * @hidden
  27419. */
  27420. _pointingPoseNode: Nullable<TransformNode>;
  27421. /**
  27422. * Name of the child mesh that can be used to cast a ray from the controller
  27423. */
  27424. static readonly POINTING_POSE: string;
  27425. /**
  27426. * Creates a new PoseEnabledController from a gamepad
  27427. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27428. */
  27429. constructor(browserGamepad: any);
  27430. private _workingMatrix;
  27431. /**
  27432. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27433. */
  27434. update(): void;
  27435. /**
  27436. * Updates only the pose device and mesh without doing any button event checking
  27437. */
  27438. protected _updatePoseAndMesh(): void;
  27439. /**
  27440. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27441. * @param poseData raw pose fromthe device
  27442. */
  27443. updateFromDevice(poseData: DevicePose): void;
  27444. /**
  27445. * @hidden
  27446. */
  27447. _meshAttachedObservable: Observable<AbstractMesh>;
  27448. /**
  27449. * Attaches a mesh to the controller
  27450. * @param mesh the mesh to be attached
  27451. */
  27452. attachToMesh(mesh: AbstractMesh): void;
  27453. /**
  27454. * Attaches the controllers mesh to a camera
  27455. * @param camera the camera the mesh should be attached to
  27456. */
  27457. attachToPoseControlledCamera(camera: TargetCamera): void;
  27458. /**
  27459. * Disposes of the controller
  27460. */
  27461. dispose(): void;
  27462. /**
  27463. * The mesh that is attached to the controller
  27464. */
  27465. get mesh(): Nullable<AbstractMesh>;
  27466. /**
  27467. * Gets the ray of the controller in the direction the controller is pointing
  27468. * @param length the length the resulting ray should be
  27469. * @returns a ray in the direction the controller is pointing
  27470. */
  27471. getForwardRay(length?: number): Ray;
  27472. }
  27473. }
  27474. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  27475. import { Observable } from "babylonjs/Misc/observable";
  27476. import { Scene } from "babylonjs/scene";
  27477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27478. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  27479. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  27480. import { Nullable } from "babylonjs/types";
  27481. /**
  27482. * Defines the WebVRController object that represents controllers tracked in 3D space
  27483. */
  27484. export abstract class WebVRController extends PoseEnabledController {
  27485. /**
  27486. * Internal, the default controller model for the controller
  27487. */
  27488. protected _defaultModel: Nullable<AbstractMesh>;
  27489. /**
  27490. * Fired when the trigger state has changed
  27491. */
  27492. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27493. /**
  27494. * Fired when the main button state has changed
  27495. */
  27496. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27497. /**
  27498. * Fired when the secondary button state has changed
  27499. */
  27500. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27501. /**
  27502. * Fired when the pad state has changed
  27503. */
  27504. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27505. /**
  27506. * Fired when controllers stick values have changed
  27507. */
  27508. onPadValuesChangedObservable: Observable<StickValues>;
  27509. /**
  27510. * Array of button availible on the controller
  27511. */
  27512. protected _buttons: Array<MutableGamepadButton>;
  27513. private _onButtonStateChange;
  27514. /**
  27515. * Fired when a controller button's state has changed
  27516. * @param callback the callback containing the button that was modified
  27517. */
  27518. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27519. /**
  27520. * X and Y axis corresponding to the controllers joystick
  27521. */
  27522. pad: StickValues;
  27523. /**
  27524. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27525. */
  27526. hand: string;
  27527. /**
  27528. * The default controller model for the controller
  27529. */
  27530. get defaultModel(): Nullable<AbstractMesh>;
  27531. /**
  27532. * Creates a new WebVRController from a gamepad
  27533. * @param vrGamepad the gamepad that the WebVRController should be created from
  27534. */
  27535. constructor(vrGamepad: any);
  27536. /**
  27537. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27538. */
  27539. update(): void;
  27540. /**
  27541. * Function to be called when a button is modified
  27542. */
  27543. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27544. /**
  27545. * Loads a mesh and attaches it to the controller
  27546. * @param scene the scene the mesh should be added to
  27547. * @param meshLoaded callback for when the mesh has been loaded
  27548. */
  27549. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27550. private _setButtonValue;
  27551. private _changes;
  27552. private _checkChanges;
  27553. /**
  27554. * Disposes of th webVRCOntroller
  27555. */
  27556. dispose(): void;
  27557. }
  27558. }
  27559. declare module "babylonjs/Lights/hemisphericLight" {
  27560. import { Nullable } from "babylonjs/types";
  27561. import { Scene } from "babylonjs/scene";
  27562. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27563. import { Color3 } from "babylonjs/Maths/math.color";
  27564. import { Effect } from "babylonjs/Materials/effect";
  27565. import { Light } from "babylonjs/Lights/light";
  27566. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  27567. /**
  27568. * The HemisphericLight simulates the ambient environment light,
  27569. * so the passed direction is the light reflection direction, not the incoming direction.
  27570. */
  27571. export class HemisphericLight extends Light {
  27572. /**
  27573. * The groundColor is the light in the opposite direction to the one specified during creation.
  27574. * 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.
  27575. */
  27576. groundColor: Color3;
  27577. /**
  27578. * The light reflection direction, not the incoming direction.
  27579. */
  27580. direction: Vector3;
  27581. /**
  27582. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27583. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27584. * The HemisphericLight can't cast shadows.
  27585. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27586. * @param name The friendly name of the light
  27587. * @param direction The direction of the light reflection
  27588. * @param scene The scene the light belongs to
  27589. */
  27590. constructor(name: string, direction: Vector3, scene: Scene);
  27591. protected _buildUniformLayout(): void;
  27592. /**
  27593. * Returns the string "HemisphericLight".
  27594. * @return The class name
  27595. */
  27596. getClassName(): string;
  27597. /**
  27598. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27599. * Returns the updated direction.
  27600. * @param target The target the direction should point to
  27601. * @return The computed direction
  27602. */
  27603. setDirectionToTarget(target: Vector3): Vector3;
  27604. /**
  27605. * Returns the shadow generator associated to the light.
  27606. * @returns Always null for hemispheric lights because it does not support shadows.
  27607. */
  27608. getShadowGenerator(): Nullable<IShadowGenerator>;
  27609. /**
  27610. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27611. * @param effect The effect to update
  27612. * @param lightIndex The index of the light in the effect to update
  27613. * @returns The hemispheric light
  27614. */
  27615. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27616. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27617. /**
  27618. * Computes the world matrix of the node
  27619. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27620. * @param useWasUpdatedFlag defines a reserved property
  27621. * @returns the world matrix
  27622. */
  27623. computeWorldMatrix(): Matrix;
  27624. /**
  27625. * Returns the integer 3.
  27626. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27627. */
  27628. getTypeID(): number;
  27629. /**
  27630. * Prepares the list of defines specific to the light type.
  27631. * @param defines the list of defines
  27632. * @param lightIndex defines the index of the light for the effect
  27633. */
  27634. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27635. }
  27636. }
  27637. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  27638. /** @hidden */
  27639. export var vrMultiviewToSingleviewPixelShader: {
  27640. name: string;
  27641. shader: string;
  27642. };
  27643. }
  27644. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  27645. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27646. import { Scene } from "babylonjs/scene";
  27647. /**
  27648. * Renders to multiple views with a single draw call
  27649. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27650. */
  27651. export class MultiviewRenderTarget extends RenderTargetTexture {
  27652. /**
  27653. * Creates a multiview render target
  27654. * @param scene scene used with the render target
  27655. * @param size the size of the render target (used for each view)
  27656. */
  27657. constructor(scene: Scene, size?: number | {
  27658. width: number;
  27659. height: number;
  27660. } | {
  27661. ratio: number;
  27662. });
  27663. /**
  27664. * @hidden
  27665. * @param faceIndex the face index, if its a cube texture
  27666. */
  27667. _bindFrameBuffer(faceIndex?: number): void;
  27668. /**
  27669. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27670. * @returns the view count
  27671. */
  27672. getViewCount(): number;
  27673. }
  27674. }
  27675. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  27676. import { Camera } from "babylonjs/Cameras/camera";
  27677. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27678. import { Nullable } from "babylonjs/types";
  27679. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27680. import { Matrix } from "babylonjs/Maths/math.vector";
  27681. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27682. module "babylonjs/Engines/engine" {
  27683. interface Engine {
  27684. /**
  27685. * Creates a new multiview render target
  27686. * @param width defines the width of the texture
  27687. * @param height defines the height of the texture
  27688. * @returns the created multiview texture
  27689. */
  27690. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27691. /**
  27692. * Binds a multiview framebuffer to be drawn to
  27693. * @param multiviewTexture texture to bind
  27694. */
  27695. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27696. }
  27697. }
  27698. module "babylonjs/Cameras/camera" {
  27699. interface Camera {
  27700. /**
  27701. * @hidden
  27702. * 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)
  27703. */
  27704. _useMultiviewToSingleView: boolean;
  27705. /**
  27706. * @hidden
  27707. * 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)
  27708. */
  27709. _multiviewTexture: Nullable<RenderTargetTexture>;
  27710. /**
  27711. * @hidden
  27712. * ensures the multiview texture of the camera exists and has the specified width/height
  27713. * @param width height to set on the multiview texture
  27714. * @param height width to set on the multiview texture
  27715. */
  27716. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27717. }
  27718. }
  27719. module "babylonjs/scene" {
  27720. interface Scene {
  27721. /** @hidden */
  27722. _transformMatrixR: Matrix;
  27723. /** @hidden */
  27724. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27725. /** @hidden */
  27726. _createMultiviewUbo(): void;
  27727. /** @hidden */
  27728. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27729. /** @hidden */
  27730. _renderMultiviewToSingleView(camera: Camera): void;
  27731. }
  27732. }
  27733. }
  27734. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  27735. import { Camera } from "babylonjs/Cameras/camera";
  27736. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27737. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  27738. import "babylonjs/Engines/Extensions/engine.multiview";
  27739. /**
  27740. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27741. * This will not be used for webXR as it supports displaying texture arrays directly
  27742. */
  27743. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27744. /**
  27745. * Gets a string identifying the name of the class
  27746. * @returns "VRMultiviewToSingleviewPostProcess" string
  27747. */
  27748. getClassName(): string;
  27749. /**
  27750. * Initializes a VRMultiviewToSingleview
  27751. * @param name name of the post process
  27752. * @param camera camera to be applied to
  27753. * @param scaleFactor scaling factor to the size of the output texture
  27754. */
  27755. constructor(name: string, camera: Camera, scaleFactor: number);
  27756. }
  27757. }
  27758. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  27759. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  27760. import { Nullable } from "babylonjs/types";
  27761. import { Size } from "babylonjs/Maths/math.size";
  27762. import { Observable } from "babylonjs/Misc/observable";
  27763. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  27764. /**
  27765. * Interface used to define additional presentation attributes
  27766. */
  27767. export interface IVRPresentationAttributes {
  27768. /**
  27769. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27770. */
  27771. highRefreshRate: boolean;
  27772. /**
  27773. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27774. */
  27775. foveationLevel: number;
  27776. }
  27777. module "babylonjs/Engines/engine" {
  27778. interface Engine {
  27779. /** @hidden */
  27780. _vrDisplay: any;
  27781. /** @hidden */
  27782. _vrSupported: boolean;
  27783. /** @hidden */
  27784. _oldSize: Size;
  27785. /** @hidden */
  27786. _oldHardwareScaleFactor: number;
  27787. /** @hidden */
  27788. _vrExclusivePointerMode: boolean;
  27789. /** @hidden */
  27790. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27791. /** @hidden */
  27792. _onVRDisplayPointerRestricted: () => void;
  27793. /** @hidden */
  27794. _onVRDisplayPointerUnrestricted: () => void;
  27795. /** @hidden */
  27796. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27797. /** @hidden */
  27798. _onVrDisplayDisconnect: Nullable<() => void>;
  27799. /** @hidden */
  27800. _onVrDisplayPresentChange: Nullable<() => void>;
  27801. /**
  27802. * Observable signaled when VR display mode changes
  27803. */
  27804. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27805. /**
  27806. * Observable signaled when VR request present is complete
  27807. */
  27808. onVRRequestPresentComplete: Observable<boolean>;
  27809. /**
  27810. * Observable signaled when VR request present starts
  27811. */
  27812. onVRRequestPresentStart: Observable<Engine>;
  27813. /**
  27814. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27815. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27816. */
  27817. isInVRExclusivePointerMode: boolean;
  27818. /**
  27819. * Gets a boolean indicating if a webVR device was detected
  27820. * @returns true if a webVR device was detected
  27821. */
  27822. isVRDevicePresent(): boolean;
  27823. /**
  27824. * Gets the current webVR device
  27825. * @returns the current webVR device (or null)
  27826. */
  27827. getVRDevice(): any;
  27828. /**
  27829. * Initializes a webVR display and starts listening to display change events
  27830. * The onVRDisplayChangedObservable will be notified upon these changes
  27831. * @returns A promise containing a VRDisplay and if vr is supported
  27832. */
  27833. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27834. /** @hidden */
  27835. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27836. /**
  27837. * Gets or sets the presentation attributes used to configure VR rendering
  27838. */
  27839. vrPresentationAttributes?: IVRPresentationAttributes;
  27840. /**
  27841. * Call this function to switch to webVR mode
  27842. * Will do nothing if webVR is not supported or if there is no webVR device
  27843. * @param options the webvr options provided to the camera. mainly used for multiview
  27844. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27845. */
  27846. enableVR(options: WebVROptions): void;
  27847. /** @hidden */
  27848. _onVRFullScreenTriggered(): void;
  27849. }
  27850. }
  27851. }
  27852. declare module "babylonjs/Cameras/VR/webVRCamera" {
  27853. import { Nullable } from "babylonjs/types";
  27854. import { Observable } from "babylonjs/Misc/observable";
  27855. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  27856. import { Scene } from "babylonjs/scene";
  27857. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27858. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  27859. import { Node } from "babylonjs/node";
  27860. import { Ray } from "babylonjs/Culling/ray";
  27861. import "babylonjs/Cameras/RigModes/webVRRigMode";
  27862. import "babylonjs/Engines/Extensions/engine.webVR";
  27863. /**
  27864. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27865. * IMPORTANT!! The data is right-hand data.
  27866. * @export
  27867. * @interface DevicePose
  27868. */
  27869. export interface DevicePose {
  27870. /**
  27871. * The position of the device, values in array are [x,y,z].
  27872. */
  27873. readonly position: Nullable<Float32Array>;
  27874. /**
  27875. * The linearVelocity of the device, values in array are [x,y,z].
  27876. */
  27877. readonly linearVelocity: Nullable<Float32Array>;
  27878. /**
  27879. * The linearAcceleration of the device, values in array are [x,y,z].
  27880. */
  27881. readonly linearAcceleration: Nullable<Float32Array>;
  27882. /**
  27883. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27884. */
  27885. readonly orientation: Nullable<Float32Array>;
  27886. /**
  27887. * The angularVelocity of the device, values in array are [x,y,z].
  27888. */
  27889. readonly angularVelocity: Nullable<Float32Array>;
  27890. /**
  27891. * The angularAcceleration of the device, values in array are [x,y,z].
  27892. */
  27893. readonly angularAcceleration: Nullable<Float32Array>;
  27894. }
  27895. /**
  27896. * Interface representing a pose controlled object in Babylon.
  27897. * A pose controlled object has both regular pose values as well as pose values
  27898. * from an external device such as a VR head mounted display
  27899. */
  27900. export interface PoseControlled {
  27901. /**
  27902. * The position of the object in babylon space.
  27903. */
  27904. position: Vector3;
  27905. /**
  27906. * The rotation quaternion of the object in babylon space.
  27907. */
  27908. rotationQuaternion: Quaternion;
  27909. /**
  27910. * The position of the device in babylon space.
  27911. */
  27912. devicePosition?: Vector3;
  27913. /**
  27914. * The rotation quaternion of the device in babylon space.
  27915. */
  27916. deviceRotationQuaternion: Quaternion;
  27917. /**
  27918. * The raw pose coming from the device.
  27919. */
  27920. rawPose: Nullable<DevicePose>;
  27921. /**
  27922. * The scale of the device to be used when translating from device space to babylon space.
  27923. */
  27924. deviceScaleFactor: number;
  27925. /**
  27926. * Updates the poseControlled values based on the input device pose.
  27927. * @param poseData the pose data to update the object with
  27928. */
  27929. updateFromDevice(poseData: DevicePose): void;
  27930. }
  27931. /**
  27932. * Set of options to customize the webVRCamera
  27933. */
  27934. export interface WebVROptions {
  27935. /**
  27936. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27937. */
  27938. trackPosition?: boolean;
  27939. /**
  27940. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27941. */
  27942. positionScale?: number;
  27943. /**
  27944. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27945. */
  27946. displayName?: string;
  27947. /**
  27948. * Should the native controller meshes be initialized. (default: true)
  27949. */
  27950. controllerMeshes?: boolean;
  27951. /**
  27952. * Creating a default HemiLight only on controllers. (default: true)
  27953. */
  27954. defaultLightingOnControllers?: boolean;
  27955. /**
  27956. * If you don't want to use the default VR button of the helper. (default: false)
  27957. */
  27958. useCustomVRButton?: boolean;
  27959. /**
  27960. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27961. */
  27962. customVRButton?: HTMLButtonElement;
  27963. /**
  27964. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27965. */
  27966. rayLength?: number;
  27967. /**
  27968. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27969. */
  27970. defaultHeight?: number;
  27971. /**
  27972. * If multiview should be used if availible (default: false)
  27973. */
  27974. useMultiview?: boolean;
  27975. }
  27976. /**
  27977. * This represents a WebVR camera.
  27978. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27979. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27980. */
  27981. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27982. private webVROptions;
  27983. /**
  27984. * @hidden
  27985. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27986. */
  27987. _vrDevice: any;
  27988. /**
  27989. * The rawPose of the vrDevice.
  27990. */
  27991. rawPose: Nullable<DevicePose>;
  27992. private _onVREnabled;
  27993. private _specsVersion;
  27994. private _attached;
  27995. private _frameData;
  27996. protected _descendants: Array<Node>;
  27997. private _deviceRoomPosition;
  27998. /** @hidden */
  27999. _deviceRoomRotationQuaternion: Quaternion;
  28000. private _standingMatrix;
  28001. /**
  28002. * Represents device position in babylon space.
  28003. */
  28004. devicePosition: Vector3;
  28005. /**
  28006. * Represents device rotation in babylon space.
  28007. */
  28008. deviceRotationQuaternion: Quaternion;
  28009. /**
  28010. * The scale of the device to be used when translating from device space to babylon space.
  28011. */
  28012. deviceScaleFactor: number;
  28013. private _deviceToWorld;
  28014. private _worldToDevice;
  28015. /**
  28016. * References to the webVR controllers for the vrDevice.
  28017. */
  28018. controllers: Array<WebVRController>;
  28019. /**
  28020. * Emits an event when a controller is attached.
  28021. */
  28022. onControllersAttachedObservable: Observable<WebVRController[]>;
  28023. /**
  28024. * Emits an event when a controller's mesh has been loaded;
  28025. */
  28026. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28027. /**
  28028. * Emits an event when the HMD's pose has been updated.
  28029. */
  28030. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28031. private _poseSet;
  28032. /**
  28033. * If the rig cameras be used as parent instead of this camera.
  28034. */
  28035. rigParenting: boolean;
  28036. private _lightOnControllers;
  28037. private _defaultHeight?;
  28038. /**
  28039. * Instantiates a WebVRFreeCamera.
  28040. * @param name The name of the WebVRFreeCamera
  28041. * @param position The starting anchor position for the camera
  28042. * @param scene The scene the camera belongs to
  28043. * @param webVROptions a set of customizable options for the webVRCamera
  28044. */
  28045. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28046. /**
  28047. * Gets the device distance from the ground in meters.
  28048. * @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.
  28049. */
  28050. deviceDistanceToRoomGround(): number;
  28051. /**
  28052. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28053. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28054. */
  28055. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28056. /**
  28057. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28058. * @returns A promise with a boolean set to if the standing matrix is supported.
  28059. */
  28060. useStandingMatrixAsync(): Promise<boolean>;
  28061. /**
  28062. * Disposes the camera
  28063. */
  28064. dispose(): void;
  28065. /**
  28066. * Gets a vrController by name.
  28067. * @param name The name of the controller to retreive
  28068. * @returns the controller matching the name specified or null if not found
  28069. */
  28070. getControllerByName(name: string): Nullable<WebVRController>;
  28071. private _leftController;
  28072. /**
  28073. * The controller corresponding to the users left hand.
  28074. */
  28075. get leftController(): Nullable<WebVRController>;
  28076. private _rightController;
  28077. /**
  28078. * The controller corresponding to the users right hand.
  28079. */
  28080. get rightController(): Nullable<WebVRController>;
  28081. /**
  28082. * Casts a ray forward from the vrCamera's gaze.
  28083. * @param length Length of the ray (default: 100)
  28084. * @returns the ray corresponding to the gaze
  28085. */
  28086. getForwardRay(length?: number): Ray;
  28087. /**
  28088. * @hidden
  28089. * Updates the camera based on device's frame data
  28090. */
  28091. _checkInputs(): void;
  28092. /**
  28093. * Updates the poseControlled values based on the input device pose.
  28094. * @param poseData Pose coming from the device
  28095. */
  28096. updateFromDevice(poseData: DevicePose): void;
  28097. private _detachIfAttached;
  28098. /**
  28099. * WebVR's attach control will start broadcasting frames to the device.
  28100. * Note that in certain browsers (chrome for example) this function must be called
  28101. * within a user-interaction callback. Example:
  28102. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28103. *
  28104. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28105. */
  28106. attachControl(noPreventDefault?: boolean): void;
  28107. /**
  28108. * Detach the current controls from the specified dom element.
  28109. */
  28110. detachControl(): void;
  28111. /**
  28112. * @returns the name of this class
  28113. */
  28114. getClassName(): string;
  28115. /**
  28116. * Calls resetPose on the vrDisplay
  28117. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28118. */
  28119. resetToCurrentRotation(): void;
  28120. /**
  28121. * @hidden
  28122. * Updates the rig cameras (left and right eye)
  28123. */
  28124. _updateRigCameras(): void;
  28125. private _workingVector;
  28126. private _oneVector;
  28127. private _workingMatrix;
  28128. private updateCacheCalled;
  28129. private _correctPositionIfNotTrackPosition;
  28130. /**
  28131. * @hidden
  28132. * Updates the cached values of the camera
  28133. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28134. */
  28135. _updateCache(ignoreParentClass?: boolean): void;
  28136. /**
  28137. * @hidden
  28138. * Get current device position in babylon world
  28139. */
  28140. _computeDevicePosition(): void;
  28141. /**
  28142. * Updates the current device position and rotation in the babylon world
  28143. */
  28144. update(): void;
  28145. /**
  28146. * @hidden
  28147. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28148. * @returns an identity matrix
  28149. */
  28150. _getViewMatrix(): Matrix;
  28151. private _tmpMatrix;
  28152. /**
  28153. * This function is called by the two RIG cameras.
  28154. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28155. * @hidden
  28156. */
  28157. _getWebVRViewMatrix(): Matrix;
  28158. /** @hidden */
  28159. _getWebVRProjectionMatrix(): Matrix;
  28160. private _onGamepadConnectedObserver;
  28161. private _onGamepadDisconnectedObserver;
  28162. private _updateCacheWhenTrackingDisabledObserver;
  28163. /**
  28164. * Initializes the controllers and their meshes
  28165. */
  28166. initControllers(): void;
  28167. }
  28168. }
  28169. declare module "babylonjs/Materials/materialHelper" {
  28170. import { Nullable } from "babylonjs/types";
  28171. import { Scene } from "babylonjs/scene";
  28172. import { Engine } from "babylonjs/Engines/engine";
  28173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28174. import { Light } from "babylonjs/Lights/light";
  28175. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  28176. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28177. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  28178. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28179. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  28180. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  28181. /**
  28182. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28183. *
  28184. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28185. *
  28186. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28187. */
  28188. export class MaterialHelper {
  28189. /**
  28190. * Bind the current view position to an effect.
  28191. * @param effect The effect to be bound
  28192. * @param scene The scene the eyes position is used from
  28193. * @param variableName name of the shader variable that will hold the eye position
  28194. */
  28195. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  28196. /**
  28197. * Helps preparing the defines values about the UVs in used in the effect.
  28198. * UVs are shared as much as we can accross channels in the shaders.
  28199. * @param texture The texture we are preparing the UVs for
  28200. * @param defines The defines to update
  28201. * @param key The channel key "diffuse", "specular"... used in the shader
  28202. */
  28203. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28204. /**
  28205. * Binds a texture matrix value to its corrsponding uniform
  28206. * @param texture The texture to bind the matrix for
  28207. * @param uniformBuffer The uniform buffer receivin the data
  28208. * @param key The channel key "diffuse", "specular"... used in the shader
  28209. */
  28210. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28211. /**
  28212. * Gets the current status of the fog (should it be enabled?)
  28213. * @param mesh defines the mesh to evaluate for fog support
  28214. * @param scene defines the hosting scene
  28215. * @returns true if fog must be enabled
  28216. */
  28217. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28218. /**
  28219. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28220. * @param mesh defines the current mesh
  28221. * @param scene defines the current scene
  28222. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28223. * @param pointsCloud defines if point cloud rendering has to be turned on
  28224. * @param fogEnabled defines if fog has to be turned on
  28225. * @param alphaTest defines if alpha testing has to be turned on
  28226. * @param defines defines the current list of defines
  28227. */
  28228. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28229. /**
  28230. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28231. * @param scene defines the current scene
  28232. * @param engine defines the current engine
  28233. * @param defines specifies the list of active defines
  28234. * @param useInstances defines if instances have to be turned on
  28235. * @param useClipPlane defines if clip plane have to be turned on
  28236. * @param useInstances defines if instances have to be turned on
  28237. * @param useThinInstances defines if thin instances have to be turned on
  28238. */
  28239. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28240. /**
  28241. * Prepares the defines for bones
  28242. * @param mesh The mesh containing the geometry data we will draw
  28243. * @param defines The defines to update
  28244. */
  28245. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  28246. /**
  28247. * Prepares the defines for morph targets
  28248. * @param mesh The mesh containing the geometry data we will draw
  28249. * @param defines The defines to update
  28250. */
  28251. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  28252. /**
  28253. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  28254. * @param mesh The mesh containing the geometry data we will draw
  28255. * @param defines The defines to update
  28256. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28257. * @param useBones Precise whether bones should be used or not (override mesh info)
  28258. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28259. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28260. * @returns false if defines are considered not dirty and have not been checked
  28261. */
  28262. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28263. /**
  28264. * Prepares the defines related to multiview
  28265. * @param scene The scene we are intending to draw
  28266. * @param defines The defines to update
  28267. */
  28268. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28269. /**
  28270. * Prepares the defines related to the prepass
  28271. * @param scene The scene we are intending to draw
  28272. * @param defines The defines to update
  28273. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28274. */
  28275. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28276. /**
  28277. * Prepares the defines related to the light information passed in parameter
  28278. * @param scene The scene we are intending to draw
  28279. * @param mesh The mesh the effect is compiling for
  28280. * @param light The light the effect is compiling for
  28281. * @param lightIndex The index of the light
  28282. * @param defines The defines to update
  28283. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28284. * @param state Defines the current state regarding what is needed (normals, etc...)
  28285. */
  28286. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28287. needNormals: boolean;
  28288. needRebuild: boolean;
  28289. shadowEnabled: boolean;
  28290. specularEnabled: boolean;
  28291. lightmapMode: boolean;
  28292. }): void;
  28293. /**
  28294. * Prepares the defines related to the light information passed in parameter
  28295. * @param scene The scene we are intending to draw
  28296. * @param mesh The mesh the effect is compiling for
  28297. * @param defines The defines to update
  28298. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28299. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  28300. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28301. * @returns true if normals will be required for the rest of the effect
  28302. */
  28303. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28304. /**
  28305. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28306. * @param lightIndex defines the light index
  28307. * @param uniformsList The uniform list
  28308. * @param samplersList The sampler list
  28309. * @param projectedLightTexture defines if projected texture must be used
  28310. * @param uniformBuffersList defines an optional list of uniform buffers
  28311. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28312. */
  28313. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28314. /**
  28315. * Prepares the uniforms and samplers list to be used in the effect
  28316. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  28317. * @param samplersList The sampler list
  28318. * @param defines The defines helping in the list generation
  28319. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  28320. */
  28321. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28322. /**
  28323. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28324. * @param defines The defines to update while falling back
  28325. * @param fallbacks The authorized effect fallbacks
  28326. * @param maxSimultaneousLights The maximum number of lights allowed
  28327. * @param rank the current rank of the Effect
  28328. * @returns The newly affected rank
  28329. */
  28330. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28331. private static _TmpMorphInfluencers;
  28332. /**
  28333. * Prepares the list of attributes required for morph targets according to the effect defines.
  28334. * @param attribs The current list of supported attribs
  28335. * @param mesh The mesh to prepare the morph targets attributes for
  28336. * @param influencers The number of influencers
  28337. */
  28338. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28339. /**
  28340. * Prepares the list of attributes required for morph targets according to the effect defines.
  28341. * @param attribs The current list of supported attribs
  28342. * @param mesh The mesh to prepare the morph targets attributes for
  28343. * @param defines The current Defines of the effect
  28344. */
  28345. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28346. /**
  28347. * Prepares the list of attributes required for bones according to the effect defines.
  28348. * @param attribs The current list of supported attribs
  28349. * @param mesh The mesh to prepare the bones attributes for
  28350. * @param defines The current Defines of the effect
  28351. * @param fallbacks The current efffect fallback strategy
  28352. */
  28353. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28354. /**
  28355. * Check and prepare the list of attributes required for instances according to the effect defines.
  28356. * @param attribs The current list of supported attribs
  28357. * @param defines The current MaterialDefines of the effect
  28358. */
  28359. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28360. /**
  28361. * Add the list of attributes required for instances to the attribs array.
  28362. * @param attribs The current list of supported attribs
  28363. */
  28364. static PushAttributesForInstances(attribs: string[]): void;
  28365. /**
  28366. * Binds the light information to the effect.
  28367. * @param light The light containing the generator
  28368. * @param effect The effect we are binding the data to
  28369. * @param lightIndex The light index in the effect used to render
  28370. */
  28371. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28372. /**
  28373. * Binds the lights information from the scene to the effect for the given mesh.
  28374. * @param light Light to bind
  28375. * @param lightIndex Light index
  28376. * @param scene The scene where the light belongs to
  28377. * @param effect The effect we are binding the data to
  28378. * @param useSpecular Defines if specular is supported
  28379. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28380. */
  28381. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28382. /**
  28383. * Binds the lights information from the scene to the effect for the given mesh.
  28384. * @param scene The scene the lights belongs to
  28385. * @param mesh The mesh we are binding the information to render
  28386. * @param effect The effect we are binding the data to
  28387. * @param defines The generated defines for the effect
  28388. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28389. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28390. */
  28391. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28392. private static _tempFogColor;
  28393. /**
  28394. * Binds the fog information from the scene to the effect for the given mesh.
  28395. * @param scene The scene the lights belongs to
  28396. * @param mesh The mesh we are binding the information to render
  28397. * @param effect The effect we are binding the data to
  28398. * @param linearSpace Defines if the fog effect is applied in linear space
  28399. */
  28400. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28401. /**
  28402. * Binds the bones information from the mesh to the effect.
  28403. * @param mesh The mesh we are binding the information to render
  28404. * @param effect The effect we are binding the data to
  28405. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28406. */
  28407. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28408. private static _CopyBonesTransformationMatrices;
  28409. /**
  28410. * Binds the morph targets information from the mesh to the effect.
  28411. * @param abstractMesh The mesh we are binding the information to render
  28412. * @param effect The effect we are binding the data to
  28413. */
  28414. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28415. /**
  28416. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28417. * @param defines The generated defines used in the effect
  28418. * @param effect The effect we are binding the data to
  28419. * @param scene The scene we are willing to render with logarithmic scale for
  28420. */
  28421. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28422. /**
  28423. * Binds the clip plane information from the scene to the effect.
  28424. * @param scene The scene the clip plane information are extracted from
  28425. * @param effect The effect we are binding the data to
  28426. */
  28427. static BindClipPlane(effect: Effect, scene: Scene): void;
  28428. }
  28429. }
  28430. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  28431. /** @hidden */
  28432. export var bayerDitherFunctions: {
  28433. name: string;
  28434. shader: string;
  28435. };
  28436. }
  28437. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  28438. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  28439. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  28440. /** @hidden */
  28441. export var shadowMapFragmentDeclaration: {
  28442. name: string;
  28443. shader: string;
  28444. };
  28445. }
  28446. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  28447. /** @hidden */
  28448. export var shadowMapFragment: {
  28449. name: string;
  28450. shader: string;
  28451. };
  28452. }
  28453. declare module "babylonjs/Shaders/shadowMap.fragment" {
  28454. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  28455. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  28456. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  28457. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  28458. /** @hidden */
  28459. export var shadowMapPixelShader: {
  28460. name: string;
  28461. shader: string;
  28462. };
  28463. }
  28464. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  28465. /** @hidden */
  28466. export var shadowMapVertexDeclaration: {
  28467. name: string;
  28468. shader: string;
  28469. };
  28470. }
  28471. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  28472. /** @hidden */
  28473. export var shadowMapVertexNormalBias: {
  28474. name: string;
  28475. shader: string;
  28476. };
  28477. }
  28478. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  28479. /** @hidden */
  28480. export var shadowMapVertexMetric: {
  28481. name: string;
  28482. shader: string;
  28483. };
  28484. }
  28485. declare module "babylonjs/Shaders/shadowMap.vertex" {
  28486. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28487. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28488. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28489. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28490. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  28491. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  28492. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  28493. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28494. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28495. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28496. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  28497. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  28498. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  28499. /** @hidden */
  28500. export var shadowMapVertexShader: {
  28501. name: string;
  28502. shader: string;
  28503. };
  28504. }
  28505. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  28506. /** @hidden */
  28507. export var depthBoxBlurPixelShader: {
  28508. name: string;
  28509. shader: string;
  28510. };
  28511. }
  28512. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  28513. /** @hidden */
  28514. export var shadowMapFragmentSoftTransparentShadow: {
  28515. name: string;
  28516. shader: string;
  28517. };
  28518. }
  28519. declare module "babylonjs/Meshes/instancedMesh" {
  28520. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28521. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  28522. import { Camera } from "babylonjs/Cameras/camera";
  28523. import { Node } from "babylonjs/node";
  28524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28525. import { Mesh } from "babylonjs/Meshes/mesh";
  28526. import { Material } from "babylonjs/Materials/material";
  28527. import { Skeleton } from "babylonjs/Bones/skeleton";
  28528. import { Light } from "babylonjs/Lights/light";
  28529. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28530. /**
  28531. * Creates an instance based on a source mesh.
  28532. */
  28533. export class InstancedMesh extends AbstractMesh {
  28534. private _sourceMesh;
  28535. private _currentLOD;
  28536. /** @hidden */
  28537. _indexInSourceMeshInstanceArray: number;
  28538. constructor(name: string, source: Mesh);
  28539. /**
  28540. * Returns the string "InstancedMesh".
  28541. */
  28542. getClassName(): string;
  28543. /** Gets the list of lights affecting that mesh */
  28544. get lightSources(): Light[];
  28545. _resyncLightSources(): void;
  28546. _resyncLightSource(light: Light): void;
  28547. _removeLightSource(light: Light, dispose: boolean): void;
  28548. /**
  28549. * If the source mesh receives shadows
  28550. */
  28551. get receiveShadows(): boolean;
  28552. /**
  28553. * The material of the source mesh
  28554. */
  28555. get material(): Nullable<Material>;
  28556. /**
  28557. * Visibility of the source mesh
  28558. */
  28559. get visibility(): number;
  28560. /**
  28561. * Skeleton of the source mesh
  28562. */
  28563. get skeleton(): Nullable<Skeleton>;
  28564. /**
  28565. * Rendering ground id of the source mesh
  28566. */
  28567. get renderingGroupId(): number;
  28568. set renderingGroupId(value: number);
  28569. /**
  28570. * Returns the total number of vertices (integer).
  28571. */
  28572. getTotalVertices(): number;
  28573. /**
  28574. * Returns a positive integer : the total number of indices in this mesh geometry.
  28575. * @returns the numner of indices or zero if the mesh has no geometry.
  28576. */
  28577. getTotalIndices(): number;
  28578. /**
  28579. * The source mesh of the instance
  28580. */
  28581. get sourceMesh(): Mesh;
  28582. /**
  28583. * Creates a new InstancedMesh object from the mesh model.
  28584. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28585. * @param name defines the name of the new instance
  28586. * @returns a new InstancedMesh
  28587. */
  28588. createInstance(name: string): InstancedMesh;
  28589. /**
  28590. * Is this node ready to be used/rendered
  28591. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28592. * @return {boolean} is it ready
  28593. */
  28594. isReady(completeCheck?: boolean): boolean;
  28595. /**
  28596. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28597. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  28598. * @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.
  28599. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  28600. */
  28601. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28602. /**
  28603. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28604. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28605. * The `data` are either a numeric array either a Float32Array.
  28606. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  28607. * 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).
  28608. * Note that a new underlying VertexBuffer object is created each call.
  28609. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28610. *
  28611. * Possible `kind` values :
  28612. * - VertexBuffer.PositionKind
  28613. * - VertexBuffer.UVKind
  28614. * - VertexBuffer.UV2Kind
  28615. * - VertexBuffer.UV3Kind
  28616. * - VertexBuffer.UV4Kind
  28617. * - VertexBuffer.UV5Kind
  28618. * - VertexBuffer.UV6Kind
  28619. * - VertexBuffer.ColorKind
  28620. * - VertexBuffer.MatricesIndicesKind
  28621. * - VertexBuffer.MatricesIndicesExtraKind
  28622. * - VertexBuffer.MatricesWeightsKind
  28623. * - VertexBuffer.MatricesWeightsExtraKind
  28624. *
  28625. * Returns the Mesh.
  28626. */
  28627. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28628. /**
  28629. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28630. * If the mesh has no geometry, it is simply returned as it is.
  28631. * The `data` are either a numeric array either a Float32Array.
  28632. * No new underlying VertexBuffer object is created.
  28633. * 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.
  28634. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28635. *
  28636. * Possible `kind` values :
  28637. * - VertexBuffer.PositionKind
  28638. * - VertexBuffer.UVKind
  28639. * - VertexBuffer.UV2Kind
  28640. * - VertexBuffer.UV3Kind
  28641. * - VertexBuffer.UV4Kind
  28642. * - VertexBuffer.UV5Kind
  28643. * - VertexBuffer.UV6Kind
  28644. * - VertexBuffer.ColorKind
  28645. * - VertexBuffer.MatricesIndicesKind
  28646. * - VertexBuffer.MatricesIndicesExtraKind
  28647. * - VertexBuffer.MatricesWeightsKind
  28648. * - VertexBuffer.MatricesWeightsExtraKind
  28649. *
  28650. * Returns the Mesh.
  28651. */
  28652. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28653. /**
  28654. * Sets the mesh indices.
  28655. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28656. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28657. * This method creates a new index buffer each call.
  28658. * Returns the Mesh.
  28659. */
  28660. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28661. /**
  28662. * Boolean : True if the mesh owns the requested kind of data.
  28663. */
  28664. isVerticesDataPresent(kind: string): boolean;
  28665. /**
  28666. * Returns an array of indices (IndicesArray).
  28667. */
  28668. getIndices(): Nullable<IndicesArray>;
  28669. get _positions(): Nullable<Vector3[]>;
  28670. /**
  28671. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28672. * This means the mesh underlying bounding box and sphere are recomputed.
  28673. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28674. * @returns the current mesh
  28675. */
  28676. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28677. /** @hidden */
  28678. _preActivate(): InstancedMesh;
  28679. /** @hidden */
  28680. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28681. /** @hidden */
  28682. _postActivate(): void;
  28683. getWorldMatrix(): Matrix;
  28684. get isAnInstance(): boolean;
  28685. /**
  28686. * Returns the current associated LOD AbstractMesh.
  28687. */
  28688. getLOD(camera: Camera): AbstractMesh;
  28689. /** @hidden */
  28690. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28691. /** @hidden */
  28692. _syncSubMeshes(): InstancedMesh;
  28693. /** @hidden */
  28694. _generatePointsArray(): boolean;
  28695. /** @hidden */
  28696. _updateBoundingInfo(): AbstractMesh;
  28697. /**
  28698. * Creates a new InstancedMesh from the current mesh.
  28699. * - name (string) : the cloned mesh name
  28700. * - newParent (optional Node) : the optional Node to parent the clone to.
  28701. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28702. *
  28703. * Returns the clone.
  28704. */
  28705. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28706. /**
  28707. * Disposes the InstancedMesh.
  28708. * Returns nothing.
  28709. */
  28710. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28711. }
  28712. module "babylonjs/Meshes/mesh" {
  28713. interface Mesh {
  28714. /**
  28715. * Register a custom buffer that will be instanced
  28716. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28717. * @param kind defines the buffer kind
  28718. * @param stride defines the stride in floats
  28719. */
  28720. registerInstancedBuffer(kind: string, stride: number): void;
  28721. /**
  28722. * true to use the edge renderer for all instances of this mesh
  28723. */
  28724. edgesShareWithInstances: boolean;
  28725. /** @hidden */
  28726. _userInstancedBuffersStorage: {
  28727. data: {
  28728. [key: string]: Float32Array;
  28729. };
  28730. sizes: {
  28731. [key: string]: number;
  28732. };
  28733. vertexBuffers: {
  28734. [key: string]: Nullable<VertexBuffer>;
  28735. };
  28736. strides: {
  28737. [key: string]: number;
  28738. };
  28739. };
  28740. }
  28741. }
  28742. module "babylonjs/Meshes/abstractMesh" {
  28743. interface AbstractMesh {
  28744. /**
  28745. * Object used to store instanced buffers defined by user
  28746. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28747. */
  28748. instancedBuffers: {
  28749. [key: string]: any;
  28750. };
  28751. }
  28752. }
  28753. }
  28754. declare module "babylonjs/Materials/shaderMaterial" {
  28755. import { Nullable } from "babylonjs/types";
  28756. import { Scene } from "babylonjs/scene";
  28757. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28759. import { Mesh } from "babylonjs/Meshes/mesh";
  28760. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28761. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28762. import { Effect } from "babylonjs/Materials/effect";
  28763. import { Material } from "babylonjs/Materials/material";
  28764. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28765. /**
  28766. * Defines the options associated with the creation of a shader material.
  28767. */
  28768. export interface IShaderMaterialOptions {
  28769. /**
  28770. * Does the material work in alpha blend mode
  28771. */
  28772. needAlphaBlending: boolean;
  28773. /**
  28774. * Does the material work in alpha test mode
  28775. */
  28776. needAlphaTesting: boolean;
  28777. /**
  28778. * The list of attribute names used in the shader
  28779. */
  28780. attributes: string[];
  28781. /**
  28782. * The list of unifrom names used in the shader
  28783. */
  28784. uniforms: string[];
  28785. /**
  28786. * The list of UBO names used in the shader
  28787. */
  28788. uniformBuffers: string[];
  28789. /**
  28790. * The list of sampler names used in the shader
  28791. */
  28792. samplers: string[];
  28793. /**
  28794. * The list of defines used in the shader
  28795. */
  28796. defines: string[];
  28797. }
  28798. /**
  28799. * 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.
  28800. *
  28801. * This returned material effects how the mesh will look based on the code in the shaders.
  28802. *
  28803. * @see https://doc.babylonjs.com/how_to/shader_material
  28804. */
  28805. export class ShaderMaterial extends Material {
  28806. private _shaderPath;
  28807. private _options;
  28808. private _textures;
  28809. private _textureArrays;
  28810. private _floats;
  28811. private _ints;
  28812. private _floatsArrays;
  28813. private _colors3;
  28814. private _colors3Arrays;
  28815. private _colors4;
  28816. private _colors4Arrays;
  28817. private _vectors2;
  28818. private _vectors3;
  28819. private _vectors4;
  28820. private _matrices;
  28821. private _matrixArrays;
  28822. private _matrices3x3;
  28823. private _matrices2x2;
  28824. private _vectors2Arrays;
  28825. private _vectors3Arrays;
  28826. private _vectors4Arrays;
  28827. private _cachedWorldViewMatrix;
  28828. private _cachedWorldViewProjectionMatrix;
  28829. private _renderId;
  28830. private _multiview;
  28831. private _cachedDefines;
  28832. /** Define the Url to load snippets */
  28833. static SnippetUrl: string;
  28834. /** Snippet ID if the material was created from the snippet server */
  28835. snippetId: string;
  28836. /**
  28837. * Instantiate a new shader material.
  28838. * 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.
  28839. * This returned material effects how the mesh will look based on the code in the shaders.
  28840. * @see https://doc.babylonjs.com/how_to/shader_material
  28841. * @param name Define the name of the material in the scene
  28842. * @param scene Define the scene the material belongs to
  28843. * @param shaderPath Defines the route to the shader code in one of three ways:
  28844. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28845. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28846. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28847. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28848. * @param options Define the options used to create the shader
  28849. */
  28850. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28851. /**
  28852. * Gets the shader path used to define the shader code
  28853. * It can be modified to trigger a new compilation
  28854. */
  28855. get shaderPath(): any;
  28856. /**
  28857. * Sets the shader path used to define the shader code
  28858. * It can be modified to trigger a new compilation
  28859. */
  28860. set shaderPath(shaderPath: any);
  28861. /**
  28862. * Gets the options used to compile the shader.
  28863. * They can be modified to trigger a new compilation
  28864. */
  28865. get options(): IShaderMaterialOptions;
  28866. /**
  28867. * Gets the current class name of the material e.g. "ShaderMaterial"
  28868. * Mainly use in serialization.
  28869. * @returns the class name
  28870. */
  28871. getClassName(): string;
  28872. /**
  28873. * Specifies if the material will require alpha blending
  28874. * @returns a boolean specifying if alpha blending is needed
  28875. */
  28876. needAlphaBlending(): boolean;
  28877. /**
  28878. * Specifies if this material should be rendered in alpha test mode
  28879. * @returns a boolean specifying if an alpha test is needed.
  28880. */
  28881. needAlphaTesting(): boolean;
  28882. private _checkUniform;
  28883. /**
  28884. * Set a texture in the shader.
  28885. * @param name Define the name of the uniform samplers as defined in the shader
  28886. * @param texture Define the texture to bind to this sampler
  28887. * @return the material itself allowing "fluent" like uniform updates
  28888. */
  28889. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28890. /**
  28891. * Set a texture array in the shader.
  28892. * @param name Define the name of the uniform sampler array as defined in the shader
  28893. * @param textures Define the list of textures to bind to this sampler
  28894. * @return the material itself allowing "fluent" like uniform updates
  28895. */
  28896. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28897. /**
  28898. * Set a float in the shader.
  28899. * @param name Define the name of the uniform as defined in the shader
  28900. * @param value Define the value to give to the uniform
  28901. * @return the material itself allowing "fluent" like uniform updates
  28902. */
  28903. setFloat(name: string, value: number): ShaderMaterial;
  28904. /**
  28905. * Set a int in the shader.
  28906. * @param name Define the name of the uniform as defined in the shader
  28907. * @param value Define the value to give to the uniform
  28908. * @return the material itself allowing "fluent" like uniform updates
  28909. */
  28910. setInt(name: string, value: number): ShaderMaterial;
  28911. /**
  28912. * Set an array of floats in the shader.
  28913. * @param name Define the name of the uniform as defined in the shader
  28914. * @param value Define the value to give to the uniform
  28915. * @return the material itself allowing "fluent" like uniform updates
  28916. */
  28917. setFloats(name: string, value: number[]): ShaderMaterial;
  28918. /**
  28919. * Set a vec3 in the shader from a Color3.
  28920. * @param name Define the name of the uniform as defined in the shader
  28921. * @param value Define the value to give to the uniform
  28922. * @return the material itself allowing "fluent" like uniform updates
  28923. */
  28924. setColor3(name: string, value: Color3): ShaderMaterial;
  28925. /**
  28926. * Set a vec3 array in the shader from a Color3 array.
  28927. * @param name Define the name of the uniform as defined in the shader
  28928. * @param value Define the value to give to the uniform
  28929. * @return the material itself allowing "fluent" like uniform updates
  28930. */
  28931. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28932. /**
  28933. * Set a vec4 in the shader from a Color4.
  28934. * @param name Define the name of the uniform as defined in the shader
  28935. * @param value Define the value to give to the uniform
  28936. * @return the material itself allowing "fluent" like uniform updates
  28937. */
  28938. setColor4(name: string, value: Color4): ShaderMaterial;
  28939. /**
  28940. * Set a vec4 array in the shader from a Color4 array.
  28941. * @param name Define the name of the uniform as defined in the shader
  28942. * @param value Define the value to give to the uniform
  28943. * @return the material itself allowing "fluent" like uniform updates
  28944. */
  28945. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28946. /**
  28947. * Set a vec2 in the shader from a Vector2.
  28948. * @param name Define the name of the uniform as defined in the shader
  28949. * @param value Define the value to give to the uniform
  28950. * @return the material itself allowing "fluent" like uniform updates
  28951. */
  28952. setVector2(name: string, value: Vector2): ShaderMaterial;
  28953. /**
  28954. * Set a vec3 in the shader from a Vector3.
  28955. * @param name Define the name of the uniform as defined in the shader
  28956. * @param value Define the value to give to the uniform
  28957. * @return the material itself allowing "fluent" like uniform updates
  28958. */
  28959. setVector3(name: string, value: Vector3): ShaderMaterial;
  28960. /**
  28961. * Set a vec4 in the shader from a Vector4.
  28962. * @param name Define the name of the uniform as defined in the shader
  28963. * @param value Define the value to give to the uniform
  28964. * @return the material itself allowing "fluent" like uniform updates
  28965. */
  28966. setVector4(name: string, value: Vector4): ShaderMaterial;
  28967. /**
  28968. * Set a mat4 in the shader from a Matrix.
  28969. * @param name Define the name of the uniform as defined in the shader
  28970. * @param value Define the value to give to the uniform
  28971. * @return the material itself allowing "fluent" like uniform updates
  28972. */
  28973. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28974. /**
  28975. * Set a float32Array in the shader from a matrix array.
  28976. * @param name Define the name of the uniform as defined in the shader
  28977. * @param value Define the value to give to the uniform
  28978. * @return the material itself allowing "fluent" like uniform updates
  28979. */
  28980. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28981. /**
  28982. * Set a mat3 in the shader from a Float32Array.
  28983. * @param name Define the name of the uniform as defined in the shader
  28984. * @param value Define the value to give to the uniform
  28985. * @return the material itself allowing "fluent" like uniform updates
  28986. */
  28987. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28988. /**
  28989. * Set a mat2 in the shader from a Float32Array.
  28990. * @param name Define the name of the uniform as defined in the shader
  28991. * @param value Define the value to give to the uniform
  28992. * @return the material itself allowing "fluent" like uniform updates
  28993. */
  28994. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28995. /**
  28996. * Set a vec2 array in the shader from a number array.
  28997. * @param name Define the name of the uniform as defined in the shader
  28998. * @param value Define the value to give to the uniform
  28999. * @return the material itself allowing "fluent" like uniform updates
  29000. */
  29001. setArray2(name: string, value: number[]): ShaderMaterial;
  29002. /**
  29003. * Set a vec3 array in the shader from a number array.
  29004. * @param name Define the name of the uniform as defined in the shader
  29005. * @param value Define the value to give to the uniform
  29006. * @return the material itself allowing "fluent" like uniform updates
  29007. */
  29008. setArray3(name: string, value: number[]): ShaderMaterial;
  29009. /**
  29010. * Set a vec4 array in the shader from a number array.
  29011. * @param name Define the name of the uniform as defined in the shader
  29012. * @param value Define the value to give to the uniform
  29013. * @return the material itself allowing "fluent" like uniform updates
  29014. */
  29015. setArray4(name: string, value: number[]): ShaderMaterial;
  29016. private _checkCache;
  29017. /**
  29018. * Specifies that the submesh is ready to be used
  29019. * @param mesh defines the mesh to check
  29020. * @param subMesh defines which submesh to check
  29021. * @param useInstances specifies that instances should be used
  29022. * @returns a boolean indicating that the submesh is ready or not
  29023. */
  29024. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29025. /**
  29026. * Checks if the material is ready to render the requested mesh
  29027. * @param mesh Define the mesh to render
  29028. * @param useInstances Define whether or not the material is used with instances
  29029. * @returns true if ready, otherwise false
  29030. */
  29031. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29032. /**
  29033. * Binds the world matrix to the material
  29034. * @param world defines the world transformation matrix
  29035. * @param effectOverride - If provided, use this effect instead of internal effect
  29036. */
  29037. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  29038. /**
  29039. * Binds the submesh to this material by preparing the effect and shader to draw
  29040. * @param world defines the world transformation matrix
  29041. * @param mesh defines the mesh containing the submesh
  29042. * @param subMesh defines the submesh to bind the material to
  29043. */
  29044. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29045. /**
  29046. * Binds the material to the mesh
  29047. * @param world defines the world transformation matrix
  29048. * @param mesh defines the mesh to bind the material to
  29049. * @param effectOverride - If provided, use this effect instead of internal effect
  29050. */
  29051. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29052. protected _afterBind(mesh?: Mesh): void;
  29053. /**
  29054. * Gets the active textures from the material
  29055. * @returns an array of textures
  29056. */
  29057. getActiveTextures(): BaseTexture[];
  29058. /**
  29059. * Specifies if the material uses a texture
  29060. * @param texture defines the texture to check against the material
  29061. * @returns a boolean specifying if the material uses the texture
  29062. */
  29063. hasTexture(texture: BaseTexture): boolean;
  29064. /**
  29065. * Makes a duplicate of the material, and gives it a new name
  29066. * @param name defines the new name for the duplicated material
  29067. * @returns the cloned material
  29068. */
  29069. clone(name: string): ShaderMaterial;
  29070. /**
  29071. * Disposes the material
  29072. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29073. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29074. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29075. */
  29076. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29077. /**
  29078. * Serializes this material in a JSON representation
  29079. * @returns the serialized material object
  29080. */
  29081. serialize(): any;
  29082. /**
  29083. * Creates a shader material from parsed shader material data
  29084. * @param source defines the JSON represnetation of the material
  29085. * @param scene defines the hosting scene
  29086. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29087. * @returns a new material
  29088. */
  29089. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29090. /**
  29091. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29092. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29093. * @param url defines the url to load from
  29094. * @param scene defines the hosting scene
  29095. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29096. * @returns a promise that will resolve to the new ShaderMaterial
  29097. */
  29098. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29099. /**
  29100. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29101. * @param snippetId defines the snippet to load
  29102. * @param scene defines the hosting scene
  29103. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29104. * @returns a promise that will resolve to the new ShaderMaterial
  29105. */
  29106. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29107. }
  29108. }
  29109. declare module "babylonjs/Shaders/color.fragment" {
  29110. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  29111. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  29112. /** @hidden */
  29113. export var colorPixelShader: {
  29114. name: string;
  29115. shader: string;
  29116. };
  29117. }
  29118. declare module "babylonjs/Shaders/color.vertex" {
  29119. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  29120. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  29121. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29122. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29123. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  29124. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  29125. /** @hidden */
  29126. export var colorVertexShader: {
  29127. name: string;
  29128. shader: string;
  29129. };
  29130. }
  29131. declare module "babylonjs/Meshes/linesMesh" {
  29132. import { Nullable } from "babylonjs/types";
  29133. import { Scene } from "babylonjs/scene";
  29134. import { Color3 } from "babylonjs/Maths/math.color";
  29135. import { Node } from "babylonjs/node";
  29136. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29137. import { Mesh } from "babylonjs/Meshes/mesh";
  29138. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29139. import { Effect } from "babylonjs/Materials/effect";
  29140. import { Material } from "babylonjs/Materials/material";
  29141. import "babylonjs/Shaders/color.fragment";
  29142. import "babylonjs/Shaders/color.vertex";
  29143. /**
  29144. * Line mesh
  29145. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29146. */
  29147. export class LinesMesh extends Mesh {
  29148. /**
  29149. * If vertex color should be applied to the mesh
  29150. */
  29151. readonly useVertexColor?: boolean | undefined;
  29152. /**
  29153. * If vertex alpha should be applied to the mesh
  29154. */
  29155. readonly useVertexAlpha?: boolean | undefined;
  29156. /**
  29157. * Color of the line (Default: White)
  29158. */
  29159. color: Color3;
  29160. /**
  29161. * Alpha of the line (Default: 1)
  29162. */
  29163. alpha: number;
  29164. /**
  29165. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29166. * This margin is expressed in world space coordinates, so its value may vary.
  29167. * Default value is 0.1
  29168. */
  29169. intersectionThreshold: number;
  29170. private _colorShader;
  29171. private color4;
  29172. /**
  29173. * Creates a new LinesMesh
  29174. * @param name defines the name
  29175. * @param scene defines the hosting scene
  29176. * @param parent defines the parent mesh if any
  29177. * @param source defines the optional source LinesMesh used to clone data from
  29178. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29179. * When false, achieved by calling a clone(), also passing False.
  29180. * This will make creation of children, recursive.
  29181. * @param useVertexColor defines if this LinesMesh supports vertex color
  29182. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29183. */
  29184. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29185. /**
  29186. * If vertex color should be applied to the mesh
  29187. */
  29188. useVertexColor?: boolean | undefined,
  29189. /**
  29190. * If vertex alpha should be applied to the mesh
  29191. */
  29192. useVertexAlpha?: boolean | undefined);
  29193. private _addClipPlaneDefine;
  29194. private _removeClipPlaneDefine;
  29195. isReady(): boolean;
  29196. /**
  29197. * Returns the string "LineMesh"
  29198. */
  29199. getClassName(): string;
  29200. /**
  29201. * @hidden
  29202. */
  29203. get material(): Material;
  29204. /**
  29205. * @hidden
  29206. */
  29207. set material(value: Material);
  29208. /**
  29209. * @hidden
  29210. */
  29211. get checkCollisions(): boolean;
  29212. /** @hidden */
  29213. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29214. /** @hidden */
  29215. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29216. /**
  29217. * Disposes of the line mesh
  29218. * @param doNotRecurse If children should be disposed
  29219. */
  29220. dispose(doNotRecurse?: boolean): void;
  29221. /**
  29222. * Returns a new LineMesh object cloned from the current one.
  29223. */
  29224. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29225. /**
  29226. * Creates a new InstancedLinesMesh object from the mesh model.
  29227. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29228. * @param name defines the name of the new instance
  29229. * @returns a new InstancedLinesMesh
  29230. */
  29231. createInstance(name: string): InstancedLinesMesh;
  29232. }
  29233. /**
  29234. * Creates an instance based on a source LinesMesh
  29235. */
  29236. export class InstancedLinesMesh extends InstancedMesh {
  29237. /**
  29238. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29239. * This margin is expressed in world space coordinates, so its value may vary.
  29240. * Initilized with the intersectionThreshold value of the source LinesMesh
  29241. */
  29242. intersectionThreshold: number;
  29243. constructor(name: string, source: LinesMesh);
  29244. /**
  29245. * Returns the string "InstancedLinesMesh".
  29246. */
  29247. getClassName(): string;
  29248. }
  29249. }
  29250. declare module "babylonjs/Shaders/line.fragment" {
  29251. /** @hidden */
  29252. export var linePixelShader: {
  29253. name: string;
  29254. shader: string;
  29255. };
  29256. }
  29257. declare module "babylonjs/Shaders/line.vertex" {
  29258. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29259. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29260. /** @hidden */
  29261. export var lineVertexShader: {
  29262. name: string;
  29263. shader: string;
  29264. };
  29265. }
  29266. declare module "babylonjs/Rendering/edgesRenderer" {
  29267. import { Immutable, Nullable } from "babylonjs/types";
  29268. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29270. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  29271. import { IDisposable } from "babylonjs/scene";
  29272. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  29273. import "babylonjs/Shaders/line.fragment";
  29274. import "babylonjs/Shaders/line.vertex";
  29275. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29276. import { SmartArray } from "babylonjs/Misc/smartArray";
  29277. module "babylonjs/scene" {
  29278. interface Scene {
  29279. /** @hidden */
  29280. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  29281. }
  29282. }
  29283. module "babylonjs/Meshes/abstractMesh" {
  29284. interface AbstractMesh {
  29285. /**
  29286. * Gets the edgesRenderer associated with the mesh
  29287. */
  29288. edgesRenderer: Nullable<EdgesRenderer>;
  29289. }
  29290. }
  29291. module "babylonjs/Meshes/linesMesh" {
  29292. interface LinesMesh {
  29293. /**
  29294. * Enables the edge rendering mode on the mesh.
  29295. * This mode makes the mesh edges visible
  29296. * @param epsilon defines the maximal distance between two angles to detect a face
  29297. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29298. * @returns the currentAbstractMesh
  29299. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29300. */
  29301. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29302. }
  29303. }
  29304. module "babylonjs/Meshes/linesMesh" {
  29305. interface InstancedLinesMesh {
  29306. /**
  29307. * Enables the edge rendering mode on the mesh.
  29308. * This mode makes the mesh edges visible
  29309. * @param epsilon defines the maximal distance between two angles to detect a face
  29310. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29311. * @returns the current InstancedLinesMesh
  29312. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29313. */
  29314. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  29315. }
  29316. }
  29317. /**
  29318. * Defines the minimum contract an Edges renderer should follow.
  29319. */
  29320. export interface IEdgesRenderer extends IDisposable {
  29321. /**
  29322. * Gets or sets a boolean indicating if the edgesRenderer is active
  29323. */
  29324. isEnabled: boolean;
  29325. /**
  29326. * Renders the edges of the attached mesh,
  29327. */
  29328. render(): void;
  29329. /**
  29330. * Checks wether or not the edges renderer is ready to render.
  29331. * @return true if ready, otherwise false.
  29332. */
  29333. isReady(): boolean;
  29334. /**
  29335. * List of instances to render in case the source mesh has instances
  29336. */
  29337. customInstances: SmartArray<Matrix>;
  29338. }
  29339. /**
  29340. * Defines the additional options of the edges renderer
  29341. */
  29342. export interface IEdgesRendererOptions {
  29343. /**
  29344. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29345. * If not defined, the default value is true
  29346. */
  29347. useAlternateEdgeFinder?: boolean;
  29348. /**
  29349. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29350. * If not defined, the default value is true.
  29351. * 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)
  29352. * This option is used only if useAlternateEdgeFinder = true
  29353. */
  29354. useFastVertexMerger?: boolean;
  29355. /**
  29356. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  29357. * The default value is 1e-6
  29358. * This option is used only if useAlternateEdgeFinder = true
  29359. */
  29360. epsilonVertexMerge?: number;
  29361. /**
  29362. * 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
  29363. * 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.
  29364. * This option is used only if useAlternateEdgeFinder = true
  29365. */
  29366. applyTessellation?: boolean;
  29367. /**
  29368. * 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
  29369. * The default value is 1e-6
  29370. * This option is used only if useAlternateEdgeFinder = true
  29371. */
  29372. epsilonVertexAligned?: number;
  29373. }
  29374. /**
  29375. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29376. */
  29377. export class EdgesRenderer implements IEdgesRenderer {
  29378. /**
  29379. * Define the size of the edges with an orthographic camera
  29380. */
  29381. edgesWidthScalerForOrthographic: number;
  29382. /**
  29383. * Define the size of the edges with a perspective camera
  29384. */
  29385. edgesWidthScalerForPerspective: number;
  29386. protected _source: AbstractMesh;
  29387. protected _linesPositions: number[];
  29388. protected _linesNormals: number[];
  29389. protected _linesIndices: number[];
  29390. protected _epsilon: number;
  29391. protected _indicesCount: number;
  29392. protected _lineShader: ShaderMaterial;
  29393. protected _ib: DataBuffer;
  29394. protected _buffers: {
  29395. [key: string]: Nullable<VertexBuffer>;
  29396. };
  29397. protected _buffersForInstances: {
  29398. [key: string]: Nullable<VertexBuffer>;
  29399. };
  29400. protected _checkVerticesInsteadOfIndices: boolean;
  29401. protected _options: Nullable<IEdgesRendererOptions>;
  29402. private _meshRebuildObserver;
  29403. private _meshDisposeObserver;
  29404. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29405. isEnabled: boolean;
  29406. /** Gets the vertices generated by the edge renderer */
  29407. get linesPositions(): Immutable<Array<number>>;
  29408. /** Gets the normals generated by the edge renderer */
  29409. get linesNormals(): Immutable<Array<number>>;
  29410. /** Gets the indices generated by the edge renderer */
  29411. get linesIndices(): Immutable<Array<number>>;
  29412. /**
  29413. * List of instances to render in case the source mesh has instances
  29414. */
  29415. customInstances: SmartArray<Matrix>;
  29416. private static GetShader;
  29417. /**
  29418. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29419. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29420. * @param source Mesh used to create edges
  29421. * @param epsilon sum of angles in adjacency to check for edge
  29422. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29423. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29424. * @param options The options to apply when generating the edges
  29425. */
  29426. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29427. protected _prepareRessources(): void;
  29428. /** @hidden */
  29429. _rebuild(): void;
  29430. /**
  29431. * Releases the required resources for the edges renderer
  29432. */
  29433. dispose(): void;
  29434. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29435. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29436. /**
  29437. * Checks if the pair of p0 and p1 is en edge
  29438. * @param faceIndex
  29439. * @param edge
  29440. * @param faceNormals
  29441. * @param p0
  29442. * @param p1
  29443. * @private
  29444. */
  29445. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29446. /**
  29447. * push line into the position, normal and index buffer
  29448. * @protected
  29449. */
  29450. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29451. /**
  29452. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29453. */
  29454. private _tessellateTriangle;
  29455. private _generateEdgesLinesAlternate;
  29456. /**
  29457. * Generates lines edges from adjacencjes
  29458. * @private
  29459. */
  29460. _generateEdgesLines(): void;
  29461. /**
  29462. * Checks wether or not the edges renderer is ready to render.
  29463. * @return true if ready, otherwise false.
  29464. */
  29465. isReady(): boolean;
  29466. /**
  29467. * Renders the edges of the attached mesh,
  29468. */
  29469. render(): void;
  29470. }
  29471. /**
  29472. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29473. */
  29474. export class LineEdgesRenderer extends EdgesRenderer {
  29475. /**
  29476. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29477. * @param source LineMesh used to generate edges
  29478. * @param epsilon not important (specified angle for edge detection)
  29479. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29480. */
  29481. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29482. /**
  29483. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29484. */
  29485. _generateEdgesLines(): void;
  29486. }
  29487. }
  29488. declare module "babylonjs/Rendering/renderingGroup" {
  29489. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  29490. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29492. import { Nullable } from "babylonjs/types";
  29493. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  29494. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  29495. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  29496. import { Material } from "babylonjs/Materials/material";
  29497. import { Scene } from "babylonjs/scene";
  29498. /**
  29499. * This represents the object necessary to create a rendering group.
  29500. * This is exclusively used and created by the rendering manager.
  29501. * To modify the behavior, you use the available helpers in your scene or meshes.
  29502. * @hidden
  29503. */
  29504. export class RenderingGroup {
  29505. index: number;
  29506. private static _zeroVector;
  29507. private _scene;
  29508. private _opaqueSubMeshes;
  29509. private _transparentSubMeshes;
  29510. private _alphaTestSubMeshes;
  29511. private _depthOnlySubMeshes;
  29512. private _particleSystems;
  29513. private _spriteManagers;
  29514. private _opaqueSortCompareFn;
  29515. private _alphaTestSortCompareFn;
  29516. private _transparentSortCompareFn;
  29517. private _renderOpaque;
  29518. private _renderAlphaTest;
  29519. private _renderTransparent;
  29520. /** @hidden */
  29521. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29522. onBeforeTransparentRendering: () => void;
  29523. /**
  29524. * Set the opaque sort comparison function.
  29525. * If null the sub meshes will be render in the order they were created
  29526. */
  29527. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29528. /**
  29529. * Set the alpha test sort comparison function.
  29530. * If null the sub meshes will be render in the order they were created
  29531. */
  29532. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29533. /**
  29534. * Set the transparent sort comparison function.
  29535. * If null the sub meshes will be render in the order they were created
  29536. */
  29537. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29538. /**
  29539. * Creates a new rendering group.
  29540. * @param index The rendering group index
  29541. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29542. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29543. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29544. */
  29545. 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>);
  29546. /**
  29547. * Render all the sub meshes contained in the group.
  29548. * @param customRenderFunction Used to override the default render behaviour of the group.
  29549. * @returns true if rendered some submeshes.
  29550. */
  29551. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29552. /**
  29553. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29554. * @param subMeshes The submeshes to render
  29555. */
  29556. private renderOpaqueSorted;
  29557. /**
  29558. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29559. * @param subMeshes The submeshes to render
  29560. */
  29561. private renderAlphaTestSorted;
  29562. /**
  29563. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29564. * @param subMeshes The submeshes to render
  29565. */
  29566. private renderTransparentSorted;
  29567. /**
  29568. * Renders the submeshes in a specified order.
  29569. * @param subMeshes The submeshes to sort before render
  29570. * @param sortCompareFn The comparison function use to sort
  29571. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29572. * @param transparent Specifies to activate blending if true
  29573. */
  29574. private static renderSorted;
  29575. /**
  29576. * Renders the submeshes in the order they were dispatched (no sort applied).
  29577. * @param subMeshes The submeshes to render
  29578. */
  29579. private static renderUnsorted;
  29580. /**
  29581. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29582. * are rendered back to front if in the same alpha index.
  29583. *
  29584. * @param a The first submesh
  29585. * @param b The second submesh
  29586. * @returns The result of the comparison
  29587. */
  29588. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29589. /**
  29590. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29591. * are rendered back to front.
  29592. *
  29593. * @param a The first submesh
  29594. * @param b The second submesh
  29595. * @returns The result of the comparison
  29596. */
  29597. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29598. /**
  29599. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29600. * are rendered front to back (prevent overdraw).
  29601. *
  29602. * @param a The first submesh
  29603. * @param b The second submesh
  29604. * @returns The result of the comparison
  29605. */
  29606. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29607. /**
  29608. * Resets the different lists of submeshes to prepare a new frame.
  29609. */
  29610. prepare(): void;
  29611. dispose(): void;
  29612. /**
  29613. * Inserts the submesh in its correct queue depending on its material.
  29614. * @param subMesh The submesh to dispatch
  29615. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29616. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29617. */
  29618. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29619. dispatchSprites(spriteManager: ISpriteManager): void;
  29620. dispatchParticles(particleSystem: IParticleSystem): void;
  29621. private _renderParticles;
  29622. private _renderSprites;
  29623. }
  29624. }
  29625. declare module "babylonjs/Rendering/renderingManager" {
  29626. import { Nullable } from "babylonjs/types";
  29627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29628. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29629. import { SmartArray } from "babylonjs/Misc/smartArray";
  29630. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  29631. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  29632. import { Material } from "babylonjs/Materials/material";
  29633. import { Scene } from "babylonjs/scene";
  29634. import { Camera } from "babylonjs/Cameras/camera";
  29635. /**
  29636. * Interface describing the different options available in the rendering manager
  29637. * regarding Auto Clear between groups.
  29638. */
  29639. export interface IRenderingManagerAutoClearSetup {
  29640. /**
  29641. * Defines whether or not autoclear is enable.
  29642. */
  29643. autoClear: boolean;
  29644. /**
  29645. * Defines whether or not to autoclear the depth buffer.
  29646. */
  29647. depth: boolean;
  29648. /**
  29649. * Defines whether or not to autoclear the stencil buffer.
  29650. */
  29651. stencil: boolean;
  29652. }
  29653. /**
  29654. * This class is used by the onRenderingGroupObservable
  29655. */
  29656. export class RenderingGroupInfo {
  29657. /**
  29658. * The Scene that being rendered
  29659. */
  29660. scene: Scene;
  29661. /**
  29662. * The camera currently used for the rendering pass
  29663. */
  29664. camera: Nullable<Camera>;
  29665. /**
  29666. * The ID of the renderingGroup being processed
  29667. */
  29668. renderingGroupId: number;
  29669. }
  29670. /**
  29671. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29672. * It is enable to manage the different groups as well as the different necessary sort functions.
  29673. * This should not be used directly aside of the few static configurations
  29674. */
  29675. export class RenderingManager {
  29676. /**
  29677. * The max id used for rendering groups (not included)
  29678. */
  29679. static MAX_RENDERINGGROUPS: number;
  29680. /**
  29681. * The min id used for rendering groups (included)
  29682. */
  29683. static MIN_RENDERINGGROUPS: number;
  29684. /**
  29685. * Used to globally prevent autoclearing scenes.
  29686. */
  29687. static AUTOCLEAR: boolean;
  29688. /**
  29689. * @hidden
  29690. */
  29691. _useSceneAutoClearSetup: boolean;
  29692. private _scene;
  29693. private _renderingGroups;
  29694. private _depthStencilBufferAlreadyCleaned;
  29695. private _autoClearDepthStencil;
  29696. private _customOpaqueSortCompareFn;
  29697. private _customAlphaTestSortCompareFn;
  29698. private _customTransparentSortCompareFn;
  29699. private _renderingGroupInfo;
  29700. /**
  29701. * Instantiates a new rendering group for a particular scene
  29702. * @param scene Defines the scene the groups belongs to
  29703. */
  29704. constructor(scene: Scene);
  29705. private _clearDepthStencilBuffer;
  29706. /**
  29707. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29708. * @hidden
  29709. */
  29710. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29711. /**
  29712. * Resets the different information of the group to prepare a new frame
  29713. * @hidden
  29714. */
  29715. reset(): void;
  29716. /**
  29717. * Dispose and release the group and its associated resources.
  29718. * @hidden
  29719. */
  29720. dispose(): void;
  29721. /**
  29722. * Clear the info related to rendering groups preventing retention points during dispose.
  29723. */
  29724. freeRenderingGroups(): void;
  29725. private _prepareRenderingGroup;
  29726. /**
  29727. * Add a sprite manager to the rendering manager in order to render it this frame.
  29728. * @param spriteManager Define the sprite manager to render
  29729. */
  29730. dispatchSprites(spriteManager: ISpriteManager): void;
  29731. /**
  29732. * Add a particle system to the rendering manager in order to render it this frame.
  29733. * @param particleSystem Define the particle system to render
  29734. */
  29735. dispatchParticles(particleSystem: IParticleSystem): void;
  29736. /**
  29737. * Add a submesh to the manager in order to render it this frame
  29738. * @param subMesh The submesh to dispatch
  29739. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29740. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29741. */
  29742. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29743. /**
  29744. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29745. * This allowed control for front to back rendering or reversly depending of the special needs.
  29746. *
  29747. * @param renderingGroupId The rendering group id corresponding to its index
  29748. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29749. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29750. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29751. */
  29752. 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;
  29753. /**
  29754. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29755. *
  29756. * @param renderingGroupId The rendering group id corresponding to its index
  29757. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29758. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29759. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29760. */
  29761. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29762. /**
  29763. * Gets the current auto clear configuration for one rendering group of the rendering
  29764. * manager.
  29765. * @param index the rendering group index to get the information for
  29766. * @returns The auto clear setup for the requested rendering group
  29767. */
  29768. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29769. }
  29770. }
  29771. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  29772. import { SmartArray } from "babylonjs/Misc/smartArray";
  29773. import { Nullable } from "babylonjs/types";
  29774. import { Scene } from "babylonjs/scene";
  29775. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29776. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29778. import { Mesh } from "babylonjs/Meshes/mesh";
  29779. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  29780. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29781. import { Effect } from "babylonjs/Materials/effect";
  29782. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29783. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29784. import "babylonjs/Shaders/shadowMap.fragment";
  29785. import "babylonjs/Shaders/shadowMap.vertex";
  29786. import "babylonjs/Shaders/depthBoxBlur.fragment";
  29787. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  29788. import { Observable } from "babylonjs/Misc/observable";
  29789. /**
  29790. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29791. */
  29792. export interface ICustomShaderOptions {
  29793. /**
  29794. * Gets or sets the custom shader name to use
  29795. */
  29796. shaderName: string;
  29797. /**
  29798. * The list of attribute names used in the shader
  29799. */
  29800. attributes?: string[];
  29801. /**
  29802. * The list of unifrom names used in the shader
  29803. */
  29804. uniforms?: string[];
  29805. /**
  29806. * The list of sampler names used in the shader
  29807. */
  29808. samplers?: string[];
  29809. /**
  29810. * The list of defines used in the shader
  29811. */
  29812. defines?: string[];
  29813. }
  29814. /**
  29815. * Interface to implement to create a shadow generator compatible with BJS.
  29816. */
  29817. export interface IShadowGenerator {
  29818. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29819. id: string;
  29820. /**
  29821. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29822. * @returns The render target texture if present otherwise, null
  29823. */
  29824. getShadowMap(): Nullable<RenderTargetTexture>;
  29825. /**
  29826. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29827. * @param subMesh The submesh we want to render in the shadow map
  29828. * @param useInstances Defines wether will draw in the map using instances
  29829. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29830. * @returns true if ready otherwise, false
  29831. */
  29832. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29833. /**
  29834. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29835. * @param defines Defines of the material we want to update
  29836. * @param lightIndex Index of the light in the enabled light list of the material
  29837. */
  29838. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29839. /**
  29840. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29841. * defined in the generator but impacting the effect).
  29842. * It implies the unifroms available on the materials are the standard BJS ones.
  29843. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29844. * @param effect The effect we are binfing the information for
  29845. */
  29846. bindShadowLight(lightIndex: string, effect: Effect): void;
  29847. /**
  29848. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29849. * (eq to shadow prjection matrix * light transform matrix)
  29850. * @returns The transform matrix used to create the shadow map
  29851. */
  29852. getTransformMatrix(): Matrix;
  29853. /**
  29854. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29855. * Cube and 2D textures for instance.
  29856. */
  29857. recreateShadowMap(): void;
  29858. /**
  29859. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29860. * @param onCompiled Callback triggered at the and of the effects compilation
  29861. * @param options Sets of optional options forcing the compilation with different modes
  29862. */
  29863. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29864. useInstances: boolean;
  29865. }>): void;
  29866. /**
  29867. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29868. * @param options Sets of optional options forcing the compilation with different modes
  29869. * @returns A promise that resolves when the compilation completes
  29870. */
  29871. forceCompilationAsync(options?: Partial<{
  29872. useInstances: boolean;
  29873. }>): Promise<void>;
  29874. /**
  29875. * Serializes the shadow generator setup to a json object.
  29876. * @returns The serialized JSON object
  29877. */
  29878. serialize(): any;
  29879. /**
  29880. * Disposes the Shadow map and related Textures and effects.
  29881. */
  29882. dispose(): void;
  29883. }
  29884. /**
  29885. * Default implementation IShadowGenerator.
  29886. * This is the main object responsible of generating shadows in the framework.
  29887. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29888. */
  29889. export class ShadowGenerator implements IShadowGenerator {
  29890. /**
  29891. * Name of the shadow generator class
  29892. */
  29893. static CLASSNAME: string;
  29894. /**
  29895. * Shadow generator mode None: no filtering applied.
  29896. */
  29897. static readonly FILTER_NONE: number;
  29898. /**
  29899. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29900. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29901. */
  29902. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29903. /**
  29904. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29905. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29906. */
  29907. static readonly FILTER_POISSONSAMPLING: number;
  29908. /**
  29909. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29910. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29911. */
  29912. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29913. /**
  29914. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29915. * edge artifacts on steep falloff.
  29916. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29917. */
  29918. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29919. /**
  29920. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29921. * edge artifacts on steep falloff.
  29922. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29923. */
  29924. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29925. /**
  29926. * Shadow generator mode PCF: Percentage Closer Filtering
  29927. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29928. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29929. */
  29930. static readonly FILTER_PCF: number;
  29931. /**
  29932. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29933. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29934. * Contact Hardening
  29935. */
  29936. static readonly FILTER_PCSS: number;
  29937. /**
  29938. * Reserved for PCF and PCSS
  29939. * Highest Quality.
  29940. *
  29941. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29942. *
  29943. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29944. */
  29945. static readonly QUALITY_HIGH: number;
  29946. /**
  29947. * Reserved for PCF and PCSS
  29948. * Good tradeoff for quality/perf cross devices
  29949. *
  29950. * Execute PCF on a 3*3 kernel.
  29951. *
  29952. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29953. */
  29954. static readonly QUALITY_MEDIUM: number;
  29955. /**
  29956. * Reserved for PCF and PCSS
  29957. * The lowest quality but the fastest.
  29958. *
  29959. * Execute PCF on a 1*1 kernel.
  29960. *
  29961. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29962. */
  29963. static readonly QUALITY_LOW: number;
  29964. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29965. id: string;
  29966. /** Gets or sets the custom shader name to use */
  29967. customShaderOptions: ICustomShaderOptions;
  29968. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29969. customAllowRendering: (subMesh: SubMesh) => boolean;
  29970. /**
  29971. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29972. */
  29973. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29974. /**
  29975. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29976. */
  29977. onAfterShadowMapRenderObservable: Observable<Effect>;
  29978. /**
  29979. * Observable triggered before a mesh is rendered in the shadow map.
  29980. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29981. */
  29982. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29983. /**
  29984. * Observable triggered after a mesh is rendered in the shadow map.
  29985. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29986. */
  29987. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29988. protected _bias: number;
  29989. /**
  29990. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29991. */
  29992. get bias(): number;
  29993. /**
  29994. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29995. */
  29996. set bias(bias: number);
  29997. protected _normalBias: number;
  29998. /**
  29999. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30000. */
  30001. get normalBias(): number;
  30002. /**
  30003. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30004. */
  30005. set normalBias(normalBias: number);
  30006. protected _blurBoxOffset: number;
  30007. /**
  30008. * Gets the blur box offset: offset applied during the blur pass.
  30009. * Only useful if useKernelBlur = false
  30010. */
  30011. get blurBoxOffset(): number;
  30012. /**
  30013. * Sets the blur box offset: offset applied during the blur pass.
  30014. * Only useful if useKernelBlur = false
  30015. */
  30016. set blurBoxOffset(value: number);
  30017. protected _blurScale: number;
  30018. /**
  30019. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30020. * 2 means half of the size.
  30021. */
  30022. get blurScale(): number;
  30023. /**
  30024. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30025. * 2 means half of the size.
  30026. */
  30027. set blurScale(value: number);
  30028. protected _blurKernel: number;
  30029. /**
  30030. * Gets the blur kernel: kernel size of the blur pass.
  30031. * Only useful if useKernelBlur = true
  30032. */
  30033. get blurKernel(): number;
  30034. /**
  30035. * Sets the blur kernel: kernel size of the blur pass.
  30036. * Only useful if useKernelBlur = true
  30037. */
  30038. set blurKernel(value: number);
  30039. protected _useKernelBlur: boolean;
  30040. /**
  30041. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30042. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30043. */
  30044. get useKernelBlur(): boolean;
  30045. /**
  30046. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30047. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30048. */
  30049. set useKernelBlur(value: boolean);
  30050. protected _depthScale: number;
  30051. /**
  30052. * Gets the depth scale used in ESM mode.
  30053. */
  30054. get depthScale(): number;
  30055. /**
  30056. * Sets the depth scale used in ESM mode.
  30057. * This can override the scale stored on the light.
  30058. */
  30059. set depthScale(value: number);
  30060. protected _validateFilter(filter: number): number;
  30061. protected _filter: number;
  30062. /**
  30063. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30064. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30065. */
  30066. get filter(): number;
  30067. /**
  30068. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30069. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30070. */
  30071. set filter(value: number);
  30072. /**
  30073. * Gets if the current filter is set to Poisson Sampling.
  30074. */
  30075. get usePoissonSampling(): boolean;
  30076. /**
  30077. * Sets the current filter to Poisson Sampling.
  30078. */
  30079. set usePoissonSampling(value: boolean);
  30080. /**
  30081. * Gets if the current filter is set to ESM.
  30082. */
  30083. get useExponentialShadowMap(): boolean;
  30084. /**
  30085. * Sets the current filter is to ESM.
  30086. */
  30087. set useExponentialShadowMap(value: boolean);
  30088. /**
  30089. * Gets if the current filter is set to filtered ESM.
  30090. */
  30091. get useBlurExponentialShadowMap(): boolean;
  30092. /**
  30093. * Gets if the current filter is set to filtered ESM.
  30094. */
  30095. set useBlurExponentialShadowMap(value: boolean);
  30096. /**
  30097. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30098. * exponential to prevent steep falloff artifacts).
  30099. */
  30100. get useCloseExponentialShadowMap(): boolean;
  30101. /**
  30102. * Sets the current filter to "close ESM" (using the inverse of the
  30103. * exponential to prevent steep falloff artifacts).
  30104. */
  30105. set useCloseExponentialShadowMap(value: boolean);
  30106. /**
  30107. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30108. * exponential to prevent steep falloff artifacts).
  30109. */
  30110. get useBlurCloseExponentialShadowMap(): boolean;
  30111. /**
  30112. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30113. * exponential to prevent steep falloff artifacts).
  30114. */
  30115. set useBlurCloseExponentialShadowMap(value: boolean);
  30116. /**
  30117. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30118. */
  30119. get usePercentageCloserFiltering(): boolean;
  30120. /**
  30121. * Sets the current filter to "PCF" (percentage closer filtering).
  30122. */
  30123. set usePercentageCloserFiltering(value: boolean);
  30124. protected _filteringQuality: number;
  30125. /**
  30126. * Gets the PCF or PCSS Quality.
  30127. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30128. */
  30129. get filteringQuality(): number;
  30130. /**
  30131. * Sets the PCF or PCSS Quality.
  30132. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30133. */
  30134. set filteringQuality(filteringQuality: number);
  30135. /**
  30136. * Gets if the current filter is set to "PCSS" (contact hardening).
  30137. */
  30138. get useContactHardeningShadow(): boolean;
  30139. /**
  30140. * Sets the current filter to "PCSS" (contact hardening).
  30141. */
  30142. set useContactHardeningShadow(value: boolean);
  30143. protected _contactHardeningLightSizeUVRatio: number;
  30144. /**
  30145. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30146. * Using a ratio helps keeping shape stability independently of the map size.
  30147. *
  30148. * It does not account for the light projection as it was having too much
  30149. * instability during the light setup or during light position changes.
  30150. *
  30151. * Only valid if useContactHardeningShadow is true.
  30152. */
  30153. get contactHardeningLightSizeUVRatio(): number;
  30154. /**
  30155. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30156. * Using a ratio helps keeping shape stability independently of the map size.
  30157. *
  30158. * It does not account for the light projection as it was having too much
  30159. * instability during the light setup or during light position changes.
  30160. *
  30161. * Only valid if useContactHardeningShadow is true.
  30162. */
  30163. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30164. protected _darkness: number;
  30165. /** Gets or sets the actual darkness of a shadow */
  30166. get darkness(): number;
  30167. set darkness(value: number);
  30168. /**
  30169. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30170. * 0 means strongest and 1 would means no shadow.
  30171. * @returns the darkness.
  30172. */
  30173. getDarkness(): number;
  30174. /**
  30175. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30176. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30177. * @returns the shadow generator allowing fluent coding.
  30178. */
  30179. setDarkness(darkness: number): ShadowGenerator;
  30180. protected _transparencyShadow: boolean;
  30181. /** Gets or sets the ability to have transparent shadow */
  30182. get transparencyShadow(): boolean;
  30183. set transparencyShadow(value: boolean);
  30184. /**
  30185. * Sets the ability to have transparent shadow (boolean).
  30186. * @param transparent True if transparent else False
  30187. * @returns the shadow generator allowing fluent coding
  30188. */
  30189. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30190. /**
  30191. * Enables or disables shadows with varying strength based on the transparency
  30192. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30193. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30194. * mesh.visibility * alphaTexture.a
  30195. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30196. */
  30197. enableSoftTransparentShadow: boolean;
  30198. protected _shadowMap: Nullable<RenderTargetTexture>;
  30199. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30200. /**
  30201. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30202. * @returns The render target texture if present otherwise, null
  30203. */
  30204. getShadowMap(): Nullable<RenderTargetTexture>;
  30205. /**
  30206. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30207. * @returns The render target texture if the shadow map is present otherwise, null
  30208. */
  30209. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30210. /**
  30211. * Gets the class name of that object
  30212. * @returns "ShadowGenerator"
  30213. */
  30214. getClassName(): string;
  30215. /**
  30216. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30217. * @param mesh Mesh to add
  30218. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30219. * @returns the Shadow Generator itself
  30220. */
  30221. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30222. /**
  30223. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30224. * @param mesh Mesh to remove
  30225. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30226. * @returns the Shadow Generator itself
  30227. */
  30228. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30229. /**
  30230. * Controls the extent to which the shadows fade out at the edge of the frustum
  30231. */
  30232. frustumEdgeFalloff: number;
  30233. protected _light: IShadowLight;
  30234. /**
  30235. * Returns the associated light object.
  30236. * @returns the light generating the shadow
  30237. */
  30238. getLight(): IShadowLight;
  30239. /**
  30240. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30241. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30242. * It might on the other hand introduce peter panning.
  30243. */
  30244. forceBackFacesOnly: boolean;
  30245. protected _scene: Scene;
  30246. protected _lightDirection: Vector3;
  30247. protected _effect: Effect;
  30248. protected _viewMatrix: Matrix;
  30249. protected _projectionMatrix: Matrix;
  30250. protected _transformMatrix: Matrix;
  30251. protected _cachedPosition: Vector3;
  30252. protected _cachedDirection: Vector3;
  30253. protected _cachedDefines: string;
  30254. protected _currentRenderID: number;
  30255. protected _boxBlurPostprocess: Nullable<PostProcess>;
  30256. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  30257. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  30258. protected _blurPostProcesses: PostProcess[];
  30259. protected _mapSize: number;
  30260. protected _currentFaceIndex: number;
  30261. protected _currentFaceIndexCache: number;
  30262. protected _textureType: number;
  30263. protected _defaultTextureMatrix: Matrix;
  30264. protected _storedUniqueId: Nullable<number>;
  30265. /** @hidden */
  30266. static _SceneComponentInitialization: (scene: Scene) => void;
  30267. /**
  30268. * Gets or sets the size of the texture what stores the shadows
  30269. */
  30270. get mapSize(): number;
  30271. set mapSize(size: number);
  30272. /**
  30273. * Creates a ShadowGenerator object.
  30274. * A ShadowGenerator is the required tool to use the shadows.
  30275. * Each light casting shadows needs to use its own ShadowGenerator.
  30276. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  30277. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  30278. * @param light The light object generating the shadows.
  30279. * @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.
  30280. */
  30281. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  30282. protected _initializeGenerator(): void;
  30283. protected _createTargetRenderTexture(): void;
  30284. protected _initializeShadowMap(): void;
  30285. protected _initializeBlurRTTAndPostProcesses(): void;
  30286. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  30287. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  30288. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  30289. protected _applyFilterValues(): void;
  30290. /**
  30291. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30292. * @param onCompiled Callback triggered at the and of the effects compilation
  30293. * @param options Sets of optional options forcing the compilation with different modes
  30294. */
  30295. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30296. useInstances: boolean;
  30297. }>): void;
  30298. /**
  30299. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30300. * @param options Sets of optional options forcing the compilation with different modes
  30301. * @returns A promise that resolves when the compilation completes
  30302. */
  30303. forceCompilationAsync(options?: Partial<{
  30304. useInstances: boolean;
  30305. }>): Promise<void>;
  30306. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  30307. private _prepareShadowDefines;
  30308. /**
  30309. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30310. * @param subMesh The submesh we want to render in the shadow map
  30311. * @param useInstances Defines wether will draw in the map using instances
  30312. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30313. * @returns true if ready otherwise, false
  30314. */
  30315. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30316. /**
  30317. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30318. * @param defines Defines of the material we want to update
  30319. * @param lightIndex Index of the light in the enabled light list of the material
  30320. */
  30321. prepareDefines(defines: any, lightIndex: number): void;
  30322. /**
  30323. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30324. * defined in the generator but impacting the effect).
  30325. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30326. * @param effect The effect we are binfing the information for
  30327. */
  30328. bindShadowLight(lightIndex: string, effect: Effect): void;
  30329. /**
  30330. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30331. * (eq to shadow prjection matrix * light transform matrix)
  30332. * @returns The transform matrix used to create the shadow map
  30333. */
  30334. getTransformMatrix(): Matrix;
  30335. /**
  30336. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30337. * Cube and 2D textures for instance.
  30338. */
  30339. recreateShadowMap(): void;
  30340. protected _disposeBlurPostProcesses(): void;
  30341. protected _disposeRTTandPostProcesses(): void;
  30342. /**
  30343. * Disposes the ShadowGenerator.
  30344. * Returns nothing.
  30345. */
  30346. dispose(): void;
  30347. /**
  30348. * Serializes the shadow generator setup to a json object.
  30349. * @returns The serialized JSON object
  30350. */
  30351. serialize(): any;
  30352. /**
  30353. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30354. * @param parsedShadowGenerator The JSON object to parse
  30355. * @param scene The scene to create the shadow map for
  30356. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  30357. * @returns The parsed shadow generator
  30358. */
  30359. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  30360. }
  30361. }
  30362. declare module "babylonjs/Materials/shadowDepthWrapper" {
  30363. import { Nullable } from "babylonjs/types";
  30364. import { Scene } from "babylonjs/scene";
  30365. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30366. import { Material } from "babylonjs/Materials/material";
  30367. import { Effect } from "babylonjs/Materials/effect";
  30368. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  30369. /**
  30370. * Options to be used when creating a shadow depth material
  30371. */
  30372. export interface IIOptionShadowDepthMaterial {
  30373. /** Variables in the vertex shader code that need to have their names remapped.
  30374. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30375. * "var_name" should be either: worldPos or vNormalW
  30376. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30377. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30378. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30379. */
  30380. remappedVariables?: string[];
  30381. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30382. standalone?: boolean;
  30383. }
  30384. /**
  30385. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30386. */
  30387. export class ShadowDepthWrapper {
  30388. private _scene;
  30389. private _options?;
  30390. private _baseMaterial;
  30391. private _onEffectCreatedObserver;
  30392. private _subMeshToEffect;
  30393. private _subMeshToDepthEffect;
  30394. private _meshes;
  30395. /** @hidden */
  30396. _matriceNames: any;
  30397. /** Gets the standalone status of the wrapper */
  30398. get standalone(): boolean;
  30399. /** Gets the base material the wrapper is built upon */
  30400. get baseMaterial(): Material;
  30401. /**
  30402. * Instantiate a new shadow depth wrapper.
  30403. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30404. * generate the shadow depth map. For more information, please refer to the documentation:
  30405. * https://doc.babylonjs.com/babylon101/shadows
  30406. * @param baseMaterial Material to wrap
  30407. * @param scene Define the scene the material belongs to
  30408. * @param options Options used to create the wrapper
  30409. */
  30410. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30411. /**
  30412. * Gets the effect to use to generate the depth map
  30413. * @param subMesh subMesh to get the effect for
  30414. * @param shadowGenerator shadow generator to get the effect for
  30415. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30416. */
  30417. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30418. /**
  30419. * Specifies that the submesh is ready to be used for depth rendering
  30420. * @param subMesh submesh to check
  30421. * @param defines the list of defines to take into account when checking the effect
  30422. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30423. * @param useInstances specifies that instances should be used
  30424. * @returns a boolean indicating that the submesh is ready or not
  30425. */
  30426. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30427. /**
  30428. * Disposes the resources
  30429. */
  30430. dispose(): void;
  30431. private _makeEffect;
  30432. }
  30433. }
  30434. declare module "babylonjs/Materials/material" {
  30435. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30436. import { SmartArray } from "babylonjs/Misc/smartArray";
  30437. import { Observable } from "babylonjs/Misc/observable";
  30438. import { Nullable } from "babylonjs/types";
  30439. import { Scene } from "babylonjs/scene";
  30440. import { Matrix } from "babylonjs/Maths/math.vector";
  30441. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30443. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30444. import { Effect } from "babylonjs/Materials/effect";
  30445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30446. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30447. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30448. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30449. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  30450. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  30451. import { Mesh } from "babylonjs/Meshes/mesh";
  30452. import { Animation } from "babylonjs/Animations/animation";
  30453. /**
  30454. * Options for compiling materials.
  30455. */
  30456. export interface IMaterialCompilationOptions {
  30457. /**
  30458. * Defines whether clip planes are enabled.
  30459. */
  30460. clipPlane: boolean;
  30461. /**
  30462. * Defines whether instances are enabled.
  30463. */
  30464. useInstances: boolean;
  30465. }
  30466. /**
  30467. * Options passed when calling customShaderNameResolve
  30468. */
  30469. export interface ICustomShaderNameResolveOptions {
  30470. /**
  30471. * 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
  30472. */
  30473. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30474. }
  30475. /**
  30476. * Base class for the main features of a material in Babylon.js
  30477. */
  30478. export class Material implements IAnimatable {
  30479. /**
  30480. * Returns the triangle fill mode
  30481. */
  30482. static readonly TriangleFillMode: number;
  30483. /**
  30484. * Returns the wireframe mode
  30485. */
  30486. static readonly WireFrameFillMode: number;
  30487. /**
  30488. * Returns the point fill mode
  30489. */
  30490. static readonly PointFillMode: number;
  30491. /**
  30492. * Returns the point list draw mode
  30493. */
  30494. static readonly PointListDrawMode: number;
  30495. /**
  30496. * Returns the line list draw mode
  30497. */
  30498. static readonly LineListDrawMode: number;
  30499. /**
  30500. * Returns the line loop draw mode
  30501. */
  30502. static readonly LineLoopDrawMode: number;
  30503. /**
  30504. * Returns the line strip draw mode
  30505. */
  30506. static readonly LineStripDrawMode: number;
  30507. /**
  30508. * Returns the triangle strip draw mode
  30509. */
  30510. static readonly TriangleStripDrawMode: number;
  30511. /**
  30512. * Returns the triangle fan draw mode
  30513. */
  30514. static readonly TriangleFanDrawMode: number;
  30515. /**
  30516. * Stores the clock-wise side orientation
  30517. */
  30518. static readonly ClockWiseSideOrientation: number;
  30519. /**
  30520. * Stores the counter clock-wise side orientation
  30521. */
  30522. static readonly CounterClockWiseSideOrientation: number;
  30523. /**
  30524. * The dirty texture flag value
  30525. */
  30526. static readonly TextureDirtyFlag: number;
  30527. /**
  30528. * The dirty light flag value
  30529. */
  30530. static readonly LightDirtyFlag: number;
  30531. /**
  30532. * The dirty fresnel flag value
  30533. */
  30534. static readonly FresnelDirtyFlag: number;
  30535. /**
  30536. * The dirty attribute flag value
  30537. */
  30538. static readonly AttributesDirtyFlag: number;
  30539. /**
  30540. * The dirty misc flag value
  30541. */
  30542. static readonly MiscDirtyFlag: number;
  30543. /**
  30544. * The dirty prepass flag value
  30545. */
  30546. static readonly PrePassDirtyFlag: number;
  30547. /**
  30548. * The all dirty flag value
  30549. */
  30550. static readonly AllDirtyFlag: number;
  30551. /**
  30552. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30553. */
  30554. static readonly MATERIAL_OPAQUE: number;
  30555. /**
  30556. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30557. */
  30558. static readonly MATERIAL_ALPHATEST: number;
  30559. /**
  30560. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30561. */
  30562. static readonly MATERIAL_ALPHABLEND: number;
  30563. /**
  30564. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30565. * They are also discarded below the alpha cutoff threshold to improve performances.
  30566. */
  30567. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30568. /**
  30569. * The Whiteout method is used to blend normals.
  30570. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30571. */
  30572. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30573. /**
  30574. * The Reoriented Normal Mapping method is used to blend normals.
  30575. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30576. */
  30577. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30578. /**
  30579. * Custom callback helping to override the default shader used in the material.
  30580. */
  30581. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30582. /**
  30583. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30584. */
  30585. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30586. /**
  30587. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30588. * This means that the material can keep using a previous shader while a new one is being compiled.
  30589. * This is mostly used when shader parallel compilation is supported (true by default)
  30590. */
  30591. allowShaderHotSwapping: boolean;
  30592. /**
  30593. * The ID of the material
  30594. */
  30595. id: string;
  30596. /**
  30597. * Gets or sets the unique id of the material
  30598. */
  30599. uniqueId: number;
  30600. /**
  30601. * The name of the material
  30602. */
  30603. name: string;
  30604. /**
  30605. * Gets or sets user defined metadata
  30606. */
  30607. metadata: any;
  30608. /**
  30609. * For internal use only. Please do not use.
  30610. */
  30611. reservedDataStore: any;
  30612. /**
  30613. * Specifies if the ready state should be checked on each call
  30614. */
  30615. checkReadyOnEveryCall: boolean;
  30616. /**
  30617. * Specifies if the ready state should be checked once
  30618. */
  30619. checkReadyOnlyOnce: boolean;
  30620. /**
  30621. * The state of the material
  30622. */
  30623. state: string;
  30624. /**
  30625. * If the material can be rendered to several textures with MRT extension
  30626. */
  30627. get canRenderToMRT(): boolean;
  30628. /**
  30629. * The alpha value of the material
  30630. */
  30631. protected _alpha: number;
  30632. /**
  30633. * List of inspectable custom properties (used by the Inspector)
  30634. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30635. */
  30636. inspectableCustomProperties: IInspectable[];
  30637. /**
  30638. * Sets the alpha value of the material
  30639. */
  30640. set alpha(value: number);
  30641. /**
  30642. * Gets the alpha value of the material
  30643. */
  30644. get alpha(): number;
  30645. /**
  30646. * Specifies if back face culling is enabled
  30647. */
  30648. protected _backFaceCulling: boolean;
  30649. /**
  30650. * Sets the back-face culling state
  30651. */
  30652. set backFaceCulling(value: boolean);
  30653. /**
  30654. * Gets the back-face culling state
  30655. */
  30656. get backFaceCulling(): boolean;
  30657. /**
  30658. * Stores the value for side orientation
  30659. */
  30660. sideOrientation: number;
  30661. /**
  30662. * Callback triggered when the material is compiled
  30663. */
  30664. onCompiled: Nullable<(effect: Effect) => void>;
  30665. /**
  30666. * Callback triggered when an error occurs
  30667. */
  30668. onError: Nullable<(effect: Effect, errors: string) => void>;
  30669. /**
  30670. * Callback triggered to get the render target textures
  30671. */
  30672. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30673. /**
  30674. * Gets a boolean indicating that current material needs to register RTT
  30675. */
  30676. get hasRenderTargetTextures(): boolean;
  30677. /**
  30678. * Specifies if the material should be serialized
  30679. */
  30680. doNotSerialize: boolean;
  30681. /**
  30682. * @hidden
  30683. */
  30684. _storeEffectOnSubMeshes: boolean;
  30685. /**
  30686. * Stores the animations for the material
  30687. */
  30688. animations: Nullable<Array<Animation>>;
  30689. /**
  30690. * An event triggered when the material is disposed
  30691. */
  30692. onDisposeObservable: Observable<Material>;
  30693. /**
  30694. * An observer which watches for dispose events
  30695. */
  30696. private _onDisposeObserver;
  30697. private _onUnBindObservable;
  30698. /**
  30699. * Called during a dispose event
  30700. */
  30701. set onDispose(callback: () => void);
  30702. private _onBindObservable;
  30703. /**
  30704. * An event triggered when the material is bound
  30705. */
  30706. get onBindObservable(): Observable<AbstractMesh>;
  30707. /**
  30708. * An observer which watches for bind events
  30709. */
  30710. private _onBindObserver;
  30711. /**
  30712. * Called during a bind event
  30713. */
  30714. set onBind(callback: (Mesh: AbstractMesh) => void);
  30715. /**
  30716. * An event triggered when the material is unbound
  30717. */
  30718. get onUnBindObservable(): Observable<Material>;
  30719. protected _onEffectCreatedObservable: Nullable<Observable<{
  30720. effect: Effect;
  30721. subMesh: Nullable<SubMesh>;
  30722. }>>;
  30723. /**
  30724. * An event triggered when the effect is (re)created
  30725. */
  30726. get onEffectCreatedObservable(): Observable<{
  30727. effect: Effect;
  30728. subMesh: Nullable<SubMesh>;
  30729. }>;
  30730. /**
  30731. * Stores the value of the alpha mode
  30732. */
  30733. private _alphaMode;
  30734. /**
  30735. * Sets the value of the alpha mode.
  30736. *
  30737. * | Value | Type | Description |
  30738. * | --- | --- | --- |
  30739. * | 0 | ALPHA_DISABLE | |
  30740. * | 1 | ALPHA_ADD | |
  30741. * | 2 | ALPHA_COMBINE | |
  30742. * | 3 | ALPHA_SUBTRACT | |
  30743. * | 4 | ALPHA_MULTIPLY | |
  30744. * | 5 | ALPHA_MAXIMIZED | |
  30745. * | 6 | ALPHA_ONEONE | |
  30746. * | 7 | ALPHA_PREMULTIPLIED | |
  30747. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30748. * | 9 | ALPHA_INTERPOLATE | |
  30749. * | 10 | ALPHA_SCREENMODE | |
  30750. *
  30751. */
  30752. set alphaMode(value: number);
  30753. /**
  30754. * Gets the value of the alpha mode
  30755. */
  30756. get alphaMode(): number;
  30757. /**
  30758. * Stores the state of the need depth pre-pass value
  30759. */
  30760. private _needDepthPrePass;
  30761. /**
  30762. * Sets the need depth pre-pass value
  30763. */
  30764. set needDepthPrePass(value: boolean);
  30765. /**
  30766. * Gets the depth pre-pass value
  30767. */
  30768. get needDepthPrePass(): boolean;
  30769. /**
  30770. * Specifies if depth writing should be disabled
  30771. */
  30772. disableDepthWrite: boolean;
  30773. /**
  30774. * Specifies if color writing should be disabled
  30775. */
  30776. disableColorWrite: boolean;
  30777. /**
  30778. * Specifies if depth writing should be forced
  30779. */
  30780. forceDepthWrite: boolean;
  30781. /**
  30782. * Specifies the depth function that should be used. 0 means the default engine function
  30783. */
  30784. depthFunction: number;
  30785. /**
  30786. * Specifies if there should be a separate pass for culling
  30787. */
  30788. separateCullingPass: boolean;
  30789. /**
  30790. * Stores the state specifing if fog should be enabled
  30791. */
  30792. private _fogEnabled;
  30793. /**
  30794. * Sets the state for enabling fog
  30795. */
  30796. set fogEnabled(value: boolean);
  30797. /**
  30798. * Gets the value of the fog enabled state
  30799. */
  30800. get fogEnabled(): boolean;
  30801. /**
  30802. * Stores the size of points
  30803. */
  30804. pointSize: number;
  30805. /**
  30806. * Stores the z offset value
  30807. */
  30808. zOffset: number;
  30809. get wireframe(): boolean;
  30810. /**
  30811. * Sets the state of wireframe mode
  30812. */
  30813. set wireframe(value: boolean);
  30814. /**
  30815. * Gets the value specifying if point clouds are enabled
  30816. */
  30817. get pointsCloud(): boolean;
  30818. /**
  30819. * Sets the state of point cloud mode
  30820. */
  30821. set pointsCloud(value: boolean);
  30822. /**
  30823. * Gets the material fill mode
  30824. */
  30825. get fillMode(): number;
  30826. /**
  30827. * Sets the material fill mode
  30828. */
  30829. set fillMode(value: number);
  30830. /**
  30831. * @hidden
  30832. * Stores the effects for the material
  30833. */
  30834. _effect: Nullable<Effect>;
  30835. /**
  30836. * Specifies if uniform buffers should be used
  30837. */
  30838. private _useUBO;
  30839. /**
  30840. * Stores a reference to the scene
  30841. */
  30842. private _scene;
  30843. /**
  30844. * Stores the fill mode state
  30845. */
  30846. private _fillMode;
  30847. /**
  30848. * Specifies if the depth write state should be cached
  30849. */
  30850. private _cachedDepthWriteState;
  30851. /**
  30852. * Specifies if the color write state should be cached
  30853. */
  30854. private _cachedColorWriteState;
  30855. /**
  30856. * Specifies if the depth function state should be cached
  30857. */
  30858. private _cachedDepthFunctionState;
  30859. /**
  30860. * Stores the uniform buffer
  30861. */
  30862. protected _uniformBuffer: UniformBuffer;
  30863. /** @hidden */
  30864. _indexInSceneMaterialArray: number;
  30865. /** @hidden */
  30866. meshMap: Nullable<{
  30867. [id: string]: AbstractMesh | undefined;
  30868. }>;
  30869. /**
  30870. * Creates a material instance
  30871. * @param name defines the name of the material
  30872. * @param scene defines the scene to reference
  30873. * @param doNotAdd specifies if the material should be added to the scene
  30874. */
  30875. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30876. /**
  30877. * Returns a string representation of the current material
  30878. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30879. * @returns a string with material information
  30880. */
  30881. toString(fullDetails?: boolean): string;
  30882. /**
  30883. * Gets the class name of the material
  30884. * @returns a string with the class name of the material
  30885. */
  30886. getClassName(): string;
  30887. /**
  30888. * Specifies if updates for the material been locked
  30889. */
  30890. get isFrozen(): boolean;
  30891. /**
  30892. * Locks updates for the material
  30893. */
  30894. freeze(): void;
  30895. /**
  30896. * Unlocks updates for the material
  30897. */
  30898. unfreeze(): void;
  30899. /**
  30900. * Specifies if the material is ready to be used
  30901. * @param mesh defines the mesh to check
  30902. * @param useInstances specifies if instances should be used
  30903. * @returns a boolean indicating if the material is ready to be used
  30904. */
  30905. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30906. /**
  30907. * Specifies that the submesh is ready to be used
  30908. * @param mesh defines the mesh to check
  30909. * @param subMesh defines which submesh to check
  30910. * @param useInstances specifies that instances should be used
  30911. * @returns a boolean indicating that the submesh is ready or not
  30912. */
  30913. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30914. /**
  30915. * Returns the material effect
  30916. * @returns the effect associated with the material
  30917. */
  30918. getEffect(): Nullable<Effect>;
  30919. /**
  30920. * Returns the current scene
  30921. * @returns a Scene
  30922. */
  30923. getScene(): Scene;
  30924. /**
  30925. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30926. */
  30927. protected _forceAlphaTest: boolean;
  30928. /**
  30929. * The transparency mode of the material.
  30930. */
  30931. protected _transparencyMode: Nullable<number>;
  30932. /**
  30933. * Gets the current transparency mode.
  30934. */
  30935. get transparencyMode(): Nullable<number>;
  30936. /**
  30937. * Sets the transparency mode of the material.
  30938. *
  30939. * | Value | Type | Description |
  30940. * | ----- | ----------------------------------- | ----------- |
  30941. * | 0 | OPAQUE | |
  30942. * | 1 | ALPHATEST | |
  30943. * | 2 | ALPHABLEND | |
  30944. * | 3 | ALPHATESTANDBLEND | |
  30945. *
  30946. */
  30947. set transparencyMode(value: Nullable<number>);
  30948. /**
  30949. * Returns true if alpha blending should be disabled.
  30950. */
  30951. protected get _disableAlphaBlending(): boolean;
  30952. /**
  30953. * Specifies whether or not this material should be rendered in alpha blend mode.
  30954. * @returns a boolean specifying if alpha blending is needed
  30955. */
  30956. needAlphaBlending(): boolean;
  30957. /**
  30958. * Specifies if the mesh will require alpha blending
  30959. * @param mesh defines the mesh to check
  30960. * @returns a boolean specifying if alpha blending is needed for the mesh
  30961. */
  30962. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30963. /**
  30964. * Specifies whether or not this material should be rendered in alpha test mode.
  30965. * @returns a boolean specifying if an alpha test is needed.
  30966. */
  30967. needAlphaTesting(): boolean;
  30968. /**
  30969. * Specifies if material alpha testing should be turned on for the mesh
  30970. * @param mesh defines the mesh to check
  30971. */
  30972. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30973. /**
  30974. * Gets the texture used for the alpha test
  30975. * @returns the texture to use for alpha testing
  30976. */
  30977. getAlphaTestTexture(): Nullable<BaseTexture>;
  30978. /**
  30979. * Marks the material to indicate that it needs to be re-calculated
  30980. */
  30981. markDirty(): void;
  30982. /** @hidden */
  30983. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30984. /**
  30985. * Binds the material to the mesh
  30986. * @param world defines the world transformation matrix
  30987. * @param mesh defines the mesh to bind the material to
  30988. */
  30989. bind(world: Matrix, mesh?: Mesh): void;
  30990. /**
  30991. * Binds the submesh to the material
  30992. * @param world defines the world transformation matrix
  30993. * @param mesh defines the mesh containing the submesh
  30994. * @param subMesh defines the submesh to bind the material to
  30995. */
  30996. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30997. /**
  30998. * Binds the world matrix to the material
  30999. * @param world defines the world transformation matrix
  31000. */
  31001. bindOnlyWorldMatrix(world: Matrix): void;
  31002. /**
  31003. * Binds the scene's uniform buffer to the effect.
  31004. * @param effect defines the effect to bind to the scene uniform buffer
  31005. * @param sceneUbo defines the uniform buffer storing scene data
  31006. */
  31007. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  31008. /**
  31009. * Binds the view matrix to the effect
  31010. * @param effect defines the effect to bind the view matrix to
  31011. */
  31012. bindView(effect: Effect): void;
  31013. /**
  31014. * Binds the view projection matrix to the effect
  31015. * @param effect defines the effect to bind the view projection matrix to
  31016. */
  31017. bindViewProjection(effect: Effect): void;
  31018. /**
  31019. * Processes to execute after binding the material to a mesh
  31020. * @param mesh defines the rendered mesh
  31021. */
  31022. protected _afterBind(mesh?: Mesh): void;
  31023. /**
  31024. * Unbinds the material from the mesh
  31025. */
  31026. unbind(): void;
  31027. /**
  31028. * Gets the active textures from the material
  31029. * @returns an array of textures
  31030. */
  31031. getActiveTextures(): BaseTexture[];
  31032. /**
  31033. * Specifies if the material uses a texture
  31034. * @param texture defines the texture to check against the material
  31035. * @returns a boolean specifying if the material uses the texture
  31036. */
  31037. hasTexture(texture: BaseTexture): boolean;
  31038. /**
  31039. * Makes a duplicate of the material, and gives it a new name
  31040. * @param name defines the new name for the duplicated material
  31041. * @returns the cloned material
  31042. */
  31043. clone(name: string): Nullable<Material>;
  31044. /**
  31045. * Gets the meshes bound to the material
  31046. * @returns an array of meshes bound to the material
  31047. */
  31048. getBindedMeshes(): AbstractMesh[];
  31049. /**
  31050. * Force shader compilation
  31051. * @param mesh defines the mesh associated with this material
  31052. * @param onCompiled defines a function to execute once the material is compiled
  31053. * @param options defines the options to configure the compilation
  31054. * @param onError defines a function to execute if the material fails compiling
  31055. */
  31056. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  31057. /**
  31058. * Force shader compilation
  31059. * @param mesh defines the mesh that will use this material
  31060. * @param options defines additional options for compiling the shaders
  31061. * @returns a promise that resolves when the compilation completes
  31062. */
  31063. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  31064. private static readonly _AllDirtyCallBack;
  31065. private static readonly _ImageProcessingDirtyCallBack;
  31066. private static readonly _TextureDirtyCallBack;
  31067. private static readonly _FresnelDirtyCallBack;
  31068. private static readonly _MiscDirtyCallBack;
  31069. private static readonly _PrePassDirtyCallBack;
  31070. private static readonly _LightsDirtyCallBack;
  31071. private static readonly _AttributeDirtyCallBack;
  31072. private static _FresnelAndMiscDirtyCallBack;
  31073. private static _TextureAndMiscDirtyCallBack;
  31074. private static readonly _DirtyCallbackArray;
  31075. private static readonly _RunDirtyCallBacks;
  31076. /**
  31077. * Marks a define in the material to indicate that it needs to be re-computed
  31078. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  31079. */
  31080. markAsDirty(flag: number): void;
  31081. /**
  31082. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  31083. * @param func defines a function which checks material defines against the submeshes
  31084. */
  31085. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  31086. /**
  31087. * Indicates that the scene should check if the rendering now needs a prepass
  31088. */
  31089. protected _markScenePrePassDirty(): void;
  31090. /**
  31091. * Indicates that we need to re-calculated for all submeshes
  31092. */
  31093. protected _markAllSubMeshesAsAllDirty(): void;
  31094. /**
  31095. * Indicates that image processing needs to be re-calculated for all submeshes
  31096. */
  31097. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  31098. /**
  31099. * Indicates that textures need to be re-calculated for all submeshes
  31100. */
  31101. protected _markAllSubMeshesAsTexturesDirty(): void;
  31102. /**
  31103. * Indicates that fresnel needs to be re-calculated for all submeshes
  31104. */
  31105. protected _markAllSubMeshesAsFresnelDirty(): void;
  31106. /**
  31107. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  31108. */
  31109. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  31110. /**
  31111. * Indicates that lights need to be re-calculated for all submeshes
  31112. */
  31113. protected _markAllSubMeshesAsLightsDirty(): void;
  31114. /**
  31115. * Indicates that attributes need to be re-calculated for all submeshes
  31116. */
  31117. protected _markAllSubMeshesAsAttributesDirty(): void;
  31118. /**
  31119. * Indicates that misc needs to be re-calculated for all submeshes
  31120. */
  31121. protected _markAllSubMeshesAsMiscDirty(): void;
  31122. /**
  31123. * Indicates that prepass needs to be re-calculated for all submeshes
  31124. */
  31125. protected _markAllSubMeshesAsPrePassDirty(): void;
  31126. /**
  31127. * Indicates that textures and misc need to be re-calculated for all submeshes
  31128. */
  31129. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  31130. /**
  31131. * Sets the required values to the prepass renderer.
  31132. * @param prePassRenderer defines the prepass renderer to setup.
  31133. * @returns true if the pre pass is needed.
  31134. */
  31135. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  31136. /**
  31137. * Disposes the material
  31138. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31139. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31140. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  31141. */
  31142. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31143. /** @hidden */
  31144. private releaseVertexArrayObject;
  31145. /**
  31146. * Serializes this material
  31147. * @returns the serialized material object
  31148. */
  31149. serialize(): any;
  31150. /**
  31151. * Creates a material from parsed material data
  31152. * @param parsedMaterial defines parsed material data
  31153. * @param scene defines the hosting scene
  31154. * @param rootUrl defines the root URL to use to load textures
  31155. * @returns a new material
  31156. */
  31157. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31158. }
  31159. }
  31160. declare module "babylonjs/Materials/multiMaterial" {
  31161. import { Nullable } from "babylonjs/types";
  31162. import { Scene } from "babylonjs/scene";
  31163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31164. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31165. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31166. import { Material } from "babylonjs/Materials/material";
  31167. /**
  31168. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31169. * separate meshes. This can be use to improve performances.
  31170. * @see https://doc.babylonjs.com/how_to/multi_materials
  31171. */
  31172. export class MultiMaterial extends Material {
  31173. private _subMaterials;
  31174. /**
  31175. * Gets or Sets the list of Materials used within the multi material.
  31176. * They need to be ordered according to the submeshes order in the associated mesh
  31177. */
  31178. get subMaterials(): Nullable<Material>[];
  31179. set subMaterials(value: Nullable<Material>[]);
  31180. /**
  31181. * Function used to align with Node.getChildren()
  31182. * @returns the list of Materials used within the multi material
  31183. */
  31184. getChildren(): Nullable<Material>[];
  31185. /**
  31186. * Instantiates a new Multi Material
  31187. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31188. * separate meshes. This can be use to improve performances.
  31189. * @see https://doc.babylonjs.com/how_to/multi_materials
  31190. * @param name Define the name in the scene
  31191. * @param scene Define the scene the material belongs to
  31192. */
  31193. constructor(name: string, scene: Scene);
  31194. private _hookArray;
  31195. /**
  31196. * Get one of the submaterial by its index in the submaterials array
  31197. * @param index The index to look the sub material at
  31198. * @returns The Material if the index has been defined
  31199. */
  31200. getSubMaterial(index: number): Nullable<Material>;
  31201. /**
  31202. * Get the list of active textures for the whole sub materials list.
  31203. * @returns All the textures that will be used during the rendering
  31204. */
  31205. getActiveTextures(): BaseTexture[];
  31206. /**
  31207. * Specifies if any sub-materials of this multi-material use a given texture.
  31208. * @param texture Defines the texture to check against this multi-material's sub-materials.
  31209. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  31210. */
  31211. hasTexture(texture: BaseTexture): boolean;
  31212. /**
  31213. * Gets the current class name of the material e.g. "MultiMaterial"
  31214. * Mainly use in serialization.
  31215. * @returns the class name
  31216. */
  31217. getClassName(): string;
  31218. /**
  31219. * Checks if the material is ready to render the requested sub mesh
  31220. * @param mesh Define the mesh the submesh belongs to
  31221. * @param subMesh Define the sub mesh to look readyness for
  31222. * @param useInstances Define whether or not the material is used with instances
  31223. * @returns true if ready, otherwise false
  31224. */
  31225. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31226. /**
  31227. * Clones the current material and its related sub materials
  31228. * @param name Define the name of the newly cloned material
  31229. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31230. * @returns the cloned material
  31231. */
  31232. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31233. /**
  31234. * Serializes the materials into a JSON representation.
  31235. * @returns the JSON representation
  31236. */
  31237. serialize(): any;
  31238. /**
  31239. * Dispose the material and release its associated resources
  31240. * @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)
  31241. * @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)
  31242. * @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)
  31243. */
  31244. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31245. /**
  31246. * Creates a MultiMaterial from parsed MultiMaterial data.
  31247. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31248. * @param scene defines the hosting scene
  31249. * @returns a new MultiMaterial
  31250. */
  31251. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31252. }
  31253. }
  31254. declare module "babylonjs/Meshes/subMesh" {
  31255. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  31256. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  31257. import { Engine } from "babylonjs/Engines/engine";
  31258. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  31259. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31260. import { Effect } from "babylonjs/Materials/effect";
  31261. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31262. import { Plane } from "babylonjs/Maths/math.plane";
  31263. import { Collider } from "babylonjs/Collisions/collider";
  31264. import { Material } from "babylonjs/Materials/material";
  31265. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31267. import { Mesh } from "babylonjs/Meshes/mesh";
  31268. import { Ray } from "babylonjs/Culling/ray";
  31269. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31270. /**
  31271. * Defines a subdivision inside a mesh
  31272. */
  31273. export class SubMesh implements ICullable {
  31274. /** the material index to use */
  31275. materialIndex: number;
  31276. /** vertex index start */
  31277. verticesStart: number;
  31278. /** vertices count */
  31279. verticesCount: number;
  31280. /** index start */
  31281. indexStart: number;
  31282. /** indices count */
  31283. indexCount: number;
  31284. /** @hidden */
  31285. _materialDefines: Nullable<MaterialDefines>;
  31286. /** @hidden */
  31287. _materialEffect: Nullable<Effect>;
  31288. /** @hidden */
  31289. _effectOverride: Nullable<Effect>;
  31290. /**
  31291. * Gets material defines used by the effect associated to the sub mesh
  31292. */
  31293. get materialDefines(): Nullable<MaterialDefines>;
  31294. /**
  31295. * Sets material defines used by the effect associated to the sub mesh
  31296. */
  31297. set materialDefines(defines: Nullable<MaterialDefines>);
  31298. /**
  31299. * Gets associated effect
  31300. */
  31301. get effect(): Nullable<Effect>;
  31302. /**
  31303. * Sets associated effect (effect used to render this submesh)
  31304. * @param effect defines the effect to associate with
  31305. * @param defines defines the set of defines used to compile this effect
  31306. */
  31307. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31308. /** @hidden */
  31309. _linesIndexCount: number;
  31310. private _mesh;
  31311. private _renderingMesh;
  31312. private _boundingInfo;
  31313. private _linesIndexBuffer;
  31314. /** @hidden */
  31315. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31316. /** @hidden */
  31317. _trianglePlanes: Plane[];
  31318. /** @hidden */
  31319. _lastColliderTransformMatrix: Nullable<Matrix>;
  31320. /** @hidden */
  31321. _renderId: number;
  31322. /** @hidden */
  31323. _alphaIndex: number;
  31324. /** @hidden */
  31325. _distanceToCamera: number;
  31326. /** @hidden */
  31327. _id: number;
  31328. private _currentMaterial;
  31329. /**
  31330. * Add a new submesh to a mesh
  31331. * @param materialIndex defines the material index to use
  31332. * @param verticesStart defines vertex index start
  31333. * @param verticesCount defines vertices count
  31334. * @param indexStart defines index start
  31335. * @param indexCount defines indices count
  31336. * @param mesh defines the parent mesh
  31337. * @param renderingMesh defines an optional rendering mesh
  31338. * @param createBoundingBox defines if bounding box should be created for this submesh
  31339. * @returns the new submesh
  31340. */
  31341. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31342. /**
  31343. * Creates a new submesh
  31344. * @param materialIndex defines the material index to use
  31345. * @param verticesStart defines vertex index start
  31346. * @param verticesCount defines vertices count
  31347. * @param indexStart defines index start
  31348. * @param indexCount defines indices count
  31349. * @param mesh defines the parent mesh
  31350. * @param renderingMesh defines an optional rendering mesh
  31351. * @param createBoundingBox defines if bounding box should be created for this submesh
  31352. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31353. */
  31354. constructor(
  31355. /** the material index to use */
  31356. materialIndex: number,
  31357. /** vertex index start */
  31358. verticesStart: number,
  31359. /** vertices count */
  31360. verticesCount: number,
  31361. /** index start */
  31362. indexStart: number,
  31363. /** indices count */
  31364. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31365. /**
  31366. * Returns true if this submesh covers the entire parent mesh
  31367. * @ignorenaming
  31368. */
  31369. get IsGlobal(): boolean;
  31370. /**
  31371. * Returns the submesh BoudingInfo object
  31372. * @returns current bounding info (or mesh's one if the submesh is global)
  31373. */
  31374. getBoundingInfo(): BoundingInfo;
  31375. /**
  31376. * Sets the submesh BoundingInfo
  31377. * @param boundingInfo defines the new bounding info to use
  31378. * @returns the SubMesh
  31379. */
  31380. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31381. /**
  31382. * Returns the mesh of the current submesh
  31383. * @return the parent mesh
  31384. */
  31385. getMesh(): AbstractMesh;
  31386. /**
  31387. * Returns the rendering mesh of the submesh
  31388. * @returns the rendering mesh (could be different from parent mesh)
  31389. */
  31390. getRenderingMesh(): Mesh;
  31391. /**
  31392. * Returns the replacement mesh of the submesh
  31393. * @returns the replacement mesh (could be different from parent mesh)
  31394. */
  31395. getReplacementMesh(): Nullable<AbstractMesh>;
  31396. /**
  31397. * Returns the effective mesh of the submesh
  31398. * @returns the effective mesh (could be different from parent mesh)
  31399. */
  31400. getEffectiveMesh(): AbstractMesh;
  31401. /**
  31402. * Returns the submesh material
  31403. * @returns null or the current material
  31404. */
  31405. getMaterial(): Nullable<Material>;
  31406. private _IsMultiMaterial;
  31407. /**
  31408. * Sets a new updated BoundingInfo object to the submesh
  31409. * @param data defines an optional position array to use to determine the bounding info
  31410. * @returns the SubMesh
  31411. */
  31412. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31413. /** @hidden */
  31414. _checkCollision(collider: Collider): boolean;
  31415. /**
  31416. * Updates the submesh BoundingInfo
  31417. * @param world defines the world matrix to use to update the bounding info
  31418. * @returns the submesh
  31419. */
  31420. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31421. /**
  31422. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31423. * @param frustumPlanes defines the frustum planes
  31424. * @returns true if the submesh is intersecting with the frustum
  31425. */
  31426. isInFrustum(frustumPlanes: Plane[]): boolean;
  31427. /**
  31428. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31429. * @param frustumPlanes defines the frustum planes
  31430. * @returns true if the submesh is inside the frustum
  31431. */
  31432. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31433. /**
  31434. * Renders the submesh
  31435. * @param enableAlphaMode defines if alpha needs to be used
  31436. * @returns the submesh
  31437. */
  31438. render(enableAlphaMode: boolean): SubMesh;
  31439. /**
  31440. * @hidden
  31441. */
  31442. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31443. /**
  31444. * Checks if the submesh intersects with a ray
  31445. * @param ray defines the ray to test
  31446. * @returns true is the passed ray intersects the submesh bounding box
  31447. */
  31448. canIntersects(ray: Ray): boolean;
  31449. /**
  31450. * Intersects current submesh with a ray
  31451. * @param ray defines the ray to test
  31452. * @param positions defines mesh's positions array
  31453. * @param indices defines mesh's indices array
  31454. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31455. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31456. * @returns intersection info or null if no intersection
  31457. */
  31458. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31459. /** @hidden */
  31460. private _intersectLines;
  31461. /** @hidden */
  31462. private _intersectUnIndexedLines;
  31463. /** @hidden */
  31464. private _intersectTriangles;
  31465. /** @hidden */
  31466. private _intersectUnIndexedTriangles;
  31467. /** @hidden */
  31468. _rebuild(): void;
  31469. /**
  31470. * Creates a new submesh from the passed mesh
  31471. * @param newMesh defines the new hosting mesh
  31472. * @param newRenderingMesh defines an optional rendering mesh
  31473. * @returns the new submesh
  31474. */
  31475. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31476. /**
  31477. * Release associated resources
  31478. */
  31479. dispose(): void;
  31480. /**
  31481. * Gets the class name
  31482. * @returns the string "SubMesh".
  31483. */
  31484. getClassName(): string;
  31485. /**
  31486. * Creates a new submesh from indices data
  31487. * @param materialIndex the index of the main mesh material
  31488. * @param startIndex the index where to start the copy in the mesh indices array
  31489. * @param indexCount the number of indices to copy then from the startIndex
  31490. * @param mesh the main mesh to create the submesh from
  31491. * @param renderingMesh the optional rendering mesh
  31492. * @returns a new submesh
  31493. */
  31494. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31495. }
  31496. }
  31497. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31498. /**
  31499. * Class used to represent data loading progression
  31500. */
  31501. export class SceneLoaderFlags {
  31502. private static _ForceFullSceneLoadingForIncremental;
  31503. private static _ShowLoadingScreen;
  31504. private static _CleanBoneMatrixWeights;
  31505. private static _loggingLevel;
  31506. /**
  31507. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31508. */
  31509. static get ForceFullSceneLoadingForIncremental(): boolean;
  31510. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31511. /**
  31512. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31513. */
  31514. static get ShowLoadingScreen(): boolean;
  31515. static set ShowLoadingScreen(value: boolean);
  31516. /**
  31517. * Defines the current logging level (while loading the scene)
  31518. * @ignorenaming
  31519. */
  31520. static get loggingLevel(): number;
  31521. static set loggingLevel(value: number);
  31522. /**
  31523. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31524. */
  31525. static get CleanBoneMatrixWeights(): boolean;
  31526. static set CleanBoneMatrixWeights(value: boolean);
  31527. }
  31528. }
  31529. declare module "babylonjs/Meshes/geometry" {
  31530. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31531. import { Scene } from "babylonjs/scene";
  31532. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31533. import { Engine } from "babylonjs/Engines/engine";
  31534. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31535. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31536. import { Effect } from "babylonjs/Materials/effect";
  31537. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31538. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31539. import { Mesh } from "babylonjs/Meshes/mesh";
  31540. /**
  31541. * Class used to store geometry data (vertex buffers + index buffer)
  31542. */
  31543. export class Geometry implements IGetSetVerticesData {
  31544. /**
  31545. * Gets or sets the ID of the geometry
  31546. */
  31547. id: string;
  31548. /**
  31549. * Gets or sets the unique ID of the geometry
  31550. */
  31551. uniqueId: number;
  31552. /**
  31553. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31554. */
  31555. delayLoadState: number;
  31556. /**
  31557. * Gets the file containing the data to load when running in delay load state
  31558. */
  31559. delayLoadingFile: Nullable<string>;
  31560. /**
  31561. * Callback called when the geometry is updated
  31562. */
  31563. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31564. private _scene;
  31565. private _engine;
  31566. private _meshes;
  31567. private _totalVertices;
  31568. /** @hidden */
  31569. _indices: IndicesArray;
  31570. /** @hidden */
  31571. _vertexBuffers: {
  31572. [key: string]: VertexBuffer;
  31573. };
  31574. private _isDisposed;
  31575. private _extend;
  31576. private _boundingBias;
  31577. /** @hidden */
  31578. _delayInfo: Array<string>;
  31579. private _indexBuffer;
  31580. private _indexBufferIsUpdatable;
  31581. /** @hidden */
  31582. _boundingInfo: Nullable<BoundingInfo>;
  31583. /** @hidden */
  31584. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31585. /** @hidden */
  31586. _softwareSkinningFrameId: number;
  31587. private _vertexArrayObjects;
  31588. private _updatable;
  31589. /** @hidden */
  31590. _positions: Nullable<Vector3[]>;
  31591. private _positionsCache;
  31592. /**
  31593. * 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
  31594. */
  31595. get boundingBias(): Vector2;
  31596. /**
  31597. * 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
  31598. */
  31599. set boundingBias(value: Vector2);
  31600. /**
  31601. * Static function used to attach a new empty geometry to a mesh
  31602. * @param mesh defines the mesh to attach the geometry to
  31603. * @returns the new Geometry
  31604. */
  31605. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31606. /** Get the list of meshes using this geometry */
  31607. get meshes(): Mesh[];
  31608. /**
  31609. * 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
  31610. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31611. */
  31612. useBoundingInfoFromGeometry: boolean;
  31613. /**
  31614. * Creates a new geometry
  31615. * @param id defines the unique ID
  31616. * @param scene defines the hosting scene
  31617. * @param vertexData defines the VertexData used to get geometry data
  31618. * @param updatable defines if geometry must be updatable (false by default)
  31619. * @param mesh defines the mesh that will be associated with the geometry
  31620. */
  31621. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31622. /**
  31623. * Gets the current extend of the geometry
  31624. */
  31625. get extend(): {
  31626. minimum: Vector3;
  31627. maximum: Vector3;
  31628. };
  31629. /**
  31630. * Gets the hosting scene
  31631. * @returns the hosting Scene
  31632. */
  31633. getScene(): Scene;
  31634. /**
  31635. * Gets the hosting engine
  31636. * @returns the hosting Engine
  31637. */
  31638. getEngine(): Engine;
  31639. /**
  31640. * Defines if the geometry is ready to use
  31641. * @returns true if the geometry is ready to be used
  31642. */
  31643. isReady(): boolean;
  31644. /**
  31645. * Gets a value indicating that the geometry should not be serialized
  31646. */
  31647. get doNotSerialize(): boolean;
  31648. /** @hidden */
  31649. _rebuild(): void;
  31650. /**
  31651. * Affects all geometry data in one call
  31652. * @param vertexData defines the geometry data
  31653. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31654. */
  31655. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31656. /**
  31657. * Set specific vertex data
  31658. * @param kind defines the data kind (Position, normal, etc...)
  31659. * @param data defines the vertex data to use
  31660. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31661. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31662. */
  31663. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31664. /**
  31665. * Removes a specific vertex data
  31666. * @param kind defines the data kind (Position, normal, etc...)
  31667. */
  31668. removeVerticesData(kind: string): void;
  31669. /**
  31670. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31671. * @param buffer defines the vertex buffer to use
  31672. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31673. */
  31674. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31675. /**
  31676. * Update a specific vertex buffer
  31677. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31678. * It will do nothing if the buffer is not updatable
  31679. * @param kind defines the data kind (Position, normal, etc...)
  31680. * @param data defines the data to use
  31681. * @param offset defines the offset in the target buffer where to store the data
  31682. * @param useBytes set to true if the offset is in bytes
  31683. */
  31684. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31685. /**
  31686. * Update a specific vertex buffer
  31687. * This function will create a new buffer if the current one is not updatable
  31688. * @param kind defines the data kind (Position, normal, etc...)
  31689. * @param data defines the data to use
  31690. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31691. */
  31692. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31693. private _updateBoundingInfo;
  31694. /** @hidden */
  31695. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31696. /**
  31697. * Gets total number of vertices
  31698. * @returns the total number of vertices
  31699. */
  31700. getTotalVertices(): number;
  31701. /**
  31702. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31703. * @param kind defines the data kind (Position, normal, etc...)
  31704. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31705. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31706. * @returns a float array containing vertex data
  31707. */
  31708. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31709. /**
  31710. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31711. * @param kind defines the data kind (Position, normal, etc...)
  31712. * @returns true if the vertex buffer with the specified kind is updatable
  31713. */
  31714. isVertexBufferUpdatable(kind: string): boolean;
  31715. /**
  31716. * Gets a specific vertex buffer
  31717. * @param kind defines the data kind (Position, normal, etc...)
  31718. * @returns a VertexBuffer
  31719. */
  31720. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31721. /**
  31722. * Returns all vertex buffers
  31723. * @return an object holding all vertex buffers indexed by kind
  31724. */
  31725. getVertexBuffers(): Nullable<{
  31726. [key: string]: VertexBuffer;
  31727. }>;
  31728. /**
  31729. * Gets a boolean indicating if specific vertex buffer is present
  31730. * @param kind defines the data kind (Position, normal, etc...)
  31731. * @returns true if data is present
  31732. */
  31733. isVerticesDataPresent(kind: string): boolean;
  31734. /**
  31735. * Gets a list of all attached data kinds (Position, normal, etc...)
  31736. * @returns a list of string containing all kinds
  31737. */
  31738. getVerticesDataKinds(): string[];
  31739. /**
  31740. * Update index buffer
  31741. * @param indices defines the indices to store in the index buffer
  31742. * @param offset defines the offset in the target buffer where to store the data
  31743. * @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)
  31744. */
  31745. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31746. /**
  31747. * Creates a new index buffer
  31748. * @param indices defines the indices to store in the index buffer
  31749. * @param totalVertices defines the total number of vertices (could be null)
  31750. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31751. */
  31752. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31753. /**
  31754. * Return the total number of indices
  31755. * @returns the total number of indices
  31756. */
  31757. getTotalIndices(): number;
  31758. /**
  31759. * Gets the index buffer array
  31760. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31761. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31762. * @returns the index buffer array
  31763. */
  31764. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31765. /**
  31766. * Gets the index buffer
  31767. * @return the index buffer
  31768. */
  31769. getIndexBuffer(): Nullable<DataBuffer>;
  31770. /** @hidden */
  31771. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31772. /**
  31773. * Release the associated resources for a specific mesh
  31774. * @param mesh defines the source mesh
  31775. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31776. */
  31777. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31778. /**
  31779. * Apply current geometry to a given mesh
  31780. * @param mesh defines the mesh to apply geometry to
  31781. */
  31782. applyToMesh(mesh: Mesh): void;
  31783. private _updateExtend;
  31784. private _applyToMesh;
  31785. private notifyUpdate;
  31786. /**
  31787. * Load the geometry if it was flagged as delay loaded
  31788. * @param scene defines the hosting scene
  31789. * @param onLoaded defines a callback called when the geometry is loaded
  31790. */
  31791. load(scene: Scene, onLoaded?: () => void): void;
  31792. private _queueLoad;
  31793. /**
  31794. * Invert the geometry to move from a right handed system to a left handed one.
  31795. */
  31796. toLeftHanded(): void;
  31797. /** @hidden */
  31798. _resetPointsArrayCache(): void;
  31799. /** @hidden */
  31800. _generatePointsArray(): boolean;
  31801. /**
  31802. * Gets a value indicating if the geometry is disposed
  31803. * @returns true if the geometry was disposed
  31804. */
  31805. isDisposed(): boolean;
  31806. private _disposeVertexArrayObjects;
  31807. /**
  31808. * Free all associated resources
  31809. */
  31810. dispose(): void;
  31811. /**
  31812. * Clone the current geometry into a new geometry
  31813. * @param id defines the unique ID of the new geometry
  31814. * @returns a new geometry object
  31815. */
  31816. copy(id: string): Geometry;
  31817. /**
  31818. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31819. * @return a JSON representation of the current geometry data (without the vertices data)
  31820. */
  31821. serialize(): any;
  31822. private toNumberArray;
  31823. /**
  31824. * Serialize all vertices data into a JSON oject
  31825. * @returns a JSON representation of the current geometry data
  31826. */
  31827. serializeVerticeData(): any;
  31828. /**
  31829. * Extracts a clone of a mesh geometry
  31830. * @param mesh defines the source mesh
  31831. * @param id defines the unique ID of the new geometry object
  31832. * @returns the new geometry object
  31833. */
  31834. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31835. /**
  31836. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31837. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31838. * Be aware Math.random() could cause collisions, but:
  31839. * "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"
  31840. * @returns a string containing a new GUID
  31841. */
  31842. static RandomId(): string;
  31843. /** @hidden */
  31844. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31845. private static _CleanMatricesWeights;
  31846. /**
  31847. * Create a new geometry from persisted data (Using .babylon file format)
  31848. * @param parsedVertexData defines the persisted data
  31849. * @param scene defines the hosting scene
  31850. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31851. * @returns the new geometry object
  31852. */
  31853. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31854. }
  31855. }
  31856. declare module "babylonjs/Morph/morphTarget" {
  31857. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31858. import { Observable } from "babylonjs/Misc/observable";
  31859. import { Nullable, FloatArray } from "babylonjs/types";
  31860. import { Scene } from "babylonjs/scene";
  31861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31862. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31863. /**
  31864. * Defines a target to use with MorphTargetManager
  31865. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31866. */
  31867. export class MorphTarget implements IAnimatable {
  31868. /** defines the name of the target */
  31869. name: string;
  31870. /**
  31871. * Gets or sets the list of animations
  31872. */
  31873. animations: import("babylonjs/Animations/animation").Animation[];
  31874. private _scene;
  31875. private _positions;
  31876. private _normals;
  31877. private _tangents;
  31878. private _uvs;
  31879. private _influence;
  31880. private _uniqueId;
  31881. /**
  31882. * Observable raised when the influence changes
  31883. */
  31884. onInfluenceChanged: Observable<boolean>;
  31885. /** @hidden */
  31886. _onDataLayoutChanged: Observable<void>;
  31887. /**
  31888. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31889. */
  31890. get influence(): number;
  31891. set influence(influence: number);
  31892. /**
  31893. * Gets or sets the id of the morph Target
  31894. */
  31895. id: string;
  31896. private _animationPropertiesOverride;
  31897. /**
  31898. * Gets or sets the animation properties override
  31899. */
  31900. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31901. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31902. /**
  31903. * Creates a new MorphTarget
  31904. * @param name defines the name of the target
  31905. * @param influence defines the influence to use
  31906. * @param scene defines the scene the morphtarget belongs to
  31907. */
  31908. constructor(
  31909. /** defines the name of the target */
  31910. name: string, influence?: number, scene?: Nullable<Scene>);
  31911. /**
  31912. * Gets the unique ID of this manager
  31913. */
  31914. get uniqueId(): number;
  31915. /**
  31916. * Gets a boolean defining if the target contains position data
  31917. */
  31918. get hasPositions(): boolean;
  31919. /**
  31920. * Gets a boolean defining if the target contains normal data
  31921. */
  31922. get hasNormals(): boolean;
  31923. /**
  31924. * Gets a boolean defining if the target contains tangent data
  31925. */
  31926. get hasTangents(): boolean;
  31927. /**
  31928. * Gets a boolean defining if the target contains texture coordinates data
  31929. */
  31930. get hasUVs(): boolean;
  31931. /**
  31932. * Affects position data to this target
  31933. * @param data defines the position data to use
  31934. */
  31935. setPositions(data: Nullable<FloatArray>): void;
  31936. /**
  31937. * Gets the position data stored in this target
  31938. * @returns a FloatArray containing the position data (or null if not present)
  31939. */
  31940. getPositions(): Nullable<FloatArray>;
  31941. /**
  31942. * Affects normal data to this target
  31943. * @param data defines the normal data to use
  31944. */
  31945. setNormals(data: Nullable<FloatArray>): void;
  31946. /**
  31947. * Gets the normal data stored in this target
  31948. * @returns a FloatArray containing the normal data (or null if not present)
  31949. */
  31950. getNormals(): Nullable<FloatArray>;
  31951. /**
  31952. * Affects tangent data to this target
  31953. * @param data defines the tangent data to use
  31954. */
  31955. setTangents(data: Nullable<FloatArray>): void;
  31956. /**
  31957. * Gets the tangent data stored in this target
  31958. * @returns a FloatArray containing the tangent data (or null if not present)
  31959. */
  31960. getTangents(): Nullable<FloatArray>;
  31961. /**
  31962. * Affects texture coordinates data to this target
  31963. * @param data defines the texture coordinates data to use
  31964. */
  31965. setUVs(data: Nullable<FloatArray>): void;
  31966. /**
  31967. * Gets the texture coordinates data stored in this target
  31968. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31969. */
  31970. getUVs(): Nullable<FloatArray>;
  31971. /**
  31972. * Clone the current target
  31973. * @returns a new MorphTarget
  31974. */
  31975. clone(): MorphTarget;
  31976. /**
  31977. * Serializes the current target into a Serialization object
  31978. * @returns the serialized object
  31979. */
  31980. serialize(): any;
  31981. /**
  31982. * Returns the string "MorphTarget"
  31983. * @returns "MorphTarget"
  31984. */
  31985. getClassName(): string;
  31986. /**
  31987. * Creates a new target from serialized data
  31988. * @param serializationObject defines the serialized data to use
  31989. * @returns a new MorphTarget
  31990. */
  31991. static Parse(serializationObject: any): MorphTarget;
  31992. /**
  31993. * Creates a MorphTarget from mesh data
  31994. * @param mesh defines the source mesh
  31995. * @param name defines the name to use for the new target
  31996. * @param influence defines the influence to attach to the target
  31997. * @returns a new MorphTarget
  31998. */
  31999. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32000. }
  32001. }
  32002. declare module "babylonjs/Morph/morphTargetManager" {
  32003. import { Nullable } from "babylonjs/types";
  32004. import { Scene } from "babylonjs/scene";
  32005. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32006. /**
  32007. * This class is used to deform meshes using morphing between different targets
  32008. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32009. */
  32010. export class MorphTargetManager {
  32011. private _targets;
  32012. private _targetInfluenceChangedObservers;
  32013. private _targetDataLayoutChangedObservers;
  32014. private _activeTargets;
  32015. private _scene;
  32016. private _influences;
  32017. private _supportsNormals;
  32018. private _supportsTangents;
  32019. private _supportsUVs;
  32020. private _vertexCount;
  32021. private _uniqueId;
  32022. private _tempInfluences;
  32023. /**
  32024. * Gets or sets a boolean indicating if normals must be morphed
  32025. */
  32026. enableNormalMorphing: boolean;
  32027. /**
  32028. * Gets or sets a boolean indicating if tangents must be morphed
  32029. */
  32030. enableTangentMorphing: boolean;
  32031. /**
  32032. * Gets or sets a boolean indicating if UV must be morphed
  32033. */
  32034. enableUVMorphing: boolean;
  32035. /**
  32036. * Creates a new MorphTargetManager
  32037. * @param scene defines the current scene
  32038. */
  32039. constructor(scene?: Nullable<Scene>);
  32040. /**
  32041. * Gets the unique ID of this manager
  32042. */
  32043. get uniqueId(): number;
  32044. /**
  32045. * Gets the number of vertices handled by this manager
  32046. */
  32047. get vertexCount(): number;
  32048. /**
  32049. * Gets a boolean indicating if this manager supports morphing of normals
  32050. */
  32051. get supportsNormals(): boolean;
  32052. /**
  32053. * Gets a boolean indicating if this manager supports morphing of tangents
  32054. */
  32055. get supportsTangents(): boolean;
  32056. /**
  32057. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32058. */
  32059. get supportsUVs(): boolean;
  32060. /**
  32061. * Gets the number of targets stored in this manager
  32062. */
  32063. get numTargets(): number;
  32064. /**
  32065. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32066. */
  32067. get numInfluencers(): number;
  32068. /**
  32069. * Gets the list of influences (one per target)
  32070. */
  32071. get influences(): Float32Array;
  32072. /**
  32073. * Gets the active target at specified index. An active target is a target with an influence > 0
  32074. * @param index defines the index to check
  32075. * @returns the requested target
  32076. */
  32077. getActiveTarget(index: number): MorphTarget;
  32078. /**
  32079. * Gets the target at specified index
  32080. * @param index defines the index to check
  32081. * @returns the requested target
  32082. */
  32083. getTarget(index: number): MorphTarget;
  32084. /**
  32085. * Add a new target to this manager
  32086. * @param target defines the target to add
  32087. */
  32088. addTarget(target: MorphTarget): void;
  32089. /**
  32090. * Removes a target from the manager
  32091. * @param target defines the target to remove
  32092. */
  32093. removeTarget(target: MorphTarget): void;
  32094. /**
  32095. * Clone the current manager
  32096. * @returns a new MorphTargetManager
  32097. */
  32098. clone(): MorphTargetManager;
  32099. /**
  32100. * Serializes the current manager into a Serialization object
  32101. * @returns the serialized object
  32102. */
  32103. serialize(): any;
  32104. private _syncActiveTargets;
  32105. /**
  32106. * Syncrhonize the targets with all the meshes using this morph target manager
  32107. */
  32108. synchronize(): void;
  32109. /**
  32110. * Creates a new MorphTargetManager from serialized data
  32111. * @param serializationObject defines the serialized data
  32112. * @param scene defines the hosting scene
  32113. * @returns the new MorphTargetManager
  32114. */
  32115. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32116. }
  32117. }
  32118. declare module "babylonjs/Meshes/meshLODLevel" {
  32119. import { Mesh } from "babylonjs/Meshes/mesh";
  32120. import { Nullable } from "babylonjs/types";
  32121. /**
  32122. * Class used to represent a specific level of detail of a mesh
  32123. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32124. */
  32125. export class MeshLODLevel {
  32126. /** Defines the distance where this level should start being displayed */
  32127. distance: number;
  32128. /** Defines the mesh to use to render this level */
  32129. mesh: Nullable<Mesh>;
  32130. /**
  32131. * Creates a new LOD level
  32132. * @param distance defines the distance where this level should star being displayed
  32133. * @param mesh defines the mesh to use to render this level
  32134. */
  32135. constructor(
  32136. /** Defines the distance where this level should start being displayed */
  32137. distance: number,
  32138. /** Defines the mesh to use to render this level */
  32139. mesh: Nullable<Mesh>);
  32140. }
  32141. }
  32142. declare module "babylonjs/Misc/canvasGenerator" {
  32143. /**
  32144. * Helper class used to generate a canvas to manipulate images
  32145. */
  32146. export class CanvasGenerator {
  32147. /**
  32148. * Create a new canvas (or offscreen canvas depending on the context)
  32149. * @param width defines the expected width
  32150. * @param height defines the expected height
  32151. * @return a new canvas or offscreen canvas
  32152. */
  32153. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32154. }
  32155. }
  32156. declare module "babylonjs/Meshes/groundMesh" {
  32157. import { Scene } from "babylonjs/scene";
  32158. import { Vector3 } from "babylonjs/Maths/math.vector";
  32159. import { Mesh } from "babylonjs/Meshes/mesh";
  32160. /**
  32161. * Mesh representing the gorund
  32162. */
  32163. export class GroundMesh extends Mesh {
  32164. /** If octree should be generated */
  32165. generateOctree: boolean;
  32166. private _heightQuads;
  32167. /** @hidden */
  32168. _subdivisionsX: number;
  32169. /** @hidden */
  32170. _subdivisionsY: number;
  32171. /** @hidden */
  32172. _width: number;
  32173. /** @hidden */
  32174. _height: number;
  32175. /** @hidden */
  32176. _minX: number;
  32177. /** @hidden */
  32178. _maxX: number;
  32179. /** @hidden */
  32180. _minZ: number;
  32181. /** @hidden */
  32182. _maxZ: number;
  32183. constructor(name: string, scene: Scene);
  32184. /**
  32185. * "GroundMesh"
  32186. * @returns "GroundMesh"
  32187. */
  32188. getClassName(): string;
  32189. /**
  32190. * The minimum of x and y subdivisions
  32191. */
  32192. get subdivisions(): number;
  32193. /**
  32194. * X subdivisions
  32195. */
  32196. get subdivisionsX(): number;
  32197. /**
  32198. * Y subdivisions
  32199. */
  32200. get subdivisionsY(): number;
  32201. /**
  32202. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32203. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32204. * @param chunksCount the number of subdivisions for x and y
  32205. * @param octreeBlocksSize (Default: 32)
  32206. */
  32207. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32208. /**
  32209. * Returns a height (y) value in the Worl system :
  32210. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32211. * @param x x coordinate
  32212. * @param z z coordinate
  32213. * @returns the ground y position if (x, z) are outside the ground surface.
  32214. */
  32215. getHeightAtCoordinates(x: number, z: number): number;
  32216. /**
  32217. * Returns a normalized vector (Vector3) orthogonal to the ground
  32218. * at the ground coordinates (x, z) expressed in the World system.
  32219. * @param x x coordinate
  32220. * @param z z coordinate
  32221. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32222. */
  32223. getNormalAtCoordinates(x: number, z: number): Vector3;
  32224. /**
  32225. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32226. * at the ground coordinates (x, z) expressed in the World system.
  32227. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32228. * @param x x coordinate
  32229. * @param z z coordinate
  32230. * @param ref vector to store the result
  32231. * @returns the GroundMesh.
  32232. */
  32233. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32234. /**
  32235. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32236. * if the ground has been updated.
  32237. * This can be used in the render loop.
  32238. * @returns the GroundMesh.
  32239. */
  32240. updateCoordinateHeights(): GroundMesh;
  32241. private _getFacetAt;
  32242. private _initHeightQuads;
  32243. private _computeHeightQuads;
  32244. /**
  32245. * Serializes this ground mesh
  32246. * @param serializationObject object to write serialization to
  32247. */
  32248. serialize(serializationObject: any): void;
  32249. /**
  32250. * Parses a serialized ground mesh
  32251. * @param parsedMesh the serialized mesh
  32252. * @param scene the scene to create the ground mesh in
  32253. * @returns the created ground mesh
  32254. */
  32255. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32256. }
  32257. }
  32258. declare module "babylonjs/Physics/physicsJoint" {
  32259. import { Vector3 } from "babylonjs/Maths/math.vector";
  32260. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32261. /**
  32262. * Interface for Physics-Joint data
  32263. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32264. */
  32265. export interface PhysicsJointData {
  32266. /**
  32267. * The main pivot of the joint
  32268. */
  32269. mainPivot?: Vector3;
  32270. /**
  32271. * The connected pivot of the joint
  32272. */
  32273. connectedPivot?: Vector3;
  32274. /**
  32275. * The main axis of the joint
  32276. */
  32277. mainAxis?: Vector3;
  32278. /**
  32279. * The connected axis of the joint
  32280. */
  32281. connectedAxis?: Vector3;
  32282. /**
  32283. * The collision of the joint
  32284. */
  32285. collision?: boolean;
  32286. /**
  32287. * Native Oimo/Cannon/Energy data
  32288. */
  32289. nativeParams?: any;
  32290. }
  32291. /**
  32292. * This is a holder class for the physics joint created by the physics plugin
  32293. * It holds a set of functions to control the underlying joint
  32294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32295. */
  32296. export class PhysicsJoint {
  32297. /**
  32298. * The type of the physics joint
  32299. */
  32300. type: number;
  32301. /**
  32302. * The data for the physics joint
  32303. */
  32304. jointData: PhysicsJointData;
  32305. private _physicsJoint;
  32306. protected _physicsPlugin: IPhysicsEnginePlugin;
  32307. /**
  32308. * Initializes the physics joint
  32309. * @param type The type of the physics joint
  32310. * @param jointData The data for the physics joint
  32311. */
  32312. constructor(
  32313. /**
  32314. * The type of the physics joint
  32315. */
  32316. type: number,
  32317. /**
  32318. * The data for the physics joint
  32319. */
  32320. jointData: PhysicsJointData);
  32321. /**
  32322. * Gets the physics joint
  32323. */
  32324. get physicsJoint(): any;
  32325. /**
  32326. * Sets the physics joint
  32327. */
  32328. set physicsJoint(newJoint: any);
  32329. /**
  32330. * Sets the physics plugin
  32331. */
  32332. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32333. /**
  32334. * Execute a function that is physics-plugin specific.
  32335. * @param {Function} func the function that will be executed.
  32336. * It accepts two parameters: the physics world and the physics joint
  32337. */
  32338. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32339. /**
  32340. * Distance-Joint type
  32341. */
  32342. static DistanceJoint: number;
  32343. /**
  32344. * Hinge-Joint type
  32345. */
  32346. static HingeJoint: number;
  32347. /**
  32348. * Ball-and-Socket joint type
  32349. */
  32350. static BallAndSocketJoint: number;
  32351. /**
  32352. * Wheel-Joint type
  32353. */
  32354. static WheelJoint: number;
  32355. /**
  32356. * Slider-Joint type
  32357. */
  32358. static SliderJoint: number;
  32359. /**
  32360. * Prismatic-Joint type
  32361. */
  32362. static PrismaticJoint: number;
  32363. /**
  32364. * Universal-Joint type
  32365. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32366. */
  32367. static UniversalJoint: number;
  32368. /**
  32369. * Hinge-Joint 2 type
  32370. */
  32371. static Hinge2Joint: number;
  32372. /**
  32373. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32374. */
  32375. static PointToPointJoint: number;
  32376. /**
  32377. * Spring-Joint type
  32378. */
  32379. static SpringJoint: number;
  32380. /**
  32381. * Lock-Joint type
  32382. */
  32383. static LockJoint: number;
  32384. }
  32385. /**
  32386. * A class representing a physics distance joint
  32387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32388. */
  32389. export class DistanceJoint extends PhysicsJoint {
  32390. /**
  32391. *
  32392. * @param jointData The data for the Distance-Joint
  32393. */
  32394. constructor(jointData: DistanceJointData);
  32395. /**
  32396. * Update the predefined distance.
  32397. * @param maxDistance The maximum preferred distance
  32398. * @param minDistance The minimum preferred distance
  32399. */
  32400. updateDistance(maxDistance: number, minDistance?: number): void;
  32401. }
  32402. /**
  32403. * Represents a Motor-Enabled Joint
  32404. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32405. */
  32406. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32407. /**
  32408. * Initializes the Motor-Enabled Joint
  32409. * @param type The type of the joint
  32410. * @param jointData The physica joint data for the joint
  32411. */
  32412. constructor(type: number, jointData: PhysicsJointData);
  32413. /**
  32414. * Set the motor values.
  32415. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32416. * @param force the force to apply
  32417. * @param maxForce max force for this motor.
  32418. */
  32419. setMotor(force?: number, maxForce?: number): void;
  32420. /**
  32421. * Set the motor's limits.
  32422. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32423. * @param upperLimit The upper limit of the motor
  32424. * @param lowerLimit The lower limit of the motor
  32425. */
  32426. setLimit(upperLimit: number, lowerLimit?: number): void;
  32427. }
  32428. /**
  32429. * This class represents a single physics Hinge-Joint
  32430. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32431. */
  32432. export class HingeJoint extends MotorEnabledJoint {
  32433. /**
  32434. * Initializes the Hinge-Joint
  32435. * @param jointData The joint data for the Hinge-Joint
  32436. */
  32437. constructor(jointData: PhysicsJointData);
  32438. /**
  32439. * Set the motor values.
  32440. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32441. * @param {number} force the force to apply
  32442. * @param {number} maxForce max force for this motor.
  32443. */
  32444. setMotor(force?: number, maxForce?: number): void;
  32445. /**
  32446. * Set the motor's limits.
  32447. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32448. * @param upperLimit The upper limit of the motor
  32449. * @param lowerLimit The lower limit of the motor
  32450. */
  32451. setLimit(upperLimit: number, lowerLimit?: number): void;
  32452. }
  32453. /**
  32454. * This class represents a dual hinge physics joint (same as wheel joint)
  32455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32456. */
  32457. export class Hinge2Joint extends MotorEnabledJoint {
  32458. /**
  32459. * Initializes the Hinge2-Joint
  32460. * @param jointData The joint data for the Hinge2-Joint
  32461. */
  32462. constructor(jointData: PhysicsJointData);
  32463. /**
  32464. * Set the motor values.
  32465. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32466. * @param {number} targetSpeed the speed the motor is to reach
  32467. * @param {number} maxForce max force for this motor.
  32468. * @param {motorIndex} the motor's index, 0 or 1.
  32469. */
  32470. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32471. /**
  32472. * Set the motor limits.
  32473. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32474. * @param {number} upperLimit the upper limit
  32475. * @param {number} lowerLimit lower limit
  32476. * @param {motorIndex} the motor's index, 0 or 1.
  32477. */
  32478. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32479. }
  32480. /**
  32481. * Interface for a motor enabled joint
  32482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32483. */
  32484. export interface IMotorEnabledJoint {
  32485. /**
  32486. * Physics joint
  32487. */
  32488. physicsJoint: any;
  32489. /**
  32490. * Sets the motor of the motor-enabled joint
  32491. * @param force The force of the motor
  32492. * @param maxForce The maximum force of the motor
  32493. * @param motorIndex The index of the motor
  32494. */
  32495. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32496. /**
  32497. * Sets the limit of the motor
  32498. * @param upperLimit The upper limit of the motor
  32499. * @param lowerLimit The lower limit of the motor
  32500. * @param motorIndex The index of the motor
  32501. */
  32502. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32503. }
  32504. /**
  32505. * Joint data for a Distance-Joint
  32506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32507. */
  32508. export interface DistanceJointData extends PhysicsJointData {
  32509. /**
  32510. * Max distance the 2 joint objects can be apart
  32511. */
  32512. maxDistance: number;
  32513. }
  32514. /**
  32515. * Joint data from a spring joint
  32516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32517. */
  32518. export interface SpringJointData extends PhysicsJointData {
  32519. /**
  32520. * Length of the spring
  32521. */
  32522. length: number;
  32523. /**
  32524. * Stiffness of the spring
  32525. */
  32526. stiffness: number;
  32527. /**
  32528. * Damping of the spring
  32529. */
  32530. damping: number;
  32531. /** this callback will be called when applying the force to the impostors. */
  32532. forceApplicationCallback: () => void;
  32533. }
  32534. }
  32535. declare module "babylonjs/Physics/physicsRaycastResult" {
  32536. import { Vector3 } from "babylonjs/Maths/math.vector";
  32537. /**
  32538. * Holds the data for the raycast result
  32539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32540. */
  32541. export class PhysicsRaycastResult {
  32542. private _hasHit;
  32543. private _hitDistance;
  32544. private _hitNormalWorld;
  32545. private _hitPointWorld;
  32546. private _rayFromWorld;
  32547. private _rayToWorld;
  32548. /**
  32549. * Gets if there was a hit
  32550. */
  32551. get hasHit(): boolean;
  32552. /**
  32553. * Gets the distance from the hit
  32554. */
  32555. get hitDistance(): number;
  32556. /**
  32557. * Gets the hit normal/direction in the world
  32558. */
  32559. get hitNormalWorld(): Vector3;
  32560. /**
  32561. * Gets the hit point in the world
  32562. */
  32563. get hitPointWorld(): Vector3;
  32564. /**
  32565. * Gets the ray "start point" of the ray in the world
  32566. */
  32567. get rayFromWorld(): Vector3;
  32568. /**
  32569. * Gets the ray "end point" of the ray in the world
  32570. */
  32571. get rayToWorld(): Vector3;
  32572. /**
  32573. * Sets the hit data (normal & point in world space)
  32574. * @param hitNormalWorld defines the normal in world space
  32575. * @param hitPointWorld defines the point in world space
  32576. */
  32577. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32578. /**
  32579. * Sets the distance from the start point to the hit point
  32580. * @param distance
  32581. */
  32582. setHitDistance(distance: number): void;
  32583. /**
  32584. * Calculates the distance manually
  32585. */
  32586. calculateHitDistance(): void;
  32587. /**
  32588. * Resets all the values to default
  32589. * @param from The from point on world space
  32590. * @param to The to point on world space
  32591. */
  32592. reset(from?: Vector3, to?: Vector3): void;
  32593. }
  32594. /**
  32595. * Interface for the size containing width and height
  32596. */
  32597. interface IXYZ {
  32598. /**
  32599. * X
  32600. */
  32601. x: number;
  32602. /**
  32603. * Y
  32604. */
  32605. y: number;
  32606. /**
  32607. * Z
  32608. */
  32609. z: number;
  32610. }
  32611. }
  32612. declare module "babylonjs/Physics/IPhysicsEngine" {
  32613. import { Nullable } from "babylonjs/types";
  32614. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  32615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32616. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  32617. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  32618. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  32619. /**
  32620. * Interface used to describe a physics joint
  32621. */
  32622. export interface PhysicsImpostorJoint {
  32623. /** Defines the main impostor to which the joint is linked */
  32624. mainImpostor: PhysicsImpostor;
  32625. /** Defines the impostor that is connected to the main impostor using this joint */
  32626. connectedImpostor: PhysicsImpostor;
  32627. /** Defines the joint itself */
  32628. joint: PhysicsJoint;
  32629. }
  32630. /** @hidden */
  32631. export interface IPhysicsEnginePlugin {
  32632. world: any;
  32633. name: string;
  32634. setGravity(gravity: Vector3): void;
  32635. setTimeStep(timeStep: number): void;
  32636. getTimeStep(): number;
  32637. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32638. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32639. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32640. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32641. removePhysicsBody(impostor: PhysicsImpostor): void;
  32642. generateJoint(joint: PhysicsImpostorJoint): void;
  32643. removeJoint(joint: PhysicsImpostorJoint): void;
  32644. isSupported(): boolean;
  32645. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32646. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32647. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32648. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32649. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32650. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32651. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32652. getBodyMass(impostor: PhysicsImpostor): number;
  32653. getBodyFriction(impostor: PhysicsImpostor): number;
  32654. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32655. getBodyRestitution(impostor: PhysicsImpostor): number;
  32656. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32657. getBodyPressure?(impostor: PhysicsImpostor): number;
  32658. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32659. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32660. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32661. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32662. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32663. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32664. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32665. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32666. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32667. sleepBody(impostor: PhysicsImpostor): void;
  32668. wakeUpBody(impostor: PhysicsImpostor): void;
  32669. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32670. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32671. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32672. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32673. getRadius(impostor: PhysicsImpostor): number;
  32674. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32675. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32676. dispose(): void;
  32677. }
  32678. /**
  32679. * Interface used to define a physics engine
  32680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32681. */
  32682. export interface IPhysicsEngine {
  32683. /**
  32684. * Gets the gravity vector used by the simulation
  32685. */
  32686. gravity: Vector3;
  32687. /**
  32688. * Sets the gravity vector used by the simulation
  32689. * @param gravity defines the gravity vector to use
  32690. */
  32691. setGravity(gravity: Vector3): void;
  32692. /**
  32693. * Set the time step of the physics engine.
  32694. * Default is 1/60.
  32695. * To slow it down, enter 1/600 for example.
  32696. * To speed it up, 1/30
  32697. * @param newTimeStep the new timestep to apply to this world.
  32698. */
  32699. setTimeStep(newTimeStep: number): void;
  32700. /**
  32701. * Get the time step of the physics engine.
  32702. * @returns the current time step
  32703. */
  32704. getTimeStep(): number;
  32705. /**
  32706. * Set the sub time step of the physics engine.
  32707. * Default is 0 meaning there is no sub steps
  32708. * To increase physics resolution precision, set a small value (like 1 ms)
  32709. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32710. */
  32711. setSubTimeStep(subTimeStep: number): void;
  32712. /**
  32713. * Get the sub time step of the physics engine.
  32714. * @returns the current sub time step
  32715. */
  32716. getSubTimeStep(): number;
  32717. /**
  32718. * Release all resources
  32719. */
  32720. dispose(): void;
  32721. /**
  32722. * Gets the name of the current physics plugin
  32723. * @returns the name of the plugin
  32724. */
  32725. getPhysicsPluginName(): string;
  32726. /**
  32727. * Adding a new impostor for the impostor tracking.
  32728. * This will be done by the impostor itself.
  32729. * @param impostor the impostor to add
  32730. */
  32731. addImpostor(impostor: PhysicsImpostor): void;
  32732. /**
  32733. * Remove an impostor from the engine.
  32734. * This impostor and its mesh will not longer be updated by the physics engine.
  32735. * @param impostor the impostor to remove
  32736. */
  32737. removeImpostor(impostor: PhysicsImpostor): void;
  32738. /**
  32739. * Add a joint to the physics engine
  32740. * @param mainImpostor defines the main impostor to which the joint is added.
  32741. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32742. * @param joint defines the joint that will connect both impostors.
  32743. */
  32744. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32745. /**
  32746. * Removes a joint from the simulation
  32747. * @param mainImpostor defines the impostor used with the joint
  32748. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32749. * @param joint defines the joint to remove
  32750. */
  32751. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32752. /**
  32753. * Gets the current plugin used to run the simulation
  32754. * @returns current plugin
  32755. */
  32756. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32757. /**
  32758. * Gets the list of physic impostors
  32759. * @returns an array of PhysicsImpostor
  32760. */
  32761. getImpostors(): Array<PhysicsImpostor>;
  32762. /**
  32763. * Gets the impostor for a physics enabled object
  32764. * @param object defines the object impersonated by the impostor
  32765. * @returns the PhysicsImpostor or null if not found
  32766. */
  32767. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32768. /**
  32769. * Gets the impostor for a physics body object
  32770. * @param body defines physics body used by the impostor
  32771. * @returns the PhysicsImpostor or null if not found
  32772. */
  32773. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32774. /**
  32775. * Does a raycast in the physics world
  32776. * @param from when should the ray start?
  32777. * @param to when should the ray end?
  32778. * @returns PhysicsRaycastResult
  32779. */
  32780. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32781. /**
  32782. * Called by the scene. No need to call it.
  32783. * @param delta defines the timespam between frames
  32784. */
  32785. _step(delta: number): void;
  32786. }
  32787. }
  32788. declare module "babylonjs/Physics/physicsImpostor" {
  32789. import { Nullable, IndicesArray } from "babylonjs/types";
  32790. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  32791. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32793. import { Scene } from "babylonjs/scene";
  32794. import { Bone } from "babylonjs/Bones/bone";
  32795. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32796. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  32797. import { Space } from "babylonjs/Maths/math.axis";
  32798. /**
  32799. * The interface for the physics imposter parameters
  32800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32801. */
  32802. export interface PhysicsImpostorParameters {
  32803. /**
  32804. * The mass of the physics imposter
  32805. */
  32806. mass: number;
  32807. /**
  32808. * The friction of the physics imposter
  32809. */
  32810. friction?: number;
  32811. /**
  32812. * The coefficient of restitution of the physics imposter
  32813. */
  32814. restitution?: number;
  32815. /**
  32816. * The native options of the physics imposter
  32817. */
  32818. nativeOptions?: any;
  32819. /**
  32820. * Specifies if the parent should be ignored
  32821. */
  32822. ignoreParent?: boolean;
  32823. /**
  32824. * Specifies if bi-directional transformations should be disabled
  32825. */
  32826. disableBidirectionalTransformation?: boolean;
  32827. /**
  32828. * The pressure inside the physics imposter, soft object only
  32829. */
  32830. pressure?: number;
  32831. /**
  32832. * The stiffness the physics imposter, soft object only
  32833. */
  32834. stiffness?: number;
  32835. /**
  32836. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32837. */
  32838. velocityIterations?: number;
  32839. /**
  32840. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32841. */
  32842. positionIterations?: number;
  32843. /**
  32844. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32845. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32846. * Add to fix multiple points
  32847. */
  32848. fixedPoints?: number;
  32849. /**
  32850. * The collision margin around a soft object
  32851. */
  32852. margin?: number;
  32853. /**
  32854. * The collision margin around a soft object
  32855. */
  32856. damping?: number;
  32857. /**
  32858. * The path for a rope based on an extrusion
  32859. */
  32860. path?: any;
  32861. /**
  32862. * The shape of an extrusion used for a rope based on an extrusion
  32863. */
  32864. shape?: any;
  32865. }
  32866. /**
  32867. * Interface for a physics-enabled object
  32868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32869. */
  32870. export interface IPhysicsEnabledObject {
  32871. /**
  32872. * The position of the physics-enabled object
  32873. */
  32874. position: Vector3;
  32875. /**
  32876. * The rotation of the physics-enabled object
  32877. */
  32878. rotationQuaternion: Nullable<Quaternion>;
  32879. /**
  32880. * The scale of the physics-enabled object
  32881. */
  32882. scaling: Vector3;
  32883. /**
  32884. * The rotation of the physics-enabled object
  32885. */
  32886. rotation?: Vector3;
  32887. /**
  32888. * The parent of the physics-enabled object
  32889. */
  32890. parent?: any;
  32891. /**
  32892. * The bounding info of the physics-enabled object
  32893. * @returns The bounding info of the physics-enabled object
  32894. */
  32895. getBoundingInfo(): BoundingInfo;
  32896. /**
  32897. * Computes the world matrix
  32898. * @param force Specifies if the world matrix should be computed by force
  32899. * @returns A world matrix
  32900. */
  32901. computeWorldMatrix(force: boolean): Matrix;
  32902. /**
  32903. * Gets the world matrix
  32904. * @returns A world matrix
  32905. */
  32906. getWorldMatrix?(): Matrix;
  32907. /**
  32908. * Gets the child meshes
  32909. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32910. * @returns An array of abstract meshes
  32911. */
  32912. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32913. /**
  32914. * Gets the vertex data
  32915. * @param kind The type of vertex data
  32916. * @returns A nullable array of numbers, or a float32 array
  32917. */
  32918. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32919. /**
  32920. * Gets the indices from the mesh
  32921. * @returns A nullable array of index arrays
  32922. */
  32923. getIndices?(): Nullable<IndicesArray>;
  32924. /**
  32925. * Gets the scene from the mesh
  32926. * @returns the indices array or null
  32927. */
  32928. getScene?(): Scene;
  32929. /**
  32930. * Gets the absolute position from the mesh
  32931. * @returns the absolute position
  32932. */
  32933. getAbsolutePosition(): Vector3;
  32934. /**
  32935. * Gets the absolute pivot point from the mesh
  32936. * @returns the absolute pivot point
  32937. */
  32938. getAbsolutePivotPoint(): Vector3;
  32939. /**
  32940. * Rotates the mesh
  32941. * @param axis The axis of rotation
  32942. * @param amount The amount of rotation
  32943. * @param space The space of the rotation
  32944. * @returns The rotation transform node
  32945. */
  32946. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32947. /**
  32948. * Translates the mesh
  32949. * @param axis The axis of translation
  32950. * @param distance The distance of translation
  32951. * @param space The space of the translation
  32952. * @returns The transform node
  32953. */
  32954. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32955. /**
  32956. * Sets the absolute position of the mesh
  32957. * @param absolutePosition The absolute position of the mesh
  32958. * @returns The transform node
  32959. */
  32960. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32961. /**
  32962. * Gets the class name of the mesh
  32963. * @returns The class name
  32964. */
  32965. getClassName(): string;
  32966. }
  32967. /**
  32968. * Represents a physics imposter
  32969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32970. */
  32971. export class PhysicsImpostor {
  32972. /**
  32973. * The physics-enabled object used as the physics imposter
  32974. */
  32975. object: IPhysicsEnabledObject;
  32976. /**
  32977. * The type of the physics imposter
  32978. */
  32979. type: number;
  32980. private _options;
  32981. private _scene?;
  32982. /**
  32983. * The default object size of the imposter
  32984. */
  32985. static DEFAULT_OBJECT_SIZE: Vector3;
  32986. /**
  32987. * The identity quaternion of the imposter
  32988. */
  32989. static IDENTITY_QUATERNION: Quaternion;
  32990. /** @hidden */
  32991. _pluginData: any;
  32992. private _physicsEngine;
  32993. private _physicsBody;
  32994. private _bodyUpdateRequired;
  32995. private _onBeforePhysicsStepCallbacks;
  32996. private _onAfterPhysicsStepCallbacks;
  32997. /** @hidden */
  32998. _onPhysicsCollideCallbacks: Array<{
  32999. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33000. otherImpostors: Array<PhysicsImpostor>;
  33001. }>;
  33002. private _deltaPosition;
  33003. private _deltaRotation;
  33004. private _deltaRotationConjugated;
  33005. /** @hidden */
  33006. _isFromLine: boolean;
  33007. private _parent;
  33008. private _isDisposed;
  33009. private static _tmpVecs;
  33010. private static _tmpQuat;
  33011. /**
  33012. * Specifies if the physics imposter is disposed
  33013. */
  33014. get isDisposed(): boolean;
  33015. /**
  33016. * Gets the mass of the physics imposter
  33017. */
  33018. get mass(): number;
  33019. set mass(value: number);
  33020. /**
  33021. * Gets the coefficient of friction
  33022. */
  33023. get friction(): number;
  33024. /**
  33025. * Sets the coefficient of friction
  33026. */
  33027. set friction(value: number);
  33028. /**
  33029. * Gets the coefficient of restitution
  33030. */
  33031. get restitution(): number;
  33032. /**
  33033. * Sets the coefficient of restitution
  33034. */
  33035. set restitution(value: number);
  33036. /**
  33037. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33038. */
  33039. get pressure(): number;
  33040. /**
  33041. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33042. */
  33043. set pressure(value: number);
  33044. /**
  33045. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33046. */
  33047. get stiffness(): number;
  33048. /**
  33049. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33050. */
  33051. set stiffness(value: number);
  33052. /**
  33053. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33054. */
  33055. get velocityIterations(): number;
  33056. /**
  33057. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33058. */
  33059. set velocityIterations(value: number);
  33060. /**
  33061. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33062. */
  33063. get positionIterations(): number;
  33064. /**
  33065. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33066. */
  33067. set positionIterations(value: number);
  33068. /**
  33069. * The unique id of the physics imposter
  33070. * set by the physics engine when adding this impostor to the array
  33071. */
  33072. uniqueId: number;
  33073. /**
  33074. * @hidden
  33075. */
  33076. soft: boolean;
  33077. /**
  33078. * @hidden
  33079. */
  33080. segments: number;
  33081. private _joints;
  33082. /**
  33083. * Initializes the physics imposter
  33084. * @param object The physics-enabled object used as the physics imposter
  33085. * @param type The type of the physics imposter
  33086. * @param _options The options for the physics imposter
  33087. * @param _scene The Babylon scene
  33088. */
  33089. constructor(
  33090. /**
  33091. * The physics-enabled object used as the physics imposter
  33092. */
  33093. object: IPhysicsEnabledObject,
  33094. /**
  33095. * The type of the physics imposter
  33096. */
  33097. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33098. /**
  33099. * This function will completly initialize this impostor.
  33100. * It will create a new body - but only if this mesh has no parent.
  33101. * If it has, this impostor will not be used other than to define the impostor
  33102. * of the child mesh.
  33103. * @hidden
  33104. */
  33105. _init(): void;
  33106. private _getPhysicsParent;
  33107. /**
  33108. * Should a new body be generated.
  33109. * @returns boolean specifying if body initialization is required
  33110. */
  33111. isBodyInitRequired(): boolean;
  33112. /**
  33113. * Sets the updated scaling
  33114. * @param updated Specifies if the scaling is updated
  33115. */
  33116. setScalingUpdated(): void;
  33117. /**
  33118. * Force a regeneration of this or the parent's impostor's body.
  33119. * Use under cautious - This will remove all joints already implemented.
  33120. */
  33121. forceUpdate(): void;
  33122. /**
  33123. * Gets the body that holds this impostor. Either its own, or its parent.
  33124. */
  33125. get physicsBody(): any;
  33126. /**
  33127. * Get the parent of the physics imposter
  33128. * @returns Physics imposter or null
  33129. */
  33130. get parent(): Nullable<PhysicsImpostor>;
  33131. /**
  33132. * Sets the parent of the physics imposter
  33133. */
  33134. set parent(value: Nullable<PhysicsImpostor>);
  33135. /**
  33136. * Set the physics body. Used mainly by the physics engine/plugin
  33137. */
  33138. set physicsBody(physicsBody: any);
  33139. /**
  33140. * Resets the update flags
  33141. */
  33142. resetUpdateFlags(): void;
  33143. /**
  33144. * Gets the object extend size
  33145. * @returns the object extend size
  33146. */
  33147. getObjectExtendSize(): Vector3;
  33148. /**
  33149. * Gets the object center
  33150. * @returns The object center
  33151. */
  33152. getObjectCenter(): Vector3;
  33153. /**
  33154. * Get a specific parameter from the options parameters
  33155. * @param paramName The object parameter name
  33156. * @returns The object parameter
  33157. */
  33158. getParam(paramName: string): any;
  33159. /**
  33160. * Sets a specific parameter in the options given to the physics plugin
  33161. * @param paramName The parameter name
  33162. * @param value The value of the parameter
  33163. */
  33164. setParam(paramName: string, value: number): void;
  33165. /**
  33166. * Specifically change the body's mass option. Won't recreate the physics body object
  33167. * @param mass The mass of the physics imposter
  33168. */
  33169. setMass(mass: number): void;
  33170. /**
  33171. * Gets the linear velocity
  33172. * @returns linear velocity or null
  33173. */
  33174. getLinearVelocity(): Nullable<Vector3>;
  33175. /**
  33176. * Sets the linear velocity
  33177. * @param velocity linear velocity or null
  33178. */
  33179. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33180. /**
  33181. * Gets the angular velocity
  33182. * @returns angular velocity or null
  33183. */
  33184. getAngularVelocity(): Nullable<Vector3>;
  33185. /**
  33186. * Sets the angular velocity
  33187. * @param velocity The velocity or null
  33188. */
  33189. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33190. /**
  33191. * Execute a function with the physics plugin native code
  33192. * Provide a function the will have two variables - the world object and the physics body object
  33193. * @param func The function to execute with the physics plugin native code
  33194. */
  33195. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33196. /**
  33197. * Register a function that will be executed before the physics world is stepping forward
  33198. * @param func The function to execute before the physics world is stepped forward
  33199. */
  33200. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33201. /**
  33202. * Unregister a function that will be executed before the physics world is stepping forward
  33203. * @param func The function to execute before the physics world is stepped forward
  33204. */
  33205. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33206. /**
  33207. * Register a function that will be executed after the physics step
  33208. * @param func The function to execute after physics step
  33209. */
  33210. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33211. /**
  33212. * Unregisters a function that will be executed after the physics step
  33213. * @param func The function to execute after physics step
  33214. */
  33215. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33216. /**
  33217. * register a function that will be executed when this impostor collides against a different body
  33218. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33219. * @param func Callback that is executed on collision
  33220. */
  33221. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33222. /**
  33223. * Unregisters the physics imposter on contact
  33224. * @param collideAgainst The physics object to collide against
  33225. * @param func Callback to execute on collision
  33226. */
  33227. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33228. private _tmpQuat;
  33229. private _tmpQuat2;
  33230. /**
  33231. * Get the parent rotation
  33232. * @returns The parent rotation
  33233. */
  33234. getParentsRotation(): Quaternion;
  33235. /**
  33236. * this function is executed by the physics engine.
  33237. */
  33238. beforeStep: () => void;
  33239. /**
  33240. * this function is executed by the physics engine
  33241. */
  33242. afterStep: () => void;
  33243. /**
  33244. * Legacy collision detection event support
  33245. */
  33246. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33247. /**
  33248. * event and body object due to cannon's event-based architecture.
  33249. */
  33250. onCollide: (e: {
  33251. body: any;
  33252. point: Nullable<Vector3>;
  33253. }) => void;
  33254. /**
  33255. * Apply a force
  33256. * @param force The force to apply
  33257. * @param contactPoint The contact point for the force
  33258. * @returns The physics imposter
  33259. */
  33260. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33261. /**
  33262. * Apply an impulse
  33263. * @param force The impulse force
  33264. * @param contactPoint The contact point for the impulse force
  33265. * @returns The physics imposter
  33266. */
  33267. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33268. /**
  33269. * A help function to create a joint
  33270. * @param otherImpostor A physics imposter used to create a joint
  33271. * @param jointType The type of joint
  33272. * @param jointData The data for the joint
  33273. * @returns The physics imposter
  33274. */
  33275. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33276. /**
  33277. * Add a joint to this impostor with a different impostor
  33278. * @param otherImpostor A physics imposter used to add a joint
  33279. * @param joint The joint to add
  33280. * @returns The physics imposter
  33281. */
  33282. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33283. /**
  33284. * Add an anchor to a cloth impostor
  33285. * @param otherImpostor rigid impostor to anchor to
  33286. * @param width ratio across width from 0 to 1
  33287. * @param height ratio up height from 0 to 1
  33288. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33289. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33290. * @returns impostor the soft imposter
  33291. */
  33292. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33293. /**
  33294. * Add a hook to a rope impostor
  33295. * @param otherImpostor rigid impostor to anchor to
  33296. * @param length ratio across rope from 0 to 1
  33297. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33298. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33299. * @returns impostor the rope imposter
  33300. */
  33301. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33302. /**
  33303. * Will keep this body still, in a sleep mode.
  33304. * @returns the physics imposter
  33305. */
  33306. sleep(): PhysicsImpostor;
  33307. /**
  33308. * Wake the body up.
  33309. * @returns The physics imposter
  33310. */
  33311. wakeUp(): PhysicsImpostor;
  33312. /**
  33313. * Clones the physics imposter
  33314. * @param newObject The physics imposter clones to this physics-enabled object
  33315. * @returns A nullable physics imposter
  33316. */
  33317. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33318. /**
  33319. * Disposes the physics imposter
  33320. */
  33321. dispose(): void;
  33322. /**
  33323. * Sets the delta position
  33324. * @param position The delta position amount
  33325. */
  33326. setDeltaPosition(position: Vector3): void;
  33327. /**
  33328. * Sets the delta rotation
  33329. * @param rotation The delta rotation amount
  33330. */
  33331. setDeltaRotation(rotation: Quaternion): void;
  33332. /**
  33333. * Gets the box size of the physics imposter and stores the result in the input parameter
  33334. * @param result Stores the box size
  33335. * @returns The physics imposter
  33336. */
  33337. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33338. /**
  33339. * Gets the radius of the physics imposter
  33340. * @returns Radius of the physics imposter
  33341. */
  33342. getRadius(): number;
  33343. /**
  33344. * Sync a bone with this impostor
  33345. * @param bone The bone to sync to the impostor.
  33346. * @param boneMesh The mesh that the bone is influencing.
  33347. * @param jointPivot The pivot of the joint / bone in local space.
  33348. * @param distToJoint Optional distance from the impostor to the joint.
  33349. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33350. */
  33351. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33352. /**
  33353. * Sync impostor to a bone
  33354. * @param bone The bone that the impostor will be synced to.
  33355. * @param boneMesh The mesh that the bone is influencing.
  33356. * @param jointPivot The pivot of the joint / bone in local space.
  33357. * @param distToJoint Optional distance from the impostor to the joint.
  33358. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33359. * @param boneAxis Optional vector3 axis the bone is aligned with
  33360. */
  33361. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33362. /**
  33363. * No-Imposter type
  33364. */
  33365. static NoImpostor: number;
  33366. /**
  33367. * Sphere-Imposter type
  33368. */
  33369. static SphereImpostor: number;
  33370. /**
  33371. * Box-Imposter type
  33372. */
  33373. static BoxImpostor: number;
  33374. /**
  33375. * Plane-Imposter type
  33376. */
  33377. static PlaneImpostor: number;
  33378. /**
  33379. * Mesh-imposter type
  33380. */
  33381. static MeshImpostor: number;
  33382. /**
  33383. * Capsule-Impostor type (Ammo.js plugin only)
  33384. */
  33385. static CapsuleImpostor: number;
  33386. /**
  33387. * Cylinder-Imposter type
  33388. */
  33389. static CylinderImpostor: number;
  33390. /**
  33391. * Particle-Imposter type
  33392. */
  33393. static ParticleImpostor: number;
  33394. /**
  33395. * Heightmap-Imposter type
  33396. */
  33397. static HeightmapImpostor: number;
  33398. /**
  33399. * ConvexHull-Impostor type (Ammo.js plugin only)
  33400. */
  33401. static ConvexHullImpostor: number;
  33402. /**
  33403. * Custom-Imposter type (Ammo.js plugin only)
  33404. */
  33405. static CustomImpostor: number;
  33406. /**
  33407. * Rope-Imposter type
  33408. */
  33409. static RopeImpostor: number;
  33410. /**
  33411. * Cloth-Imposter type
  33412. */
  33413. static ClothImpostor: number;
  33414. /**
  33415. * Softbody-Imposter type
  33416. */
  33417. static SoftbodyImpostor: number;
  33418. }
  33419. }
  33420. declare module "babylonjs/Meshes/mesh" {
  33421. import { Observable } from "babylonjs/Misc/observable";
  33422. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33423. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33424. import { Camera } from "babylonjs/Cameras/camera";
  33425. import { Scene } from "babylonjs/scene";
  33426. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33427. import { Color4 } from "babylonjs/Maths/math.color";
  33428. import { Engine } from "babylonjs/Engines/engine";
  33429. import { Node } from "babylonjs/node";
  33430. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33431. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33432. import { Buffer } from "babylonjs/Meshes/buffer";
  33433. import { Geometry } from "babylonjs/Meshes/geometry";
  33434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33435. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33436. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33437. import { Effect } from "babylonjs/Materials/effect";
  33438. import { Material } from "babylonjs/Materials/material";
  33439. import { Skeleton } from "babylonjs/Bones/skeleton";
  33440. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33441. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33442. import { Path3D } from "babylonjs/Maths/math.path";
  33443. import { Plane } from "babylonjs/Maths/math.plane";
  33444. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33445. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33446. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33447. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33448. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33449. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33450. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33451. /**
  33452. * @hidden
  33453. **/
  33454. export class _CreationDataStorage {
  33455. closePath?: boolean;
  33456. closeArray?: boolean;
  33457. idx: number[];
  33458. dashSize: number;
  33459. gapSize: number;
  33460. path3D: Path3D;
  33461. pathArray: Vector3[][];
  33462. arc: number;
  33463. radius: number;
  33464. cap: number;
  33465. tessellation: number;
  33466. }
  33467. /**
  33468. * @hidden
  33469. **/
  33470. class _InstanceDataStorage {
  33471. visibleInstances: any;
  33472. batchCache: _InstancesBatch;
  33473. instancesBufferSize: number;
  33474. instancesBuffer: Nullable<Buffer>;
  33475. instancesData: Float32Array;
  33476. overridenInstanceCount: number;
  33477. isFrozen: boolean;
  33478. previousBatch: Nullable<_InstancesBatch>;
  33479. hardwareInstancedRendering: boolean;
  33480. sideOrientation: number;
  33481. manualUpdate: boolean;
  33482. previousRenderId: number;
  33483. }
  33484. /**
  33485. * @hidden
  33486. **/
  33487. export class _InstancesBatch {
  33488. mustReturn: boolean;
  33489. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33490. renderSelf: boolean[];
  33491. hardwareInstancedRendering: boolean[];
  33492. }
  33493. /**
  33494. * @hidden
  33495. **/
  33496. class _ThinInstanceDataStorage {
  33497. instancesCount: number;
  33498. matrixBuffer: Nullable<Buffer>;
  33499. matrixBufferSize: number;
  33500. matrixData: Nullable<Float32Array>;
  33501. boundingVectors: Array<Vector3>;
  33502. worldMatrices: Nullable<Matrix[]>;
  33503. }
  33504. /**
  33505. * Class used to represent renderable models
  33506. */
  33507. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33508. /**
  33509. * Mesh side orientation : usually the external or front surface
  33510. */
  33511. static readonly FRONTSIDE: number;
  33512. /**
  33513. * Mesh side orientation : usually the internal or back surface
  33514. */
  33515. static readonly BACKSIDE: number;
  33516. /**
  33517. * Mesh side orientation : both internal and external or front and back surfaces
  33518. */
  33519. static readonly DOUBLESIDE: number;
  33520. /**
  33521. * Mesh side orientation : by default, `FRONTSIDE`
  33522. */
  33523. static readonly DEFAULTSIDE: number;
  33524. /**
  33525. * Mesh cap setting : no cap
  33526. */
  33527. static readonly NO_CAP: number;
  33528. /**
  33529. * Mesh cap setting : one cap at the beginning of the mesh
  33530. */
  33531. static readonly CAP_START: number;
  33532. /**
  33533. * Mesh cap setting : one cap at the end of the mesh
  33534. */
  33535. static readonly CAP_END: number;
  33536. /**
  33537. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33538. */
  33539. static readonly CAP_ALL: number;
  33540. /**
  33541. * Mesh pattern setting : no flip or rotate
  33542. */
  33543. static readonly NO_FLIP: number;
  33544. /**
  33545. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33546. */
  33547. static readonly FLIP_TILE: number;
  33548. /**
  33549. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33550. */
  33551. static readonly ROTATE_TILE: number;
  33552. /**
  33553. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33554. */
  33555. static readonly FLIP_ROW: number;
  33556. /**
  33557. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33558. */
  33559. static readonly ROTATE_ROW: number;
  33560. /**
  33561. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33562. */
  33563. static readonly FLIP_N_ROTATE_TILE: number;
  33564. /**
  33565. * Mesh pattern setting : rotate pattern and rotate
  33566. */
  33567. static readonly FLIP_N_ROTATE_ROW: number;
  33568. /**
  33569. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33570. */
  33571. static readonly CENTER: number;
  33572. /**
  33573. * Mesh tile positioning : part tiles on left
  33574. */
  33575. static readonly LEFT: number;
  33576. /**
  33577. * Mesh tile positioning : part tiles on right
  33578. */
  33579. static readonly RIGHT: number;
  33580. /**
  33581. * Mesh tile positioning : part tiles on top
  33582. */
  33583. static readonly TOP: number;
  33584. /**
  33585. * Mesh tile positioning : part tiles on bottom
  33586. */
  33587. static readonly BOTTOM: number;
  33588. /**
  33589. * Gets the default side orientation.
  33590. * @param orientation the orientation to value to attempt to get
  33591. * @returns the default orientation
  33592. * @hidden
  33593. */
  33594. static _GetDefaultSideOrientation(orientation?: number): number;
  33595. private _internalMeshDataInfo;
  33596. get computeBonesUsingShaders(): boolean;
  33597. set computeBonesUsingShaders(value: boolean);
  33598. /**
  33599. * An event triggered before rendering the mesh
  33600. */
  33601. get onBeforeRenderObservable(): Observable<Mesh>;
  33602. /**
  33603. * An event triggered before binding the mesh
  33604. */
  33605. get onBeforeBindObservable(): Observable<Mesh>;
  33606. /**
  33607. * An event triggered after rendering the mesh
  33608. */
  33609. get onAfterRenderObservable(): Observable<Mesh>;
  33610. /**
  33611. * An event triggered before drawing the mesh
  33612. */
  33613. get onBeforeDrawObservable(): Observable<Mesh>;
  33614. private _onBeforeDrawObserver;
  33615. /**
  33616. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33617. */
  33618. set onBeforeDraw(callback: () => void);
  33619. get hasInstances(): boolean;
  33620. get hasThinInstances(): boolean;
  33621. /**
  33622. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33623. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33624. */
  33625. delayLoadState: number;
  33626. /**
  33627. * Gets the list of instances created from this mesh
  33628. * it is not supposed to be modified manually.
  33629. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33630. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33631. */
  33632. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  33633. /**
  33634. * Gets the file containing delay loading data for this mesh
  33635. */
  33636. delayLoadingFile: string;
  33637. /** @hidden */
  33638. _binaryInfo: any;
  33639. /**
  33640. * User defined function used to change how LOD level selection is done
  33641. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33642. */
  33643. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33644. /**
  33645. * Gets or sets the morph target manager
  33646. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33647. */
  33648. get morphTargetManager(): Nullable<MorphTargetManager>;
  33649. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33650. /** @hidden */
  33651. _creationDataStorage: Nullable<_CreationDataStorage>;
  33652. /** @hidden */
  33653. _geometry: Nullable<Geometry>;
  33654. /** @hidden */
  33655. _delayInfo: Array<string>;
  33656. /** @hidden */
  33657. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33658. /** @hidden */
  33659. _instanceDataStorage: _InstanceDataStorage;
  33660. /** @hidden */
  33661. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33662. private _effectiveMaterial;
  33663. /** @hidden */
  33664. _shouldGenerateFlatShading: boolean;
  33665. /** @hidden */
  33666. _originalBuilderSideOrientation: number;
  33667. /**
  33668. * Use this property to change the original side orientation defined at construction time
  33669. */
  33670. overrideMaterialSideOrientation: Nullable<number>;
  33671. /**
  33672. * Gets the source mesh (the one used to clone this one from)
  33673. */
  33674. get source(): Nullable<Mesh>;
  33675. /**
  33676. * Gets the list of clones of this mesh
  33677. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33678. * Note that useClonedMeshMap=true is the default setting
  33679. */
  33680. get cloneMeshMap(): Nullable<{
  33681. [id: string]: Mesh | undefined;
  33682. }>;
  33683. /**
  33684. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33685. */
  33686. get isUnIndexed(): boolean;
  33687. set isUnIndexed(value: boolean);
  33688. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33689. get worldMatrixInstancedBuffer(): Float32Array;
  33690. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33691. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33692. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33693. /**
  33694. * @constructor
  33695. * @param name The value used by scene.getMeshByName() to do a lookup.
  33696. * @param scene The scene to add this mesh to.
  33697. * @param parent The parent of this mesh, if it has one
  33698. * @param source An optional Mesh from which geometry is shared, cloned.
  33699. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33700. * When false, achieved by calling a clone(), also passing False.
  33701. * This will make creation of children, recursive.
  33702. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33703. */
  33704. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33705. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33706. doNotInstantiate: boolean;
  33707. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33708. /**
  33709. * Gets the class name
  33710. * @returns the string "Mesh".
  33711. */
  33712. getClassName(): string;
  33713. /** @hidden */
  33714. get _isMesh(): boolean;
  33715. /**
  33716. * Returns a description of this mesh
  33717. * @param fullDetails define if full details about this mesh must be used
  33718. * @returns a descriptive string representing this mesh
  33719. */
  33720. toString(fullDetails?: boolean): string;
  33721. /** @hidden */
  33722. _unBindEffect(): void;
  33723. /**
  33724. * Gets a boolean indicating if this mesh has LOD
  33725. */
  33726. get hasLODLevels(): boolean;
  33727. /**
  33728. * Gets the list of MeshLODLevel associated with the current mesh
  33729. * @returns an array of MeshLODLevel
  33730. */
  33731. getLODLevels(): MeshLODLevel[];
  33732. private _sortLODLevels;
  33733. /**
  33734. * Add a mesh as LOD level triggered at the given distance.
  33735. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33736. * @param distance The distance from the center of the object to show this level
  33737. * @param mesh The mesh to be added as LOD level (can be null)
  33738. * @return This mesh (for chaining)
  33739. */
  33740. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33741. /**
  33742. * Returns the LOD level mesh at the passed distance or null if not found.
  33743. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33744. * @param distance The distance from the center of the object to show this level
  33745. * @returns a Mesh or `null`
  33746. */
  33747. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33748. /**
  33749. * Remove a mesh from the LOD array
  33750. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33751. * @param mesh defines the mesh to be removed
  33752. * @return This mesh (for chaining)
  33753. */
  33754. removeLODLevel(mesh: Mesh): Mesh;
  33755. /**
  33756. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33757. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33758. * @param camera defines the camera to use to compute distance
  33759. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33760. * @return This mesh (for chaining)
  33761. */
  33762. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33763. /**
  33764. * Gets the mesh internal Geometry object
  33765. */
  33766. get geometry(): Nullable<Geometry>;
  33767. /**
  33768. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33769. * @returns the total number of vertices
  33770. */
  33771. getTotalVertices(): number;
  33772. /**
  33773. * Returns the content of an associated vertex buffer
  33774. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33775. * - VertexBuffer.PositionKind
  33776. * - VertexBuffer.UVKind
  33777. * - VertexBuffer.UV2Kind
  33778. * - VertexBuffer.UV3Kind
  33779. * - VertexBuffer.UV4Kind
  33780. * - VertexBuffer.UV5Kind
  33781. * - VertexBuffer.UV6Kind
  33782. * - VertexBuffer.ColorKind
  33783. * - VertexBuffer.MatricesIndicesKind
  33784. * - VertexBuffer.MatricesIndicesExtraKind
  33785. * - VertexBuffer.MatricesWeightsKind
  33786. * - VertexBuffer.MatricesWeightsExtraKind
  33787. * @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
  33788. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33789. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33790. */
  33791. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33792. /**
  33793. * Returns the mesh VertexBuffer object from the requested `kind`
  33794. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33795. * - VertexBuffer.PositionKind
  33796. * - VertexBuffer.NormalKind
  33797. * - VertexBuffer.UVKind
  33798. * - VertexBuffer.UV2Kind
  33799. * - VertexBuffer.UV3Kind
  33800. * - VertexBuffer.UV4Kind
  33801. * - VertexBuffer.UV5Kind
  33802. * - VertexBuffer.UV6Kind
  33803. * - VertexBuffer.ColorKind
  33804. * - VertexBuffer.MatricesIndicesKind
  33805. * - VertexBuffer.MatricesIndicesExtraKind
  33806. * - VertexBuffer.MatricesWeightsKind
  33807. * - VertexBuffer.MatricesWeightsExtraKind
  33808. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33809. */
  33810. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33811. /**
  33812. * Tests if a specific vertex buffer is associated with this mesh
  33813. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33814. * - VertexBuffer.PositionKind
  33815. * - VertexBuffer.NormalKind
  33816. * - VertexBuffer.UVKind
  33817. * - VertexBuffer.UV2Kind
  33818. * - VertexBuffer.UV3Kind
  33819. * - VertexBuffer.UV4Kind
  33820. * - VertexBuffer.UV5Kind
  33821. * - VertexBuffer.UV6Kind
  33822. * - VertexBuffer.ColorKind
  33823. * - VertexBuffer.MatricesIndicesKind
  33824. * - VertexBuffer.MatricesIndicesExtraKind
  33825. * - VertexBuffer.MatricesWeightsKind
  33826. * - VertexBuffer.MatricesWeightsExtraKind
  33827. * @returns a boolean
  33828. */
  33829. isVerticesDataPresent(kind: string): boolean;
  33830. /**
  33831. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33832. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33833. * - VertexBuffer.PositionKind
  33834. * - VertexBuffer.UVKind
  33835. * - VertexBuffer.UV2Kind
  33836. * - VertexBuffer.UV3Kind
  33837. * - VertexBuffer.UV4Kind
  33838. * - VertexBuffer.UV5Kind
  33839. * - VertexBuffer.UV6Kind
  33840. * - VertexBuffer.ColorKind
  33841. * - VertexBuffer.MatricesIndicesKind
  33842. * - VertexBuffer.MatricesIndicesExtraKind
  33843. * - VertexBuffer.MatricesWeightsKind
  33844. * - VertexBuffer.MatricesWeightsExtraKind
  33845. * @returns a boolean
  33846. */
  33847. isVertexBufferUpdatable(kind: string): boolean;
  33848. /**
  33849. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33850. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33851. * - VertexBuffer.PositionKind
  33852. * - VertexBuffer.NormalKind
  33853. * - VertexBuffer.UVKind
  33854. * - VertexBuffer.UV2Kind
  33855. * - VertexBuffer.UV3Kind
  33856. * - VertexBuffer.UV4Kind
  33857. * - VertexBuffer.UV5Kind
  33858. * - VertexBuffer.UV6Kind
  33859. * - VertexBuffer.ColorKind
  33860. * - VertexBuffer.MatricesIndicesKind
  33861. * - VertexBuffer.MatricesIndicesExtraKind
  33862. * - VertexBuffer.MatricesWeightsKind
  33863. * - VertexBuffer.MatricesWeightsExtraKind
  33864. * @returns an array of strings
  33865. */
  33866. getVerticesDataKinds(): string[];
  33867. /**
  33868. * Returns a positive integer : the total number of indices in this mesh geometry.
  33869. * @returns the numner of indices or zero if the mesh has no geometry.
  33870. */
  33871. getTotalIndices(): number;
  33872. /**
  33873. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33874. * @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.
  33875. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33876. * @returns the indices array or an empty array if the mesh has no geometry
  33877. */
  33878. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33879. get isBlocked(): boolean;
  33880. /**
  33881. * Determine if the current mesh is ready to be rendered
  33882. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33883. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33884. * @returns true if all associated assets are ready (material, textures, shaders)
  33885. */
  33886. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33887. /**
  33888. * 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.
  33889. */
  33890. get areNormalsFrozen(): boolean;
  33891. /**
  33892. * 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.
  33893. * @returns the current mesh
  33894. */
  33895. freezeNormals(): Mesh;
  33896. /**
  33897. * 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
  33898. * @returns the current mesh
  33899. */
  33900. unfreezeNormals(): Mesh;
  33901. /**
  33902. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33903. */
  33904. set overridenInstanceCount(count: number);
  33905. /** @hidden */
  33906. _preActivate(): Mesh;
  33907. /** @hidden */
  33908. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33909. /** @hidden */
  33910. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33911. protected _afterComputeWorldMatrix(): void;
  33912. /** @hidden */
  33913. _postActivate(): void;
  33914. /**
  33915. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33916. * This means the mesh underlying bounding box and sphere are recomputed.
  33917. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33918. * @returns the current mesh
  33919. */
  33920. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33921. /** @hidden */
  33922. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33923. /**
  33924. * This function will subdivide the mesh into multiple submeshes
  33925. * @param count defines the expected number of submeshes
  33926. */
  33927. subdivide(count: number): void;
  33928. /**
  33929. * Copy a FloatArray into a specific associated vertex buffer
  33930. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33931. * - VertexBuffer.PositionKind
  33932. * - VertexBuffer.UVKind
  33933. * - VertexBuffer.UV2Kind
  33934. * - VertexBuffer.UV3Kind
  33935. * - VertexBuffer.UV4Kind
  33936. * - VertexBuffer.UV5Kind
  33937. * - VertexBuffer.UV6Kind
  33938. * - VertexBuffer.ColorKind
  33939. * - VertexBuffer.MatricesIndicesKind
  33940. * - VertexBuffer.MatricesIndicesExtraKind
  33941. * - VertexBuffer.MatricesWeightsKind
  33942. * - VertexBuffer.MatricesWeightsExtraKind
  33943. * @param data defines the data source
  33944. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33945. * @param stride defines the data stride size (can be null)
  33946. * @returns the current mesh
  33947. */
  33948. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33949. /**
  33950. * Delete a vertex buffer associated with this mesh
  33951. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33952. * - VertexBuffer.PositionKind
  33953. * - VertexBuffer.UVKind
  33954. * - VertexBuffer.UV2Kind
  33955. * - VertexBuffer.UV3Kind
  33956. * - VertexBuffer.UV4Kind
  33957. * - VertexBuffer.UV5Kind
  33958. * - VertexBuffer.UV6Kind
  33959. * - VertexBuffer.ColorKind
  33960. * - VertexBuffer.MatricesIndicesKind
  33961. * - VertexBuffer.MatricesIndicesExtraKind
  33962. * - VertexBuffer.MatricesWeightsKind
  33963. * - VertexBuffer.MatricesWeightsExtraKind
  33964. */
  33965. removeVerticesData(kind: string): void;
  33966. /**
  33967. * Flags an associated vertex buffer as updatable
  33968. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33969. * - VertexBuffer.PositionKind
  33970. * - VertexBuffer.UVKind
  33971. * - VertexBuffer.UV2Kind
  33972. * - VertexBuffer.UV3Kind
  33973. * - VertexBuffer.UV4Kind
  33974. * - VertexBuffer.UV5Kind
  33975. * - VertexBuffer.UV6Kind
  33976. * - VertexBuffer.ColorKind
  33977. * - VertexBuffer.MatricesIndicesKind
  33978. * - VertexBuffer.MatricesIndicesExtraKind
  33979. * - VertexBuffer.MatricesWeightsKind
  33980. * - VertexBuffer.MatricesWeightsExtraKind
  33981. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33982. */
  33983. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33984. /**
  33985. * Sets the mesh global Vertex Buffer
  33986. * @param buffer defines the buffer to use
  33987. * @returns the current mesh
  33988. */
  33989. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33990. /**
  33991. * Update a specific associated vertex buffer
  33992. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33993. * - VertexBuffer.PositionKind
  33994. * - VertexBuffer.UVKind
  33995. * - VertexBuffer.UV2Kind
  33996. * - VertexBuffer.UV3Kind
  33997. * - VertexBuffer.UV4Kind
  33998. * - VertexBuffer.UV5Kind
  33999. * - VertexBuffer.UV6Kind
  34000. * - VertexBuffer.ColorKind
  34001. * - VertexBuffer.MatricesIndicesKind
  34002. * - VertexBuffer.MatricesIndicesExtraKind
  34003. * - VertexBuffer.MatricesWeightsKind
  34004. * - VertexBuffer.MatricesWeightsExtraKind
  34005. * @param data defines the data source
  34006. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34007. * @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)
  34008. * @returns the current mesh
  34009. */
  34010. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34011. /**
  34012. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34013. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34014. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34015. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34016. * @returns the current mesh
  34017. */
  34018. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34019. /**
  34020. * Creates a un-shared specific occurence of the geometry for the mesh.
  34021. * @returns the current mesh
  34022. */
  34023. makeGeometryUnique(): Mesh;
  34024. /**
  34025. * Set the index buffer of this mesh
  34026. * @param indices defines the source data
  34027. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34028. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34029. * @returns the current mesh
  34030. */
  34031. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34032. /**
  34033. * Update the current index buffer
  34034. * @param indices defines the source data
  34035. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34036. * @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)
  34037. * @returns the current mesh
  34038. */
  34039. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34040. /**
  34041. * Invert the geometry to move from a right handed system to a left handed one.
  34042. * @returns the current mesh
  34043. */
  34044. toLeftHanded(): Mesh;
  34045. /** @hidden */
  34046. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34047. /** @hidden */
  34048. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34049. /**
  34050. * Registers for this mesh a javascript function called just before the rendering process
  34051. * @param func defines the function to call before rendering this mesh
  34052. * @returns the current mesh
  34053. */
  34054. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34055. /**
  34056. * Disposes a previously registered javascript function called before the rendering
  34057. * @param func defines the function to remove
  34058. * @returns the current mesh
  34059. */
  34060. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34061. /**
  34062. * Registers for this mesh a javascript function called just after the rendering is complete
  34063. * @param func defines the function to call after rendering this mesh
  34064. * @returns the current mesh
  34065. */
  34066. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34067. /**
  34068. * Disposes a previously registered javascript function called after the rendering.
  34069. * @param func defines the function to remove
  34070. * @returns the current mesh
  34071. */
  34072. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34073. /** @hidden */
  34074. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34075. /** @hidden */
  34076. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34077. /** @hidden */
  34078. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34079. /** @hidden */
  34080. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34081. /** @hidden */
  34082. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34083. /** @hidden */
  34084. _rebuild(): void;
  34085. /** @hidden */
  34086. _freeze(): void;
  34087. /** @hidden */
  34088. _unFreeze(): void;
  34089. /**
  34090. * 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
  34091. * @param subMesh defines the subMesh to render
  34092. * @param enableAlphaMode defines if alpha mode can be changed
  34093. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34094. * @returns the current mesh
  34095. */
  34096. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34097. private _onBeforeDraw;
  34098. /**
  34099. * Renormalize the mesh and patch it up if there are no weights
  34100. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34101. * However in the case of zero weights then we set just a single influence to 1.
  34102. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34103. */
  34104. cleanMatrixWeights(): void;
  34105. private normalizeSkinFourWeights;
  34106. private normalizeSkinWeightsAndExtra;
  34107. /**
  34108. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34109. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34110. * the user know there was an issue with importing the mesh
  34111. * @returns a validation object with skinned, valid and report string
  34112. */
  34113. validateSkinning(): {
  34114. skinned: boolean;
  34115. valid: boolean;
  34116. report: string;
  34117. };
  34118. /** @hidden */
  34119. _checkDelayState(): Mesh;
  34120. private _queueLoad;
  34121. /**
  34122. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34123. * A mesh is in the frustum if its bounding box intersects the frustum
  34124. * @param frustumPlanes defines the frustum to test
  34125. * @returns true if the mesh is in the frustum planes
  34126. */
  34127. isInFrustum(frustumPlanes: Plane[]): boolean;
  34128. /**
  34129. * Sets the mesh material by the material or multiMaterial `id` property
  34130. * @param id is a string identifying the material or the multiMaterial
  34131. * @returns the current mesh
  34132. */
  34133. setMaterialByID(id: string): Mesh;
  34134. /**
  34135. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34136. * @returns an array of IAnimatable
  34137. */
  34138. getAnimatables(): IAnimatable[];
  34139. /**
  34140. * Modifies the mesh geometry according to the passed transformation matrix.
  34141. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34142. * The mesh normals are modified using the same transformation.
  34143. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34144. * @param transform defines the transform matrix to use
  34145. * @see https://doc.babylonjs.com/resources/baking_transformations
  34146. * @returns the current mesh
  34147. */
  34148. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34149. /**
  34150. * Modifies the mesh geometry according to its own current World Matrix.
  34151. * The mesh World Matrix is then reset.
  34152. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34153. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34154. * @see https://doc.babylonjs.com/resources/baking_transformations
  34155. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34156. * @returns the current mesh
  34157. */
  34158. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34159. /** @hidden */
  34160. get _positions(): Nullable<Vector3[]>;
  34161. /** @hidden */
  34162. _resetPointsArrayCache(): Mesh;
  34163. /** @hidden */
  34164. _generatePointsArray(): boolean;
  34165. /**
  34166. * Returns a new Mesh object generated from the current mesh properties.
  34167. * This method must not get confused with createInstance()
  34168. * @param name is a string, the name given to the new mesh
  34169. * @param newParent can be any Node object (default `null`)
  34170. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34171. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34172. * @returns a new mesh
  34173. */
  34174. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34175. /**
  34176. * Releases resources associated with this mesh.
  34177. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34178. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34179. */
  34180. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34181. /** @hidden */
  34182. _disposeInstanceSpecificData(): void;
  34183. /** @hidden */
  34184. _disposeThinInstanceSpecificData(): void;
  34185. /**
  34186. * Modifies the mesh geometry according to a displacement map.
  34187. * 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.
  34188. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34189. * @param url is a string, the URL from the image file is to be downloaded.
  34190. * @param minHeight is the lower limit of the displacement.
  34191. * @param maxHeight is the upper limit of the displacement.
  34192. * @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.
  34193. * @param uvOffset is an optional vector2 used to offset UV.
  34194. * @param uvScale is an optional vector2 used to scale UV.
  34195. * @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.
  34196. * @returns the Mesh.
  34197. */
  34198. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34199. /**
  34200. * Modifies the mesh geometry according to a displacementMap buffer.
  34201. * 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.
  34202. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34203. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34204. * @param heightMapWidth is the width of the buffer image.
  34205. * @param heightMapHeight is the height of the buffer image.
  34206. * @param minHeight is the lower limit of the displacement.
  34207. * @param maxHeight is the upper limit of the displacement.
  34208. * @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.
  34209. * @param uvOffset is an optional vector2 used to offset UV.
  34210. * @param uvScale is an optional vector2 used to scale UV.
  34211. * @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.
  34212. * @returns the Mesh.
  34213. */
  34214. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34215. /**
  34216. * Modify the mesh to get a flat shading rendering.
  34217. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34218. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34219. * @returns current mesh
  34220. */
  34221. convertToFlatShadedMesh(): Mesh;
  34222. /**
  34223. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34224. * In other words, more vertices, no more indices and a single bigger VBO.
  34225. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34226. * @returns current mesh
  34227. */
  34228. convertToUnIndexedMesh(): Mesh;
  34229. /**
  34230. * Inverses facet orientations.
  34231. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34232. * @param flipNormals will also inverts the normals
  34233. * @returns current mesh
  34234. */
  34235. flipFaces(flipNormals?: boolean): Mesh;
  34236. /**
  34237. * Increase the number of facets and hence vertices in a mesh
  34238. * Vertex normals are interpolated from existing vertex normals
  34239. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34240. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34241. */
  34242. increaseVertices(numberPerEdge: number): void;
  34243. /**
  34244. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34245. * This will undo any application of covertToFlatShadedMesh
  34246. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34247. */
  34248. forceSharedVertices(): void;
  34249. /** @hidden */
  34250. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34251. /** @hidden */
  34252. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34253. /**
  34254. * Creates a new InstancedMesh object from the mesh model.
  34255. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34256. * @param name defines the name of the new instance
  34257. * @returns a new InstancedMesh
  34258. */
  34259. createInstance(name: string): InstancedMesh;
  34260. /**
  34261. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34262. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34263. * @returns the current mesh
  34264. */
  34265. synchronizeInstances(): Mesh;
  34266. /**
  34267. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34268. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34269. * This should be used together with the simplification to avoid disappearing triangles.
  34270. * @param successCallback an optional success callback to be called after the optimization finished.
  34271. * @returns the current mesh
  34272. */
  34273. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34274. /**
  34275. * Serialize current mesh
  34276. * @param serializationObject defines the object which will receive the serialization data
  34277. */
  34278. serialize(serializationObject: any): void;
  34279. /** @hidden */
  34280. _syncGeometryWithMorphTargetManager(): void;
  34281. /** @hidden */
  34282. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34283. /**
  34284. * Returns a new Mesh object parsed from the source provided.
  34285. * @param parsedMesh is the source
  34286. * @param scene defines the hosting scene
  34287. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34288. * @returns a new Mesh
  34289. */
  34290. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34291. /**
  34292. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34293. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34294. * @param name defines the name of the mesh to create
  34295. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34296. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34297. * @param closePath creates a seam between the first and the last points of each path of the path array
  34298. * @param offset is taken in account only if the `pathArray` is containing a single path
  34299. * @param scene defines the hosting scene
  34300. * @param updatable defines if the mesh must be flagged as updatable
  34301. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34302. * @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)
  34303. * @returns a new Mesh
  34304. */
  34305. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34306. /**
  34307. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34308. * @param name defines the name of the mesh to create
  34309. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34310. * @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
  34311. * @param scene defines the hosting scene
  34312. * @param updatable defines if the mesh must be flagged as updatable
  34313. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34314. * @returns a new Mesh
  34315. */
  34316. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34317. /**
  34318. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34319. * @param name defines the name of the mesh to create
  34320. * @param size sets the size (float) of each box side (default 1)
  34321. * @param scene defines the hosting scene
  34322. * @param updatable defines if the mesh must be flagged as updatable
  34323. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34324. * @returns a new Mesh
  34325. */
  34326. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34327. /**
  34328. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34329. * @param name defines the name of the mesh to create
  34330. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34331. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34332. * @param scene defines the hosting scene
  34333. * @param updatable defines if the mesh must be flagged as updatable
  34334. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34335. * @returns a new Mesh
  34336. */
  34337. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34338. /**
  34339. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34340. * @param name defines the name of the mesh to create
  34341. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34342. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34343. * @param scene defines the hosting scene
  34344. * @returns a new Mesh
  34345. */
  34346. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34347. /**
  34348. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34349. * @param name defines the name of the mesh to create
  34350. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34351. * @param diameterTop set the top cap diameter (floats, default 1)
  34352. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34353. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34354. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34355. * @param scene defines the hosting scene
  34356. * @param updatable defines if the mesh must be flagged as updatable
  34357. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34358. * @returns a new Mesh
  34359. */
  34360. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34361. /**
  34362. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34363. * @param name defines the name of the mesh to create
  34364. * @param diameter sets the diameter size (float) of the torus (default 1)
  34365. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34366. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34367. * @param scene defines the hosting scene
  34368. * @param updatable defines if the mesh must be flagged as updatable
  34369. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34370. * @returns a new Mesh
  34371. */
  34372. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34373. /**
  34374. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34375. * @param name defines the name of the mesh to create
  34376. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34377. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34378. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34379. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34380. * @param p the number of windings on X axis (positive integers, default 2)
  34381. * @param q the number of windings on Y axis (positive integers, default 3)
  34382. * @param scene defines the hosting scene
  34383. * @param updatable defines if the mesh must be flagged as updatable
  34384. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34385. * @returns a new Mesh
  34386. */
  34387. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34388. /**
  34389. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34390. * @param name defines the name of the mesh to create
  34391. * @param points is an array successive Vector3
  34392. * @param scene defines the hosting scene
  34393. * @param updatable defines if the mesh must be flagged as updatable
  34394. * @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).
  34395. * @returns a new Mesh
  34396. */
  34397. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34398. /**
  34399. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34400. * @param name defines the name of the mesh to create
  34401. * @param points is an array successive Vector3
  34402. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34403. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34404. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34405. * @param scene defines the hosting scene
  34406. * @param updatable defines if the mesh must be flagged as updatable
  34407. * @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)
  34408. * @returns a new Mesh
  34409. */
  34410. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34411. /**
  34412. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34413. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34414. * 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.
  34415. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34416. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34417. * Remember you can only change the shape positions, not their number when updating a polygon.
  34418. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34419. * @param name defines the name of the mesh to create
  34420. * @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
  34421. * @param scene defines the hosting scene
  34422. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34423. * @param updatable defines if the mesh must be flagged as updatable
  34424. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34425. * @param earcutInjection can be used to inject your own earcut reference
  34426. * @returns a new Mesh
  34427. */
  34428. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34429. /**
  34430. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34432. * @param name defines the name of the mesh to create
  34433. * @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
  34434. * @param depth defines the height of extrusion
  34435. * @param scene defines the hosting scene
  34436. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34437. * @param updatable defines if the mesh must be flagged as updatable
  34438. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34439. * @param earcutInjection can be used to inject your own earcut reference
  34440. * @returns a new Mesh
  34441. */
  34442. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34443. /**
  34444. * Creates an extruded shape mesh.
  34445. * 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
  34446. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34448. * @param name defines the name of the mesh to create
  34449. * @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
  34450. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34451. * @param scale is the value to scale the shape
  34452. * @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
  34453. * @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
  34454. * @param scene defines the hosting scene
  34455. * @param updatable defines if the mesh must be flagged as updatable
  34456. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34457. * @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)
  34458. * @returns a new Mesh
  34459. */
  34460. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34461. /**
  34462. * Creates an custom extruded shape mesh.
  34463. * The custom extrusion is a parametric shape.
  34464. * It has no predefined shape. Its final shape will depend on the input parameters.
  34465. * Please consider using the same method from the MeshBuilder class instead
  34466. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34467. * @param name defines the name of the mesh to create
  34468. * @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
  34469. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34470. * @param scaleFunction is a custom Javascript function called on each path point
  34471. * @param rotationFunction is a custom Javascript function called on each path point
  34472. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34473. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34474. * @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
  34475. * @param scene defines the hosting scene
  34476. * @param updatable defines if the mesh must be flagged as updatable
  34477. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34478. * @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)
  34479. * @returns a new Mesh
  34480. */
  34481. 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;
  34482. /**
  34483. * Creates lathe mesh.
  34484. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34485. * Please consider using the same method from the MeshBuilder class instead
  34486. * @param name defines the name of the mesh to create
  34487. * @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
  34488. * @param radius is the radius value of the lathe
  34489. * @param tessellation is the side number of the lathe.
  34490. * @param scene defines the hosting scene
  34491. * @param updatable defines if the mesh must be flagged as updatable
  34492. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34493. * @returns a new Mesh
  34494. */
  34495. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34496. /**
  34497. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34498. * @param name defines the name of the mesh to create
  34499. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34500. * @param scene defines the hosting scene
  34501. * @param updatable defines if the mesh must be flagged as updatable
  34502. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34503. * @returns a new Mesh
  34504. */
  34505. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34506. /**
  34507. * Creates a ground mesh.
  34508. * Please consider using the same method from the MeshBuilder class instead
  34509. * @param name defines the name of the mesh to create
  34510. * @param width set the width of the ground
  34511. * @param height set the height of the ground
  34512. * @param subdivisions sets the number of subdivisions per side
  34513. * @param scene defines the hosting scene
  34514. * @param updatable defines if the mesh must be flagged as updatable
  34515. * @returns a new Mesh
  34516. */
  34517. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34518. /**
  34519. * Creates a tiled ground mesh.
  34520. * Please consider using the same method from the MeshBuilder class instead
  34521. * @param name defines the name of the mesh to create
  34522. * @param xmin set the ground minimum X coordinate
  34523. * @param zmin set the ground minimum Y coordinate
  34524. * @param xmax set the ground maximum X coordinate
  34525. * @param zmax set the ground maximum Z coordinate
  34526. * @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
  34527. * @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
  34528. * @param scene defines the hosting scene
  34529. * @param updatable defines if the mesh must be flagged as updatable
  34530. * @returns a new Mesh
  34531. */
  34532. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34533. w: number;
  34534. h: number;
  34535. }, precision: {
  34536. w: number;
  34537. h: number;
  34538. }, scene: Scene, updatable?: boolean): Mesh;
  34539. /**
  34540. * Creates a ground mesh from a height map.
  34541. * Please consider using the same method from the MeshBuilder class instead
  34542. * @see https://doc.babylonjs.com/babylon101/height_map
  34543. * @param name defines the name of the mesh to create
  34544. * @param url sets the URL of the height map image resource
  34545. * @param width set the ground width size
  34546. * @param height set the ground height size
  34547. * @param subdivisions sets the number of subdivision per side
  34548. * @param minHeight is the minimum altitude on the ground
  34549. * @param maxHeight is the maximum altitude on the ground
  34550. * @param scene defines the hosting scene
  34551. * @param updatable defines if the mesh must be flagged as updatable
  34552. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34553. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34554. * @returns a new Mesh
  34555. */
  34556. 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;
  34557. /**
  34558. * Creates a tube mesh.
  34559. * The tube is a parametric shape.
  34560. * It has no predefined shape. Its final shape will depend on the input parameters.
  34561. * Please consider using the same method from the MeshBuilder class instead
  34562. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34563. * @param name defines the name of the mesh to create
  34564. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34565. * @param radius sets the tube radius size
  34566. * @param tessellation is the number of sides on the tubular surface
  34567. * @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
  34568. * @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
  34569. * @param scene defines the hosting scene
  34570. * @param updatable defines if the mesh must be flagged as updatable
  34571. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34572. * @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)
  34573. * @returns a new Mesh
  34574. */
  34575. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34576. (i: number, distance: number): number;
  34577. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34578. /**
  34579. * Creates a polyhedron mesh.
  34580. * Please consider using the same method from the MeshBuilder class instead.
  34581. * * 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
  34582. * * The parameter `size` (positive float, default 1) sets the polygon size
  34583. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34584. * * 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`
  34585. * * 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
  34586. * * 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)`)
  34587. * * 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
  34588. * * 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
  34589. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34592. * @param name defines the name of the mesh to create
  34593. * @param options defines the options used to create the mesh
  34594. * @param scene defines the hosting scene
  34595. * @returns a new Mesh
  34596. */
  34597. static CreatePolyhedron(name: string, options: {
  34598. type?: number;
  34599. size?: number;
  34600. sizeX?: number;
  34601. sizeY?: number;
  34602. sizeZ?: number;
  34603. custom?: any;
  34604. faceUV?: Vector4[];
  34605. faceColors?: Color4[];
  34606. updatable?: boolean;
  34607. sideOrientation?: number;
  34608. }, scene: Scene): Mesh;
  34609. /**
  34610. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34611. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34612. * * 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`)
  34613. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34614. * * 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
  34615. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34618. * @param name defines the name of the mesh
  34619. * @param options defines the options used to create the mesh
  34620. * @param scene defines the hosting scene
  34621. * @returns a new Mesh
  34622. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34623. */
  34624. static CreateIcoSphere(name: string, options: {
  34625. radius?: number;
  34626. flat?: boolean;
  34627. subdivisions?: number;
  34628. sideOrientation?: number;
  34629. updatable?: boolean;
  34630. }, scene: Scene): Mesh;
  34631. /**
  34632. * Creates a decal mesh.
  34633. * Please consider using the same method from the MeshBuilder class instead.
  34634. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34635. * @param name defines the name of the mesh
  34636. * @param sourceMesh defines the mesh receiving the decal
  34637. * @param position sets the position of the decal in world coordinates
  34638. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34639. * @param size sets the decal scaling
  34640. * @param angle sets the angle to rotate the decal
  34641. * @returns a new Mesh
  34642. */
  34643. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34644. /** Creates a Capsule Mesh
  34645. * @param name defines the name of the mesh.
  34646. * @param options the constructors options used to shape the mesh.
  34647. * @param scene defines the scene the mesh is scoped to.
  34648. * @returns the capsule mesh
  34649. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34650. */
  34651. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34652. /**
  34653. * Prepare internal position array for software CPU skinning
  34654. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34655. */
  34656. setPositionsForCPUSkinning(): Float32Array;
  34657. /**
  34658. * Prepare internal normal array for software CPU skinning
  34659. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34660. */
  34661. setNormalsForCPUSkinning(): Float32Array;
  34662. /**
  34663. * Updates the vertex buffer by applying transformation from the bones
  34664. * @param skeleton defines the skeleton to apply to current mesh
  34665. * @returns the current mesh
  34666. */
  34667. applySkeleton(skeleton: Skeleton): Mesh;
  34668. /**
  34669. * 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
  34670. * @param meshes defines the list of meshes to scan
  34671. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34672. */
  34673. static MinMax(meshes: AbstractMesh[]): {
  34674. min: Vector3;
  34675. max: Vector3;
  34676. };
  34677. /**
  34678. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34679. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34680. * @returns a vector3
  34681. */
  34682. static Center(meshesOrMinMaxVector: {
  34683. min: Vector3;
  34684. max: Vector3;
  34685. } | AbstractMesh[]): Vector3;
  34686. /**
  34687. * Merge the array of meshes into a single mesh for performance reasons.
  34688. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34689. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34690. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34691. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34692. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34693. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34694. * @returns a new mesh
  34695. */
  34696. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34697. /** @hidden */
  34698. addInstance(instance: InstancedMesh): void;
  34699. /** @hidden */
  34700. removeInstance(instance: InstancedMesh): void;
  34701. }
  34702. }
  34703. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  34704. import { Vector3 } from "babylonjs/Maths/math.vector";
  34705. import { Mesh } from "babylonjs/Meshes/mesh";
  34706. /**
  34707. * The options Interface for creating a Capsule Mesh
  34708. */
  34709. export interface ICreateCapsuleOptions {
  34710. /** The Orientation of the capsule. Default : Vector3.Up() */
  34711. orientation?: Vector3;
  34712. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34713. subdivisions: number;
  34714. /** Number of cylindrical segments on the capsule. */
  34715. tessellation: number;
  34716. /** Height or Length of the capsule. */
  34717. height: number;
  34718. /** Radius of the capsule. */
  34719. radius: number;
  34720. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34721. capSubdivisions: number;
  34722. /** Overwrite for the top radius. */
  34723. radiusTop?: number;
  34724. /** Overwrite for the bottom radius. */
  34725. radiusBottom?: number;
  34726. /** Overwrite for the top capSubdivisions. */
  34727. topCapSubdivisions?: number;
  34728. /** Overwrite for the bottom capSubdivisions. */
  34729. bottomCapSubdivisions?: number;
  34730. }
  34731. /**
  34732. * Class containing static functions to help procedurally build meshes
  34733. */
  34734. export class CapsuleBuilder {
  34735. /**
  34736. * Creates a capsule or a pill mesh
  34737. * @param name defines the name of the mesh
  34738. * @param options The constructors options.
  34739. * @param scene The scene the mesh is scoped to.
  34740. * @returns Capsule Mesh
  34741. */
  34742. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34743. }
  34744. }
  34745. declare module "babylonjs/Meshes/mesh.vertexData" {
  34746. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  34747. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  34748. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34749. import { Geometry } from "babylonjs/Meshes/geometry";
  34750. import { Mesh } from "babylonjs/Meshes/mesh";
  34751. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  34752. /**
  34753. * Define an interface for all classes that will get and set the data on vertices
  34754. */
  34755. export interface IGetSetVerticesData {
  34756. /**
  34757. * Gets a boolean indicating if specific vertex data is present
  34758. * @param kind defines the vertex data kind to use
  34759. * @returns true is data kind is present
  34760. */
  34761. isVerticesDataPresent(kind: string): boolean;
  34762. /**
  34763. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34764. * @param kind defines the data kind (Position, normal, etc...)
  34765. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34766. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34767. * @returns a float array containing vertex data
  34768. */
  34769. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34770. /**
  34771. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34772. * @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.
  34773. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34774. * @returns the indices array or an empty array if the mesh has no geometry
  34775. */
  34776. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34777. /**
  34778. * Set specific vertex data
  34779. * @param kind defines the data kind (Position, normal, etc...)
  34780. * @param data defines the vertex data to use
  34781. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34782. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34783. */
  34784. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34785. /**
  34786. * Update a specific associated vertex buffer
  34787. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34788. * - VertexBuffer.PositionKind
  34789. * - VertexBuffer.UVKind
  34790. * - VertexBuffer.UV2Kind
  34791. * - VertexBuffer.UV3Kind
  34792. * - VertexBuffer.UV4Kind
  34793. * - VertexBuffer.UV5Kind
  34794. * - VertexBuffer.UV6Kind
  34795. * - VertexBuffer.ColorKind
  34796. * - VertexBuffer.MatricesIndicesKind
  34797. * - VertexBuffer.MatricesIndicesExtraKind
  34798. * - VertexBuffer.MatricesWeightsKind
  34799. * - VertexBuffer.MatricesWeightsExtraKind
  34800. * @param data defines the data source
  34801. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34802. * @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)
  34803. */
  34804. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34805. /**
  34806. * Creates a new index buffer
  34807. * @param indices defines the indices to store in the index buffer
  34808. * @param totalVertices defines the total number of vertices (could be null)
  34809. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34810. */
  34811. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34812. }
  34813. /**
  34814. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34815. */
  34816. export class VertexData {
  34817. /**
  34818. * Mesh side orientation : usually the external or front surface
  34819. */
  34820. static readonly FRONTSIDE: number;
  34821. /**
  34822. * Mesh side orientation : usually the internal or back surface
  34823. */
  34824. static readonly BACKSIDE: number;
  34825. /**
  34826. * Mesh side orientation : both internal and external or front and back surfaces
  34827. */
  34828. static readonly DOUBLESIDE: number;
  34829. /**
  34830. * Mesh side orientation : by default, `FRONTSIDE`
  34831. */
  34832. static readonly DEFAULTSIDE: number;
  34833. /**
  34834. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34835. */
  34836. positions: Nullable<FloatArray>;
  34837. /**
  34838. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34839. */
  34840. normals: Nullable<FloatArray>;
  34841. /**
  34842. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34843. */
  34844. tangents: Nullable<FloatArray>;
  34845. /**
  34846. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34847. */
  34848. uvs: Nullable<FloatArray>;
  34849. /**
  34850. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34851. */
  34852. uvs2: Nullable<FloatArray>;
  34853. /**
  34854. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34855. */
  34856. uvs3: Nullable<FloatArray>;
  34857. /**
  34858. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34859. */
  34860. uvs4: Nullable<FloatArray>;
  34861. /**
  34862. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34863. */
  34864. uvs5: Nullable<FloatArray>;
  34865. /**
  34866. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34867. */
  34868. uvs6: Nullable<FloatArray>;
  34869. /**
  34870. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34871. */
  34872. colors: Nullable<FloatArray>;
  34873. /**
  34874. * 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).
  34875. */
  34876. matricesIndices: Nullable<FloatArray>;
  34877. /**
  34878. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34879. */
  34880. matricesWeights: Nullable<FloatArray>;
  34881. /**
  34882. * An array extending the number of possible indices
  34883. */
  34884. matricesIndicesExtra: Nullable<FloatArray>;
  34885. /**
  34886. * An array extending the number of possible weights when the number of indices is extended
  34887. */
  34888. matricesWeightsExtra: Nullable<FloatArray>;
  34889. /**
  34890. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34891. */
  34892. indices: Nullable<IndicesArray>;
  34893. /**
  34894. * Uses the passed data array to set the set the values for the specified kind of data
  34895. * @param data a linear array of floating numbers
  34896. * @param kind the type of data that is being set, eg positions, colors etc
  34897. */
  34898. set(data: FloatArray, kind: string): void;
  34899. /**
  34900. * Associates the vertexData to the passed Mesh.
  34901. * Sets it as updatable or not (default `false`)
  34902. * @param mesh the mesh the vertexData is applied to
  34903. * @param updatable when used and having the value true allows new data to update the vertexData
  34904. * @returns the VertexData
  34905. */
  34906. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34907. /**
  34908. * Associates the vertexData to the passed Geometry.
  34909. * Sets it as updatable or not (default `false`)
  34910. * @param geometry the geometry the vertexData is applied to
  34911. * @param updatable when used and having the value true allows new data to update the vertexData
  34912. * @returns VertexData
  34913. */
  34914. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34915. /**
  34916. * Updates the associated mesh
  34917. * @param mesh the mesh to be updated
  34918. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34919. * @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
  34920. * @returns VertexData
  34921. */
  34922. updateMesh(mesh: Mesh): VertexData;
  34923. /**
  34924. * Updates the associated geometry
  34925. * @param geometry the geometry to be updated
  34926. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34927. * @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
  34928. * @returns VertexData.
  34929. */
  34930. updateGeometry(geometry: Geometry): VertexData;
  34931. private _applyTo;
  34932. private _update;
  34933. /**
  34934. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34935. * @param matrix the transforming matrix
  34936. * @returns the VertexData
  34937. */
  34938. transform(matrix: Matrix): VertexData;
  34939. /**
  34940. * Merges the passed VertexData into the current one
  34941. * @param other the VertexData to be merged into the current one
  34942. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34943. * @returns the modified VertexData
  34944. */
  34945. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34946. private _mergeElement;
  34947. private _validate;
  34948. /**
  34949. * Serializes the VertexData
  34950. * @returns a serialized object
  34951. */
  34952. serialize(): any;
  34953. /**
  34954. * Extracts the vertexData from a mesh
  34955. * @param mesh the mesh from which to extract the VertexData
  34956. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34957. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34958. * @returns the object VertexData associated to the passed mesh
  34959. */
  34960. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34961. /**
  34962. * Extracts the vertexData from the geometry
  34963. * @param geometry the geometry from which to extract the VertexData
  34964. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  34965. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34966. * @returns the object VertexData associated to the passed mesh
  34967. */
  34968. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34969. private static _ExtractFrom;
  34970. /**
  34971. * Creates the VertexData for a Ribbon
  34972. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34973. * * pathArray array of paths, each of which an array of successive Vector3
  34974. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34975. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34976. * * 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
  34977. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34978. * * 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)
  34979. * * 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)
  34980. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34981. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34982. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34983. * @returns the VertexData of the ribbon
  34984. */
  34985. static CreateRibbon(options: {
  34986. pathArray: Vector3[][];
  34987. closeArray?: boolean;
  34988. closePath?: boolean;
  34989. offset?: number;
  34990. sideOrientation?: number;
  34991. frontUVs?: Vector4;
  34992. backUVs?: Vector4;
  34993. invertUV?: boolean;
  34994. uvs?: Vector2[];
  34995. colors?: Color4[];
  34996. }): VertexData;
  34997. /**
  34998. * Creates the VertexData for a box
  34999. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35000. * * size sets the width, height and depth of the box to the value of size, optional default 1
  35001. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  35002. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  35003. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  35004. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35005. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35006. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35007. * * 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)
  35008. * * 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)
  35009. * @returns the VertexData of the box
  35010. */
  35011. static CreateBox(options: {
  35012. size?: number;
  35013. width?: number;
  35014. height?: number;
  35015. depth?: number;
  35016. faceUV?: Vector4[];
  35017. faceColors?: Color4[];
  35018. sideOrientation?: number;
  35019. frontUVs?: Vector4;
  35020. backUVs?: Vector4;
  35021. }): VertexData;
  35022. /**
  35023. * Creates the VertexData for a tiled box
  35024. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35025. * * faceTiles sets the pattern, tile size and number of tiles for a face
  35026. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35027. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35028. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35029. * @returns the VertexData of the box
  35030. */
  35031. static CreateTiledBox(options: {
  35032. pattern?: number;
  35033. width?: number;
  35034. height?: number;
  35035. depth?: number;
  35036. tileSize?: number;
  35037. tileWidth?: number;
  35038. tileHeight?: number;
  35039. alignHorizontal?: number;
  35040. alignVertical?: number;
  35041. faceUV?: Vector4[];
  35042. faceColors?: Color4[];
  35043. sideOrientation?: number;
  35044. }): VertexData;
  35045. /**
  35046. * Creates the VertexData for a tiled plane
  35047. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35048. * * pattern a limited pattern arrangement depending on the number
  35049. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  35050. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  35051. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  35052. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35053. * * 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)
  35054. * * 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)
  35055. * @returns the VertexData of the tiled plane
  35056. */
  35057. static CreateTiledPlane(options: {
  35058. pattern?: number;
  35059. tileSize?: number;
  35060. tileWidth?: number;
  35061. tileHeight?: number;
  35062. size?: number;
  35063. width?: number;
  35064. height?: number;
  35065. alignHorizontal?: number;
  35066. alignVertical?: number;
  35067. sideOrientation?: number;
  35068. frontUVs?: Vector4;
  35069. backUVs?: Vector4;
  35070. }): VertexData;
  35071. /**
  35072. * Creates the VertexData for an ellipsoid, defaults to a sphere
  35073. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35074. * * segments sets the number of horizontal strips optional, default 32
  35075. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  35076. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  35077. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  35078. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  35079. * * 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
  35080. * * 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
  35081. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35082. * * 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)
  35083. * * 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)
  35084. * @returns the VertexData of the ellipsoid
  35085. */
  35086. static CreateSphere(options: {
  35087. segments?: number;
  35088. diameter?: number;
  35089. diameterX?: number;
  35090. diameterY?: number;
  35091. diameterZ?: number;
  35092. arc?: number;
  35093. slice?: number;
  35094. sideOrientation?: number;
  35095. frontUVs?: Vector4;
  35096. backUVs?: Vector4;
  35097. }): VertexData;
  35098. /**
  35099. * Creates the VertexData for a cylinder, cone or prism
  35100. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35101. * * height sets the height (y direction) of the cylinder, optional, default 2
  35102. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  35103. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  35104. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  35105. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35106. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  35107. * * 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
  35108. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35109. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35110. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  35111. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  35112. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35113. * * 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)
  35114. * * 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)
  35115. * @returns the VertexData of the cylinder, cone or prism
  35116. */
  35117. static CreateCylinder(options: {
  35118. height?: number;
  35119. diameterTop?: number;
  35120. diameterBottom?: number;
  35121. diameter?: number;
  35122. tessellation?: number;
  35123. subdivisions?: number;
  35124. arc?: number;
  35125. faceColors?: Color4[];
  35126. faceUV?: Vector4[];
  35127. hasRings?: boolean;
  35128. enclose?: boolean;
  35129. sideOrientation?: number;
  35130. frontUVs?: Vector4;
  35131. backUVs?: Vector4;
  35132. }): VertexData;
  35133. /**
  35134. * Creates the VertexData for a torus
  35135. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35136. * * diameter the diameter of the torus, optional default 1
  35137. * * thickness the diameter of the tube forming the torus, optional default 0.5
  35138. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35139. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35140. * * 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)
  35141. * * 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)
  35142. * @returns the VertexData of the torus
  35143. */
  35144. static CreateTorus(options: {
  35145. diameter?: number;
  35146. thickness?: number;
  35147. tessellation?: number;
  35148. sideOrientation?: number;
  35149. frontUVs?: Vector4;
  35150. backUVs?: Vector4;
  35151. }): VertexData;
  35152. /**
  35153. * Creates the VertexData of the LineSystem
  35154. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  35155. * - lines an array of lines, each line being an array of successive Vector3
  35156. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  35157. * @returns the VertexData of the LineSystem
  35158. */
  35159. static CreateLineSystem(options: {
  35160. lines: Vector3[][];
  35161. colors?: Nullable<Color4[][]>;
  35162. }): VertexData;
  35163. /**
  35164. * Create the VertexData for a DashedLines
  35165. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  35166. * - points an array successive Vector3
  35167. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  35168. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  35169. * - dashNb the intended total number of dashes, optional, default 200
  35170. * @returns the VertexData for the DashedLines
  35171. */
  35172. static CreateDashedLines(options: {
  35173. points: Vector3[];
  35174. dashSize?: number;
  35175. gapSize?: number;
  35176. dashNb?: number;
  35177. }): VertexData;
  35178. /**
  35179. * Creates the VertexData for a Ground
  35180. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35181. * - width the width (x direction) of the ground, optional, default 1
  35182. * - height the height (z direction) of the ground, optional, default 1
  35183. * - subdivisions the number of subdivisions per side, optional, default 1
  35184. * @returns the VertexData of the Ground
  35185. */
  35186. static CreateGround(options: {
  35187. width?: number;
  35188. height?: number;
  35189. subdivisions?: number;
  35190. subdivisionsX?: number;
  35191. subdivisionsY?: number;
  35192. }): VertexData;
  35193. /**
  35194. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  35195. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35196. * * xmin the ground minimum X coordinate, optional, default -1
  35197. * * zmin the ground minimum Z coordinate, optional, default -1
  35198. * * xmax the ground maximum X coordinate, optional, default 1
  35199. * * zmax the ground maximum Z coordinate, optional, default 1
  35200. * * 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}
  35201. * * 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}
  35202. * @returns the VertexData of the TiledGround
  35203. */
  35204. static CreateTiledGround(options: {
  35205. xmin: number;
  35206. zmin: number;
  35207. xmax: number;
  35208. zmax: number;
  35209. subdivisions?: {
  35210. w: number;
  35211. h: number;
  35212. };
  35213. precision?: {
  35214. w: number;
  35215. h: number;
  35216. };
  35217. }): VertexData;
  35218. /**
  35219. * Creates the VertexData of the Ground designed from a heightmap
  35220. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  35221. * * width the width (x direction) of the ground
  35222. * * height the height (z direction) of the ground
  35223. * * subdivisions the number of subdivisions per side
  35224. * * minHeight the minimum altitude on the ground, optional, default 0
  35225. * * maxHeight the maximum altitude on the ground, optional default 1
  35226. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  35227. * * buffer the array holding the image color data
  35228. * * bufferWidth the width of image
  35229. * * bufferHeight the height of image
  35230. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  35231. * @returns the VertexData of the Ground designed from a heightmap
  35232. */
  35233. static CreateGroundFromHeightMap(options: {
  35234. width: number;
  35235. height: number;
  35236. subdivisions: number;
  35237. minHeight: number;
  35238. maxHeight: number;
  35239. colorFilter: Color3;
  35240. buffer: Uint8Array;
  35241. bufferWidth: number;
  35242. bufferHeight: number;
  35243. alphaFilter: number;
  35244. }): VertexData;
  35245. /**
  35246. * Creates the VertexData for a Plane
  35247. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  35248. * * size sets the width and height of the plane to the value of size, optional default 1
  35249. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  35250. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  35251. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35252. * * 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)
  35253. * * 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)
  35254. * @returns the VertexData of the box
  35255. */
  35256. static CreatePlane(options: {
  35257. size?: number;
  35258. width?: number;
  35259. height?: number;
  35260. sideOrientation?: number;
  35261. frontUVs?: Vector4;
  35262. backUVs?: Vector4;
  35263. }): VertexData;
  35264. /**
  35265. * Creates the VertexData of the Disc or regular Polygon
  35266. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  35267. * * radius the radius of the disc, optional default 0.5
  35268. * * tessellation the number of polygon sides, optional, default 64
  35269. * * 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
  35270. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35271. * * 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)
  35272. * * 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)
  35273. * @returns the VertexData of the box
  35274. */
  35275. static CreateDisc(options: {
  35276. radius?: number;
  35277. tessellation?: number;
  35278. arc?: number;
  35279. sideOrientation?: number;
  35280. frontUVs?: Vector4;
  35281. backUVs?: Vector4;
  35282. }): VertexData;
  35283. /**
  35284. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  35285. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  35286. * @param polygon a mesh built from polygonTriangulation.build()
  35287. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35288. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35289. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35290. * @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)
  35291. * @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)
  35292. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  35293. * @returns the VertexData of the Polygon
  35294. */
  35295. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  35296. /**
  35297. * Creates the VertexData of the IcoSphere
  35298. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  35299. * * radius the radius of the IcoSphere, optional default 1
  35300. * * radiusX allows stretching in the x direction, optional, default radius
  35301. * * radiusY allows stretching in the y direction, optional, default radius
  35302. * * radiusZ allows stretching in the z direction, optional, default radius
  35303. * * flat when true creates a flat shaded mesh, optional, default true
  35304. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35305. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35306. * * 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)
  35307. * * 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)
  35308. * @returns the VertexData of the IcoSphere
  35309. */
  35310. static CreateIcoSphere(options: {
  35311. radius?: number;
  35312. radiusX?: number;
  35313. radiusY?: number;
  35314. radiusZ?: number;
  35315. flat?: boolean;
  35316. subdivisions?: number;
  35317. sideOrientation?: number;
  35318. frontUVs?: Vector4;
  35319. backUVs?: Vector4;
  35320. }): VertexData;
  35321. /**
  35322. * Creates the VertexData for a Polyhedron
  35323. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  35324. * * type provided types are:
  35325. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  35326. * * 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)
  35327. * * size the size of the IcoSphere, optional default 1
  35328. * * sizeX allows stretching in the x direction, optional, default size
  35329. * * sizeY allows stretching in the y direction, optional, default size
  35330. * * sizeZ allows stretching in the z direction, optional, default size
  35331. * * 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
  35332. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35333. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35334. * * flat when true creates a flat shaded mesh, optional, default true
  35335. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35336. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35337. * * 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)
  35338. * * 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)
  35339. * @returns the VertexData of the Polyhedron
  35340. */
  35341. static CreatePolyhedron(options: {
  35342. type?: number;
  35343. size?: number;
  35344. sizeX?: number;
  35345. sizeY?: number;
  35346. sizeZ?: number;
  35347. custom?: any;
  35348. faceUV?: Vector4[];
  35349. faceColors?: Color4[];
  35350. flat?: boolean;
  35351. sideOrientation?: number;
  35352. frontUVs?: Vector4;
  35353. backUVs?: Vector4;
  35354. }): VertexData;
  35355. /**
  35356. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  35357. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  35358. * @returns the VertexData of the Capsule
  35359. */
  35360. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  35361. /**
  35362. * Creates the VertexData for a TorusKnot
  35363. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  35364. * * radius the radius of the torus knot, optional, default 2
  35365. * * tube the thickness of the tube, optional, default 0.5
  35366. * * radialSegments the number of sides on each tube segments, optional, default 32
  35367. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  35368. * * p the number of windings around the z axis, optional, default 2
  35369. * * q the number of windings around the x axis, optional, default 3
  35370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35371. * * 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)
  35372. * * 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)
  35373. * @returns the VertexData of the Torus Knot
  35374. */
  35375. static CreateTorusKnot(options: {
  35376. radius?: number;
  35377. tube?: number;
  35378. radialSegments?: number;
  35379. tubularSegments?: number;
  35380. p?: number;
  35381. q?: number;
  35382. sideOrientation?: number;
  35383. frontUVs?: Vector4;
  35384. backUVs?: Vector4;
  35385. }): VertexData;
  35386. /**
  35387. * Compute normals for given positions and indices
  35388. * @param positions an array of vertex positions, [...., x, y, z, ......]
  35389. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  35390. * @param normals an array of vertex normals, [...., x, y, z, ......]
  35391. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  35392. * * facetNormals : optional array of facet normals (vector3)
  35393. * * facetPositions : optional array of facet positions (vector3)
  35394. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  35395. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  35396. * * bInfo : optional bounding info, required for facetPartitioning computation
  35397. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  35398. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  35399. * * useRightHandedSystem: optional boolean to for right handed system computation
  35400. * * depthSort : optional boolean to enable the facet depth sort computation
  35401. * * distanceTo : optional Vector3 to compute the facet depth from this location
  35402. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  35403. */
  35404. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  35405. facetNormals?: any;
  35406. facetPositions?: any;
  35407. facetPartitioning?: any;
  35408. ratio?: number;
  35409. bInfo?: any;
  35410. bbSize?: Vector3;
  35411. subDiv?: any;
  35412. useRightHandedSystem?: boolean;
  35413. depthSort?: boolean;
  35414. distanceTo?: Vector3;
  35415. depthSortedFacets?: any;
  35416. }): void;
  35417. /** @hidden */
  35418. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  35419. /**
  35420. * Applies VertexData created from the imported parameters to the geometry
  35421. * @param parsedVertexData the parsed data from an imported file
  35422. * @param geometry the geometry to apply the VertexData to
  35423. */
  35424. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  35425. }
  35426. }
  35427. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35428. import { Nullable } from "babylonjs/types";
  35429. import { Scene } from "babylonjs/scene";
  35430. import { Vector4 } from "babylonjs/Maths/math.vector";
  35431. import { Mesh } from "babylonjs/Meshes/mesh";
  35432. /**
  35433. * Class containing static functions to help procedurally build meshes
  35434. */
  35435. export class DiscBuilder {
  35436. /**
  35437. * Creates a plane polygonal mesh. By default, this is a disc
  35438. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35439. * * 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
  35440. * * 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
  35441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35444. * @param name defines the name of the mesh
  35445. * @param options defines the options used to create the mesh
  35446. * @param scene defines the hosting scene
  35447. * @returns the plane polygonal mesh
  35448. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35449. */
  35450. static CreateDisc(name: string, options: {
  35451. radius?: number;
  35452. tessellation?: number;
  35453. arc?: number;
  35454. updatable?: boolean;
  35455. sideOrientation?: number;
  35456. frontUVs?: Vector4;
  35457. backUVs?: Vector4;
  35458. }, scene?: Nullable<Scene>): Mesh;
  35459. }
  35460. }
  35461. declare module "babylonjs/Particles/solidParticleSystem" {
  35462. import { Nullable } from "babylonjs/types";
  35463. import { Mesh } from "babylonjs/Meshes/mesh";
  35464. import { Scene, IDisposable } from "babylonjs/scene";
  35465. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35466. import { Material } from "babylonjs/Materials/material";
  35467. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35468. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35469. /**
  35470. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35471. *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.
  35472. * The SPS is also a particle system. It provides some methods to manage the particles.
  35473. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35474. *
  35475. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35476. */
  35477. export class SolidParticleSystem implements IDisposable {
  35478. /**
  35479. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35480. * Example : var p = SPS.particles[i];
  35481. */
  35482. particles: SolidParticle[];
  35483. /**
  35484. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35485. */
  35486. nbParticles: number;
  35487. /**
  35488. * If the particles must ever face the camera (default false). Useful for planar particles.
  35489. */
  35490. billboard: boolean;
  35491. /**
  35492. * Recompute normals when adding a shape
  35493. */
  35494. recomputeNormals: boolean;
  35495. /**
  35496. * This a counter ofr your own usage. It's not set by any SPS functions.
  35497. */
  35498. counter: number;
  35499. /**
  35500. * The SPS name. This name is also given to the underlying mesh.
  35501. */
  35502. name: string;
  35503. /**
  35504. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35505. */
  35506. mesh: Mesh;
  35507. /**
  35508. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35509. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35510. */
  35511. vars: any;
  35512. /**
  35513. * This array is populated when the SPS is set as 'pickable'.
  35514. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35515. * Each element of this array is an object `{idx: int, faceId: int}`.
  35516. * `idx` is the picked particle index in the `SPS.particles` array
  35517. * `faceId` is the picked face index counted within this particle.
  35518. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35519. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35520. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35521. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35522. */
  35523. pickedParticles: {
  35524. idx: number;
  35525. faceId: number;
  35526. }[];
  35527. /**
  35528. * This array is populated when the SPS is set as 'pickable'
  35529. * Each key of this array is a submesh index.
  35530. * Each element of this array is a second array defined like this :
  35531. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35532. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35533. * `idx` is the picked particle index in the `SPS.particles` array
  35534. * `faceId` is the picked face index counted within this particle.
  35535. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35536. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35537. */
  35538. pickedBySubMesh: {
  35539. idx: number;
  35540. faceId: number;
  35541. }[][];
  35542. /**
  35543. * This array is populated when `enableDepthSort` is set to true.
  35544. * Each element of this array is an instance of the class DepthSortedParticle.
  35545. */
  35546. depthSortedParticles: DepthSortedParticle[];
  35547. /**
  35548. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35549. * @hidden
  35550. */
  35551. _bSphereOnly: boolean;
  35552. /**
  35553. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35554. * @hidden
  35555. */
  35556. _bSphereRadiusFactor: number;
  35557. private _scene;
  35558. private _positions;
  35559. private _indices;
  35560. private _normals;
  35561. private _colors;
  35562. private _uvs;
  35563. private _indices32;
  35564. private _positions32;
  35565. private _normals32;
  35566. private _fixedNormal32;
  35567. private _colors32;
  35568. private _uvs32;
  35569. private _index;
  35570. private _updatable;
  35571. private _pickable;
  35572. private _isVisibilityBoxLocked;
  35573. private _alwaysVisible;
  35574. private _depthSort;
  35575. private _expandable;
  35576. private _shapeCounter;
  35577. private _copy;
  35578. private _color;
  35579. private _computeParticleColor;
  35580. private _computeParticleTexture;
  35581. private _computeParticleRotation;
  35582. private _computeParticleVertex;
  35583. private _computeBoundingBox;
  35584. private _depthSortParticles;
  35585. private _camera;
  35586. private _mustUnrotateFixedNormals;
  35587. private _particlesIntersect;
  35588. private _needs32Bits;
  35589. private _isNotBuilt;
  35590. private _lastParticleId;
  35591. private _idxOfId;
  35592. private _multimaterialEnabled;
  35593. private _useModelMaterial;
  35594. private _indicesByMaterial;
  35595. private _materialIndexes;
  35596. private _depthSortFunction;
  35597. private _materialSortFunction;
  35598. private _materials;
  35599. private _multimaterial;
  35600. private _materialIndexesById;
  35601. private _defaultMaterial;
  35602. private _autoUpdateSubMeshes;
  35603. private _tmpVertex;
  35604. /**
  35605. * Creates a SPS (Solid Particle System) object.
  35606. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35607. * @param scene (Scene) is the scene in which the SPS is added.
  35608. * @param options defines the options of the sps e.g.
  35609. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35610. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35611. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35612. * * 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.
  35613. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35614. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35615. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35616. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35617. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35618. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35619. */
  35620. constructor(name: string, scene: Scene, options?: {
  35621. updatable?: boolean;
  35622. isPickable?: boolean;
  35623. enableDepthSort?: boolean;
  35624. particleIntersection?: boolean;
  35625. boundingSphereOnly?: boolean;
  35626. bSphereRadiusFactor?: number;
  35627. expandable?: boolean;
  35628. useModelMaterial?: boolean;
  35629. enableMultiMaterial?: boolean;
  35630. });
  35631. /**
  35632. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35633. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35634. * @returns the created mesh
  35635. */
  35636. buildMesh(): Mesh;
  35637. /**
  35638. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35639. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35640. * Thus the particles generated from `digest()` have their property `position` set yet.
  35641. * @param mesh ( Mesh ) is the mesh to be digested
  35642. * @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
  35643. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35644. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35645. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35646. * @returns the current SPS
  35647. */
  35648. digest(mesh: Mesh, options?: {
  35649. facetNb?: number;
  35650. number?: number;
  35651. delta?: number;
  35652. storage?: [];
  35653. }): SolidParticleSystem;
  35654. /**
  35655. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35656. * @hidden
  35657. */
  35658. private _unrotateFixedNormals;
  35659. /**
  35660. * Resets the temporary working copy particle
  35661. * @hidden
  35662. */
  35663. private _resetCopy;
  35664. /**
  35665. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35666. * @param p the current index in the positions array to be updated
  35667. * @param ind the current index in the indices array
  35668. * @param shape a Vector3 array, the shape geometry
  35669. * @param positions the positions array to be updated
  35670. * @param meshInd the shape indices array
  35671. * @param indices the indices array to be updated
  35672. * @param meshUV the shape uv array
  35673. * @param uvs the uv array to be updated
  35674. * @param meshCol the shape color array
  35675. * @param colors the color array to be updated
  35676. * @param meshNor the shape normals array
  35677. * @param normals the normals array to be updated
  35678. * @param idx the particle index
  35679. * @param idxInShape the particle index in its shape
  35680. * @param options the addShape() method passed options
  35681. * @model the particle model
  35682. * @hidden
  35683. */
  35684. private _meshBuilder;
  35685. /**
  35686. * Returns a shape Vector3 array from positions float array
  35687. * @param positions float array
  35688. * @returns a vector3 array
  35689. * @hidden
  35690. */
  35691. private _posToShape;
  35692. /**
  35693. * Returns a shapeUV array from a float uvs (array deep copy)
  35694. * @param uvs as a float array
  35695. * @returns a shapeUV array
  35696. * @hidden
  35697. */
  35698. private _uvsToShapeUV;
  35699. /**
  35700. * Adds a new particle object in the particles array
  35701. * @param idx particle index in particles array
  35702. * @param id particle id
  35703. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35704. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35705. * @param model particle ModelShape object
  35706. * @param shapeId model shape identifier
  35707. * @param idxInShape index of the particle in the current model
  35708. * @param bInfo model bounding info object
  35709. * @param storage target storage array, if any
  35710. * @hidden
  35711. */
  35712. private _addParticle;
  35713. /**
  35714. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35715. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35716. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35717. * @param nb (positive integer) the number of particles to be created from this model
  35718. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35719. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35720. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35721. * @returns the number of shapes in the system
  35722. */
  35723. addShape(mesh: Mesh, nb: number, options?: {
  35724. positionFunction?: any;
  35725. vertexFunction?: any;
  35726. storage?: [];
  35727. }): number;
  35728. /**
  35729. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35730. * @hidden
  35731. */
  35732. private _rebuildParticle;
  35733. /**
  35734. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35735. * @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.
  35736. * @returns the SPS.
  35737. */
  35738. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35739. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35740. * Returns an array with the removed particles.
  35741. * 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.
  35742. * The SPS can't be empty so at least one particle needs to remain in place.
  35743. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35744. * @param start index of the first particle to remove
  35745. * @param end index of the last particle to remove (included)
  35746. * @returns an array populated with the removed particles
  35747. */
  35748. removeParticles(start: number, end: number): SolidParticle[];
  35749. /**
  35750. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35751. * @param solidParticleArray an array populated with Solid Particles objects
  35752. * @returns the SPS
  35753. */
  35754. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35755. /**
  35756. * Creates a new particle and modifies the SPS mesh geometry :
  35757. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35758. * - calls _addParticle() to populate the particle array
  35759. * factorized code from addShape() and insertParticlesFromArray()
  35760. * @param idx particle index in the particles array
  35761. * @param i particle index in its shape
  35762. * @param modelShape particle ModelShape object
  35763. * @param shape shape vertex array
  35764. * @param meshInd shape indices array
  35765. * @param meshUV shape uv array
  35766. * @param meshCol shape color array
  35767. * @param meshNor shape normals array
  35768. * @param bbInfo shape bounding info
  35769. * @param storage target particle storage
  35770. * @options addShape() passed options
  35771. * @hidden
  35772. */
  35773. private _insertNewParticle;
  35774. /**
  35775. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35776. * This method calls `updateParticle()` for each particle of the SPS.
  35777. * For an animated SPS, it is usually called within the render loop.
  35778. * 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.
  35779. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35780. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35781. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35782. * @returns the SPS.
  35783. */
  35784. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35785. /**
  35786. * Disposes the SPS.
  35787. */
  35788. dispose(): void;
  35789. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35790. * idx is the particle index in the SPS
  35791. * faceId is the picked face index counted within this particle.
  35792. * Returns null if the pickInfo can't identify a picked particle.
  35793. * @param pickingInfo (PickingInfo object)
  35794. * @returns {idx: number, faceId: number} or null
  35795. */
  35796. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35797. idx: number;
  35798. faceId: number;
  35799. }>;
  35800. /**
  35801. * Returns a SolidParticle object from its identifier : particle.id
  35802. * @param id (integer) the particle Id
  35803. * @returns the searched particle or null if not found in the SPS.
  35804. */
  35805. getParticleById(id: number): Nullable<SolidParticle>;
  35806. /**
  35807. * Returns a new array populated with the particles having the passed shapeId.
  35808. * @param shapeId (integer) the shape identifier
  35809. * @returns a new solid particle array
  35810. */
  35811. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35812. /**
  35813. * Populates the passed array "ref" with the particles having the passed shapeId.
  35814. * @param shapeId the shape identifier
  35815. * @returns the SPS
  35816. * @param ref
  35817. */
  35818. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35819. /**
  35820. * Computes the required SubMeshes according the materials assigned to the particles.
  35821. * @returns the solid particle system.
  35822. * Does nothing if called before the SPS mesh is built.
  35823. */
  35824. computeSubMeshes(): SolidParticleSystem;
  35825. /**
  35826. * Sorts the solid particles by material when MultiMaterial is enabled.
  35827. * Updates the indices32 array.
  35828. * Updates the indicesByMaterial array.
  35829. * Updates the mesh indices array.
  35830. * @returns the SPS
  35831. * @hidden
  35832. */
  35833. private _sortParticlesByMaterial;
  35834. /**
  35835. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35836. * @hidden
  35837. */
  35838. private _setMaterialIndexesById;
  35839. /**
  35840. * Returns an array with unique values of Materials from the passed array
  35841. * @param array the material array to be checked and filtered
  35842. * @hidden
  35843. */
  35844. private _filterUniqueMaterialId;
  35845. /**
  35846. * Sets a new Standard Material as _defaultMaterial if not already set.
  35847. * @hidden
  35848. */
  35849. private _setDefaultMaterial;
  35850. /**
  35851. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35852. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35853. * @returns the SPS.
  35854. */
  35855. refreshVisibleSize(): SolidParticleSystem;
  35856. /**
  35857. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35858. * @param size the size (float) of the visibility box
  35859. * note : this doesn't lock the SPS mesh bounding box.
  35860. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35861. */
  35862. setVisibilityBox(size: number): void;
  35863. /**
  35864. * Gets whether the SPS as always visible or not
  35865. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35866. */
  35867. get isAlwaysVisible(): boolean;
  35868. /**
  35869. * Sets the SPS as always visible or not
  35870. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35871. */
  35872. set isAlwaysVisible(val: boolean);
  35873. /**
  35874. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35875. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35876. */
  35877. set isVisibilityBoxLocked(val: boolean);
  35878. /**
  35879. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35880. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35881. */
  35882. get isVisibilityBoxLocked(): boolean;
  35883. /**
  35884. * Tells to `setParticles()` to compute the particle rotations or not.
  35885. * Default value : true. The SPS is faster when it's set to false.
  35886. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35887. */
  35888. set computeParticleRotation(val: boolean);
  35889. /**
  35890. * Tells to `setParticles()` to compute the particle colors or not.
  35891. * Default value : true. The SPS is faster when it's set to false.
  35892. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35893. */
  35894. set computeParticleColor(val: boolean);
  35895. set computeParticleTexture(val: boolean);
  35896. /**
  35897. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35898. * Default value : false. The SPS is faster when it's set to false.
  35899. * Note : the particle custom vertex positions aren't stored values.
  35900. */
  35901. set computeParticleVertex(val: boolean);
  35902. /**
  35903. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35904. */
  35905. set computeBoundingBox(val: boolean);
  35906. /**
  35907. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35908. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35909. * Default : `true`
  35910. */
  35911. set depthSortParticles(val: boolean);
  35912. /**
  35913. * Gets if `setParticles()` computes the particle rotations or not.
  35914. * Default value : true. The SPS is faster when it's set to false.
  35915. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35916. */
  35917. get computeParticleRotation(): boolean;
  35918. /**
  35919. * Gets if `setParticles()` computes the particle colors or not.
  35920. * Default value : true. The SPS is faster when it's set to false.
  35921. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35922. */
  35923. get computeParticleColor(): boolean;
  35924. /**
  35925. * Gets if `setParticles()` computes the particle textures or not.
  35926. * Default value : true. The SPS is faster when it's set to false.
  35927. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35928. */
  35929. get computeParticleTexture(): boolean;
  35930. /**
  35931. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35932. * Default value : false. The SPS is faster when it's set to false.
  35933. * Note : the particle custom vertex positions aren't stored values.
  35934. */
  35935. get computeParticleVertex(): boolean;
  35936. /**
  35937. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35938. */
  35939. get computeBoundingBox(): boolean;
  35940. /**
  35941. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35942. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35943. * Default : `true`
  35944. */
  35945. get depthSortParticles(): boolean;
  35946. /**
  35947. * Gets if the SPS is created as expandable at construction time.
  35948. * Default : `false`
  35949. */
  35950. get expandable(): boolean;
  35951. /**
  35952. * Gets if the SPS supports the Multi Materials
  35953. */
  35954. get multimaterialEnabled(): boolean;
  35955. /**
  35956. * Gets if the SPS uses the model materials for its own multimaterial.
  35957. */
  35958. get useModelMaterial(): boolean;
  35959. /**
  35960. * The SPS used material array.
  35961. */
  35962. get materials(): Material[];
  35963. /**
  35964. * Sets the SPS MultiMaterial from the passed materials.
  35965. * Note : the passed array is internally copied and not used then by reference.
  35966. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35967. */
  35968. setMultiMaterial(materials: Material[]): void;
  35969. /**
  35970. * The SPS computed multimaterial object
  35971. */
  35972. get multimaterial(): MultiMaterial;
  35973. set multimaterial(mm: MultiMaterial);
  35974. /**
  35975. * If the subMeshes must be updated on the next call to setParticles()
  35976. */
  35977. get autoUpdateSubMeshes(): boolean;
  35978. set autoUpdateSubMeshes(val: boolean);
  35979. /**
  35980. * This function does nothing. It may be overwritten to set all the particle first values.
  35981. * The SPS doesn't call this function, you may have to call it by your own.
  35982. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35983. */
  35984. initParticles(): void;
  35985. /**
  35986. * This function does nothing. It may be overwritten to recycle a particle.
  35987. * The SPS doesn't call this function, you may have to call it by your own.
  35988. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35989. * @param particle The particle to recycle
  35990. * @returns the recycled particle
  35991. */
  35992. recycleParticle(particle: SolidParticle): SolidParticle;
  35993. /**
  35994. * Updates a particle : this function should be overwritten by the user.
  35995. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35996. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35997. * @example : just set a particle position or velocity and recycle conditions
  35998. * @param particle The particle to update
  35999. * @returns the updated particle
  36000. */
  36001. updateParticle(particle: SolidParticle): SolidParticle;
  36002. /**
  36003. * Updates a vertex of a particle : it can be overwritten by the user.
  36004. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36005. * @param particle the current particle
  36006. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36007. * @param pt the index of the current vertex in the particle shape
  36008. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36009. * @example : just set a vertex particle position or color
  36010. * @returns the sps
  36011. */
  36012. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36013. /**
  36014. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36015. * This does nothing and may be overwritten by the user.
  36016. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36017. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36018. * @param update the boolean update value actually passed to setParticles()
  36019. */
  36020. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36021. /**
  36022. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36023. * This will be passed three parameters.
  36024. * This does nothing and may be overwritten by the user.
  36025. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36026. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36027. * @param update the boolean update value actually passed to setParticles()
  36028. */
  36029. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36030. }
  36031. }
  36032. declare module "babylonjs/Particles/solidParticle" {
  36033. import { Nullable } from "babylonjs/types";
  36034. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36035. import { Color4 } from "babylonjs/Maths/math.color";
  36036. import { Mesh } from "babylonjs/Meshes/mesh";
  36037. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36038. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36039. import { Plane } from "babylonjs/Maths/math.plane";
  36040. import { Material } from "babylonjs/Materials/material";
  36041. /**
  36042. * Represents one particle of a solid particle system.
  36043. */
  36044. export class SolidParticle {
  36045. /**
  36046. * particle global index
  36047. */
  36048. idx: number;
  36049. /**
  36050. * particle identifier
  36051. */
  36052. id: number;
  36053. /**
  36054. * The color of the particle
  36055. */
  36056. color: Nullable<Color4>;
  36057. /**
  36058. * The world space position of the particle.
  36059. */
  36060. position: Vector3;
  36061. /**
  36062. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36063. */
  36064. rotation: Vector3;
  36065. /**
  36066. * The world space rotation quaternion of the particle.
  36067. */
  36068. rotationQuaternion: Nullable<Quaternion>;
  36069. /**
  36070. * The scaling of the particle.
  36071. */
  36072. scaling: Vector3;
  36073. /**
  36074. * The uvs of the particle.
  36075. */
  36076. uvs: Vector4;
  36077. /**
  36078. * The current speed of the particle.
  36079. */
  36080. velocity: Vector3;
  36081. /**
  36082. * The pivot point in the particle local space.
  36083. */
  36084. pivot: Vector3;
  36085. /**
  36086. * Must the particle be translated from its pivot point in its local space ?
  36087. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36088. * Default : false
  36089. */
  36090. translateFromPivot: boolean;
  36091. /**
  36092. * Is the particle active or not ?
  36093. */
  36094. alive: boolean;
  36095. /**
  36096. * Is the particle visible or not ?
  36097. */
  36098. isVisible: boolean;
  36099. /**
  36100. * Index of this particle in the global "positions" array (Internal use)
  36101. * @hidden
  36102. */
  36103. _pos: number;
  36104. /**
  36105. * @hidden Index of this particle in the global "indices" array (Internal use)
  36106. */
  36107. _ind: number;
  36108. /**
  36109. * @hidden ModelShape of this particle (Internal use)
  36110. */
  36111. _model: ModelShape;
  36112. /**
  36113. * ModelShape id of this particle
  36114. */
  36115. shapeId: number;
  36116. /**
  36117. * Index of the particle in its shape id
  36118. */
  36119. idxInShape: number;
  36120. /**
  36121. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36122. */
  36123. _modelBoundingInfo: BoundingInfo;
  36124. /**
  36125. * @hidden Particle BoundingInfo object (Internal use)
  36126. */
  36127. _boundingInfo: BoundingInfo;
  36128. /**
  36129. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36130. */
  36131. _sps: SolidParticleSystem;
  36132. /**
  36133. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36134. */
  36135. _stillInvisible: boolean;
  36136. /**
  36137. * @hidden Last computed particle rotation matrix
  36138. */
  36139. _rotationMatrix: number[];
  36140. /**
  36141. * Parent particle Id, if any.
  36142. * Default null.
  36143. */
  36144. parentId: Nullable<number>;
  36145. /**
  36146. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36147. */
  36148. materialIndex: Nullable<number>;
  36149. /**
  36150. * Custom object or properties.
  36151. */
  36152. props: Nullable<any>;
  36153. /**
  36154. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36155. * The possible values are :
  36156. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36157. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36158. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36159. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36160. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36161. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36162. * */
  36163. cullingStrategy: number;
  36164. /**
  36165. * @hidden Internal global position in the SPS.
  36166. */
  36167. _globalPosition: Vector3;
  36168. /**
  36169. * Creates a Solid Particle object.
  36170. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36171. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36172. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36173. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36174. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36175. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36176. * @param shapeId (integer) is the model shape identifier in the SPS.
  36177. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36178. * @param sps defines the sps it is associated to
  36179. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36180. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36181. */
  36182. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36183. /**
  36184. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36185. * @param target the particle target
  36186. * @returns the current particle
  36187. */
  36188. copyToRef(target: SolidParticle): SolidParticle;
  36189. /**
  36190. * Legacy support, changed scale to scaling
  36191. */
  36192. get scale(): Vector3;
  36193. /**
  36194. * Legacy support, changed scale to scaling
  36195. */
  36196. set scale(scale: Vector3);
  36197. /**
  36198. * Legacy support, changed quaternion to rotationQuaternion
  36199. */
  36200. get quaternion(): Nullable<Quaternion>;
  36201. /**
  36202. * Legacy support, changed quaternion to rotationQuaternion
  36203. */
  36204. set quaternion(q: Nullable<Quaternion>);
  36205. /**
  36206. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36207. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36208. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36209. * @returns true if it intersects
  36210. */
  36211. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36212. /**
  36213. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36214. * A particle is in the frustum if its bounding box intersects the frustum
  36215. * @param frustumPlanes defines the frustum to test
  36216. * @returns true if the particle is in the frustum planes
  36217. */
  36218. isInFrustum(frustumPlanes: Plane[]): boolean;
  36219. /**
  36220. * get the rotation matrix of the particle
  36221. * @hidden
  36222. */
  36223. getRotationMatrix(m: Matrix): void;
  36224. }
  36225. /**
  36226. * Represents the shape of the model used by one particle of a solid particle system.
  36227. * SPS internal tool, don't use it manually.
  36228. */
  36229. export class ModelShape {
  36230. /**
  36231. * The shape id
  36232. * @hidden
  36233. */
  36234. shapeID: number;
  36235. /**
  36236. * flat array of model positions (internal use)
  36237. * @hidden
  36238. */
  36239. _shape: Vector3[];
  36240. /**
  36241. * flat array of model UVs (internal use)
  36242. * @hidden
  36243. */
  36244. _shapeUV: number[];
  36245. /**
  36246. * color array of the model
  36247. * @hidden
  36248. */
  36249. _shapeColors: number[];
  36250. /**
  36251. * indices array of the model
  36252. * @hidden
  36253. */
  36254. _indices: number[];
  36255. /**
  36256. * normals array of the model
  36257. * @hidden
  36258. */
  36259. _normals: number[];
  36260. /**
  36261. * length of the shape in the model indices array (internal use)
  36262. * @hidden
  36263. */
  36264. _indicesLength: number;
  36265. /**
  36266. * Custom position function (internal use)
  36267. * @hidden
  36268. */
  36269. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36270. /**
  36271. * Custom vertex function (internal use)
  36272. * @hidden
  36273. */
  36274. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36275. /**
  36276. * Model material (internal use)
  36277. * @hidden
  36278. */
  36279. _material: Nullable<Material>;
  36280. /**
  36281. * 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.
  36282. * SPS internal tool, don't use it manually.
  36283. * @hidden
  36284. */
  36285. 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>);
  36286. }
  36287. /**
  36288. * Represents a Depth Sorted Particle in the solid particle system.
  36289. * @hidden
  36290. */
  36291. export class DepthSortedParticle {
  36292. /**
  36293. * Particle index
  36294. */
  36295. idx: number;
  36296. /**
  36297. * Index of the particle in the "indices" array
  36298. */
  36299. ind: number;
  36300. /**
  36301. * Length of the particle shape in the "indices" array
  36302. */
  36303. indicesLength: number;
  36304. /**
  36305. * Squared distance from the particle to the camera
  36306. */
  36307. sqDistance: number;
  36308. /**
  36309. * Material index when used with MultiMaterials
  36310. */
  36311. materialIndex: number;
  36312. /**
  36313. * Creates a new sorted particle
  36314. * @param materialIndex
  36315. */
  36316. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36317. }
  36318. /**
  36319. * Represents a solid particle vertex
  36320. */
  36321. export class SolidParticleVertex {
  36322. /**
  36323. * Vertex position
  36324. */
  36325. position: Vector3;
  36326. /**
  36327. * Vertex color
  36328. */
  36329. color: Color4;
  36330. /**
  36331. * Vertex UV
  36332. */
  36333. uv: Vector2;
  36334. /**
  36335. * Creates a new solid particle vertex
  36336. */
  36337. constructor();
  36338. /** Vertex x coordinate */
  36339. get x(): number;
  36340. set x(val: number);
  36341. /** Vertex y coordinate */
  36342. get y(): number;
  36343. set y(val: number);
  36344. /** Vertex z coordinate */
  36345. get z(): number;
  36346. set z(val: number);
  36347. }
  36348. }
  36349. declare module "babylonjs/Collisions/meshCollisionData" {
  36350. import { Collider } from "babylonjs/Collisions/collider";
  36351. import { Vector3 } from "babylonjs/Maths/math.vector";
  36352. import { Nullable } from "babylonjs/types";
  36353. import { Observer } from "babylonjs/Misc/observable";
  36354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36355. /**
  36356. * @hidden
  36357. */
  36358. export class _MeshCollisionData {
  36359. _checkCollisions: boolean;
  36360. _collisionMask: number;
  36361. _collisionGroup: number;
  36362. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36363. _collider: Nullable<Collider>;
  36364. _oldPositionForCollisions: Vector3;
  36365. _diffPositionForCollisions: Vector3;
  36366. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36367. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36368. _collisionResponse: boolean;
  36369. }
  36370. }
  36371. declare module "babylonjs/Meshes/abstractMesh" {
  36372. import { Observable } from "babylonjs/Misc/observable";
  36373. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36374. import { Camera } from "babylonjs/Cameras/camera";
  36375. import { Scene, IDisposable } from "babylonjs/scene";
  36376. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36377. import { Node } from "babylonjs/node";
  36378. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36379. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36380. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36381. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36382. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36383. import { Material } from "babylonjs/Materials/material";
  36384. import { Light } from "babylonjs/Lights/light";
  36385. import { Skeleton } from "babylonjs/Bones/skeleton";
  36386. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36387. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36388. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36389. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36390. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36391. import { Plane } from "babylonjs/Maths/math.plane";
  36392. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36393. import { Ray } from "babylonjs/Culling/ray";
  36394. import { Collider } from "babylonjs/Collisions/collider";
  36395. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36396. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36397. import { IEdgesRendererOptions } from "babylonjs/Rendering/edgesRenderer";
  36398. /** @hidden */
  36399. class _FacetDataStorage {
  36400. facetPositions: Vector3[];
  36401. facetNormals: Vector3[];
  36402. facetPartitioning: number[][];
  36403. facetNb: number;
  36404. partitioningSubdivisions: number;
  36405. partitioningBBoxRatio: number;
  36406. facetDataEnabled: boolean;
  36407. facetParameters: any;
  36408. bbSize: Vector3;
  36409. subDiv: {
  36410. max: number;
  36411. X: number;
  36412. Y: number;
  36413. Z: number;
  36414. };
  36415. facetDepthSort: boolean;
  36416. facetDepthSortEnabled: boolean;
  36417. depthSortedIndices: IndicesArray;
  36418. depthSortedFacets: {
  36419. ind: number;
  36420. sqDistance: number;
  36421. }[];
  36422. facetDepthSortFunction: (f1: {
  36423. ind: number;
  36424. sqDistance: number;
  36425. }, f2: {
  36426. ind: number;
  36427. sqDistance: number;
  36428. }) => number;
  36429. facetDepthSortFrom: Vector3;
  36430. facetDepthSortOrigin: Vector3;
  36431. invertedMatrix: Matrix;
  36432. }
  36433. /**
  36434. * @hidden
  36435. **/
  36436. class _InternalAbstractMeshDataInfo {
  36437. _hasVertexAlpha: boolean;
  36438. _useVertexColors: boolean;
  36439. _numBoneInfluencers: number;
  36440. _applyFog: boolean;
  36441. _receiveShadows: boolean;
  36442. _facetData: _FacetDataStorage;
  36443. _visibility: number;
  36444. _skeleton: Nullable<Skeleton>;
  36445. _layerMask: number;
  36446. _computeBonesUsingShaders: boolean;
  36447. _isActive: boolean;
  36448. _onlyForInstances: boolean;
  36449. _isActiveIntermediate: boolean;
  36450. _onlyForInstancesIntermediate: boolean;
  36451. _actAsRegularMesh: boolean;
  36452. _currentLOD: Nullable<AbstractMesh>;
  36453. _currentLODIsUpToDate: boolean;
  36454. }
  36455. /**
  36456. * Class used to store all common mesh properties
  36457. */
  36458. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36459. /** No occlusion */
  36460. static OCCLUSION_TYPE_NONE: number;
  36461. /** Occlusion set to optimisitic */
  36462. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36463. /** Occlusion set to strict */
  36464. static OCCLUSION_TYPE_STRICT: number;
  36465. /** Use an accurante occlusion algorithm */
  36466. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36467. /** Use a conservative occlusion algorithm */
  36468. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36469. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36470. * Test order :
  36471. * Is the bounding sphere outside the frustum ?
  36472. * If not, are the bounding box vertices outside the frustum ?
  36473. * It not, then the cullable object is in the frustum.
  36474. */
  36475. static readonly CULLINGSTRATEGY_STANDARD: number;
  36476. /** Culling strategy : Bounding Sphere Only.
  36477. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36478. * It's also less accurate than the standard because some not visible objects can still be selected.
  36479. * Test : is the bounding sphere outside the frustum ?
  36480. * If not, then the cullable object is in the frustum.
  36481. */
  36482. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36483. /** Culling strategy : Optimistic Inclusion.
  36484. * This in an inclusion test first, then the standard exclusion test.
  36485. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36486. * 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.
  36487. * Anyway, it's as accurate as the standard strategy.
  36488. * Test :
  36489. * Is the cullable object bounding sphere center in the frustum ?
  36490. * If not, apply the default culling strategy.
  36491. */
  36492. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36493. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36494. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36495. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36496. * 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.
  36497. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36498. * Test :
  36499. * Is the cullable object bounding sphere center in the frustum ?
  36500. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36501. */
  36502. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36503. /**
  36504. * No billboard
  36505. */
  36506. static get BILLBOARDMODE_NONE(): number;
  36507. /** Billboard on X axis */
  36508. static get BILLBOARDMODE_X(): number;
  36509. /** Billboard on Y axis */
  36510. static get BILLBOARDMODE_Y(): number;
  36511. /** Billboard on Z axis */
  36512. static get BILLBOARDMODE_Z(): number;
  36513. /** Billboard on all axes */
  36514. static get BILLBOARDMODE_ALL(): number;
  36515. /** Billboard on using position instead of orientation */
  36516. static get BILLBOARDMODE_USE_POSITION(): number;
  36517. /** @hidden */
  36518. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36519. /**
  36520. * The culling strategy to use to check whether the mesh must be rendered or not.
  36521. * This value can be changed at any time and will be used on the next render mesh selection.
  36522. * The possible values are :
  36523. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36524. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36525. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36526. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36527. * Please read each static variable documentation to get details about the culling process.
  36528. * */
  36529. cullingStrategy: number;
  36530. /**
  36531. * Gets the number of facets in the mesh
  36532. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36533. */
  36534. get facetNb(): number;
  36535. /**
  36536. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36537. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36538. */
  36539. get partitioningSubdivisions(): number;
  36540. set partitioningSubdivisions(nb: number);
  36541. /**
  36542. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36543. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36544. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36545. */
  36546. get partitioningBBoxRatio(): number;
  36547. set partitioningBBoxRatio(ratio: number);
  36548. /**
  36549. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36550. * Works only for updatable meshes.
  36551. * Doesn't work with multi-materials
  36552. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36553. */
  36554. get mustDepthSortFacets(): boolean;
  36555. set mustDepthSortFacets(sort: boolean);
  36556. /**
  36557. * The location (Vector3) where the facet depth sort must be computed from.
  36558. * By default, the active camera position.
  36559. * Used only when facet depth sort is enabled
  36560. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36561. */
  36562. get facetDepthSortFrom(): Vector3;
  36563. set facetDepthSortFrom(location: Vector3);
  36564. /**
  36565. * gets a boolean indicating if facetData is enabled
  36566. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36567. */
  36568. get isFacetDataEnabled(): boolean;
  36569. /** @hidden */
  36570. _updateNonUniformScalingState(value: boolean): boolean;
  36571. /**
  36572. * An event triggered when this mesh collides with another one
  36573. */
  36574. onCollideObservable: Observable<AbstractMesh>;
  36575. /** Set a function to call when this mesh collides with another one */
  36576. set onCollide(callback: () => void);
  36577. /**
  36578. * An event triggered when the collision's position changes
  36579. */
  36580. onCollisionPositionChangeObservable: Observable<Vector3>;
  36581. /** Set a function to call when the collision's position changes */
  36582. set onCollisionPositionChange(callback: () => void);
  36583. /**
  36584. * An event triggered when material is changed
  36585. */
  36586. onMaterialChangedObservable: Observable<AbstractMesh>;
  36587. /**
  36588. * Gets or sets the orientation for POV movement & rotation
  36589. */
  36590. definedFacingForward: boolean;
  36591. /** @hidden */
  36592. _occlusionQuery: Nullable<WebGLQuery>;
  36593. /** @hidden */
  36594. _renderingGroup: Nullable<RenderingGroup>;
  36595. /**
  36596. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36597. */
  36598. get visibility(): number;
  36599. /**
  36600. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36601. */
  36602. set visibility(value: number);
  36603. /** Gets or sets the alpha index used to sort transparent meshes
  36604. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36605. */
  36606. alphaIndex: number;
  36607. /**
  36608. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36609. */
  36610. isVisible: boolean;
  36611. /**
  36612. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36613. */
  36614. isPickable: boolean;
  36615. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36616. showSubMeshesBoundingBox: boolean;
  36617. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36618. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36619. */
  36620. isBlocker: boolean;
  36621. /**
  36622. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36623. */
  36624. enablePointerMoveEvents: boolean;
  36625. private _renderingGroupId;
  36626. /**
  36627. * Specifies the rendering group id for this mesh (0 by default)
  36628. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36629. */
  36630. get renderingGroupId(): number;
  36631. set renderingGroupId(value: number);
  36632. private _material;
  36633. /** Gets or sets current material */
  36634. get material(): Nullable<Material>;
  36635. set material(value: Nullable<Material>);
  36636. /**
  36637. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36638. * @see https://doc.babylonjs.com/babylon101/shadows
  36639. */
  36640. get receiveShadows(): boolean;
  36641. set receiveShadows(value: boolean);
  36642. /** Defines color to use when rendering outline */
  36643. outlineColor: Color3;
  36644. /** Define width to use when rendering outline */
  36645. outlineWidth: number;
  36646. /** Defines color to use when rendering overlay */
  36647. overlayColor: Color3;
  36648. /** Defines alpha to use when rendering overlay */
  36649. overlayAlpha: number;
  36650. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36651. get hasVertexAlpha(): boolean;
  36652. set hasVertexAlpha(value: boolean);
  36653. /** 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) */
  36654. get useVertexColors(): boolean;
  36655. set useVertexColors(value: boolean);
  36656. /**
  36657. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36658. */
  36659. get computeBonesUsingShaders(): boolean;
  36660. set computeBonesUsingShaders(value: boolean);
  36661. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36662. get numBoneInfluencers(): number;
  36663. set numBoneInfluencers(value: number);
  36664. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36665. get applyFog(): boolean;
  36666. set applyFog(value: boolean);
  36667. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36668. useOctreeForRenderingSelection: boolean;
  36669. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36670. useOctreeForPicking: boolean;
  36671. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36672. useOctreeForCollisions: boolean;
  36673. /**
  36674. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36675. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36676. */
  36677. get layerMask(): number;
  36678. set layerMask(value: number);
  36679. /**
  36680. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36681. */
  36682. alwaysSelectAsActiveMesh: boolean;
  36683. /**
  36684. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36685. */
  36686. doNotSyncBoundingInfo: boolean;
  36687. /**
  36688. * Gets or sets the current action manager
  36689. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36690. */
  36691. actionManager: Nullable<AbstractActionManager>;
  36692. private _meshCollisionData;
  36693. /**
  36694. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36695. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36696. */
  36697. ellipsoid: Vector3;
  36698. /**
  36699. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36700. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36701. */
  36702. ellipsoidOffset: Vector3;
  36703. /**
  36704. * Gets or sets a collision mask used to mask collisions (default is -1).
  36705. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36706. */
  36707. get collisionMask(): number;
  36708. set collisionMask(mask: number);
  36709. /**
  36710. * Gets or sets a collision response flag (default is true).
  36711. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36712. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36713. * to respond to the collision.
  36714. */
  36715. get collisionResponse(): boolean;
  36716. set collisionResponse(response: boolean);
  36717. /**
  36718. * Gets or sets the current collision group mask (-1 by default).
  36719. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36720. */
  36721. get collisionGroup(): number;
  36722. set collisionGroup(mask: number);
  36723. /**
  36724. * Gets or sets current surrounding meshes (null by default).
  36725. *
  36726. * By default collision detection is tested against every mesh in the scene.
  36727. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36728. * meshes will be tested for the collision.
  36729. *
  36730. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36731. */
  36732. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36733. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36734. /**
  36735. * Defines edge width used when edgesRenderer is enabled
  36736. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36737. */
  36738. edgesWidth: number;
  36739. /**
  36740. * Defines edge color used when edgesRenderer is enabled
  36741. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36742. */
  36743. edgesColor: Color4;
  36744. /** @hidden */
  36745. _edgesRenderer: Nullable<IEdgesRenderer>;
  36746. /** @hidden */
  36747. _masterMesh: Nullable<AbstractMesh>;
  36748. /** @hidden */
  36749. _boundingInfo: Nullable<BoundingInfo>;
  36750. /** @hidden */
  36751. _renderId: number;
  36752. /**
  36753. * Gets or sets the list of subMeshes
  36754. * @see https://doc.babylonjs.com/how_to/multi_materials
  36755. */
  36756. subMeshes: SubMesh[];
  36757. /** @hidden */
  36758. _intersectionsInProgress: AbstractMesh[];
  36759. /** @hidden */
  36760. _unIndexed: boolean;
  36761. /** @hidden */
  36762. _lightSources: Light[];
  36763. /** Gets the list of lights affecting that mesh */
  36764. get lightSources(): Light[];
  36765. /** @hidden */
  36766. get _positions(): Nullable<Vector3[]>;
  36767. /** @hidden */
  36768. _waitingData: {
  36769. lods: Nullable<any>;
  36770. actions: Nullable<any>;
  36771. freezeWorldMatrix: Nullable<boolean>;
  36772. };
  36773. /** @hidden */
  36774. _bonesTransformMatrices: Nullable<Float32Array>;
  36775. /** @hidden */
  36776. _transformMatrixTexture: Nullable<RawTexture>;
  36777. /**
  36778. * Gets or sets a skeleton to apply skining transformations
  36779. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36780. */
  36781. set skeleton(value: Nullable<Skeleton>);
  36782. get skeleton(): Nullable<Skeleton>;
  36783. /**
  36784. * An event triggered when the mesh is rebuilt.
  36785. */
  36786. onRebuildObservable: Observable<AbstractMesh>;
  36787. /**
  36788. * Creates a new AbstractMesh
  36789. * @param name defines the name of the mesh
  36790. * @param scene defines the hosting scene
  36791. */
  36792. constructor(name: string, scene?: Nullable<Scene>);
  36793. /**
  36794. * Returns the string "AbstractMesh"
  36795. * @returns "AbstractMesh"
  36796. */
  36797. getClassName(): string;
  36798. /**
  36799. * Gets a string representation of the current mesh
  36800. * @param fullDetails defines a boolean indicating if full details must be included
  36801. * @returns a string representation of the current mesh
  36802. */
  36803. toString(fullDetails?: boolean): string;
  36804. /**
  36805. * @hidden
  36806. */
  36807. protected _getEffectiveParent(): Nullable<Node>;
  36808. /** @hidden */
  36809. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36810. /** @hidden */
  36811. _rebuild(): void;
  36812. /** @hidden */
  36813. _resyncLightSources(): void;
  36814. /** @hidden */
  36815. _resyncLightSource(light: Light): void;
  36816. /** @hidden */
  36817. _unBindEffect(): void;
  36818. /** @hidden */
  36819. _removeLightSource(light: Light, dispose: boolean): void;
  36820. private _markSubMeshesAsDirty;
  36821. /** @hidden */
  36822. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36823. /** @hidden */
  36824. _markSubMeshesAsAttributesDirty(): void;
  36825. /** @hidden */
  36826. _markSubMeshesAsMiscDirty(): void;
  36827. /**
  36828. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36829. */
  36830. get scaling(): Vector3;
  36831. set scaling(newScaling: Vector3);
  36832. /**
  36833. * Returns true if the mesh is blocked. Implemented by child classes
  36834. */
  36835. get isBlocked(): boolean;
  36836. /**
  36837. * Returns the mesh itself by default. Implemented by child classes
  36838. * @param camera defines the camera to use to pick the right LOD level
  36839. * @returns the currentAbstractMesh
  36840. */
  36841. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36842. /**
  36843. * Returns 0 by default. Implemented by child classes
  36844. * @returns an integer
  36845. */
  36846. getTotalVertices(): number;
  36847. /**
  36848. * Returns a positive integer : the total number of indices in this mesh geometry.
  36849. * @returns the numner of indices or zero if the mesh has no geometry.
  36850. */
  36851. getTotalIndices(): number;
  36852. /**
  36853. * Returns null by default. Implemented by child classes
  36854. * @returns null
  36855. */
  36856. getIndices(): Nullable<IndicesArray>;
  36857. /**
  36858. * Returns the array of the requested vertex data kind. Implemented by child classes
  36859. * @param kind defines the vertex data kind to use
  36860. * @returns null
  36861. */
  36862. getVerticesData(kind: string): Nullable<FloatArray>;
  36863. /**
  36864. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36865. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36866. * Note that a new underlying VertexBuffer object is created each call.
  36867. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36868. * @param kind defines vertex data kind:
  36869. * * VertexBuffer.PositionKind
  36870. * * VertexBuffer.UVKind
  36871. * * VertexBuffer.UV2Kind
  36872. * * VertexBuffer.UV3Kind
  36873. * * VertexBuffer.UV4Kind
  36874. * * VertexBuffer.UV5Kind
  36875. * * VertexBuffer.UV6Kind
  36876. * * VertexBuffer.ColorKind
  36877. * * VertexBuffer.MatricesIndicesKind
  36878. * * VertexBuffer.MatricesIndicesExtraKind
  36879. * * VertexBuffer.MatricesWeightsKind
  36880. * * VertexBuffer.MatricesWeightsExtraKind
  36881. * @param data defines the data source
  36882. * @param updatable defines if the data must be flagged as updatable (or static)
  36883. * @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
  36884. * @returns the current mesh
  36885. */
  36886. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36887. /**
  36888. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36889. * If the mesh has no geometry, it is simply returned as it is.
  36890. * @param kind defines vertex data kind:
  36891. * * VertexBuffer.PositionKind
  36892. * * VertexBuffer.UVKind
  36893. * * VertexBuffer.UV2Kind
  36894. * * VertexBuffer.UV3Kind
  36895. * * VertexBuffer.UV4Kind
  36896. * * VertexBuffer.UV5Kind
  36897. * * VertexBuffer.UV6Kind
  36898. * * VertexBuffer.ColorKind
  36899. * * VertexBuffer.MatricesIndicesKind
  36900. * * VertexBuffer.MatricesIndicesExtraKind
  36901. * * VertexBuffer.MatricesWeightsKind
  36902. * * VertexBuffer.MatricesWeightsExtraKind
  36903. * @param data defines the data source
  36904. * @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
  36905. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36906. * @returns the current mesh
  36907. */
  36908. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36909. /**
  36910. * Sets the mesh indices,
  36911. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36912. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36913. * @param totalVertices Defines the total number of vertices
  36914. * @returns the current mesh
  36915. */
  36916. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36917. /**
  36918. * Gets a boolean indicating if specific vertex data is present
  36919. * @param kind defines the vertex data kind to use
  36920. * @returns true is data kind is present
  36921. */
  36922. isVerticesDataPresent(kind: string): boolean;
  36923. /**
  36924. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36925. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36926. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36927. * @returns a BoundingInfo
  36928. */
  36929. getBoundingInfo(): BoundingInfo;
  36930. /**
  36931. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36932. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36933. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36934. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36935. * @returns the current mesh
  36936. */
  36937. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36938. /**
  36939. * Overwrite the current bounding info
  36940. * @param boundingInfo defines the new bounding info
  36941. * @returns the current mesh
  36942. */
  36943. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36944. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36945. get useBones(): boolean;
  36946. /** @hidden */
  36947. _preActivate(): void;
  36948. /** @hidden */
  36949. _preActivateForIntermediateRendering(renderId: number): void;
  36950. /** @hidden */
  36951. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36952. /** @hidden */
  36953. _postActivate(): void;
  36954. /** @hidden */
  36955. _freeze(): void;
  36956. /** @hidden */
  36957. _unFreeze(): void;
  36958. /**
  36959. * Gets the current world matrix
  36960. * @returns a Matrix
  36961. */
  36962. getWorldMatrix(): Matrix;
  36963. /** @hidden */
  36964. _getWorldMatrixDeterminant(): number;
  36965. /**
  36966. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36967. */
  36968. get isAnInstance(): boolean;
  36969. /**
  36970. * Gets a boolean indicating if this mesh has instances
  36971. */
  36972. get hasInstances(): boolean;
  36973. /**
  36974. * Gets a boolean indicating if this mesh has thin instances
  36975. */
  36976. get hasThinInstances(): boolean;
  36977. /**
  36978. * Perform relative position change from the point of view of behind the front of the mesh.
  36979. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36980. * Supports definition of mesh facing forward or backward
  36981. * @param amountRight defines the distance on the right axis
  36982. * @param amountUp defines the distance on the up axis
  36983. * @param amountForward defines the distance on the forward axis
  36984. * @returns the current mesh
  36985. */
  36986. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36987. /**
  36988. * Calculate relative position change from the point of view of behind the front of the mesh.
  36989. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36990. * Supports definition of mesh facing forward or backward
  36991. * @param amountRight defines the distance on the right axis
  36992. * @param amountUp defines the distance on the up axis
  36993. * @param amountForward defines the distance on the forward axis
  36994. * @returns the new displacement vector
  36995. */
  36996. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36997. /**
  36998. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36999. * Supports definition of mesh facing forward or backward
  37000. * @param flipBack defines the flip
  37001. * @param twirlClockwise defines the twirl
  37002. * @param tiltRight defines the tilt
  37003. * @returns the current mesh
  37004. */
  37005. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37006. /**
  37007. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37008. * Supports definition of mesh facing forward or backward.
  37009. * @param flipBack defines the flip
  37010. * @param twirlClockwise defines the twirl
  37011. * @param tiltRight defines the tilt
  37012. * @returns the new rotation vector
  37013. */
  37014. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37015. /**
  37016. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37017. * This means the mesh underlying bounding box and sphere are recomputed.
  37018. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37019. * @returns the current mesh
  37020. */
  37021. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37022. /** @hidden */
  37023. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37024. /** @hidden */
  37025. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37026. /** @hidden */
  37027. _updateBoundingInfo(): AbstractMesh;
  37028. /** @hidden */
  37029. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37030. /** @hidden */
  37031. protected _afterComputeWorldMatrix(): void;
  37032. /** @hidden */
  37033. get _effectiveMesh(): AbstractMesh;
  37034. /**
  37035. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37036. * A mesh is in the frustum if its bounding box intersects the frustum
  37037. * @param frustumPlanes defines the frustum to test
  37038. * @returns true if the mesh is in the frustum planes
  37039. */
  37040. isInFrustum(frustumPlanes: Plane[]): boolean;
  37041. /**
  37042. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37043. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37044. * @param frustumPlanes defines the frustum to test
  37045. * @returns true if the mesh is completely in the frustum planes
  37046. */
  37047. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37048. /**
  37049. * True if the mesh intersects another mesh or a SolidParticle object
  37050. * @param mesh defines a target mesh or SolidParticle to test
  37051. * @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)
  37052. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37053. * @returns true if there is an intersection
  37054. */
  37055. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37056. /**
  37057. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37058. * @param point defines the point to test
  37059. * @returns true if there is an intersection
  37060. */
  37061. intersectsPoint(point: Vector3): boolean;
  37062. /**
  37063. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37064. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37065. */
  37066. get checkCollisions(): boolean;
  37067. set checkCollisions(collisionEnabled: boolean);
  37068. /**
  37069. * Gets Collider object used to compute collisions (not physics)
  37070. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37071. */
  37072. get collider(): Nullable<Collider>;
  37073. /**
  37074. * Move the mesh using collision engine
  37075. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37076. * @param displacement defines the requested displacement vector
  37077. * @returns the current mesh
  37078. */
  37079. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37080. private _onCollisionPositionChange;
  37081. /** @hidden */
  37082. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37083. /** @hidden */
  37084. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37085. /** @hidden */
  37086. _checkCollision(collider: Collider): AbstractMesh;
  37087. /** @hidden */
  37088. _generatePointsArray(): boolean;
  37089. /**
  37090. * Checks if the passed Ray intersects with the mesh
  37091. * @param ray defines the ray to use
  37092. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37093. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37094. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37095. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37096. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  37097. * @returns the picking info
  37098. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37099. */
  37100. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  37101. /**
  37102. * Clones the current mesh
  37103. * @param name defines the mesh name
  37104. * @param newParent defines the new mesh parent
  37105. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37106. * @returns the new mesh
  37107. */
  37108. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37109. /**
  37110. * Disposes all the submeshes of the current meshnp
  37111. * @returns the current mesh
  37112. */
  37113. releaseSubMeshes(): AbstractMesh;
  37114. /**
  37115. * Releases resources associated with this abstract mesh.
  37116. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37117. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37118. */
  37119. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37120. /**
  37121. * Adds the passed mesh as a child to the current mesh
  37122. * @param mesh defines the child mesh
  37123. * @returns the current mesh
  37124. */
  37125. addChild(mesh: AbstractMesh): AbstractMesh;
  37126. /**
  37127. * Removes the passed mesh from the current mesh children list
  37128. * @param mesh defines the child mesh
  37129. * @returns the current mesh
  37130. */
  37131. removeChild(mesh: AbstractMesh): AbstractMesh;
  37132. /** @hidden */
  37133. private _initFacetData;
  37134. /**
  37135. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37136. * This method can be called within the render loop.
  37137. * 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
  37138. * @returns the current mesh
  37139. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37140. */
  37141. updateFacetData(): AbstractMesh;
  37142. /**
  37143. * Returns the facetLocalNormals array.
  37144. * The normals are expressed in the mesh local spac
  37145. * @returns an array of Vector3
  37146. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37147. */
  37148. getFacetLocalNormals(): Vector3[];
  37149. /**
  37150. * Returns the facetLocalPositions array.
  37151. * The facet positions are expressed in the mesh local space
  37152. * @returns an array of Vector3
  37153. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37154. */
  37155. getFacetLocalPositions(): Vector3[];
  37156. /**
  37157. * Returns the facetLocalPartioning array
  37158. * @returns an array of array of numbers
  37159. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37160. */
  37161. getFacetLocalPartitioning(): number[][];
  37162. /**
  37163. * Returns the i-th facet position in the world system.
  37164. * This method allocates a new Vector3 per call
  37165. * @param i defines the facet index
  37166. * @returns a new Vector3
  37167. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37168. */
  37169. getFacetPosition(i: number): Vector3;
  37170. /**
  37171. * Sets the reference Vector3 with the i-th facet position in the world system
  37172. * @param i defines the facet index
  37173. * @param ref defines the target vector
  37174. * @returns the current mesh
  37175. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37176. */
  37177. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37178. /**
  37179. * Returns the i-th facet normal in the world system.
  37180. * This method allocates a new Vector3 per call
  37181. * @param i defines the facet index
  37182. * @returns a new Vector3
  37183. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37184. */
  37185. getFacetNormal(i: number): Vector3;
  37186. /**
  37187. * Sets the reference Vector3 with the i-th facet normal in the world system
  37188. * @param i defines the facet index
  37189. * @param ref defines the target vector
  37190. * @returns the current mesh
  37191. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37192. */
  37193. getFacetNormalToRef(i: number, ref: Vector3): this;
  37194. /**
  37195. * 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)
  37196. * @param x defines x coordinate
  37197. * @param y defines y coordinate
  37198. * @param z defines z coordinate
  37199. * @returns the array of facet indexes
  37200. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37201. */
  37202. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37203. /**
  37204. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37205. * @param projected sets as the (x,y,z) world projection on the facet
  37206. * @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
  37207. * @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
  37208. * @param x defines x coordinate
  37209. * @param y defines y coordinate
  37210. * @param z defines z coordinate
  37211. * @returns the face index if found (or null instead)
  37212. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37213. */
  37214. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37215. /**
  37216. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37217. * @param projected sets as the (x,y,z) local projection on the facet
  37218. * @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
  37219. * @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
  37220. * @param x defines x coordinate
  37221. * @param y defines y coordinate
  37222. * @param z defines z coordinate
  37223. * @returns the face index if found (or null instead)
  37224. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37225. */
  37226. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37227. /**
  37228. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37229. * @returns the parameters
  37230. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37231. */
  37232. getFacetDataParameters(): any;
  37233. /**
  37234. * Disables the feature FacetData and frees the related memory
  37235. * @returns the current mesh
  37236. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37237. */
  37238. disableFacetData(): AbstractMesh;
  37239. /**
  37240. * Updates the AbstractMesh indices array
  37241. * @param indices defines the data source
  37242. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37243. * @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)
  37244. * @returns the current mesh
  37245. */
  37246. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37247. /**
  37248. * Creates new normals data for the mesh
  37249. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37250. * @returns the current mesh
  37251. */
  37252. createNormals(updatable: boolean): AbstractMesh;
  37253. /**
  37254. * Align the mesh with a normal
  37255. * @param normal defines the normal to use
  37256. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37257. * @returns the current mesh
  37258. */
  37259. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37260. /** @hidden */
  37261. _checkOcclusionQuery(): boolean;
  37262. /**
  37263. * Disables the mesh edge rendering mode
  37264. * @returns the currentAbstractMesh
  37265. */
  37266. disableEdgesRendering(): AbstractMesh;
  37267. /**
  37268. * Enables the edge rendering mode on the mesh.
  37269. * This mode makes the mesh edges visible
  37270. * @param epsilon defines the maximal distance between two angles to detect a face
  37271. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37272. * @param options options to the edge renderer
  37273. * @returns the currentAbstractMesh
  37274. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37275. */
  37276. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  37277. /**
  37278. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37279. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37280. */
  37281. getConnectedParticleSystems(): IParticleSystem[];
  37282. }
  37283. }
  37284. declare module "babylonjs/Actions/actionEvent" {
  37285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37286. import { Nullable } from "babylonjs/types";
  37287. import { Sprite } from "babylonjs/Sprites/sprite";
  37288. import { Scene } from "babylonjs/scene";
  37289. import { Vector2 } from "babylonjs/Maths/math.vector";
  37290. /**
  37291. * Interface used to define ActionEvent
  37292. */
  37293. export interface IActionEvent {
  37294. /** The mesh or sprite that triggered the action */
  37295. source: any;
  37296. /** The X mouse cursor position at the time of the event */
  37297. pointerX: number;
  37298. /** The Y mouse cursor position at the time of the event */
  37299. pointerY: number;
  37300. /** The mesh that is currently pointed at (can be null) */
  37301. meshUnderPointer: Nullable<AbstractMesh>;
  37302. /** the original (browser) event that triggered the ActionEvent */
  37303. sourceEvent?: any;
  37304. /** additional data for the event */
  37305. additionalData?: any;
  37306. }
  37307. /**
  37308. * ActionEvent is the event being sent when an action is triggered.
  37309. */
  37310. export class ActionEvent implements IActionEvent {
  37311. /** The mesh or sprite that triggered the action */
  37312. source: any;
  37313. /** The X mouse cursor position at the time of the event */
  37314. pointerX: number;
  37315. /** The Y mouse cursor position at the time of the event */
  37316. pointerY: number;
  37317. /** The mesh that is currently pointed at (can be null) */
  37318. meshUnderPointer: Nullable<AbstractMesh>;
  37319. /** the original (browser) event that triggered the ActionEvent */
  37320. sourceEvent?: any;
  37321. /** additional data for the event */
  37322. additionalData?: any;
  37323. /**
  37324. * Creates a new ActionEvent
  37325. * @param source The mesh or sprite that triggered the action
  37326. * @param pointerX The X mouse cursor position at the time of the event
  37327. * @param pointerY The Y mouse cursor position at the time of the event
  37328. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37329. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37330. * @param additionalData additional data for the event
  37331. */
  37332. constructor(
  37333. /** The mesh or sprite that triggered the action */
  37334. source: any,
  37335. /** The X mouse cursor position at the time of the event */
  37336. pointerX: number,
  37337. /** The Y mouse cursor position at the time of the event */
  37338. pointerY: number,
  37339. /** The mesh that is currently pointed at (can be null) */
  37340. meshUnderPointer: Nullable<AbstractMesh>,
  37341. /** the original (browser) event that triggered the ActionEvent */
  37342. sourceEvent?: any,
  37343. /** additional data for the event */
  37344. additionalData?: any);
  37345. /**
  37346. * Helper function to auto-create an ActionEvent from a source mesh.
  37347. * @param source The source mesh that triggered the event
  37348. * @param evt The original (browser) event
  37349. * @param additionalData additional data for the event
  37350. * @returns the new ActionEvent
  37351. */
  37352. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37353. /**
  37354. * Helper function to auto-create an ActionEvent from a source sprite
  37355. * @param source The source sprite that triggered the event
  37356. * @param scene Scene associated with the sprite
  37357. * @param evt The original (browser) event
  37358. * @param additionalData additional data for the event
  37359. * @returns the new ActionEvent
  37360. */
  37361. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37362. /**
  37363. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37364. * @param scene the scene where the event occurred
  37365. * @param evt The original (browser) event
  37366. * @returns the new ActionEvent
  37367. */
  37368. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37369. /**
  37370. * Helper function to auto-create an ActionEvent from a primitive
  37371. * @param prim defines the target primitive
  37372. * @param pointerPos defines the pointer position
  37373. * @param evt The original (browser) event
  37374. * @param additionalData additional data for the event
  37375. * @returns the new ActionEvent
  37376. */
  37377. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37378. }
  37379. }
  37380. declare module "babylonjs/Actions/abstractActionManager" {
  37381. import { IDisposable } from "babylonjs/scene";
  37382. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37383. import { IAction } from "babylonjs/Actions/action";
  37384. import { Nullable } from "babylonjs/types";
  37385. /**
  37386. * Abstract class used to decouple action Manager from scene and meshes.
  37387. * Do not instantiate.
  37388. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37389. */
  37390. export abstract class AbstractActionManager implements IDisposable {
  37391. /** Gets the list of active triggers */
  37392. static Triggers: {
  37393. [key: string]: number;
  37394. };
  37395. /** Gets the cursor to use when hovering items */
  37396. hoverCursor: string;
  37397. /** Gets the list of actions */
  37398. actions: IAction[];
  37399. /**
  37400. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37401. */
  37402. isRecursive: boolean;
  37403. /**
  37404. * Releases all associated resources
  37405. */
  37406. abstract dispose(): void;
  37407. /**
  37408. * Does this action manager has pointer triggers
  37409. */
  37410. abstract get hasPointerTriggers(): boolean;
  37411. /**
  37412. * Does this action manager has pick triggers
  37413. */
  37414. abstract get hasPickTriggers(): boolean;
  37415. /**
  37416. * Process a specific trigger
  37417. * @param trigger defines the trigger to process
  37418. * @param evt defines the event details to be processed
  37419. */
  37420. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37421. /**
  37422. * Does this action manager handles actions of any of the given triggers
  37423. * @param triggers defines the triggers to be tested
  37424. * @return a boolean indicating whether one (or more) of the triggers is handled
  37425. */
  37426. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37427. /**
  37428. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37429. * speed.
  37430. * @param triggerA defines the trigger to be tested
  37431. * @param triggerB defines the trigger to be tested
  37432. * @return a boolean indicating whether one (or more) of the triggers is handled
  37433. */
  37434. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37435. /**
  37436. * Does this action manager handles actions of a given trigger
  37437. * @param trigger defines the trigger to be tested
  37438. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37439. * @return whether the trigger is handled
  37440. */
  37441. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37442. /**
  37443. * Serialize this manager to a JSON object
  37444. * @param name defines the property name to store this manager
  37445. * @returns a JSON representation of this manager
  37446. */
  37447. abstract serialize(name: string): any;
  37448. /**
  37449. * Registers an action to this action manager
  37450. * @param action defines the action to be registered
  37451. * @return the action amended (prepared) after registration
  37452. */
  37453. abstract registerAction(action: IAction): Nullable<IAction>;
  37454. /**
  37455. * Unregisters an action to this action manager
  37456. * @param action defines the action to be unregistered
  37457. * @return a boolean indicating whether the action has been unregistered
  37458. */
  37459. abstract unregisterAction(action: IAction): Boolean;
  37460. /**
  37461. * Does exist one action manager with at least one trigger
  37462. **/
  37463. static get HasTriggers(): boolean;
  37464. /**
  37465. * Does exist one action manager with at least one pick trigger
  37466. **/
  37467. static get HasPickTriggers(): boolean;
  37468. /**
  37469. * Does exist one action manager that handles actions of a given trigger
  37470. * @param trigger defines the trigger to be tested
  37471. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37472. **/
  37473. static HasSpecificTrigger(trigger: number): boolean;
  37474. }
  37475. }
  37476. declare module "babylonjs/node" {
  37477. import { Scene } from "babylonjs/scene";
  37478. import { Nullable } from "babylonjs/types";
  37479. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37480. import { Engine } from "babylonjs/Engines/engine";
  37481. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37482. import { Observable } from "babylonjs/Misc/observable";
  37483. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37484. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37485. import { Animatable } from "babylonjs/Animations/animatable";
  37486. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37487. import { Animation } from "babylonjs/Animations/animation";
  37488. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37490. /**
  37491. * Defines how a node can be built from a string name.
  37492. */
  37493. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37494. /**
  37495. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37496. */
  37497. export class Node implements IBehaviorAware<Node> {
  37498. /** @hidden */
  37499. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37500. private static _NodeConstructors;
  37501. /**
  37502. * Add a new node constructor
  37503. * @param type defines the type name of the node to construct
  37504. * @param constructorFunc defines the constructor function
  37505. */
  37506. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37507. /**
  37508. * Returns a node constructor based on type name
  37509. * @param type defines the type name
  37510. * @param name defines the new node name
  37511. * @param scene defines the hosting scene
  37512. * @param options defines optional options to transmit to constructors
  37513. * @returns the new constructor or null
  37514. */
  37515. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37516. /**
  37517. * Gets or sets the name of the node
  37518. */
  37519. name: string;
  37520. /**
  37521. * Gets or sets the id of the node
  37522. */
  37523. id: string;
  37524. /**
  37525. * Gets or sets the unique id of the node
  37526. */
  37527. uniqueId: number;
  37528. /**
  37529. * Gets or sets a string used to store user defined state for the node
  37530. */
  37531. state: string;
  37532. /**
  37533. * Gets or sets an object used to store user defined information for the node
  37534. */
  37535. metadata: any;
  37536. /**
  37537. * For internal use only. Please do not use.
  37538. */
  37539. reservedDataStore: any;
  37540. /**
  37541. * List of inspectable custom properties (used by the Inspector)
  37542. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37543. */
  37544. inspectableCustomProperties: IInspectable[];
  37545. private _doNotSerialize;
  37546. /**
  37547. * Gets or sets a boolean used to define if the node must be serialized
  37548. */
  37549. get doNotSerialize(): boolean;
  37550. set doNotSerialize(value: boolean);
  37551. /** @hidden */
  37552. _isDisposed: boolean;
  37553. /**
  37554. * Gets a list of Animations associated with the node
  37555. */
  37556. animations: import("babylonjs/Animations/animation").Animation[];
  37557. protected _ranges: {
  37558. [name: string]: Nullable<AnimationRange>;
  37559. };
  37560. /**
  37561. * Callback raised when the node is ready to be used
  37562. */
  37563. onReady: Nullable<(node: Node) => void>;
  37564. private _isEnabled;
  37565. private _isParentEnabled;
  37566. private _isReady;
  37567. /** @hidden */
  37568. _currentRenderId: number;
  37569. private _parentUpdateId;
  37570. /** @hidden */
  37571. _childUpdateId: number;
  37572. /** @hidden */
  37573. _waitingParentId: Nullable<string>;
  37574. /** @hidden */
  37575. _scene: Scene;
  37576. /** @hidden */
  37577. _cache: any;
  37578. private _parentNode;
  37579. private _children;
  37580. /** @hidden */
  37581. _worldMatrix: Matrix;
  37582. /** @hidden */
  37583. _worldMatrixDeterminant: number;
  37584. /** @hidden */
  37585. _worldMatrixDeterminantIsDirty: boolean;
  37586. /** @hidden */
  37587. private _sceneRootNodesIndex;
  37588. /**
  37589. * Gets a boolean indicating if the node has been disposed
  37590. * @returns true if the node was disposed
  37591. */
  37592. isDisposed(): boolean;
  37593. /**
  37594. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37595. * @see https://doc.babylonjs.com/how_to/parenting
  37596. */
  37597. set parent(parent: Nullable<Node>);
  37598. get parent(): Nullable<Node>;
  37599. /** @hidden */
  37600. _addToSceneRootNodes(): void;
  37601. /** @hidden */
  37602. _removeFromSceneRootNodes(): void;
  37603. private _animationPropertiesOverride;
  37604. /**
  37605. * Gets or sets the animation properties override
  37606. */
  37607. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37608. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37609. /**
  37610. * Gets a string identifying the name of the class
  37611. * @returns "Node" string
  37612. */
  37613. getClassName(): string;
  37614. /** @hidden */
  37615. readonly _isNode: boolean;
  37616. /**
  37617. * An event triggered when the mesh is disposed
  37618. */
  37619. onDisposeObservable: Observable<Node>;
  37620. private _onDisposeObserver;
  37621. /**
  37622. * Sets a callback that will be raised when the node will be disposed
  37623. */
  37624. set onDispose(callback: () => void);
  37625. /**
  37626. * Creates a new Node
  37627. * @param name the name and id to be given to this node
  37628. * @param scene the scene this node will be added to
  37629. */
  37630. constructor(name: string, scene?: Nullable<Scene>);
  37631. /**
  37632. * Gets the scene of the node
  37633. * @returns a scene
  37634. */
  37635. getScene(): Scene;
  37636. /**
  37637. * Gets the engine of the node
  37638. * @returns a Engine
  37639. */
  37640. getEngine(): Engine;
  37641. private _behaviors;
  37642. /**
  37643. * Attach a behavior to the node
  37644. * @see https://doc.babylonjs.com/features/behaviour
  37645. * @param behavior defines the behavior to attach
  37646. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37647. * @returns the current Node
  37648. */
  37649. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37650. /**
  37651. * Remove an attached behavior
  37652. * @see https://doc.babylonjs.com/features/behaviour
  37653. * @param behavior defines the behavior to attach
  37654. * @returns the current Node
  37655. */
  37656. removeBehavior(behavior: Behavior<Node>): Node;
  37657. /**
  37658. * Gets the list of attached behaviors
  37659. * @see https://doc.babylonjs.com/features/behaviour
  37660. */
  37661. get behaviors(): Behavior<Node>[];
  37662. /**
  37663. * Gets an attached behavior by name
  37664. * @param name defines the name of the behavior to look for
  37665. * @see https://doc.babylonjs.com/features/behaviour
  37666. * @returns null if behavior was not found else the requested behavior
  37667. */
  37668. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37669. /**
  37670. * Returns the latest update of the World matrix
  37671. * @returns a Matrix
  37672. */
  37673. getWorldMatrix(): Matrix;
  37674. /** @hidden */
  37675. _getWorldMatrixDeterminant(): number;
  37676. /**
  37677. * Returns directly the latest state of the mesh World matrix.
  37678. * A Matrix is returned.
  37679. */
  37680. get worldMatrixFromCache(): Matrix;
  37681. /** @hidden */
  37682. _initCache(): void;
  37683. /** @hidden */
  37684. updateCache(force?: boolean): void;
  37685. /** @hidden */
  37686. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37687. /** @hidden */
  37688. _updateCache(ignoreParentClass?: boolean): void;
  37689. /** @hidden */
  37690. _isSynchronized(): boolean;
  37691. /** @hidden */
  37692. _markSyncedWithParent(): void;
  37693. /** @hidden */
  37694. isSynchronizedWithParent(): boolean;
  37695. /** @hidden */
  37696. isSynchronized(): boolean;
  37697. /**
  37698. * Is this node ready to be used/rendered
  37699. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37700. * @return true if the node is ready
  37701. */
  37702. isReady(completeCheck?: boolean): boolean;
  37703. /**
  37704. * Is this node enabled?
  37705. * 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
  37706. * @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
  37707. * @return whether this node (and its parent) is enabled
  37708. */
  37709. isEnabled(checkAncestors?: boolean): boolean;
  37710. /** @hidden */
  37711. protected _syncParentEnabledState(): void;
  37712. /**
  37713. * Set the enabled state of this node
  37714. * @param value defines the new enabled state
  37715. */
  37716. setEnabled(value: boolean): void;
  37717. /**
  37718. * Is this node a descendant of the given node?
  37719. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37720. * @param ancestor defines the parent node to inspect
  37721. * @returns a boolean indicating if this node is a descendant of the given node
  37722. */
  37723. isDescendantOf(ancestor: Node): boolean;
  37724. /** @hidden */
  37725. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37726. /**
  37727. * Will return all nodes that have this node as ascendant
  37728. * @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
  37729. * @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
  37730. * @return all children nodes of all types
  37731. */
  37732. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37733. /**
  37734. * Get all child-meshes of this node
  37735. * @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)
  37736. * @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
  37737. * @returns an array of AbstractMesh
  37738. */
  37739. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37740. /**
  37741. * Get all direct children of this node
  37742. * @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
  37743. * @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)
  37744. * @returns an array of Node
  37745. */
  37746. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37747. /** @hidden */
  37748. _setReady(state: boolean): void;
  37749. /**
  37750. * Get an animation by name
  37751. * @param name defines the name of the animation to look for
  37752. * @returns null if not found else the requested animation
  37753. */
  37754. getAnimationByName(name: string): Nullable<Animation>;
  37755. /**
  37756. * Creates an animation range for this node
  37757. * @param name defines the name of the range
  37758. * @param from defines the starting key
  37759. * @param to defines the end key
  37760. */
  37761. createAnimationRange(name: string, from: number, to: number): void;
  37762. /**
  37763. * Delete a specific animation range
  37764. * @param name defines the name of the range to delete
  37765. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37766. */
  37767. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37768. /**
  37769. * Get an animation range by name
  37770. * @param name defines the name of the animation range to look for
  37771. * @returns null if not found else the requested animation range
  37772. */
  37773. getAnimationRange(name: string): Nullable<AnimationRange>;
  37774. /**
  37775. * Gets the list of all animation ranges defined on this node
  37776. * @returns an array
  37777. */
  37778. getAnimationRanges(): Nullable<AnimationRange>[];
  37779. /**
  37780. * Will start the animation sequence
  37781. * @param name defines the range frames for animation sequence
  37782. * @param loop defines if the animation should loop (false by default)
  37783. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37784. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37785. * @returns the object created for this animation. If range does not exist, it will return null
  37786. */
  37787. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37788. /**
  37789. * Serialize animation ranges into a JSON compatible object
  37790. * @returns serialization object
  37791. */
  37792. serializeAnimationRanges(): any;
  37793. /**
  37794. * Computes the world matrix of the node
  37795. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37796. * @returns the world matrix
  37797. */
  37798. computeWorldMatrix(force?: boolean): Matrix;
  37799. /**
  37800. * Releases resources associated with this node.
  37801. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37802. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37803. */
  37804. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37805. /**
  37806. * Parse animation range data from a serialization object and store them into a given node
  37807. * @param node defines where to store the animation ranges
  37808. * @param parsedNode defines the serialization object to read data from
  37809. * @param scene defines the hosting scene
  37810. */
  37811. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37812. /**
  37813. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37814. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37815. * @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
  37816. * @returns the new bounding vectors
  37817. */
  37818. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37819. min: Vector3;
  37820. max: Vector3;
  37821. };
  37822. }
  37823. }
  37824. declare module "babylonjs/Animations/animation" {
  37825. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  37826. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  37827. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37828. import { Nullable } from "babylonjs/types";
  37829. import { Scene } from "babylonjs/scene";
  37830. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  37831. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37832. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  37833. import { Node } from "babylonjs/node";
  37834. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  37835. import { Size } from "babylonjs/Maths/math.size";
  37836. import { Animatable } from "babylonjs/Animations/animatable";
  37837. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  37838. /**
  37839. * @hidden
  37840. */
  37841. export class _IAnimationState {
  37842. key: number;
  37843. repeatCount: number;
  37844. workValue?: any;
  37845. loopMode?: number;
  37846. offsetValue?: any;
  37847. highLimitValue?: any;
  37848. }
  37849. /**
  37850. * Class used to store any kind of animation
  37851. */
  37852. export class Animation {
  37853. /**Name of the animation */
  37854. name: string;
  37855. /**Property to animate */
  37856. targetProperty: string;
  37857. /**The frames per second of the animation */
  37858. framePerSecond: number;
  37859. /**The data type of the animation */
  37860. dataType: number;
  37861. /**The loop mode of the animation */
  37862. loopMode?: number | undefined;
  37863. /**Specifies if blending should be enabled */
  37864. enableBlending?: boolean | undefined;
  37865. /**
  37866. * Use matrix interpolation instead of using direct key value when animating matrices
  37867. */
  37868. static AllowMatricesInterpolation: boolean;
  37869. /**
  37870. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37871. */
  37872. static AllowMatrixDecomposeForInterpolation: boolean;
  37873. /** Define the Url to load snippets */
  37874. static SnippetUrl: string;
  37875. /** Snippet ID if the animation was created from the snippet server */
  37876. snippetId: string;
  37877. /**
  37878. * Stores the key frames of the animation
  37879. */
  37880. private _keys;
  37881. /**
  37882. * Stores the easing function of the animation
  37883. */
  37884. private _easingFunction;
  37885. /**
  37886. * @hidden Internal use only
  37887. */
  37888. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  37889. /**
  37890. * The set of event that will be linked to this animation
  37891. */
  37892. private _events;
  37893. /**
  37894. * Stores an array of target property paths
  37895. */
  37896. targetPropertyPath: string[];
  37897. /**
  37898. * Stores the blending speed of the animation
  37899. */
  37900. blendingSpeed: number;
  37901. /**
  37902. * Stores the animation ranges for the animation
  37903. */
  37904. private _ranges;
  37905. /**
  37906. * @hidden Internal use
  37907. */
  37908. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37909. /**
  37910. * Sets up an animation
  37911. * @param property The property to animate
  37912. * @param animationType The animation type to apply
  37913. * @param framePerSecond The frames per second of the animation
  37914. * @param easingFunction The easing function used in the animation
  37915. * @returns The created animation
  37916. */
  37917. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37918. /**
  37919. * Create and start an animation on a node
  37920. * @param name defines the name of the global animation that will be run on all nodes
  37921. * @param node defines the root node where the animation will take place
  37922. * @param targetProperty defines property to animate
  37923. * @param framePerSecond defines the number of frame per second yo use
  37924. * @param totalFrame defines the number of frames in total
  37925. * @param from defines the initial value
  37926. * @param to defines the final value
  37927. * @param loopMode defines which loop mode you want to use (off by default)
  37928. * @param easingFunction defines the easing function to use (linear by default)
  37929. * @param onAnimationEnd defines the callback to call when animation end
  37930. * @returns the animatable created for this animation
  37931. */
  37932. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37933. /**
  37934. * Create and start an animation on a node and its descendants
  37935. * @param name defines the name of the global animation that will be run on all nodes
  37936. * @param node defines the root node where the animation will take place
  37937. * @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
  37938. * @param targetProperty defines property to animate
  37939. * @param framePerSecond defines the number of frame per second to use
  37940. * @param totalFrame defines the number of frames in total
  37941. * @param from defines the initial value
  37942. * @param to defines the final value
  37943. * @param loopMode defines which loop mode you want to use (off by default)
  37944. * @param easingFunction defines the easing function to use (linear by default)
  37945. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37946. * @returns the list of animatables created for all nodes
  37947. * @example https://www.babylonjs-playground.com/#MH0VLI
  37948. */
  37949. 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[]>;
  37950. /**
  37951. * Creates a new animation, merges it with the existing animations and starts it
  37952. * @param name Name of the animation
  37953. * @param node Node which contains the scene that begins the animations
  37954. * @param targetProperty Specifies which property to animate
  37955. * @param framePerSecond The frames per second of the animation
  37956. * @param totalFrame The total number of frames
  37957. * @param from The frame at the beginning of the animation
  37958. * @param to The frame at the end of the animation
  37959. * @param loopMode Specifies the loop mode of the animation
  37960. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37961. * @param onAnimationEnd Callback to run once the animation is complete
  37962. * @returns Nullable animation
  37963. */
  37964. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37965. /**
  37966. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37967. * @param sourceAnimation defines the Animation containing keyframes to convert
  37968. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37969. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37970. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37971. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37972. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37973. */
  37974. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37975. /**
  37976. * Transition property of an host to the target Value
  37977. * @param property The property to transition
  37978. * @param targetValue The target Value of the property
  37979. * @param host The object where the property to animate belongs
  37980. * @param scene Scene used to run the animation
  37981. * @param frameRate Framerate (in frame/s) to use
  37982. * @param transition The transition type we want to use
  37983. * @param duration The duration of the animation, in milliseconds
  37984. * @param onAnimationEnd Callback trigger at the end of the animation
  37985. * @returns Nullable animation
  37986. */
  37987. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37988. /**
  37989. * Return the array of runtime animations currently using this animation
  37990. */
  37991. get runtimeAnimations(): RuntimeAnimation[];
  37992. /**
  37993. * Specifies if any of the runtime animations are currently running
  37994. */
  37995. get hasRunningRuntimeAnimations(): boolean;
  37996. /**
  37997. * Initializes the animation
  37998. * @param name Name of the animation
  37999. * @param targetProperty Property to animate
  38000. * @param framePerSecond The frames per second of the animation
  38001. * @param dataType The data type of the animation
  38002. * @param loopMode The loop mode of the animation
  38003. * @param enableBlending Specifies if blending should be enabled
  38004. */
  38005. constructor(
  38006. /**Name of the animation */
  38007. name: string,
  38008. /**Property to animate */
  38009. targetProperty: string,
  38010. /**The frames per second of the animation */
  38011. framePerSecond: number,
  38012. /**The data type of the animation */
  38013. dataType: number,
  38014. /**The loop mode of the animation */
  38015. loopMode?: number | undefined,
  38016. /**Specifies if blending should be enabled */
  38017. enableBlending?: boolean | undefined);
  38018. /**
  38019. * Converts the animation to a string
  38020. * @param fullDetails support for multiple levels of logging within scene loading
  38021. * @returns String form of the animation
  38022. */
  38023. toString(fullDetails?: boolean): string;
  38024. /**
  38025. * Add an event to this animation
  38026. * @param event Event to add
  38027. */
  38028. addEvent(event: AnimationEvent): void;
  38029. /**
  38030. * Remove all events found at the given frame
  38031. * @param frame The frame to remove events from
  38032. */
  38033. removeEvents(frame: number): void;
  38034. /**
  38035. * Retrieves all the events from the animation
  38036. * @returns Events from the animation
  38037. */
  38038. getEvents(): AnimationEvent[];
  38039. /**
  38040. * Creates an animation range
  38041. * @param name Name of the animation range
  38042. * @param from Starting frame of the animation range
  38043. * @param to Ending frame of the animation
  38044. */
  38045. createRange(name: string, from: number, to: number): void;
  38046. /**
  38047. * Deletes an animation range by name
  38048. * @param name Name of the animation range to delete
  38049. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38050. */
  38051. deleteRange(name: string, deleteFrames?: boolean): void;
  38052. /**
  38053. * Gets the animation range by name, or null if not defined
  38054. * @param name Name of the animation range
  38055. * @returns Nullable animation range
  38056. */
  38057. getRange(name: string): Nullable<AnimationRange>;
  38058. /**
  38059. * Gets the key frames from the animation
  38060. * @returns The key frames of the animation
  38061. */
  38062. getKeys(): Array<IAnimationKey>;
  38063. /**
  38064. * Gets the highest frame rate of the animation
  38065. * @returns Highest frame rate of the animation
  38066. */
  38067. getHighestFrame(): number;
  38068. /**
  38069. * Gets the easing function of the animation
  38070. * @returns Easing function of the animation
  38071. */
  38072. getEasingFunction(): IEasingFunction;
  38073. /**
  38074. * Sets the easing function of the animation
  38075. * @param easingFunction A custom mathematical formula for animation
  38076. */
  38077. setEasingFunction(easingFunction: EasingFunction): void;
  38078. /**
  38079. * Interpolates a scalar linearly
  38080. * @param startValue Start value of the animation curve
  38081. * @param endValue End value of the animation curve
  38082. * @param gradient Scalar amount to interpolate
  38083. * @returns Interpolated scalar value
  38084. */
  38085. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38086. /**
  38087. * Interpolates a scalar cubically
  38088. * @param startValue Start value of the animation curve
  38089. * @param outTangent End tangent of the animation
  38090. * @param endValue End value of the animation curve
  38091. * @param inTangent Start tangent of the animation curve
  38092. * @param gradient Scalar amount to interpolate
  38093. * @returns Interpolated scalar value
  38094. */
  38095. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38096. /**
  38097. * Interpolates a quaternion using a spherical linear interpolation
  38098. * @param startValue Start value of the animation curve
  38099. * @param endValue End value of the animation curve
  38100. * @param gradient Scalar amount to interpolate
  38101. * @returns Interpolated quaternion value
  38102. */
  38103. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38104. /**
  38105. * Interpolates a quaternion cubically
  38106. * @param startValue Start value of the animation curve
  38107. * @param outTangent End tangent of the animation curve
  38108. * @param endValue End value of the animation curve
  38109. * @param inTangent Start tangent of the animation curve
  38110. * @param gradient Scalar amount to interpolate
  38111. * @returns Interpolated quaternion value
  38112. */
  38113. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38114. /**
  38115. * Interpolates a Vector3 linearl
  38116. * @param startValue Start value of the animation curve
  38117. * @param endValue End value of the animation curve
  38118. * @param gradient Scalar amount to interpolate
  38119. * @returns Interpolated scalar value
  38120. */
  38121. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38122. /**
  38123. * Interpolates a Vector3 cubically
  38124. * @param startValue Start value of the animation curve
  38125. * @param outTangent End tangent of the animation
  38126. * @param endValue End value of the animation curve
  38127. * @param inTangent Start tangent of the animation curve
  38128. * @param gradient Scalar amount to interpolate
  38129. * @returns InterpolatedVector3 value
  38130. */
  38131. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38132. /**
  38133. * Interpolates a Vector2 linearly
  38134. * @param startValue Start value of the animation curve
  38135. * @param endValue End value of the animation curve
  38136. * @param gradient Scalar amount to interpolate
  38137. * @returns Interpolated Vector2 value
  38138. */
  38139. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38140. /**
  38141. * Interpolates a Vector2 cubically
  38142. * @param startValue Start value of the animation curve
  38143. * @param outTangent End tangent of the animation
  38144. * @param endValue End value of the animation curve
  38145. * @param inTangent Start tangent of the animation curve
  38146. * @param gradient Scalar amount to interpolate
  38147. * @returns Interpolated Vector2 value
  38148. */
  38149. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38150. /**
  38151. * Interpolates a size linearly
  38152. * @param startValue Start value of the animation curve
  38153. * @param endValue End value of the animation curve
  38154. * @param gradient Scalar amount to interpolate
  38155. * @returns Interpolated Size value
  38156. */
  38157. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38158. /**
  38159. * Interpolates a Color3 linearly
  38160. * @param startValue Start value of the animation curve
  38161. * @param endValue End value of the animation curve
  38162. * @param gradient Scalar amount to interpolate
  38163. * @returns Interpolated Color3 value
  38164. */
  38165. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38166. /**
  38167. * Interpolates a Color4 linearly
  38168. * @param startValue Start value of the animation curve
  38169. * @param endValue End value of the animation curve
  38170. * @param gradient Scalar amount to interpolate
  38171. * @returns Interpolated Color3 value
  38172. */
  38173. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38174. /**
  38175. * @hidden Internal use only
  38176. */
  38177. _getKeyValue(value: any): any;
  38178. /**
  38179. * @hidden Internal use only
  38180. */
  38181. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38182. /**
  38183. * Defines the function to use to interpolate matrices
  38184. * @param startValue defines the start matrix
  38185. * @param endValue defines the end matrix
  38186. * @param gradient defines the gradient between both matrices
  38187. * @param result defines an optional target matrix where to store the interpolation
  38188. * @returns the interpolated matrix
  38189. */
  38190. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38191. /**
  38192. * Makes a copy of the animation
  38193. * @returns Cloned animation
  38194. */
  38195. clone(): Animation;
  38196. /**
  38197. * Sets the key frames of the animation
  38198. * @param values The animation key frames to set
  38199. */
  38200. setKeys(values: Array<IAnimationKey>): void;
  38201. /**
  38202. * Serializes the animation to an object
  38203. * @returns Serialized object
  38204. */
  38205. serialize(): any;
  38206. /**
  38207. * Float animation type
  38208. */
  38209. static readonly ANIMATIONTYPE_FLOAT: number;
  38210. /**
  38211. * Vector3 animation type
  38212. */
  38213. static readonly ANIMATIONTYPE_VECTOR3: number;
  38214. /**
  38215. * Quaternion animation type
  38216. */
  38217. static readonly ANIMATIONTYPE_QUATERNION: number;
  38218. /**
  38219. * Matrix animation type
  38220. */
  38221. static readonly ANIMATIONTYPE_MATRIX: number;
  38222. /**
  38223. * Color3 animation type
  38224. */
  38225. static readonly ANIMATIONTYPE_COLOR3: number;
  38226. /**
  38227. * Color3 animation type
  38228. */
  38229. static readonly ANIMATIONTYPE_COLOR4: number;
  38230. /**
  38231. * Vector2 animation type
  38232. */
  38233. static readonly ANIMATIONTYPE_VECTOR2: number;
  38234. /**
  38235. * Size animation type
  38236. */
  38237. static readonly ANIMATIONTYPE_SIZE: number;
  38238. /**
  38239. * Relative Loop Mode
  38240. */
  38241. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38242. /**
  38243. * Cycle Loop Mode
  38244. */
  38245. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38246. /**
  38247. * Constant Loop Mode
  38248. */
  38249. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38250. /** @hidden */
  38251. static _UniversalLerp(left: any, right: any, amount: number): any;
  38252. /**
  38253. * Parses an animation object and creates an animation
  38254. * @param parsedAnimation Parsed animation object
  38255. * @returns Animation object
  38256. */
  38257. static Parse(parsedAnimation: any): Animation;
  38258. /**
  38259. * Appends the serialized animations from the source animations
  38260. * @param source Source containing the animations
  38261. * @param destination Target to store the animations
  38262. */
  38263. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38264. /**
  38265. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38266. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38267. * @param url defines the url to load from
  38268. * @returns a promise that will resolve to the new animation or an array of animations
  38269. */
  38270. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38271. /**
  38272. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38273. * @param snippetId defines the snippet to load
  38274. * @returns a promise that will resolve to the new animation or a new array of animations
  38275. */
  38276. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38277. }
  38278. }
  38279. declare module "babylonjs/Animations/animatable.interface" {
  38280. import { Nullable } from "babylonjs/types";
  38281. import { Animation } from "babylonjs/Animations/animation";
  38282. /**
  38283. * Interface containing an array of animations
  38284. */
  38285. export interface IAnimatable {
  38286. /**
  38287. * Array of animations
  38288. */
  38289. animations: Nullable<Array<Animation>>;
  38290. }
  38291. }
  38292. declare module "babylonjs/Misc/decorators" {
  38293. import { Nullable } from "babylonjs/types";
  38294. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38295. import { Scene } from "babylonjs/scene";
  38296. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38297. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38298. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38299. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38300. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38301. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38302. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38303. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38304. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38305. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38306. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38307. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38308. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38309. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38310. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38311. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38312. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38313. /**
  38314. * Decorator used to define property that can be serialized as reference to a camera
  38315. * @param sourceName defines the name of the property to decorate
  38316. */
  38317. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38318. /**
  38319. * Class used to help serialization objects
  38320. */
  38321. export class SerializationHelper {
  38322. /** @hidden */
  38323. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38324. /** @hidden */
  38325. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38326. /** @hidden */
  38327. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38328. /** @hidden */
  38329. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38330. /**
  38331. * Appends the serialized animations from the source animations
  38332. * @param source Source containing the animations
  38333. * @param destination Target to store the animations
  38334. */
  38335. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38336. /**
  38337. * Static function used to serialized a specific entity
  38338. * @param entity defines the entity to serialize
  38339. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38340. * @returns a JSON compatible object representing the serialization of the entity
  38341. */
  38342. static Serialize<T>(entity: T, serializationObject?: any): any;
  38343. /**
  38344. * Creates a new entity from a serialization data object
  38345. * @param creationFunction defines a function used to instanciated the new entity
  38346. * @param source defines the source serialization data
  38347. * @param scene defines the hosting scene
  38348. * @param rootUrl defines the root url for resources
  38349. * @returns a new entity
  38350. */
  38351. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38352. /**
  38353. * Clones an object
  38354. * @param creationFunction defines the function used to instanciate the new object
  38355. * @param source defines the source object
  38356. * @returns the cloned object
  38357. */
  38358. static Clone<T>(creationFunction: () => T, source: T): T;
  38359. /**
  38360. * Instanciates a new object based on a source one (some data will be shared between both object)
  38361. * @param creationFunction defines the function used to instanciate the new object
  38362. * @param source defines the source object
  38363. * @returns the new object
  38364. */
  38365. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38366. }
  38367. }
  38368. declare module "babylonjs/Cameras/camera" {
  38369. import { SmartArray } from "babylonjs/Misc/smartArray";
  38370. import { Observable } from "babylonjs/Misc/observable";
  38371. import { Nullable } from "babylonjs/types";
  38372. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38373. import { Scene } from "babylonjs/scene";
  38374. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38375. import { Node } from "babylonjs/node";
  38376. import { Mesh } from "babylonjs/Meshes/mesh";
  38377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38378. import { ICullable } from "babylonjs/Culling/boundingInfo";
  38379. import { Viewport } from "babylonjs/Maths/math.viewport";
  38380. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38382. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38383. import { Ray } from "babylonjs/Culling/ray";
  38384. /**
  38385. * This is the base class of all the camera used in the application.
  38386. * @see https://doc.babylonjs.com/features/cameras
  38387. */
  38388. export class Camera extends Node {
  38389. /** @hidden */
  38390. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  38391. /**
  38392. * This is the default projection mode used by the cameras.
  38393. * It helps recreating a feeling of perspective and better appreciate depth.
  38394. * This is the best way to simulate real life cameras.
  38395. */
  38396. static readonly PERSPECTIVE_CAMERA: number;
  38397. /**
  38398. * This helps creating camera with an orthographic mode.
  38399. * 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.
  38400. */
  38401. static readonly ORTHOGRAPHIC_CAMERA: number;
  38402. /**
  38403. * This is the default FOV mode for perspective cameras.
  38404. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  38405. */
  38406. static readonly FOVMODE_VERTICAL_FIXED: number;
  38407. /**
  38408. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  38409. */
  38410. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  38411. /**
  38412. * This specifies ther is no need for a camera rig.
  38413. * Basically only one eye is rendered corresponding to the camera.
  38414. */
  38415. static readonly RIG_MODE_NONE: number;
  38416. /**
  38417. * Simulates a camera Rig with one blue eye and one red eye.
  38418. * This can be use with 3d blue and red glasses.
  38419. */
  38420. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  38421. /**
  38422. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  38423. */
  38424. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  38425. /**
  38426. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  38427. */
  38428. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  38429. /**
  38430. * Defines that both eyes of the camera will be rendered over under each other.
  38431. */
  38432. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  38433. /**
  38434. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  38435. */
  38436. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  38437. /**
  38438. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  38439. */
  38440. static readonly RIG_MODE_VR: number;
  38441. /**
  38442. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  38443. */
  38444. static readonly RIG_MODE_WEBVR: number;
  38445. /**
  38446. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  38447. */
  38448. static readonly RIG_MODE_CUSTOM: number;
  38449. /**
  38450. * Defines if by default attaching controls should prevent the default javascript event to continue.
  38451. */
  38452. static ForceAttachControlToAlwaysPreventDefault: boolean;
  38453. /**
  38454. * Define the input manager associated with the camera.
  38455. */
  38456. inputs: CameraInputsManager<Camera>;
  38457. /** @hidden */
  38458. _position: Vector3;
  38459. /**
  38460. * Define the current local position of the camera in the scene
  38461. */
  38462. get position(): Vector3;
  38463. set position(newPosition: Vector3);
  38464. protected _upVector: Vector3;
  38465. /**
  38466. * The vector the camera should consider as up.
  38467. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  38468. */
  38469. set upVector(vec: Vector3);
  38470. get upVector(): Vector3;
  38471. /**
  38472. * Define the current limit on the left side for an orthographic camera
  38473. * In scene unit
  38474. */
  38475. orthoLeft: Nullable<number>;
  38476. /**
  38477. * Define the current limit on the right side for an orthographic camera
  38478. * In scene unit
  38479. */
  38480. orthoRight: Nullable<number>;
  38481. /**
  38482. * Define the current limit on the bottom side for an orthographic camera
  38483. * In scene unit
  38484. */
  38485. orthoBottom: Nullable<number>;
  38486. /**
  38487. * Define the current limit on the top side for an orthographic camera
  38488. * In scene unit
  38489. */
  38490. orthoTop: Nullable<number>;
  38491. /**
  38492. * Field Of View is set in Radians. (default is 0.8)
  38493. */
  38494. fov: number;
  38495. /**
  38496. * Define the minimum distance the camera can see from.
  38497. * This is important to note that the depth buffer are not infinite and the closer it starts
  38498. * the more your scene might encounter depth fighting issue.
  38499. */
  38500. minZ: number;
  38501. /**
  38502. * Define the maximum distance the camera can see to.
  38503. * This is important to note that the depth buffer are not infinite and the further it end
  38504. * the more your scene might encounter depth fighting issue.
  38505. */
  38506. maxZ: number;
  38507. /**
  38508. * Define the default inertia of the camera.
  38509. * This helps giving a smooth feeling to the camera movement.
  38510. */
  38511. inertia: number;
  38512. /**
  38513. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  38514. */
  38515. mode: number;
  38516. /**
  38517. * Define whether the camera is intermediate.
  38518. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38519. */
  38520. isIntermediate: boolean;
  38521. /**
  38522. * Define the viewport of the camera.
  38523. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38524. */
  38525. viewport: Viewport;
  38526. /**
  38527. * Restricts the camera to viewing objects with the same layerMask.
  38528. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38529. */
  38530. layerMask: number;
  38531. /**
  38532. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38533. */
  38534. fovMode: number;
  38535. /**
  38536. * Rig mode of the camera.
  38537. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38538. * This is normally controlled byt the camera themselves as internal use.
  38539. */
  38540. cameraRigMode: number;
  38541. /**
  38542. * Defines the distance between both "eyes" in case of a RIG
  38543. */
  38544. interaxialDistance: number;
  38545. /**
  38546. * Defines if stereoscopic rendering is done side by side or over under.
  38547. */
  38548. isStereoscopicSideBySide: boolean;
  38549. /**
  38550. * 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
  38551. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  38552. * else in the scene. (Eg. security camera)
  38553. *
  38554. * 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)
  38555. */
  38556. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  38557. /**
  38558. * When set, the camera will render to this render target instead of the default canvas
  38559. *
  38560. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38561. */
  38562. outputRenderTarget: Nullable<RenderTargetTexture>;
  38563. /**
  38564. * Observable triggered when the camera view matrix has changed.
  38565. */
  38566. onViewMatrixChangedObservable: Observable<Camera>;
  38567. /**
  38568. * Observable triggered when the camera Projection matrix has changed.
  38569. */
  38570. onProjectionMatrixChangedObservable: Observable<Camera>;
  38571. /**
  38572. * Observable triggered when the inputs have been processed.
  38573. */
  38574. onAfterCheckInputsObservable: Observable<Camera>;
  38575. /**
  38576. * Observable triggered when reset has been called and applied to the camera.
  38577. */
  38578. onRestoreStateObservable: Observable<Camera>;
  38579. /**
  38580. * Is this camera a part of a rig system?
  38581. */
  38582. isRigCamera: boolean;
  38583. /**
  38584. * If isRigCamera set to true this will be set with the parent camera.
  38585. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38586. */
  38587. rigParent?: Camera;
  38588. /** @hidden */
  38589. _cameraRigParams: any;
  38590. /** @hidden */
  38591. _rigCameras: Camera[];
  38592. /** @hidden */
  38593. _rigPostProcess: Nullable<PostProcess>;
  38594. protected _webvrViewMatrix: Matrix;
  38595. /** @hidden */
  38596. _skipRendering: boolean;
  38597. /** @hidden */
  38598. _projectionMatrix: Matrix;
  38599. /** @hidden */
  38600. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  38601. /** @hidden */
  38602. _activeMeshes: SmartArray<AbstractMesh>;
  38603. protected _globalPosition: Vector3;
  38604. /** @hidden */
  38605. _computedViewMatrix: Matrix;
  38606. private _doNotComputeProjectionMatrix;
  38607. private _transformMatrix;
  38608. private _frustumPlanes;
  38609. private _refreshFrustumPlanes;
  38610. private _storedFov;
  38611. private _stateStored;
  38612. /**
  38613. * Instantiates a new camera object.
  38614. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38615. * @see https://doc.babylonjs.com/features/cameras
  38616. * @param name Defines the name of the camera in the scene
  38617. * @param position Defines the position of the camera
  38618. * @param scene Defines the scene the camera belongs too
  38619. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38620. */
  38621. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38622. /**
  38623. * Store current camera state (fov, position, etc..)
  38624. * @returns the camera
  38625. */
  38626. storeState(): Camera;
  38627. /**
  38628. * Restores the camera state values if it has been stored. You must call storeState() first
  38629. */
  38630. protected _restoreStateValues(): boolean;
  38631. /**
  38632. * Restored camera state. You must call storeState() first.
  38633. * @returns true if restored and false otherwise
  38634. */
  38635. restoreState(): boolean;
  38636. /**
  38637. * Gets the class name of the camera.
  38638. * @returns the class name
  38639. */
  38640. getClassName(): string;
  38641. /** @hidden */
  38642. readonly _isCamera: boolean;
  38643. /**
  38644. * Gets a string representation of the camera useful for debug purpose.
  38645. * @param fullDetails Defines that a more verboe level of logging is required
  38646. * @returns the string representation
  38647. */
  38648. toString(fullDetails?: boolean): string;
  38649. /**
  38650. * Gets the current world space position of the camera.
  38651. */
  38652. get globalPosition(): Vector3;
  38653. /**
  38654. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38655. * @returns the active meshe list
  38656. */
  38657. getActiveMeshes(): SmartArray<AbstractMesh>;
  38658. /**
  38659. * Check whether a mesh is part of the current active mesh list of the camera
  38660. * @param mesh Defines the mesh to check
  38661. * @returns true if active, false otherwise
  38662. */
  38663. isActiveMesh(mesh: Mesh): boolean;
  38664. /**
  38665. * Is this camera ready to be used/rendered
  38666. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38667. * @return true if the camera is ready
  38668. */
  38669. isReady(completeCheck?: boolean): boolean;
  38670. /** @hidden */
  38671. _initCache(): void;
  38672. /** @hidden */
  38673. _updateCache(ignoreParentClass?: boolean): void;
  38674. /** @hidden */
  38675. _isSynchronized(): boolean;
  38676. /** @hidden */
  38677. _isSynchronizedViewMatrix(): boolean;
  38678. /** @hidden */
  38679. _isSynchronizedProjectionMatrix(): boolean;
  38680. /**
  38681. * Attach the input controls to a specific dom element to get the input from.
  38682. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38683. */
  38684. attachControl(noPreventDefault?: boolean): void;
  38685. /**
  38686. * Attach the input controls to a specific dom element to get the input from.
  38687. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  38688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38689. * BACK COMPAT SIGNATURE ONLY.
  38690. */
  38691. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38692. /**
  38693. * Detach the current controls from the specified dom element.
  38694. */
  38695. detachControl(): void;
  38696. /**
  38697. * Detach the current controls from the specified dom element.
  38698. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  38699. */
  38700. detachControl(ignored: any): void;
  38701. /**
  38702. * Update the camera state according to the different inputs gathered during the frame.
  38703. */
  38704. update(): void;
  38705. /** @hidden */
  38706. _checkInputs(): void;
  38707. /** @hidden */
  38708. get rigCameras(): Camera[];
  38709. /**
  38710. * Gets the post process used by the rig cameras
  38711. */
  38712. get rigPostProcess(): Nullable<PostProcess>;
  38713. /**
  38714. * Internal, gets the first post proces.
  38715. * @returns the first post process to be run on this camera.
  38716. */
  38717. _getFirstPostProcess(): Nullable<PostProcess>;
  38718. private _cascadePostProcessesToRigCams;
  38719. /**
  38720. * Attach a post process to the camera.
  38721. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38722. * @param postProcess The post process to attach to the camera
  38723. * @param insertAt The position of the post process in case several of them are in use in the scene
  38724. * @returns the position the post process has been inserted at
  38725. */
  38726. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38727. /**
  38728. * Detach a post process to the camera.
  38729. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38730. * @param postProcess The post process to detach from the camera
  38731. */
  38732. detachPostProcess(postProcess: PostProcess): void;
  38733. /**
  38734. * Gets the current world matrix of the camera
  38735. */
  38736. getWorldMatrix(): Matrix;
  38737. /** @hidden */
  38738. _getViewMatrix(): Matrix;
  38739. /**
  38740. * Gets the current view matrix of the camera.
  38741. * @param force forces the camera to recompute the matrix without looking at the cached state
  38742. * @returns the view matrix
  38743. */
  38744. getViewMatrix(force?: boolean): Matrix;
  38745. /**
  38746. * Freeze the projection matrix.
  38747. * It will prevent the cache check of the camera projection compute and can speed up perf
  38748. * if no parameter of the camera are meant to change
  38749. * @param projection Defines manually a projection if necessary
  38750. */
  38751. freezeProjectionMatrix(projection?: Matrix): void;
  38752. /**
  38753. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38754. */
  38755. unfreezeProjectionMatrix(): void;
  38756. /**
  38757. * Gets the current projection matrix of the camera.
  38758. * @param force forces the camera to recompute the matrix without looking at the cached state
  38759. * @returns the projection matrix
  38760. */
  38761. getProjectionMatrix(force?: boolean): Matrix;
  38762. /**
  38763. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38764. * @returns a Matrix
  38765. */
  38766. getTransformationMatrix(): Matrix;
  38767. private _updateFrustumPlanes;
  38768. /**
  38769. * Checks if a cullable object (mesh...) is in the camera frustum
  38770. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38771. * @param target The object to check
  38772. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38773. * @returns true if the object is in frustum otherwise false
  38774. */
  38775. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38776. /**
  38777. * Checks if a cullable object (mesh...) is in the camera frustum
  38778. * Unlike isInFrustum this cheks the full bounding box
  38779. * @param target The object to check
  38780. * @returns true if the object is in frustum otherwise false
  38781. */
  38782. isCompletelyInFrustum(target: ICullable): boolean;
  38783. /**
  38784. * Gets a ray in the forward direction from the camera.
  38785. * @param length Defines the length of the ray to create
  38786. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38787. * @param origin Defines the start point of the ray which defaults to the camera position
  38788. * @returns the forward ray
  38789. */
  38790. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38791. /**
  38792. * Gets a ray in the forward direction from the camera.
  38793. * @param refRay the ray to (re)use when setting the values
  38794. * @param length Defines the length of the ray to create
  38795. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38796. * @param origin Defines the start point of the ray which defaults to the camera position
  38797. * @returns the forward ray
  38798. */
  38799. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38800. /**
  38801. * Releases resources associated with this node.
  38802. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38803. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38804. */
  38805. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38806. /** @hidden */
  38807. _isLeftCamera: boolean;
  38808. /**
  38809. * Gets the left camera of a rig setup in case of Rigged Camera
  38810. */
  38811. get isLeftCamera(): boolean;
  38812. /** @hidden */
  38813. _isRightCamera: boolean;
  38814. /**
  38815. * Gets the right camera of a rig setup in case of Rigged Camera
  38816. */
  38817. get isRightCamera(): boolean;
  38818. /**
  38819. * Gets the left camera of a rig setup in case of Rigged Camera
  38820. */
  38821. get leftCamera(): Nullable<FreeCamera>;
  38822. /**
  38823. * Gets the right camera of a rig setup in case of Rigged Camera
  38824. */
  38825. get rightCamera(): Nullable<FreeCamera>;
  38826. /**
  38827. * Gets the left camera target of a rig setup in case of Rigged Camera
  38828. * @returns the target position
  38829. */
  38830. getLeftTarget(): Nullable<Vector3>;
  38831. /**
  38832. * Gets the right camera target of a rig setup in case of Rigged Camera
  38833. * @returns the target position
  38834. */
  38835. getRightTarget(): Nullable<Vector3>;
  38836. /**
  38837. * @hidden
  38838. */
  38839. setCameraRigMode(mode: number, rigParams: any): void;
  38840. /** @hidden */
  38841. static _setStereoscopicRigMode(camera: Camera): void;
  38842. /** @hidden */
  38843. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38844. /** @hidden */
  38845. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38846. /** @hidden */
  38847. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38848. /** @hidden */
  38849. _getVRProjectionMatrix(): Matrix;
  38850. protected _updateCameraRotationMatrix(): void;
  38851. protected _updateWebVRCameraRotationMatrix(): void;
  38852. /**
  38853. * This function MUST be overwritten by the different WebVR cameras available.
  38854. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38855. * @hidden
  38856. */
  38857. _getWebVRProjectionMatrix(): Matrix;
  38858. /**
  38859. * This function MUST be overwritten by the different WebVR cameras available.
  38860. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38861. * @hidden
  38862. */
  38863. _getWebVRViewMatrix(): Matrix;
  38864. /** @hidden */
  38865. setCameraRigParameter(name: string, value: any): void;
  38866. /**
  38867. * needs to be overridden by children so sub has required properties to be copied
  38868. * @hidden
  38869. */
  38870. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38871. /**
  38872. * May need to be overridden by children
  38873. * @hidden
  38874. */
  38875. _updateRigCameras(): void;
  38876. /** @hidden */
  38877. _setupInputs(): void;
  38878. /**
  38879. * Serialiaze the camera setup to a json represention
  38880. * @returns the JSON representation
  38881. */
  38882. serialize(): any;
  38883. /**
  38884. * Clones the current camera.
  38885. * @param name The cloned camera name
  38886. * @returns the cloned camera
  38887. */
  38888. clone(name: string): Camera;
  38889. /**
  38890. * Gets the direction of the camera relative to a given local axis.
  38891. * @param localAxis Defines the reference axis to provide a relative direction.
  38892. * @return the direction
  38893. */
  38894. getDirection(localAxis: Vector3): Vector3;
  38895. /**
  38896. * Returns the current camera absolute rotation
  38897. */
  38898. get absoluteRotation(): Quaternion;
  38899. /**
  38900. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38901. * @param localAxis Defines the reference axis to provide a relative direction.
  38902. * @param result Defines the vector to store the result in
  38903. */
  38904. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38905. /**
  38906. * Gets a camera constructor for a given camera type
  38907. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38908. * @param name The name of the camera the result will be able to instantiate
  38909. * @param scene The scene the result will construct the camera in
  38910. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38911. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38912. * @returns a factory method to construc the camera
  38913. */
  38914. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38915. /**
  38916. * Compute the world matrix of the camera.
  38917. * @returns the camera world matrix
  38918. */
  38919. computeWorldMatrix(): Matrix;
  38920. /**
  38921. * Parse a JSON and creates the camera from the parsed information
  38922. * @param parsedCamera The JSON to parse
  38923. * @param scene The scene to instantiate the camera in
  38924. * @returns the newly constructed camera
  38925. */
  38926. static Parse(parsedCamera: any, scene: Scene): Camera;
  38927. }
  38928. }
  38929. declare module "babylonjs/PostProcesses/postProcessManager" {
  38930. import { Nullable } from "babylonjs/types";
  38931. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38933. import { Scene } from "babylonjs/scene";
  38934. /**
  38935. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38936. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38937. */
  38938. export class PostProcessManager {
  38939. private _scene;
  38940. private _indexBuffer;
  38941. private _vertexBuffers;
  38942. /**
  38943. * Creates a new instance PostProcess
  38944. * @param scene The scene that the post process is associated with.
  38945. */
  38946. constructor(scene: Scene);
  38947. private _prepareBuffers;
  38948. private _buildIndexBuffer;
  38949. /**
  38950. * Rebuilds the vertex buffers of the manager.
  38951. * @hidden
  38952. */
  38953. _rebuild(): void;
  38954. /**
  38955. * Prepares a frame to be run through a post process.
  38956. * @param sourceTexture The input texture to the post procesess. (default: null)
  38957. * @param postProcesses An array of post processes to be run. (default: null)
  38958. * @returns True if the post processes were able to be run.
  38959. * @hidden
  38960. */
  38961. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38962. /**
  38963. * Manually render a set of post processes to a texture.
  38964. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38965. * @param postProcesses An array of post processes to be run.
  38966. * @param targetTexture The target texture to render to.
  38967. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38968. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38969. * @param lodLevel defines which lod of the texture to render to
  38970. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38971. */
  38972. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38973. /**
  38974. * Finalize the result of the output of the postprocesses.
  38975. * @param doNotPresent If true the result will not be displayed to the screen.
  38976. * @param targetTexture The target texture to render to.
  38977. * @param faceIndex The index of the face to bind the target texture to.
  38978. * @param postProcesses The array of post processes to render.
  38979. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38980. * @hidden
  38981. */
  38982. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38983. /**
  38984. * Disposes of the post process manager.
  38985. */
  38986. dispose(): void;
  38987. }
  38988. }
  38989. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  38990. import { Observable } from "babylonjs/Misc/observable";
  38991. import { SmartArray } from "babylonjs/Misc/smartArray";
  38992. import { Nullable, Immutable } from "babylonjs/types";
  38993. import { Camera } from "babylonjs/Cameras/camera";
  38994. import { Scene } from "babylonjs/scene";
  38995. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  38996. import { Color4 } from "babylonjs/Maths/math.color";
  38997. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  38998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38999. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39000. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39001. import { Texture } from "babylonjs/Materials/Textures/texture";
  39002. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39003. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  39004. import "babylonjs/Engines/Extensions/engine.renderTarget";
  39005. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  39006. import { Engine } from "babylonjs/Engines/engine";
  39007. /**
  39008. * This Helps creating a texture that will be created from a camera in your scene.
  39009. * It is basically a dynamic texture that could be used to create special effects for instance.
  39010. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  39011. */
  39012. export class RenderTargetTexture extends Texture {
  39013. /**
  39014. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  39015. */
  39016. static readonly REFRESHRATE_RENDER_ONCE: number;
  39017. /**
  39018. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  39019. */
  39020. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  39021. /**
  39022. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  39023. * the central point of your effect and can save a lot of performances.
  39024. */
  39025. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  39026. /**
  39027. * Use this predicate to dynamically define the list of mesh you want to render.
  39028. * If set, the renderList property will be overwritten.
  39029. */
  39030. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  39031. private _renderList;
  39032. /**
  39033. * Use this list to define the list of mesh you want to render.
  39034. */
  39035. get renderList(): Nullable<Array<AbstractMesh>>;
  39036. set renderList(value: Nullable<Array<AbstractMesh>>);
  39037. /**
  39038. * Use this function to overload the renderList array at rendering time.
  39039. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  39040. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  39041. * the cube (if the RTT is a cube, else layerOrFace=0).
  39042. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  39043. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  39044. * hold dummy elements!
  39045. */
  39046. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  39047. private _hookArray;
  39048. /**
  39049. * Define if particles should be rendered in your texture.
  39050. */
  39051. renderParticles: boolean;
  39052. /**
  39053. * Define if sprites should be rendered in your texture.
  39054. */
  39055. renderSprites: boolean;
  39056. /**
  39057. * Define the camera used to render the texture.
  39058. */
  39059. activeCamera: Nullable<Camera>;
  39060. /**
  39061. * Override the mesh isReady function with your own one.
  39062. */
  39063. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  39064. /**
  39065. * Override the render function of the texture with your own one.
  39066. */
  39067. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  39068. /**
  39069. * Define if camera post processes should be use while rendering the texture.
  39070. */
  39071. useCameraPostProcesses: boolean;
  39072. /**
  39073. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  39074. */
  39075. ignoreCameraViewport: boolean;
  39076. private _postProcessManager;
  39077. private _postProcesses;
  39078. private _resizeObserver;
  39079. /**
  39080. * An event triggered when the texture is unbind.
  39081. */
  39082. onBeforeBindObservable: Observable<RenderTargetTexture>;
  39083. /**
  39084. * An event triggered when the texture is unbind.
  39085. */
  39086. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  39087. private _onAfterUnbindObserver;
  39088. /**
  39089. * Set a after unbind callback in the texture.
  39090. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  39091. */
  39092. set onAfterUnbind(callback: () => void);
  39093. /**
  39094. * An event triggered before rendering the texture
  39095. */
  39096. onBeforeRenderObservable: Observable<number>;
  39097. private _onBeforeRenderObserver;
  39098. /**
  39099. * Set a before render callback in the texture.
  39100. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  39101. */
  39102. set onBeforeRender(callback: (faceIndex: number) => void);
  39103. /**
  39104. * An event triggered after rendering the texture
  39105. */
  39106. onAfterRenderObservable: Observable<number>;
  39107. private _onAfterRenderObserver;
  39108. /**
  39109. * Set a after render callback in the texture.
  39110. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  39111. */
  39112. set onAfterRender(callback: (faceIndex: number) => void);
  39113. /**
  39114. * An event triggered after the texture clear
  39115. */
  39116. onClearObservable: Observable<Engine>;
  39117. private _onClearObserver;
  39118. /**
  39119. * Set a clear callback in the texture.
  39120. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  39121. */
  39122. set onClear(callback: (Engine: Engine) => void);
  39123. /**
  39124. * An event triggered when the texture is resized.
  39125. */
  39126. onResizeObservable: Observable<RenderTargetTexture>;
  39127. /**
  39128. * Define the clear color of the Render Target if it should be different from the scene.
  39129. */
  39130. clearColor: Color4;
  39131. protected _size: number | {
  39132. width: number;
  39133. height: number;
  39134. layers?: number;
  39135. };
  39136. protected _initialSizeParameter: number | {
  39137. width: number;
  39138. height: number;
  39139. } | {
  39140. ratio: number;
  39141. };
  39142. protected _sizeRatio: Nullable<number>;
  39143. /** @hidden */
  39144. _generateMipMaps: boolean;
  39145. protected _renderingManager: RenderingManager;
  39146. /** @hidden */
  39147. _waitingRenderList?: string[];
  39148. protected _doNotChangeAspectRatio: boolean;
  39149. protected _currentRefreshId: number;
  39150. protected _refreshRate: number;
  39151. protected _textureMatrix: Matrix;
  39152. protected _samples: number;
  39153. protected _renderTargetOptions: RenderTargetCreationOptions;
  39154. /**
  39155. * Gets render target creation options that were used.
  39156. */
  39157. get renderTargetOptions(): RenderTargetCreationOptions;
  39158. protected _onRatioRescale(): void;
  39159. /**
  39160. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  39161. * It must define where the camera used to render the texture is set
  39162. */
  39163. boundingBoxPosition: Vector3;
  39164. private _boundingBoxSize;
  39165. /**
  39166. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  39167. * When defined, the cubemap will switch to local mode
  39168. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  39169. * @example https://www.babylonjs-playground.com/#RNASML
  39170. */
  39171. set boundingBoxSize(value: Vector3);
  39172. get boundingBoxSize(): Vector3;
  39173. /**
  39174. * In case the RTT has been created with a depth texture, get the associated
  39175. * depth texture.
  39176. * Otherwise, return null.
  39177. */
  39178. get depthStencilTexture(): Nullable<InternalTexture>;
  39179. /**
  39180. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  39181. * or used a shadow, depth texture...
  39182. * @param name The friendly name of the texture
  39183. * @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)
  39184. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  39185. * @param generateMipMaps True if mip maps need to be generated after render.
  39186. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  39187. * @param type The type of the buffer in the RTT (int, half float, float...)
  39188. * @param isCube True if a cube texture needs to be created
  39189. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  39190. * @param generateDepthBuffer True to generate a depth buffer
  39191. * @param generateStencilBuffer True to generate a stencil buffer
  39192. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  39193. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  39194. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39195. */
  39196. constructor(name: string, size: number | {
  39197. width: number;
  39198. height: number;
  39199. layers?: number;
  39200. } | {
  39201. ratio: number;
  39202. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  39203. /**
  39204. * Creates a depth stencil texture.
  39205. * This is only available in WebGL 2 or with the depth texture extension available.
  39206. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  39207. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  39208. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  39209. */
  39210. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  39211. private _processSizeParameter;
  39212. /**
  39213. * Define the number of samples to use in case of MSAA.
  39214. * It defaults to one meaning no MSAA has been enabled.
  39215. */
  39216. get samples(): number;
  39217. set samples(value: number);
  39218. /**
  39219. * Resets the refresh counter of the texture and start bak from scratch.
  39220. * Could be useful to regenerate the texture if it is setup to render only once.
  39221. */
  39222. resetRefreshCounter(): void;
  39223. /**
  39224. * Define the refresh rate of the texture or the rendering frequency.
  39225. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  39226. */
  39227. get refreshRate(): number;
  39228. set refreshRate(value: number);
  39229. /**
  39230. * Adds a post process to the render target rendering passes.
  39231. * @param postProcess define the post process to add
  39232. */
  39233. addPostProcess(postProcess: PostProcess): void;
  39234. /**
  39235. * Clear all the post processes attached to the render target
  39236. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  39237. */
  39238. clearPostProcesses(dispose?: boolean): void;
  39239. /**
  39240. * Remove one of the post process from the list of attached post processes to the texture
  39241. * @param postProcess define the post process to remove from the list
  39242. */
  39243. removePostProcess(postProcess: PostProcess): void;
  39244. /** @hidden */
  39245. _shouldRender(): boolean;
  39246. /**
  39247. * Gets the actual render size of the texture.
  39248. * @returns the width of the render size
  39249. */
  39250. getRenderSize(): number;
  39251. /**
  39252. * Gets the actual render width of the texture.
  39253. * @returns the width of the render size
  39254. */
  39255. getRenderWidth(): number;
  39256. /**
  39257. * Gets the actual render height of the texture.
  39258. * @returns the height of the render size
  39259. */
  39260. getRenderHeight(): number;
  39261. /**
  39262. * Gets the actual number of layers of the texture.
  39263. * @returns the number of layers
  39264. */
  39265. getRenderLayers(): number;
  39266. /**
  39267. * Get if the texture can be rescaled or not.
  39268. */
  39269. get canRescale(): boolean;
  39270. /**
  39271. * Resize the texture using a ratio.
  39272. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  39273. */
  39274. scale(ratio: number): void;
  39275. /**
  39276. * Get the texture reflection matrix used to rotate/transform the reflection.
  39277. * @returns the reflection matrix
  39278. */
  39279. getReflectionTextureMatrix(): Matrix;
  39280. /**
  39281. * Resize the texture to a new desired size.
  39282. * Be carrefull as it will recreate all the data in the new texture.
  39283. * @param size Define the new size. It can be:
  39284. * - a number for squared texture,
  39285. * - an object containing { width: number, height: number }
  39286. * - or an object containing a ratio { ratio: number }
  39287. */
  39288. resize(size: number | {
  39289. width: number;
  39290. height: number;
  39291. } | {
  39292. ratio: number;
  39293. }): void;
  39294. private _defaultRenderListPrepared;
  39295. /**
  39296. * Renders all the objects from the render list into the texture.
  39297. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  39298. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  39299. */
  39300. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  39301. private _bestReflectionRenderTargetDimension;
  39302. private _prepareRenderingManager;
  39303. /**
  39304. * @hidden
  39305. * @param faceIndex face index to bind to if this is a cubetexture
  39306. * @param layer defines the index of the texture to bind in the array
  39307. */
  39308. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  39309. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  39310. private renderToTarget;
  39311. /**
  39312. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39313. * This allowed control for front to back rendering or reversly depending of the special needs.
  39314. *
  39315. * @param renderingGroupId The rendering group id corresponding to its index
  39316. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39317. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39318. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39319. */
  39320. 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;
  39321. /**
  39322. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39323. *
  39324. * @param renderingGroupId The rendering group id corresponding to its index
  39325. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39326. */
  39327. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  39328. /**
  39329. * Clones the texture.
  39330. * @returns the cloned texture
  39331. */
  39332. clone(): RenderTargetTexture;
  39333. /**
  39334. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  39335. * @returns The JSON representation of the texture
  39336. */
  39337. serialize(): any;
  39338. /**
  39339. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  39340. */
  39341. disposeFramebufferObjects(): void;
  39342. /**
  39343. * Dispose the texture and release its associated resources.
  39344. */
  39345. dispose(): void;
  39346. /** @hidden */
  39347. _rebuild(): void;
  39348. /**
  39349. * Clear the info related to rendering groups preventing retention point in material dispose.
  39350. */
  39351. freeRenderingGroups(): void;
  39352. /**
  39353. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  39354. * @returns the view count
  39355. */
  39356. getViewCount(): number;
  39357. }
  39358. }
  39359. declare module "babylonjs/Materials/effect" {
  39360. import { Observable } from "babylonjs/Misc/observable";
  39361. import { Nullable } from "babylonjs/types";
  39362. import { IDisposable } from "babylonjs/scene";
  39363. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39364. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39365. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  39366. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  39367. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39368. import { Engine } from "babylonjs/Engines/engine";
  39369. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39370. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  39371. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39372. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39373. /**
  39374. * Options to be used when creating an effect.
  39375. */
  39376. export interface IEffectCreationOptions {
  39377. /**
  39378. * Atrributes that will be used in the shader.
  39379. */
  39380. attributes: string[];
  39381. /**
  39382. * Uniform varible names that will be set in the shader.
  39383. */
  39384. uniformsNames: string[];
  39385. /**
  39386. * Uniform buffer variable names that will be set in the shader.
  39387. */
  39388. uniformBuffersNames: string[];
  39389. /**
  39390. * Sampler texture variable names that will be set in the shader.
  39391. */
  39392. samplers: string[];
  39393. /**
  39394. * Define statements that will be set in the shader.
  39395. */
  39396. defines: any;
  39397. /**
  39398. * Possible fallbacks for this effect to improve performance when needed.
  39399. */
  39400. fallbacks: Nullable<IEffectFallbacks>;
  39401. /**
  39402. * Callback that will be called when the shader is compiled.
  39403. */
  39404. onCompiled: Nullable<(effect: Effect) => void>;
  39405. /**
  39406. * Callback that will be called if an error occurs during shader compilation.
  39407. */
  39408. onError: Nullable<(effect: Effect, errors: string) => void>;
  39409. /**
  39410. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39411. */
  39412. indexParameters?: any;
  39413. /**
  39414. * Max number of lights that can be used in the shader.
  39415. */
  39416. maxSimultaneousLights?: number;
  39417. /**
  39418. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39419. */
  39420. transformFeedbackVaryings?: Nullable<string[]>;
  39421. /**
  39422. * 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
  39423. */
  39424. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39425. /**
  39426. * Is this effect rendering to several color attachments ?
  39427. */
  39428. multiTarget?: boolean;
  39429. }
  39430. /**
  39431. * Effect containing vertex and fragment shader that can be executed on an object.
  39432. */
  39433. export class Effect implements IDisposable {
  39434. /**
  39435. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39436. */
  39437. static ShadersRepository: string;
  39438. /**
  39439. * Enable logging of the shader code when a compilation error occurs
  39440. */
  39441. static LogShaderCodeOnCompilationError: boolean;
  39442. /**
  39443. * Name of the effect.
  39444. */
  39445. name: any;
  39446. /**
  39447. * String container all the define statements that should be set on the shader.
  39448. */
  39449. defines: string;
  39450. /**
  39451. * Callback that will be called when the shader is compiled.
  39452. */
  39453. onCompiled: Nullable<(effect: Effect) => void>;
  39454. /**
  39455. * Callback that will be called if an error occurs during shader compilation.
  39456. */
  39457. onError: Nullable<(effect: Effect, errors: string) => void>;
  39458. /**
  39459. * Callback that will be called when effect is bound.
  39460. */
  39461. onBind: Nullable<(effect: Effect) => void>;
  39462. /**
  39463. * Unique ID of the effect.
  39464. */
  39465. uniqueId: number;
  39466. /**
  39467. * Observable that will be called when the shader is compiled.
  39468. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39469. */
  39470. onCompileObservable: Observable<Effect>;
  39471. /**
  39472. * Observable that will be called if an error occurs during shader compilation.
  39473. */
  39474. onErrorObservable: Observable<Effect>;
  39475. /** @hidden */
  39476. _onBindObservable: Nullable<Observable<Effect>>;
  39477. /**
  39478. * @hidden
  39479. * Specifies if the effect was previously ready
  39480. */
  39481. _wasPreviouslyReady: boolean;
  39482. /**
  39483. * Observable that will be called when effect is bound.
  39484. */
  39485. get onBindObservable(): Observable<Effect>;
  39486. /** @hidden */
  39487. _bonesComputationForcedToCPU: boolean;
  39488. /** @hidden */
  39489. _multiTarget: boolean;
  39490. private static _uniqueIdSeed;
  39491. private _engine;
  39492. private _uniformBuffersNames;
  39493. private _uniformBuffersNamesList;
  39494. private _uniformsNames;
  39495. private _samplerList;
  39496. private _samplers;
  39497. private _isReady;
  39498. private _compilationError;
  39499. private _allFallbacksProcessed;
  39500. private _attributesNames;
  39501. private _attributes;
  39502. private _attributeLocationByName;
  39503. private _uniforms;
  39504. /**
  39505. * Key for the effect.
  39506. * @hidden
  39507. */
  39508. _key: string;
  39509. private _indexParameters;
  39510. private _fallbacks;
  39511. private _vertexSourceCode;
  39512. private _fragmentSourceCode;
  39513. private _vertexSourceCodeOverride;
  39514. private _fragmentSourceCodeOverride;
  39515. private _transformFeedbackVaryings;
  39516. private _rawVertexSourceCode;
  39517. private _rawFragmentSourceCode;
  39518. /**
  39519. * Compiled shader to webGL program.
  39520. * @hidden
  39521. */
  39522. _pipelineContext: Nullable<IPipelineContext>;
  39523. private _valueCache;
  39524. private static _baseCache;
  39525. /**
  39526. * Instantiates an effect.
  39527. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39528. * @param baseName Name of the effect.
  39529. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39530. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39531. * @param samplers List of sampler variables that will be passed to the shader.
  39532. * @param engine Engine to be used to render the effect
  39533. * @param defines Define statements to be added to the shader.
  39534. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39535. * @param onCompiled Callback that will be called when the shader is compiled.
  39536. * @param onError Callback that will be called if an error occurs during shader compilation.
  39537. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39538. */
  39539. 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);
  39540. private _useFinalCode;
  39541. /**
  39542. * Unique key for this effect
  39543. */
  39544. get key(): string;
  39545. /**
  39546. * If the effect has been compiled and prepared.
  39547. * @returns if the effect is compiled and prepared.
  39548. */
  39549. isReady(): boolean;
  39550. private _isReadyInternal;
  39551. /**
  39552. * The engine the effect was initialized with.
  39553. * @returns the engine.
  39554. */
  39555. getEngine(): Engine;
  39556. /**
  39557. * The pipeline context for this effect
  39558. * @returns the associated pipeline context
  39559. */
  39560. getPipelineContext(): Nullable<IPipelineContext>;
  39561. /**
  39562. * The set of names of attribute variables for the shader.
  39563. * @returns An array of attribute names.
  39564. */
  39565. getAttributesNames(): string[];
  39566. /**
  39567. * Returns the attribute at the given index.
  39568. * @param index The index of the attribute.
  39569. * @returns The location of the attribute.
  39570. */
  39571. getAttributeLocation(index: number): number;
  39572. /**
  39573. * Returns the attribute based on the name of the variable.
  39574. * @param name of the attribute to look up.
  39575. * @returns the attribute location.
  39576. */
  39577. getAttributeLocationByName(name: string): number;
  39578. /**
  39579. * The number of attributes.
  39580. * @returns the numnber of attributes.
  39581. */
  39582. getAttributesCount(): number;
  39583. /**
  39584. * Gets the index of a uniform variable.
  39585. * @param uniformName of the uniform to look up.
  39586. * @returns the index.
  39587. */
  39588. getUniformIndex(uniformName: string): number;
  39589. /**
  39590. * Returns the attribute based on the name of the variable.
  39591. * @param uniformName of the uniform to look up.
  39592. * @returns the location of the uniform.
  39593. */
  39594. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39595. /**
  39596. * Returns an array of sampler variable names
  39597. * @returns The array of sampler variable names.
  39598. */
  39599. getSamplers(): string[];
  39600. /**
  39601. * Returns an array of uniform variable names
  39602. * @returns The array of uniform variable names.
  39603. */
  39604. getUniformNames(): string[];
  39605. /**
  39606. * Returns an array of uniform buffer variable names
  39607. * @returns The array of uniform buffer variable names.
  39608. */
  39609. getUniformBuffersNames(): string[];
  39610. /**
  39611. * Returns the index parameters used to create the effect
  39612. * @returns The index parameters object
  39613. */
  39614. getIndexParameters(): any;
  39615. /**
  39616. * The error from the last compilation.
  39617. * @returns the error string.
  39618. */
  39619. getCompilationError(): string;
  39620. /**
  39621. * Gets a boolean indicating that all fallbacks were used during compilation
  39622. * @returns true if all fallbacks were used
  39623. */
  39624. allFallbacksProcessed(): boolean;
  39625. /**
  39626. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39627. * @param func The callback to be used.
  39628. */
  39629. executeWhenCompiled(func: (effect: Effect) => void): void;
  39630. private _checkIsReady;
  39631. private _loadShader;
  39632. /**
  39633. * Gets the vertex shader source code of this effect
  39634. */
  39635. get vertexSourceCode(): string;
  39636. /**
  39637. * Gets the fragment shader source code of this effect
  39638. */
  39639. get fragmentSourceCode(): string;
  39640. /**
  39641. * Gets the vertex shader source code before it has been processed by the preprocessor
  39642. */
  39643. get rawVertexSourceCode(): string;
  39644. /**
  39645. * Gets the fragment shader source code before it has been processed by the preprocessor
  39646. */
  39647. get rawFragmentSourceCode(): string;
  39648. /**
  39649. * Recompiles the webGL program
  39650. * @param vertexSourceCode The source code for the vertex shader.
  39651. * @param fragmentSourceCode The source code for the fragment shader.
  39652. * @param onCompiled Callback called when completed.
  39653. * @param onError Callback called on error.
  39654. * @hidden
  39655. */
  39656. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39657. /**
  39658. * Prepares the effect
  39659. * @hidden
  39660. */
  39661. _prepareEffect(): void;
  39662. private _getShaderCodeAndErrorLine;
  39663. private _processCompilationErrors;
  39664. /**
  39665. * Checks if the effect is supported. (Must be called after compilation)
  39666. */
  39667. get isSupported(): boolean;
  39668. /**
  39669. * Binds a texture to the engine to be used as output of the shader.
  39670. * @param channel Name of the output variable.
  39671. * @param texture Texture to bind.
  39672. * @hidden
  39673. */
  39674. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39675. /**
  39676. * Sets a texture on the engine to be used in the shader.
  39677. * @param channel Name of the sampler variable.
  39678. * @param texture Texture to set.
  39679. */
  39680. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39681. /**
  39682. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39683. * @param channel Name of the sampler variable.
  39684. * @param texture Texture to set.
  39685. */
  39686. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39687. /**
  39688. * Sets an array of textures on the engine to be used in the shader.
  39689. * @param channel Name of the variable.
  39690. * @param textures Textures to set.
  39691. */
  39692. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39693. /**
  39694. * 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)
  39695. * @param channel Name of the sampler variable.
  39696. * @param postProcess Post process to get the input texture from.
  39697. */
  39698. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39699. /**
  39700. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39701. * 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)
  39702. * @param channel Name of the sampler variable.
  39703. * @param postProcess Post process to get the output texture from.
  39704. */
  39705. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39706. /** @hidden */
  39707. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39708. /** @hidden */
  39709. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39710. /** @hidden */
  39711. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39712. /** @hidden */
  39713. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39714. /**
  39715. * Binds a buffer to a uniform.
  39716. * @param buffer Buffer to bind.
  39717. * @param name Name of the uniform variable to bind to.
  39718. */
  39719. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39720. /**
  39721. * Binds block to a uniform.
  39722. * @param blockName Name of the block to bind.
  39723. * @param index Index to bind.
  39724. */
  39725. bindUniformBlock(blockName: string, index: number): void;
  39726. /**
  39727. * Sets an interger value on a uniform variable.
  39728. * @param uniformName Name of the variable.
  39729. * @param value Value to be set.
  39730. * @returns this effect.
  39731. */
  39732. setInt(uniformName: string, value: number): Effect;
  39733. /**
  39734. * Sets an int array on a uniform variable.
  39735. * @param uniformName Name of the variable.
  39736. * @param array array to be set.
  39737. * @returns this effect.
  39738. */
  39739. setIntArray(uniformName: string, array: Int32Array): Effect;
  39740. /**
  39741. * 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)
  39742. * @param uniformName Name of the variable.
  39743. * @param array array to be set.
  39744. * @returns this effect.
  39745. */
  39746. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39747. /**
  39748. * 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)
  39749. * @param uniformName Name of the variable.
  39750. * @param array array to be set.
  39751. * @returns this effect.
  39752. */
  39753. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39754. /**
  39755. * 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)
  39756. * @param uniformName Name of the variable.
  39757. * @param array array to be set.
  39758. * @returns this effect.
  39759. */
  39760. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39761. /**
  39762. * Sets an float array on a uniform variable.
  39763. * @param uniformName Name of the variable.
  39764. * @param array array to be set.
  39765. * @returns this effect.
  39766. */
  39767. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39768. /**
  39769. * 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)
  39770. * @param uniformName Name of the variable.
  39771. * @param array array to be set.
  39772. * @returns this effect.
  39773. */
  39774. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39775. /**
  39776. * 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)
  39777. * @param uniformName Name of the variable.
  39778. * @param array array to be set.
  39779. * @returns this effect.
  39780. */
  39781. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39782. /**
  39783. * 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)
  39784. * @param uniformName Name of the variable.
  39785. * @param array array to be set.
  39786. * @returns this effect.
  39787. */
  39788. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39789. /**
  39790. * Sets an array on a uniform variable.
  39791. * @param uniformName Name of the variable.
  39792. * @param array array to be set.
  39793. * @returns this effect.
  39794. */
  39795. setArray(uniformName: string, array: number[]): Effect;
  39796. /**
  39797. * 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)
  39798. * @param uniformName Name of the variable.
  39799. * @param array array to be set.
  39800. * @returns this effect.
  39801. */
  39802. setArray2(uniformName: string, array: number[]): Effect;
  39803. /**
  39804. * 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)
  39805. * @param uniformName Name of the variable.
  39806. * @param array array to be set.
  39807. * @returns this effect.
  39808. */
  39809. setArray3(uniformName: string, array: number[]): Effect;
  39810. /**
  39811. * 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)
  39812. * @param uniformName Name of the variable.
  39813. * @param array array to be set.
  39814. * @returns this effect.
  39815. */
  39816. setArray4(uniformName: string, array: number[]): Effect;
  39817. /**
  39818. * Sets matrices on a uniform variable.
  39819. * @param uniformName Name of the variable.
  39820. * @param matrices matrices to be set.
  39821. * @returns this effect.
  39822. */
  39823. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39824. /**
  39825. * Sets matrix on a uniform variable.
  39826. * @param uniformName Name of the variable.
  39827. * @param matrix matrix to be set.
  39828. * @returns this effect.
  39829. */
  39830. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39831. /**
  39832. * 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)
  39833. * @param uniformName Name of the variable.
  39834. * @param matrix matrix to be set.
  39835. * @returns this effect.
  39836. */
  39837. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39838. /**
  39839. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39840. * @param uniformName Name of the variable.
  39841. * @param matrix matrix to be set.
  39842. * @returns this effect.
  39843. */
  39844. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39845. /**
  39846. * Sets a float on a uniform variable.
  39847. * @param uniformName Name of the variable.
  39848. * @param value value to be set.
  39849. * @returns this effect.
  39850. */
  39851. setFloat(uniformName: string, value: number): Effect;
  39852. /**
  39853. * Sets a boolean on a uniform variable.
  39854. * @param uniformName Name of the variable.
  39855. * @param bool value to be set.
  39856. * @returns this effect.
  39857. */
  39858. setBool(uniformName: string, bool: boolean): Effect;
  39859. /**
  39860. * Sets a Vector2 on a uniform variable.
  39861. * @param uniformName Name of the variable.
  39862. * @param vector2 vector2 to be set.
  39863. * @returns this effect.
  39864. */
  39865. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39866. /**
  39867. * Sets a float2 on a uniform variable.
  39868. * @param uniformName Name of the variable.
  39869. * @param x First float in float2.
  39870. * @param y Second float in float2.
  39871. * @returns this effect.
  39872. */
  39873. setFloat2(uniformName: string, x: number, y: number): Effect;
  39874. /**
  39875. * Sets a Vector3 on a uniform variable.
  39876. * @param uniformName Name of the variable.
  39877. * @param vector3 Value to be set.
  39878. * @returns this effect.
  39879. */
  39880. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39881. /**
  39882. * Sets a float3 on a uniform variable.
  39883. * @param uniformName Name of the variable.
  39884. * @param x First float in float3.
  39885. * @param y Second float in float3.
  39886. * @param z Third float in float3.
  39887. * @returns this effect.
  39888. */
  39889. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39890. /**
  39891. * Sets a Vector4 on a uniform variable.
  39892. * @param uniformName Name of the variable.
  39893. * @param vector4 Value to be set.
  39894. * @returns this effect.
  39895. */
  39896. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39897. /**
  39898. * Sets a float4 on a uniform variable.
  39899. * @param uniformName Name of the variable.
  39900. * @param x First float in float4.
  39901. * @param y Second float in float4.
  39902. * @param z Third float in float4.
  39903. * @param w Fourth float in float4.
  39904. * @returns this effect.
  39905. */
  39906. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39907. /**
  39908. * Sets a Color3 on a uniform variable.
  39909. * @param uniformName Name of the variable.
  39910. * @param color3 Value to be set.
  39911. * @returns this effect.
  39912. */
  39913. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39914. /**
  39915. * Sets a Color4 on a uniform variable.
  39916. * @param uniformName Name of the variable.
  39917. * @param color3 Value to be set.
  39918. * @param alpha Alpha value to be set.
  39919. * @returns this effect.
  39920. */
  39921. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39922. /**
  39923. * Sets a Color4 on a uniform variable
  39924. * @param uniformName defines the name of the variable
  39925. * @param color4 defines the value to be set
  39926. * @returns this effect.
  39927. */
  39928. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39929. /** Release all associated resources */
  39930. dispose(): void;
  39931. /**
  39932. * This function will add a new shader to the shader store
  39933. * @param name the name of the shader
  39934. * @param pixelShader optional pixel shader content
  39935. * @param vertexShader optional vertex shader content
  39936. */
  39937. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39938. /**
  39939. * Store of each shader (The can be looked up using effect.key)
  39940. */
  39941. static ShadersStore: {
  39942. [key: string]: string;
  39943. };
  39944. /**
  39945. * Store of each included file for a shader (The can be looked up using effect.key)
  39946. */
  39947. static IncludesShadersStore: {
  39948. [key: string]: string;
  39949. };
  39950. /**
  39951. * Resets the cache of effects.
  39952. */
  39953. static ResetCache(): void;
  39954. }
  39955. }
  39956. declare module "babylonjs/Engines/engineCapabilities" {
  39957. /**
  39958. * Interface used to describe the capabilities of the engine relatively to the current browser
  39959. */
  39960. export interface EngineCapabilities {
  39961. /** Maximum textures units per fragment shader */
  39962. maxTexturesImageUnits: number;
  39963. /** Maximum texture units per vertex shader */
  39964. maxVertexTextureImageUnits: number;
  39965. /** Maximum textures units in the entire pipeline */
  39966. maxCombinedTexturesImageUnits: number;
  39967. /** Maximum texture size */
  39968. maxTextureSize: number;
  39969. /** Maximum texture samples */
  39970. maxSamples?: number;
  39971. /** Maximum cube texture size */
  39972. maxCubemapTextureSize: number;
  39973. /** Maximum render texture size */
  39974. maxRenderTextureSize: number;
  39975. /** Maximum number of vertex attributes */
  39976. maxVertexAttribs: number;
  39977. /** Maximum number of varyings */
  39978. maxVaryingVectors: number;
  39979. /** Maximum number of uniforms per vertex shader */
  39980. maxVertexUniformVectors: number;
  39981. /** Maximum number of uniforms per fragment shader */
  39982. maxFragmentUniformVectors: number;
  39983. /** Defines if standard derivates (dx/dy) are supported */
  39984. standardDerivatives: boolean;
  39985. /** Defines if s3tc texture compression is supported */
  39986. s3tc?: WEBGL_compressed_texture_s3tc;
  39987. /** Defines if pvrtc texture compression is supported */
  39988. pvrtc: any;
  39989. /** Defines if etc1 texture compression is supported */
  39990. etc1: any;
  39991. /** Defines if etc2 texture compression is supported */
  39992. etc2: any;
  39993. /** Defines if astc texture compression is supported */
  39994. astc: any;
  39995. /** Defines if bptc texture compression is supported */
  39996. bptc: any;
  39997. /** Defines if float textures are supported */
  39998. textureFloat: boolean;
  39999. /** Defines if vertex array objects are supported */
  40000. vertexArrayObject: boolean;
  40001. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  40002. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  40003. /** Gets the maximum level of anisotropy supported */
  40004. maxAnisotropy: number;
  40005. /** Defines if instancing is supported */
  40006. instancedArrays: boolean;
  40007. /** Defines if 32 bits indices are supported */
  40008. uintIndices: boolean;
  40009. /** Defines if high precision shaders are supported */
  40010. highPrecisionShaderSupported: boolean;
  40011. /** Defines if depth reading in the fragment shader is supported */
  40012. fragmentDepthSupported: boolean;
  40013. /** Defines if float texture linear filtering is supported*/
  40014. textureFloatLinearFiltering: boolean;
  40015. /** Defines if rendering to float textures is supported */
  40016. textureFloatRender: boolean;
  40017. /** Defines if half float textures are supported*/
  40018. textureHalfFloat: boolean;
  40019. /** Defines if half float texture linear filtering is supported*/
  40020. textureHalfFloatLinearFiltering: boolean;
  40021. /** Defines if rendering to half float textures is supported */
  40022. textureHalfFloatRender: boolean;
  40023. /** Defines if textureLOD shader command is supported */
  40024. textureLOD: boolean;
  40025. /** Defines if draw buffers extension is supported */
  40026. drawBuffersExtension: boolean;
  40027. /** Defines if depth textures are supported */
  40028. depthTextureExtension: boolean;
  40029. /** Defines if float color buffer are supported */
  40030. colorBufferFloat: boolean;
  40031. /** Gets disjoint timer query extension (null if not supported) */
  40032. timerQuery?: EXT_disjoint_timer_query;
  40033. /** Defines if timestamp can be used with timer query */
  40034. canUseTimestampForTimerQuery: boolean;
  40035. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  40036. multiview?: any;
  40037. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  40038. oculusMultiview?: any;
  40039. /** Function used to let the system compiles shaders in background */
  40040. parallelShaderCompile?: {
  40041. COMPLETION_STATUS_KHR: number;
  40042. };
  40043. /** Max number of texture samples for MSAA */
  40044. maxMSAASamples: number;
  40045. /** Defines if the blend min max extension is supported */
  40046. blendMinMax: boolean;
  40047. }
  40048. }
  40049. declare module "babylonjs/States/depthCullingState" {
  40050. import { Nullable } from "babylonjs/types";
  40051. /**
  40052. * @hidden
  40053. **/
  40054. export class DepthCullingState {
  40055. private _isDepthTestDirty;
  40056. private _isDepthMaskDirty;
  40057. private _isDepthFuncDirty;
  40058. private _isCullFaceDirty;
  40059. private _isCullDirty;
  40060. private _isZOffsetDirty;
  40061. private _isFrontFaceDirty;
  40062. private _depthTest;
  40063. private _depthMask;
  40064. private _depthFunc;
  40065. private _cull;
  40066. private _cullFace;
  40067. private _zOffset;
  40068. private _frontFace;
  40069. /**
  40070. * Initializes the state.
  40071. */
  40072. constructor();
  40073. get isDirty(): boolean;
  40074. get zOffset(): number;
  40075. set zOffset(value: number);
  40076. get cullFace(): Nullable<number>;
  40077. set cullFace(value: Nullable<number>);
  40078. get cull(): Nullable<boolean>;
  40079. set cull(value: Nullable<boolean>);
  40080. get depthFunc(): Nullable<number>;
  40081. set depthFunc(value: Nullable<number>);
  40082. get depthMask(): boolean;
  40083. set depthMask(value: boolean);
  40084. get depthTest(): boolean;
  40085. set depthTest(value: boolean);
  40086. get frontFace(): Nullable<number>;
  40087. set frontFace(value: Nullable<number>);
  40088. reset(): void;
  40089. apply(gl: WebGLRenderingContext): void;
  40090. }
  40091. }
  40092. declare module "babylonjs/States/stencilState" {
  40093. /**
  40094. * @hidden
  40095. **/
  40096. export class StencilState {
  40097. /** 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 */
  40098. static readonly ALWAYS: number;
  40099. /** Passed to stencilOperation to specify that stencil value must be kept */
  40100. static readonly KEEP: number;
  40101. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40102. static readonly REPLACE: number;
  40103. private _isStencilTestDirty;
  40104. private _isStencilMaskDirty;
  40105. private _isStencilFuncDirty;
  40106. private _isStencilOpDirty;
  40107. private _stencilTest;
  40108. private _stencilMask;
  40109. private _stencilFunc;
  40110. private _stencilFuncRef;
  40111. private _stencilFuncMask;
  40112. private _stencilOpStencilFail;
  40113. private _stencilOpDepthFail;
  40114. private _stencilOpStencilDepthPass;
  40115. get isDirty(): boolean;
  40116. get stencilFunc(): number;
  40117. set stencilFunc(value: number);
  40118. get stencilFuncRef(): number;
  40119. set stencilFuncRef(value: number);
  40120. get stencilFuncMask(): number;
  40121. set stencilFuncMask(value: number);
  40122. get stencilOpStencilFail(): number;
  40123. set stencilOpStencilFail(value: number);
  40124. get stencilOpDepthFail(): number;
  40125. set stencilOpDepthFail(value: number);
  40126. get stencilOpStencilDepthPass(): number;
  40127. set stencilOpStencilDepthPass(value: number);
  40128. get stencilMask(): number;
  40129. set stencilMask(value: number);
  40130. get stencilTest(): boolean;
  40131. set stencilTest(value: boolean);
  40132. constructor();
  40133. reset(): void;
  40134. apply(gl: WebGLRenderingContext): void;
  40135. }
  40136. }
  40137. declare module "babylonjs/States/alphaCullingState" {
  40138. /**
  40139. * @hidden
  40140. **/
  40141. export class AlphaState {
  40142. private _isAlphaBlendDirty;
  40143. private _isBlendFunctionParametersDirty;
  40144. private _isBlendEquationParametersDirty;
  40145. private _isBlendConstantsDirty;
  40146. private _alphaBlend;
  40147. private _blendFunctionParameters;
  40148. private _blendEquationParameters;
  40149. private _blendConstants;
  40150. /**
  40151. * Initializes the state.
  40152. */
  40153. constructor();
  40154. get isDirty(): boolean;
  40155. get alphaBlend(): boolean;
  40156. set alphaBlend(value: boolean);
  40157. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  40158. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  40159. setAlphaEquationParameters(rgb: number, alpha: number): void;
  40160. reset(): void;
  40161. apply(gl: WebGLRenderingContext): void;
  40162. }
  40163. }
  40164. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  40165. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40166. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40167. /** @hidden */
  40168. export class WebGLShaderProcessor implements IShaderProcessor {
  40169. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  40170. }
  40171. }
  40172. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  40173. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40174. /** @hidden */
  40175. export class WebGL2ShaderProcessor implements IShaderProcessor {
  40176. attributeProcessor(attribute: string): string;
  40177. varyingProcessor(varying: string, isFragment: boolean): string;
  40178. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  40179. }
  40180. }
  40181. declare module "babylonjs/Engines/instancingAttributeInfo" {
  40182. /**
  40183. * Interface for attribute information associated with buffer instanciation
  40184. */
  40185. export interface InstancingAttributeInfo {
  40186. /**
  40187. * Name of the GLSL attribute
  40188. * if attribute index is not specified, this is used to retrieve the index from the effect
  40189. */
  40190. attributeName: string;
  40191. /**
  40192. * Index/offset of the attribute in the vertex shader
  40193. * if not specified, this will be computes from the name.
  40194. */
  40195. index?: number;
  40196. /**
  40197. * size of the attribute, 1, 2, 3 or 4
  40198. */
  40199. attributeSize: number;
  40200. /**
  40201. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  40202. */
  40203. offset: number;
  40204. /**
  40205. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  40206. * default to 1
  40207. */
  40208. divisor?: number;
  40209. /**
  40210. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  40211. * default is FLOAT
  40212. */
  40213. attributeType?: number;
  40214. /**
  40215. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  40216. */
  40217. normalized?: boolean;
  40218. }
  40219. }
  40220. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  40221. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40222. import { Nullable } from "babylonjs/types";
  40223. module "babylonjs/Engines/thinEngine" {
  40224. interface ThinEngine {
  40225. /**
  40226. * Update a video texture
  40227. * @param texture defines the texture to update
  40228. * @param video defines the video element to use
  40229. * @param invertY defines if data must be stored with Y axis inverted
  40230. */
  40231. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  40232. }
  40233. }
  40234. }
  40235. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  40236. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40237. import { Nullable } from "babylonjs/types";
  40238. module "babylonjs/Engines/thinEngine" {
  40239. interface ThinEngine {
  40240. /**
  40241. * Creates a dynamic texture
  40242. * @param width defines the width of the texture
  40243. * @param height defines the height of the texture
  40244. * @param generateMipMaps defines if the engine should generate the mip levels
  40245. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  40246. * @returns the dynamic texture inside an InternalTexture
  40247. */
  40248. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  40249. /**
  40250. * Update the content of a dynamic texture
  40251. * @param texture defines the texture to update
  40252. * @param source defines the source containing the data
  40253. * @param invertY defines if data must be stored with Y axis inverted
  40254. * @param premulAlpha defines if alpha is stored as premultiplied
  40255. * @param format defines the format of the data
  40256. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  40257. */
  40258. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  40259. }
  40260. }
  40261. }
  40262. declare module "babylonjs/Materials/Textures/videoTexture" {
  40263. import { Observable } from "babylonjs/Misc/observable";
  40264. import { Nullable } from "babylonjs/types";
  40265. import { Scene } from "babylonjs/scene";
  40266. import { Texture } from "babylonjs/Materials/Textures/texture";
  40267. import "babylonjs/Engines/Extensions/engine.videoTexture";
  40268. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  40269. /**
  40270. * Settings for finer control over video usage
  40271. */
  40272. export interface VideoTextureSettings {
  40273. /**
  40274. * Applies `autoplay` to video, if specified
  40275. */
  40276. autoPlay?: boolean;
  40277. /**
  40278. * Applies `muted` to video, if specified
  40279. */
  40280. muted?: boolean;
  40281. /**
  40282. * Applies `loop` to video, if specified
  40283. */
  40284. loop?: boolean;
  40285. /**
  40286. * Automatically updates internal texture from video at every frame in the render loop
  40287. */
  40288. autoUpdateTexture: boolean;
  40289. /**
  40290. * Image src displayed during the video loading or until the user interacts with the video.
  40291. */
  40292. poster?: string;
  40293. }
  40294. /**
  40295. * If you want to display a video in your scene, this is the special texture for that.
  40296. * This special texture works similar to other textures, with the exception of a few parameters.
  40297. * @see https://doc.babylonjs.com/how_to/video_texture
  40298. */
  40299. export class VideoTexture extends Texture {
  40300. /**
  40301. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40302. */
  40303. readonly autoUpdateTexture: boolean;
  40304. /**
  40305. * The video instance used by the texture internally
  40306. */
  40307. readonly video: HTMLVideoElement;
  40308. private _onUserActionRequestedObservable;
  40309. /**
  40310. * Event triggerd when a dom action is required by the user to play the video.
  40311. * This happens due to recent changes in browser policies preventing video to auto start.
  40312. */
  40313. get onUserActionRequestedObservable(): Observable<Texture>;
  40314. private _generateMipMaps;
  40315. private _stillImageCaptured;
  40316. private _displayingPosterTexture;
  40317. private _settings;
  40318. private _createInternalTextureOnEvent;
  40319. private _frameId;
  40320. private _currentSrc;
  40321. /**
  40322. * Creates a video texture.
  40323. * If you want to display a video in your scene, this is the special texture for that.
  40324. * This special texture works similar to other textures, with the exception of a few parameters.
  40325. * @see https://doc.babylonjs.com/how_to/video_texture
  40326. * @param name optional name, will detect from video source, if not defined
  40327. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40328. * @param scene is obviously the current scene.
  40329. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40330. * @param invertY is false by default but can be used to invert video on Y axis
  40331. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40332. * @param settings allows finer control over video usage
  40333. */
  40334. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40335. private _getName;
  40336. private _getVideo;
  40337. private _createInternalTexture;
  40338. private reset;
  40339. /**
  40340. * @hidden Internal method to initiate `update`.
  40341. */
  40342. _rebuild(): void;
  40343. /**
  40344. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40345. */
  40346. update(): void;
  40347. /**
  40348. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40349. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  40350. */
  40351. updateTexture(isVisible: boolean): void;
  40352. protected _updateInternalTexture: () => void;
  40353. /**
  40354. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40355. * @param url New url.
  40356. */
  40357. updateURL(url: string): void;
  40358. /**
  40359. * Clones the texture.
  40360. * @returns the cloned texture
  40361. */
  40362. clone(): VideoTexture;
  40363. /**
  40364. * Dispose the texture and release its associated resources.
  40365. */
  40366. dispose(): void;
  40367. /**
  40368. * Creates a video texture straight from a stream.
  40369. * @param scene Define the scene the texture should be created in
  40370. * @param stream Define the stream the texture should be created from
  40371. * @returns The created video texture as a promise
  40372. */
  40373. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40374. /**
  40375. * Creates a video texture straight from your WebCam video feed.
  40376. * @param scene Define the scene the texture should be created in
  40377. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40378. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40379. * @returns The created video texture as a promise
  40380. */
  40381. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40382. minWidth: number;
  40383. maxWidth: number;
  40384. minHeight: number;
  40385. maxHeight: number;
  40386. deviceId: string;
  40387. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40388. /**
  40389. * Creates a video texture straight from your WebCam video feed.
  40390. * @param scene Define the scene the texture should be created in
  40391. * @param onReady Define a callback to triggered once the texture will be ready
  40392. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40393. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40394. */
  40395. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40396. minWidth: number;
  40397. maxWidth: number;
  40398. minHeight: number;
  40399. maxHeight: number;
  40400. deviceId: string;
  40401. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40402. }
  40403. }
  40404. declare module "babylonjs/Engines/thinEngine" {
  40405. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  40406. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  40407. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40408. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40409. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  40410. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  40411. import { Observable } from "babylonjs/Misc/observable";
  40412. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  40413. import { StencilState } from "babylonjs/States/stencilState";
  40414. import { AlphaState } from "babylonjs/States/alphaCullingState";
  40415. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40416. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  40417. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  40418. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40419. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  40420. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  40421. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  40422. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  40423. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  40424. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40425. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  40426. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  40427. import { WebRequest } from "babylonjs/Misc/webRequest";
  40428. import { LoadFileError } from "babylonjs/Misc/fileTools";
  40429. /**
  40430. * Defines the interface used by objects working like Scene
  40431. * @hidden
  40432. */
  40433. export interface ISceneLike {
  40434. _addPendingData(data: any): void;
  40435. _removePendingData(data: any): void;
  40436. offlineProvider: IOfflineProvider;
  40437. }
  40438. /**
  40439. * Information about the current host
  40440. */
  40441. export interface HostInformation {
  40442. /**
  40443. * Defines if the current host is a mobile
  40444. */
  40445. isMobile: boolean;
  40446. }
  40447. /** Interface defining initialization parameters for Engine class */
  40448. export interface EngineOptions extends WebGLContextAttributes {
  40449. /**
  40450. * Defines if the engine should no exceed a specified device ratio
  40451. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40452. */
  40453. limitDeviceRatio?: number;
  40454. /**
  40455. * Defines if webvr should be enabled automatically
  40456. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40457. */
  40458. autoEnableWebVR?: boolean;
  40459. /**
  40460. * Defines if webgl2 should be turned off even if supported
  40461. * @see https://doc.babylonjs.com/features/webgl2
  40462. */
  40463. disableWebGL2Support?: boolean;
  40464. /**
  40465. * Defines if webaudio should be initialized as well
  40466. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40467. */
  40468. audioEngine?: boolean;
  40469. /**
  40470. * Defines if animations should run using a deterministic lock step
  40471. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40472. */
  40473. deterministicLockstep?: boolean;
  40474. /** Defines the maximum steps to use with deterministic lock step mode */
  40475. lockstepMaxSteps?: number;
  40476. /** Defines the seconds between each deterministic lock step */
  40477. timeStep?: number;
  40478. /**
  40479. * Defines that engine should ignore context lost events
  40480. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40481. */
  40482. doNotHandleContextLost?: boolean;
  40483. /**
  40484. * Defines that engine should ignore modifying touch action attribute and style
  40485. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40486. */
  40487. doNotHandleTouchAction?: boolean;
  40488. /**
  40489. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40490. */
  40491. useHighPrecisionFloats?: boolean;
  40492. /**
  40493. * Make the canvas XR Compatible for XR sessions
  40494. */
  40495. xrCompatible?: boolean;
  40496. /**
  40497. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40498. */
  40499. useHighPrecisionMatrix?: boolean;
  40500. /**
  40501. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40502. */
  40503. failIfMajorPerformanceCaveat?: boolean;
  40504. }
  40505. /**
  40506. * The base engine class (root of all engines)
  40507. */
  40508. export class ThinEngine {
  40509. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40510. static ExceptionList: ({
  40511. key: string;
  40512. capture: string;
  40513. captureConstraint: number;
  40514. targets: string[];
  40515. } | {
  40516. key: string;
  40517. capture: null;
  40518. captureConstraint: null;
  40519. targets: string[];
  40520. })[];
  40521. /** @hidden */
  40522. static _TextureLoaders: IInternalTextureLoader[];
  40523. /**
  40524. * Returns the current npm package of the sdk
  40525. */
  40526. static get NpmPackage(): string;
  40527. /**
  40528. * Returns the current version of the framework
  40529. */
  40530. static get Version(): string;
  40531. /**
  40532. * Returns a string describing the current engine
  40533. */
  40534. get description(): string;
  40535. /**
  40536. * Gets or sets the epsilon value used by collision engine
  40537. */
  40538. static CollisionsEpsilon: number;
  40539. /**
  40540. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40541. */
  40542. static get ShadersRepository(): string;
  40543. static set ShadersRepository(value: string);
  40544. /** @hidden */
  40545. _shaderProcessor: IShaderProcessor;
  40546. /**
  40547. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40548. */
  40549. forcePOTTextures: boolean;
  40550. /**
  40551. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40552. */
  40553. isFullscreen: boolean;
  40554. /**
  40555. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40556. */
  40557. cullBackFaces: boolean;
  40558. /**
  40559. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40560. */
  40561. renderEvenInBackground: boolean;
  40562. /**
  40563. * Gets or sets a boolean indicating that cache can be kept between frames
  40564. */
  40565. preventCacheWipeBetweenFrames: boolean;
  40566. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40567. validateShaderPrograms: boolean;
  40568. /**
  40569. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40570. * This can provide greater z depth for distant objects.
  40571. */
  40572. useReverseDepthBuffer: boolean;
  40573. /**
  40574. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40575. */
  40576. disableUniformBuffers: boolean;
  40577. /** @hidden */
  40578. _uniformBuffers: UniformBuffer[];
  40579. /**
  40580. * Gets a boolean indicating that the engine supports uniform buffers
  40581. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40582. */
  40583. get supportsUniformBuffers(): boolean;
  40584. /** @hidden */
  40585. _gl: WebGLRenderingContext;
  40586. /** @hidden */
  40587. _webGLVersion: number;
  40588. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40589. protected _windowIsBackground: boolean;
  40590. protected _creationOptions: EngineOptions;
  40591. protected _highPrecisionShadersAllowed: boolean;
  40592. /** @hidden */
  40593. get _shouldUseHighPrecisionShader(): boolean;
  40594. /**
  40595. * Gets a boolean indicating that only power of 2 textures are supported
  40596. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40597. */
  40598. get needPOTTextures(): boolean;
  40599. /** @hidden */
  40600. _badOS: boolean;
  40601. /** @hidden */
  40602. _badDesktopOS: boolean;
  40603. private _hardwareScalingLevel;
  40604. /** @hidden */
  40605. _caps: EngineCapabilities;
  40606. private _isStencilEnable;
  40607. private _glVersion;
  40608. private _glRenderer;
  40609. private _glVendor;
  40610. /** @hidden */
  40611. _videoTextureSupported: boolean;
  40612. protected _renderingQueueLaunched: boolean;
  40613. protected _activeRenderLoops: (() => void)[];
  40614. /**
  40615. * Observable signaled when a context lost event is raised
  40616. */
  40617. onContextLostObservable: Observable<ThinEngine>;
  40618. /**
  40619. * Observable signaled when a context restored event is raised
  40620. */
  40621. onContextRestoredObservable: Observable<ThinEngine>;
  40622. private _onContextLost;
  40623. private _onContextRestored;
  40624. protected _contextWasLost: boolean;
  40625. /** @hidden */
  40626. _doNotHandleContextLost: boolean;
  40627. /**
  40628. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40629. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40630. */
  40631. get doNotHandleContextLost(): boolean;
  40632. set doNotHandleContextLost(value: boolean);
  40633. /**
  40634. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40635. */
  40636. disableVertexArrayObjects: boolean;
  40637. /** @hidden */
  40638. protected _colorWrite: boolean;
  40639. /** @hidden */
  40640. protected _colorWriteChanged: boolean;
  40641. /** @hidden */
  40642. protected _depthCullingState: DepthCullingState;
  40643. /** @hidden */
  40644. protected _stencilState: StencilState;
  40645. /** @hidden */
  40646. _alphaState: AlphaState;
  40647. /** @hidden */
  40648. _alphaMode: number;
  40649. /** @hidden */
  40650. _alphaEquation: number;
  40651. /** @hidden */
  40652. _internalTexturesCache: InternalTexture[];
  40653. /** @hidden */
  40654. protected _activeChannel: number;
  40655. private _currentTextureChannel;
  40656. /** @hidden */
  40657. protected _boundTexturesCache: {
  40658. [key: string]: Nullable<InternalTexture>;
  40659. };
  40660. /** @hidden */
  40661. protected _currentEffect: Nullable<Effect>;
  40662. /** @hidden */
  40663. protected _currentProgram: Nullable<WebGLProgram>;
  40664. private _compiledEffects;
  40665. private _vertexAttribArraysEnabled;
  40666. /** @hidden */
  40667. protected _cachedViewport: Nullable<IViewportLike>;
  40668. private _cachedVertexArrayObject;
  40669. /** @hidden */
  40670. protected _cachedVertexBuffers: any;
  40671. /** @hidden */
  40672. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40673. /** @hidden */
  40674. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40675. /** @hidden */
  40676. _currentRenderTarget: Nullable<InternalTexture>;
  40677. private _uintIndicesCurrentlySet;
  40678. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40679. /** @hidden */
  40680. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40681. /** @hidden */
  40682. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40683. private _currentBufferPointers;
  40684. private _currentInstanceLocations;
  40685. private _currentInstanceBuffers;
  40686. private _textureUnits;
  40687. /** @hidden */
  40688. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40689. /** @hidden */
  40690. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40691. /** @hidden */
  40692. _boundRenderFunction: any;
  40693. private _vaoRecordInProgress;
  40694. private _mustWipeVertexAttributes;
  40695. private _emptyTexture;
  40696. private _emptyCubeTexture;
  40697. private _emptyTexture3D;
  40698. private _emptyTexture2DArray;
  40699. /** @hidden */
  40700. _frameHandler: number;
  40701. private _nextFreeTextureSlots;
  40702. private _maxSimultaneousTextures;
  40703. private _activeRequests;
  40704. /** @hidden */
  40705. _transformTextureUrl: Nullable<(url: string) => string>;
  40706. /**
  40707. * Gets information about the current host
  40708. */
  40709. hostInformation: HostInformation;
  40710. protected get _supportsHardwareTextureRescaling(): boolean;
  40711. private _framebufferDimensionsObject;
  40712. /**
  40713. * sets the object from which width and height will be taken from when getting render width and height
  40714. * Will fallback to the gl object
  40715. * @param dimensions the framebuffer width and height that will be used.
  40716. */
  40717. set framebufferDimensionsObject(dimensions: Nullable<{
  40718. framebufferWidth: number;
  40719. framebufferHeight: number;
  40720. }>);
  40721. /**
  40722. * Gets the current viewport
  40723. */
  40724. get currentViewport(): Nullable<IViewportLike>;
  40725. /**
  40726. * Gets the default empty texture
  40727. */
  40728. get emptyTexture(): InternalTexture;
  40729. /**
  40730. * Gets the default empty 3D texture
  40731. */
  40732. get emptyTexture3D(): InternalTexture;
  40733. /**
  40734. * Gets the default empty 2D array texture
  40735. */
  40736. get emptyTexture2DArray(): InternalTexture;
  40737. /**
  40738. * Gets the default empty cube texture
  40739. */
  40740. get emptyCubeTexture(): InternalTexture;
  40741. /**
  40742. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40743. */
  40744. readonly premultipliedAlpha: boolean;
  40745. /**
  40746. * Observable event triggered before each texture is initialized
  40747. */
  40748. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40749. /**
  40750. * Creates a new engine
  40751. * @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
  40752. * @param antialias defines enable antialiasing (default: false)
  40753. * @param options defines further options to be sent to the getContext() function
  40754. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40755. */
  40756. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40757. private _rebuildInternalTextures;
  40758. private _rebuildEffects;
  40759. /**
  40760. * Gets a boolean indicating if all created effects are ready
  40761. * @returns true if all effects are ready
  40762. */
  40763. areAllEffectsReady(): boolean;
  40764. protected _rebuildBuffers(): void;
  40765. protected _initGLContext(): void;
  40766. /**
  40767. * Gets version of the current webGL context
  40768. */
  40769. get webGLVersion(): number;
  40770. /**
  40771. * Gets a string identifying the name of the class
  40772. * @returns "Engine" string
  40773. */
  40774. getClassName(): string;
  40775. /**
  40776. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40777. */
  40778. get isStencilEnable(): boolean;
  40779. /** @hidden */
  40780. _prepareWorkingCanvas(): void;
  40781. /**
  40782. * Reset the texture cache to empty state
  40783. */
  40784. resetTextureCache(): void;
  40785. /**
  40786. * Gets an object containing information about the current webGL context
  40787. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40788. */
  40789. getGlInfo(): {
  40790. vendor: string;
  40791. renderer: string;
  40792. version: string;
  40793. };
  40794. /**
  40795. * Defines the hardware scaling level.
  40796. * By default the hardware scaling level is computed from the window device ratio.
  40797. * 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.
  40798. * @param level defines the level to use
  40799. */
  40800. setHardwareScalingLevel(level: number): void;
  40801. /**
  40802. * Gets the current hardware scaling level.
  40803. * By default the hardware scaling level is computed from the window device ratio.
  40804. * 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.
  40805. * @returns a number indicating the current hardware scaling level
  40806. */
  40807. getHardwareScalingLevel(): number;
  40808. /**
  40809. * Gets the list of loaded textures
  40810. * @returns an array containing all loaded textures
  40811. */
  40812. getLoadedTexturesCache(): InternalTexture[];
  40813. /**
  40814. * Gets the object containing all engine capabilities
  40815. * @returns the EngineCapabilities object
  40816. */
  40817. getCaps(): EngineCapabilities;
  40818. /**
  40819. * stop executing a render loop function and remove it from the execution array
  40820. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40821. */
  40822. stopRenderLoop(renderFunction?: () => void): void;
  40823. /** @hidden */
  40824. _renderLoop(): void;
  40825. /**
  40826. * Gets the HTML canvas attached with the current webGL context
  40827. * @returns a HTML canvas
  40828. */
  40829. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40830. /**
  40831. * Gets host window
  40832. * @returns the host window object
  40833. */
  40834. getHostWindow(): Nullable<Window>;
  40835. /**
  40836. * Gets the current render width
  40837. * @param useScreen defines if screen size must be used (or the current render target if any)
  40838. * @returns a number defining the current render width
  40839. */
  40840. getRenderWidth(useScreen?: boolean): number;
  40841. /**
  40842. * Gets the current render height
  40843. * @param useScreen defines if screen size must be used (or the current render target if any)
  40844. * @returns a number defining the current render height
  40845. */
  40846. getRenderHeight(useScreen?: boolean): number;
  40847. /**
  40848. * Can be used to override the current requestAnimationFrame requester.
  40849. * @hidden
  40850. */
  40851. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40852. /**
  40853. * Register and execute a render loop. The engine can have more than one render function
  40854. * @param renderFunction defines the function to continuously execute
  40855. */
  40856. runRenderLoop(renderFunction: () => void): void;
  40857. /**
  40858. * Clear the current render buffer or the current render target (if any is set up)
  40859. * @param color defines the color to use
  40860. * @param backBuffer defines if the back buffer must be cleared
  40861. * @param depth defines if the depth buffer must be cleared
  40862. * @param stencil defines if the stencil buffer must be cleared
  40863. */
  40864. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40865. private _viewportCached;
  40866. /** @hidden */
  40867. _viewport(x: number, y: number, width: number, height: number): void;
  40868. /**
  40869. * Set the WebGL's viewport
  40870. * @param viewport defines the viewport element to be used
  40871. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40872. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40873. */
  40874. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40875. /**
  40876. * Begin a new frame
  40877. */
  40878. beginFrame(): void;
  40879. /**
  40880. * Enf the current frame
  40881. */
  40882. endFrame(): void;
  40883. /**
  40884. * Resize the view according to the canvas' size
  40885. */
  40886. resize(): void;
  40887. /**
  40888. * Force a specific size of the canvas
  40889. * @param width defines the new canvas' width
  40890. * @param height defines the new canvas' height
  40891. * @returns true if the size was changed
  40892. */
  40893. setSize(width: number, height: number): boolean;
  40894. /**
  40895. * Binds the frame buffer to the specified texture.
  40896. * @param texture The texture to render to or null for the default canvas
  40897. * @param faceIndex The face of the texture to render to in case of cube texture
  40898. * @param requiredWidth The width of the target to render to
  40899. * @param requiredHeight The height of the target to render to
  40900. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40901. * @param lodLevel defines the lod level to bind to the frame buffer
  40902. * @param layer defines the 2d array index to bind to frame buffer to
  40903. */
  40904. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40905. /** @hidden */
  40906. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40907. /**
  40908. * Unbind the current render target texture from the webGL context
  40909. * @param texture defines the render target texture to unbind
  40910. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40911. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40912. */
  40913. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40914. /**
  40915. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40916. */
  40917. flushFramebuffer(): void;
  40918. /**
  40919. * Unbind the current render target and bind the default framebuffer
  40920. */
  40921. restoreDefaultFramebuffer(): void;
  40922. /** @hidden */
  40923. protected _resetVertexBufferBinding(): void;
  40924. /**
  40925. * Creates a vertex buffer
  40926. * @param data the data for the vertex buffer
  40927. * @returns the new WebGL static buffer
  40928. */
  40929. createVertexBuffer(data: DataArray): DataBuffer;
  40930. private _createVertexBuffer;
  40931. /**
  40932. * Creates a dynamic vertex buffer
  40933. * @param data the data for the dynamic vertex buffer
  40934. * @returns the new WebGL dynamic buffer
  40935. */
  40936. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40937. protected _resetIndexBufferBinding(): void;
  40938. /**
  40939. * Creates a new index buffer
  40940. * @param indices defines the content of the index buffer
  40941. * @param updatable defines if the index buffer must be updatable
  40942. * @returns a new webGL buffer
  40943. */
  40944. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40945. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40946. /**
  40947. * Bind a webGL buffer to the webGL context
  40948. * @param buffer defines the buffer to bind
  40949. */
  40950. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40951. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40952. private bindBuffer;
  40953. /**
  40954. * update the bound buffer with the given data
  40955. * @param data defines the data to update
  40956. */
  40957. updateArrayBuffer(data: Float32Array): void;
  40958. private _vertexAttribPointer;
  40959. /** @hidden */
  40960. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40961. private _bindVertexBuffersAttributes;
  40962. /**
  40963. * Records a vertex array object
  40964. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40965. * @param vertexBuffers defines the list of vertex buffers to store
  40966. * @param indexBuffer defines the index buffer to store
  40967. * @param effect defines the effect to store
  40968. * @returns the new vertex array object
  40969. */
  40970. recordVertexArrayObject(vertexBuffers: {
  40971. [key: string]: VertexBuffer;
  40972. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40973. /**
  40974. * Bind a specific vertex array object
  40975. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40976. * @param vertexArrayObject defines the vertex array object to bind
  40977. * @param indexBuffer defines the index buffer to bind
  40978. */
  40979. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40980. /**
  40981. * Bind webGl buffers directly to the webGL context
  40982. * @param vertexBuffer defines the vertex buffer to bind
  40983. * @param indexBuffer defines the index buffer to bind
  40984. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40985. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40986. * @param effect defines the effect associated with the vertex buffer
  40987. */
  40988. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40989. private _unbindVertexArrayObject;
  40990. /**
  40991. * Bind a list of vertex buffers to the webGL context
  40992. * @param vertexBuffers defines the list of vertex buffers to bind
  40993. * @param indexBuffer defines the index buffer to bind
  40994. * @param effect defines the effect associated with the vertex buffers
  40995. */
  40996. bindBuffers(vertexBuffers: {
  40997. [key: string]: Nullable<VertexBuffer>;
  40998. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40999. /**
  41000. * Unbind all instance attributes
  41001. */
  41002. unbindInstanceAttributes(): void;
  41003. /**
  41004. * Release and free the memory of a vertex array object
  41005. * @param vao defines the vertex array object to delete
  41006. */
  41007. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  41008. /** @hidden */
  41009. _releaseBuffer(buffer: DataBuffer): boolean;
  41010. protected _deleteBuffer(buffer: DataBuffer): void;
  41011. /**
  41012. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  41013. * @param instancesBuffer defines the webGL buffer to update and bind
  41014. * @param data defines the data to store in the buffer
  41015. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  41016. */
  41017. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  41018. /**
  41019. * Bind the content of a webGL buffer used with instantiation
  41020. * @param instancesBuffer defines the webGL buffer to bind
  41021. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  41022. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  41023. */
  41024. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  41025. /**
  41026. * Disable the instance attribute corresponding to the name in parameter
  41027. * @param name defines the name of the attribute to disable
  41028. */
  41029. disableInstanceAttributeByName(name: string): void;
  41030. /**
  41031. * Disable the instance attribute corresponding to the location in parameter
  41032. * @param attributeLocation defines the attribute location of the attribute to disable
  41033. */
  41034. disableInstanceAttribute(attributeLocation: number): void;
  41035. /**
  41036. * Disable the attribute corresponding to the location in parameter
  41037. * @param attributeLocation defines the attribute location of the attribute to disable
  41038. */
  41039. disableAttributeByIndex(attributeLocation: number): void;
  41040. /**
  41041. * Send a draw order
  41042. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41043. * @param indexStart defines the starting index
  41044. * @param indexCount defines the number of index to draw
  41045. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41046. */
  41047. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41048. /**
  41049. * Draw a list of points
  41050. * @param verticesStart defines the index of first vertex to draw
  41051. * @param verticesCount defines the count of vertices to draw
  41052. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41053. */
  41054. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41055. /**
  41056. * Draw a list of unindexed primitives
  41057. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41058. * @param verticesStart defines the index of first vertex to draw
  41059. * @param verticesCount defines the count of vertices to draw
  41060. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41061. */
  41062. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41063. /**
  41064. * Draw a list of indexed primitives
  41065. * @param fillMode defines the primitive to use
  41066. * @param indexStart defines the starting index
  41067. * @param indexCount defines the number of index to draw
  41068. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41069. */
  41070. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41071. /**
  41072. * Draw a list of unindexed primitives
  41073. * @param fillMode defines the primitive to use
  41074. * @param verticesStart defines the index of first vertex to draw
  41075. * @param verticesCount defines the count of vertices to draw
  41076. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41077. */
  41078. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41079. private _drawMode;
  41080. /** @hidden */
  41081. protected _reportDrawCall(): void;
  41082. /** @hidden */
  41083. _releaseEffect(effect: Effect): void;
  41084. /** @hidden */
  41085. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41086. /**
  41087. * Create a new effect (used to store vertex/fragment shaders)
  41088. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  41089. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  41090. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  41091. * @param samplers defines an array of string used to represent textures
  41092. * @param defines defines the string containing the defines to use to compile the shaders
  41093. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  41094. * @param onCompiled defines a function to call when the effect creation is successful
  41095. * @param onError defines a function to call when the effect creation has failed
  41096. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  41097. * @returns the new Effect
  41098. */
  41099. 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;
  41100. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  41101. private _compileShader;
  41102. private _compileRawShader;
  41103. /** @hidden */
  41104. _getShaderSource(shader: WebGLShader): Nullable<string>;
  41105. /**
  41106. * Directly creates a webGL program
  41107. * @param pipelineContext defines the pipeline context to attach to
  41108. * @param vertexCode defines the vertex shader code to use
  41109. * @param fragmentCode defines the fragment shader code to use
  41110. * @param context defines the webGL context to use (if not set, the current one will be used)
  41111. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41112. * @returns the new webGL program
  41113. */
  41114. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41115. /**
  41116. * Creates a webGL program
  41117. * @param pipelineContext defines the pipeline context to attach to
  41118. * @param vertexCode defines the vertex shader code to use
  41119. * @param fragmentCode defines the fragment shader code to use
  41120. * @param defines defines the string containing the defines to use to compile the shaders
  41121. * @param context defines the webGL context to use (if not set, the current one will be used)
  41122. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41123. * @returns the new webGL program
  41124. */
  41125. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41126. /**
  41127. * Creates a new pipeline context
  41128. * @returns the new pipeline
  41129. */
  41130. createPipelineContext(): IPipelineContext;
  41131. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41132. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  41133. /** @hidden */
  41134. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  41135. /** @hidden */
  41136. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  41137. /** @hidden */
  41138. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  41139. /**
  41140. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  41141. * @param pipelineContext defines the pipeline context to use
  41142. * @param uniformsNames defines the list of uniform names
  41143. * @returns an array of webGL uniform locations
  41144. */
  41145. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41146. /**
  41147. * Gets the lsit of active attributes for a given webGL program
  41148. * @param pipelineContext defines the pipeline context to use
  41149. * @param attributesNames defines the list of attribute names to get
  41150. * @returns an array of indices indicating the offset of each attribute
  41151. */
  41152. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41153. /**
  41154. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  41155. * @param effect defines the effect to activate
  41156. */
  41157. enableEffect(effect: Nullable<Effect>): void;
  41158. /**
  41159. * Set the value of an uniform to a number (int)
  41160. * @param uniform defines the webGL uniform location where to store the value
  41161. * @param value defines the int number to store
  41162. * @returns true if the value was set
  41163. */
  41164. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41165. /**
  41166. * Set the value of an uniform to an array of int32
  41167. * @param uniform defines the webGL uniform location where to store the value
  41168. * @param array defines the array of int32 to store
  41169. * @returns true if the value was set
  41170. */
  41171. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41172. /**
  41173. * Set the value of an uniform to an array of int32 (stored as vec2)
  41174. * @param uniform defines the webGL uniform location where to store the value
  41175. * @param array defines the array of int32 to store
  41176. * @returns true if the value was set
  41177. */
  41178. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41179. /**
  41180. * Set the value of an uniform to an array of int32 (stored as vec3)
  41181. * @param uniform defines the webGL uniform location where to store the value
  41182. * @param array defines the array of int32 to store
  41183. * @returns true if the value was set
  41184. */
  41185. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41186. /**
  41187. * Set the value of an uniform to an array of int32 (stored as vec4)
  41188. * @param uniform defines the webGL uniform location where to store the value
  41189. * @param array defines the array of int32 to store
  41190. * @returns true if the value was set
  41191. */
  41192. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41193. /**
  41194. * Set the value of an uniform to an array of number
  41195. * @param uniform defines the webGL uniform location where to store the value
  41196. * @param array defines the array of number to store
  41197. * @returns true if the value was set
  41198. */
  41199. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41200. /**
  41201. * Set the value of an uniform to an array of number (stored as vec2)
  41202. * @param uniform defines the webGL uniform location where to store the value
  41203. * @param array defines the array of number to store
  41204. * @returns true if the value was set
  41205. */
  41206. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41207. /**
  41208. * Set the value of an uniform to an array of number (stored as vec3)
  41209. * @param uniform defines the webGL uniform location where to store the value
  41210. * @param array defines the array of number to store
  41211. * @returns true if the value was set
  41212. */
  41213. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41214. /**
  41215. * Set the value of an uniform to an array of number (stored as vec4)
  41216. * @param uniform defines the webGL uniform location where to store the value
  41217. * @param array defines the array of number to store
  41218. * @returns true if the value was set
  41219. */
  41220. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41221. /**
  41222. * Set the value of an uniform to an array of float32 (stored as matrices)
  41223. * @param uniform defines the webGL uniform location where to store the value
  41224. * @param matrices defines the array of float32 to store
  41225. * @returns true if the value was set
  41226. */
  41227. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  41228. /**
  41229. * Set the value of an uniform to a matrix (3x3)
  41230. * @param uniform defines the webGL uniform location where to store the value
  41231. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  41232. * @returns true if the value was set
  41233. */
  41234. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41235. /**
  41236. * Set the value of an uniform to a matrix (2x2)
  41237. * @param uniform defines the webGL uniform location where to store the value
  41238. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  41239. * @returns true if the value was set
  41240. */
  41241. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41242. /**
  41243. * Set the value of an uniform to a number (float)
  41244. * @param uniform defines the webGL uniform location where to store the value
  41245. * @param value defines the float number to store
  41246. * @returns true if the value was transfered
  41247. */
  41248. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41249. /**
  41250. * Set the value of an uniform to a vec2
  41251. * @param uniform defines the webGL uniform location where to store the value
  41252. * @param x defines the 1st component of the value
  41253. * @param y defines the 2nd component of the value
  41254. * @returns true if the value was set
  41255. */
  41256. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41257. /**
  41258. * Set the value of an uniform to a vec3
  41259. * @param uniform defines the webGL uniform location where to store the value
  41260. * @param x defines the 1st component of the value
  41261. * @param y defines the 2nd component of the value
  41262. * @param z defines the 3rd component of the value
  41263. * @returns true if the value was set
  41264. */
  41265. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41266. /**
  41267. * Set the value of an uniform to a vec4
  41268. * @param uniform defines the webGL uniform location where to store the value
  41269. * @param x defines the 1st component of the value
  41270. * @param y defines the 2nd component of the value
  41271. * @param z defines the 3rd component of the value
  41272. * @param w defines the 4th component of the value
  41273. * @returns true if the value was set
  41274. */
  41275. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41276. /**
  41277. * Apply all cached states (depth, culling, stencil and alpha)
  41278. */
  41279. applyStates(): void;
  41280. /**
  41281. * Enable or disable color writing
  41282. * @param enable defines the state to set
  41283. */
  41284. setColorWrite(enable: boolean): void;
  41285. /**
  41286. * Gets a boolean indicating if color writing is enabled
  41287. * @returns the current color writing state
  41288. */
  41289. getColorWrite(): boolean;
  41290. /**
  41291. * Gets the depth culling state manager
  41292. */
  41293. get depthCullingState(): DepthCullingState;
  41294. /**
  41295. * Gets the alpha state manager
  41296. */
  41297. get alphaState(): AlphaState;
  41298. /**
  41299. * Gets the stencil state manager
  41300. */
  41301. get stencilState(): StencilState;
  41302. /**
  41303. * Clears the list of texture accessible through engine.
  41304. * This can help preventing texture load conflict due to name collision.
  41305. */
  41306. clearInternalTexturesCache(): void;
  41307. /**
  41308. * Force the entire cache to be cleared
  41309. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41310. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41311. */
  41312. wipeCaches(bruteForce?: boolean): void;
  41313. /** @hidden */
  41314. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41315. min: number;
  41316. mag: number;
  41317. };
  41318. /** @hidden */
  41319. _createTexture(): WebGLTexture;
  41320. /**
  41321. * Usually called from Texture.ts.
  41322. * Passed information to create a WebGLTexture
  41323. * @param url defines a value which contains one of the following:
  41324. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41325. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41326. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41327. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41328. * @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)
  41329. * @param scene needed for loading to the correct scene
  41330. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41331. * @param onLoad optional callback to be called upon successful completion
  41332. * @param onError optional callback to be called upon failure
  41333. * @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
  41334. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41335. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41336. * @param forcedExtension defines the extension to use to pick the right loader
  41337. * @param mimeType defines an optional mime type
  41338. * @param loaderOptions options to be passed to the loader
  41339. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41340. */
  41341. 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;
  41342. /**
  41343. * Loads an image as an HTMLImageElement.
  41344. * @param input url string, ArrayBuffer, or Blob to load
  41345. * @param onLoad callback called when the image successfully loads
  41346. * @param onError callback called when the image fails to load
  41347. * @param offlineProvider offline provider for caching
  41348. * @param mimeType optional mime type
  41349. * @returns the HTMLImageElement of the loaded image
  41350. * @hidden
  41351. */
  41352. 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>;
  41353. /**
  41354. * @hidden
  41355. */
  41356. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41357. private _unpackFlipYCached;
  41358. /**
  41359. * In case you are sharing the context with other applications, it might
  41360. * be interested to not cache the unpack flip y state to ensure a consistent
  41361. * value would be set.
  41362. */
  41363. enableUnpackFlipYCached: boolean;
  41364. /** @hidden */
  41365. _unpackFlipY(value: boolean): void;
  41366. /** @hidden */
  41367. _getUnpackAlignement(): number;
  41368. private _getTextureTarget;
  41369. /**
  41370. * Update the sampling mode of a given texture
  41371. * @param samplingMode defines the required sampling mode
  41372. * @param texture defines the texture to update
  41373. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41374. */
  41375. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41376. /**
  41377. * Update the sampling mode of a given texture
  41378. * @param texture defines the texture to update
  41379. * @param wrapU defines the texture wrap mode of the u coordinates
  41380. * @param wrapV defines the texture wrap mode of the v coordinates
  41381. * @param wrapR defines the texture wrap mode of the r coordinates
  41382. */
  41383. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41384. /** @hidden */
  41385. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41386. width: number;
  41387. height: number;
  41388. layers?: number;
  41389. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  41390. /** @hidden */
  41391. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41392. /** @hidden */
  41393. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41394. /**
  41395. * Update a portion of an internal texture
  41396. * @param texture defines the texture to update
  41397. * @param imageData defines the data to store into the texture
  41398. * @param xOffset defines the x coordinates of the update rectangle
  41399. * @param yOffset defines the y coordinates of the update rectangle
  41400. * @param width defines the width of the update rectangle
  41401. * @param height defines the height of the update rectangle
  41402. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41403. * @param lod defines the lod level to update (0 by default)
  41404. */
  41405. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41406. /** @hidden */
  41407. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41408. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41409. private _prepareWebGLTexture;
  41410. /** @hidden */
  41411. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41412. private _getDepthStencilBuffer;
  41413. /** @hidden */
  41414. _releaseFramebufferObjects(texture: InternalTexture): void;
  41415. /** @hidden */
  41416. _releaseTexture(texture: InternalTexture): void;
  41417. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41418. protected _setProgram(program: WebGLProgram): void;
  41419. protected _boundUniforms: {
  41420. [key: number]: WebGLUniformLocation;
  41421. };
  41422. /**
  41423. * Binds an effect to the webGL context
  41424. * @param effect defines the effect to bind
  41425. */
  41426. bindSamplers(effect: Effect): void;
  41427. private _activateCurrentTexture;
  41428. /** @hidden */
  41429. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41430. /** @hidden */
  41431. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  41432. /**
  41433. * Unbind all textures from the webGL context
  41434. */
  41435. unbindAllTextures(): void;
  41436. /**
  41437. * Sets a texture to the according uniform.
  41438. * @param channel The texture channel
  41439. * @param uniform The uniform to set
  41440. * @param texture The texture to apply
  41441. */
  41442. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  41443. private _bindSamplerUniformToChannel;
  41444. private _getTextureWrapMode;
  41445. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  41446. /**
  41447. * Sets an array of texture to the webGL context
  41448. * @param channel defines the channel where the texture array must be set
  41449. * @param uniform defines the associated uniform location
  41450. * @param textures defines the array of textures to bind
  41451. */
  41452. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  41453. /** @hidden */
  41454. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41455. private _setTextureParameterFloat;
  41456. private _setTextureParameterInteger;
  41457. /**
  41458. * Unbind all vertex attributes from the webGL context
  41459. */
  41460. unbindAllAttributes(): void;
  41461. /**
  41462. * 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
  41463. */
  41464. releaseEffects(): void;
  41465. /**
  41466. * Dispose and release all associated resources
  41467. */
  41468. dispose(): void;
  41469. /**
  41470. * Attach a new callback raised when context lost event is fired
  41471. * @param callback defines the callback to call
  41472. */
  41473. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41474. /**
  41475. * Attach a new callback raised when context restored event is fired
  41476. * @param callback defines the callback to call
  41477. */
  41478. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41479. /**
  41480. * Get the current error code of the webGL context
  41481. * @returns the error code
  41482. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41483. */
  41484. getError(): number;
  41485. private _canRenderToFloatFramebuffer;
  41486. private _canRenderToHalfFloatFramebuffer;
  41487. private _canRenderToFramebuffer;
  41488. /** @hidden */
  41489. _getWebGLTextureType(type: number): number;
  41490. /** @hidden */
  41491. _getInternalFormat(format: number): number;
  41492. /** @hidden */
  41493. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41494. /** @hidden */
  41495. _getRGBAMultiSampleBufferFormat(type: number): number;
  41496. /** @hidden */
  41497. _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;
  41498. /**
  41499. * Loads a file from a url
  41500. * @param url url to load
  41501. * @param onSuccess callback called when the file successfully loads
  41502. * @param onProgress callback called while file is loading (if the server supports this mode)
  41503. * @param offlineProvider defines the offline provider for caching
  41504. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41505. * @param onError callback called when the file fails to load
  41506. * @returns a file request object
  41507. * @hidden
  41508. */
  41509. 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;
  41510. /**
  41511. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41512. * @param x defines the x coordinate of the rectangle where pixels must be read
  41513. * @param y defines the y coordinate of the rectangle where pixels must be read
  41514. * @param width defines the width of the rectangle where pixels must be read
  41515. * @param height defines the height of the rectangle where pixels must be read
  41516. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41517. * @returns a Uint8Array containing RGBA colors
  41518. */
  41519. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  41520. private static _IsSupported;
  41521. private static _HasMajorPerformanceCaveat;
  41522. /**
  41523. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41524. */
  41525. static get IsSupported(): boolean;
  41526. /**
  41527. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41528. * @returns true if the engine can be created
  41529. * @ignorenaming
  41530. */
  41531. static isSupported(): boolean;
  41532. /**
  41533. * 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)
  41534. */
  41535. static get HasMajorPerformanceCaveat(): boolean;
  41536. /**
  41537. * Find the next highest power of two.
  41538. * @param x Number to start search from.
  41539. * @return Next highest power of two.
  41540. */
  41541. static CeilingPOT(x: number): number;
  41542. /**
  41543. * Find the next lowest power of two.
  41544. * @param x Number to start search from.
  41545. * @return Next lowest power of two.
  41546. */
  41547. static FloorPOT(x: number): number;
  41548. /**
  41549. * Find the nearest power of two.
  41550. * @param x Number to start search from.
  41551. * @return Next nearest power of two.
  41552. */
  41553. static NearestPOT(x: number): number;
  41554. /**
  41555. * Get the closest exponent of two
  41556. * @param value defines the value to approximate
  41557. * @param max defines the maximum value to return
  41558. * @param mode defines how to define the closest value
  41559. * @returns closest exponent of two of the given value
  41560. */
  41561. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41562. /**
  41563. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41564. * @param func - the function to be called
  41565. * @param requester - the object that will request the next frame. Falls back to window.
  41566. * @returns frame number
  41567. */
  41568. static QueueNewFrame(func: () => void, requester?: any): number;
  41569. /**
  41570. * Gets host document
  41571. * @returns the host document object
  41572. */
  41573. getHostDocument(): Nullable<Document>;
  41574. }
  41575. }
  41576. declare module "babylonjs/Materials/Textures/internalTexture" {
  41577. import { Observable } from "babylonjs/Misc/observable";
  41578. import { Nullable, int } from "babylonjs/types";
  41579. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41580. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41581. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  41582. /**
  41583. * Defines the source of the internal texture
  41584. */
  41585. export enum InternalTextureSource {
  41586. /**
  41587. * The source of the texture data is unknown
  41588. */
  41589. Unknown = 0,
  41590. /**
  41591. * Texture data comes from an URL
  41592. */
  41593. Url = 1,
  41594. /**
  41595. * Texture data is only used for temporary storage
  41596. */
  41597. Temp = 2,
  41598. /**
  41599. * Texture data comes from raw data (ArrayBuffer)
  41600. */
  41601. Raw = 3,
  41602. /**
  41603. * Texture content is dynamic (video or dynamic texture)
  41604. */
  41605. Dynamic = 4,
  41606. /**
  41607. * Texture content is generated by rendering to it
  41608. */
  41609. RenderTarget = 5,
  41610. /**
  41611. * Texture content is part of a multi render target process
  41612. */
  41613. MultiRenderTarget = 6,
  41614. /**
  41615. * Texture data comes from a cube data file
  41616. */
  41617. Cube = 7,
  41618. /**
  41619. * Texture data comes from a raw cube data
  41620. */
  41621. CubeRaw = 8,
  41622. /**
  41623. * Texture data come from a prefiltered cube data file
  41624. */
  41625. CubePrefiltered = 9,
  41626. /**
  41627. * Texture content is raw 3D data
  41628. */
  41629. Raw3D = 10,
  41630. /**
  41631. * Texture content is raw 2D array data
  41632. */
  41633. Raw2DArray = 11,
  41634. /**
  41635. * Texture content is a depth texture
  41636. */
  41637. Depth = 12,
  41638. /**
  41639. * Texture data comes from a raw cube data encoded with RGBD
  41640. */
  41641. CubeRawRGBD = 13
  41642. }
  41643. /**
  41644. * Class used to store data associated with WebGL texture data for the engine
  41645. * This class should not be used directly
  41646. */
  41647. export class InternalTexture {
  41648. /** @hidden */
  41649. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41650. /**
  41651. * Defines if the texture is ready
  41652. */
  41653. isReady: boolean;
  41654. /**
  41655. * Defines if the texture is a cube texture
  41656. */
  41657. isCube: boolean;
  41658. /**
  41659. * Defines if the texture contains 3D data
  41660. */
  41661. is3D: boolean;
  41662. /**
  41663. * Defines if the texture contains 2D array data
  41664. */
  41665. is2DArray: boolean;
  41666. /**
  41667. * Defines if the texture contains multiview data
  41668. */
  41669. isMultiview: boolean;
  41670. /**
  41671. * Gets the URL used to load this texture
  41672. */
  41673. url: string;
  41674. /** @hidden */
  41675. _originalUrl: string;
  41676. /**
  41677. * Gets the sampling mode of the texture
  41678. */
  41679. samplingMode: number;
  41680. /**
  41681. * Gets a boolean indicating if the texture needs mipmaps generation
  41682. */
  41683. generateMipMaps: boolean;
  41684. /**
  41685. * Gets the number of samples used by the texture (WebGL2+ only)
  41686. */
  41687. samples: number;
  41688. /**
  41689. * Gets the type of the texture (int, float...)
  41690. */
  41691. type: number;
  41692. /**
  41693. * Gets the format of the texture (RGB, RGBA...)
  41694. */
  41695. format: number;
  41696. /**
  41697. * Observable called when the texture is loaded
  41698. */
  41699. onLoadedObservable: Observable<InternalTexture>;
  41700. /**
  41701. * Gets the width of the texture
  41702. */
  41703. width: number;
  41704. /**
  41705. * Gets the height of the texture
  41706. */
  41707. height: number;
  41708. /**
  41709. * Gets the depth of the texture
  41710. */
  41711. depth: number;
  41712. /**
  41713. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41714. */
  41715. baseWidth: number;
  41716. /**
  41717. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41718. */
  41719. baseHeight: number;
  41720. /**
  41721. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41722. */
  41723. baseDepth: number;
  41724. /**
  41725. * Gets a boolean indicating if the texture is inverted on Y axis
  41726. */
  41727. invertY: boolean;
  41728. /** @hidden */
  41729. _invertVScale: boolean;
  41730. /** @hidden */
  41731. _associatedChannel: number;
  41732. /** @hidden */
  41733. _source: InternalTextureSource;
  41734. /** @hidden */
  41735. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41736. /** @hidden */
  41737. _bufferView: Nullable<ArrayBufferView>;
  41738. /** @hidden */
  41739. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41740. /** @hidden */
  41741. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41742. /** @hidden */
  41743. _size: number;
  41744. /** @hidden */
  41745. _extension: string;
  41746. /** @hidden */
  41747. _files: Nullable<string[]>;
  41748. /** @hidden */
  41749. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41750. /** @hidden */
  41751. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41752. /** @hidden */
  41753. _framebuffer: Nullable<WebGLFramebuffer>;
  41754. /** @hidden */
  41755. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41756. /** @hidden */
  41757. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41758. /** @hidden */
  41759. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41760. /** @hidden */
  41761. _attachments: Nullable<number[]>;
  41762. /** @hidden */
  41763. _textureArray: Nullable<InternalTexture[]>;
  41764. /** @hidden */
  41765. _cachedCoordinatesMode: Nullable<number>;
  41766. /** @hidden */
  41767. _cachedWrapU: Nullable<number>;
  41768. /** @hidden */
  41769. _cachedWrapV: Nullable<number>;
  41770. /** @hidden */
  41771. _cachedWrapR: Nullable<number>;
  41772. /** @hidden */
  41773. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41774. /** @hidden */
  41775. _isDisabled: boolean;
  41776. /** @hidden */
  41777. _compression: Nullable<string>;
  41778. /** @hidden */
  41779. _generateStencilBuffer: boolean;
  41780. /** @hidden */
  41781. _generateDepthBuffer: boolean;
  41782. /** @hidden */
  41783. _comparisonFunction: number;
  41784. /** @hidden */
  41785. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41786. /** @hidden */
  41787. _lodGenerationScale: number;
  41788. /** @hidden */
  41789. _lodGenerationOffset: number;
  41790. /** @hidden */
  41791. _depthStencilTexture: Nullable<InternalTexture>;
  41792. /** @hidden */
  41793. _colorTextureArray: Nullable<WebGLTexture>;
  41794. /** @hidden */
  41795. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41796. /** @hidden */
  41797. _lodTextureHigh: Nullable<BaseTexture>;
  41798. /** @hidden */
  41799. _lodTextureMid: Nullable<BaseTexture>;
  41800. /** @hidden */
  41801. _lodTextureLow: Nullable<BaseTexture>;
  41802. /** @hidden */
  41803. _isRGBD: boolean;
  41804. /** @hidden */
  41805. _linearSpecularLOD: boolean;
  41806. /** @hidden */
  41807. _irradianceTexture: Nullable<BaseTexture>;
  41808. /** @hidden */
  41809. _webGLTexture: Nullable<WebGLTexture>;
  41810. /** @hidden */
  41811. _references: number;
  41812. /** @hidden */
  41813. _gammaSpace: Nullable<boolean>;
  41814. private _engine;
  41815. /**
  41816. * Gets the Engine the texture belongs to.
  41817. * @returns The babylon engine
  41818. */
  41819. getEngine(): ThinEngine;
  41820. /**
  41821. * Gets the data source type of the texture
  41822. */
  41823. get source(): InternalTextureSource;
  41824. /**
  41825. * Creates a new InternalTexture
  41826. * @param engine defines the engine to use
  41827. * @param source defines the type of data that will be used
  41828. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41829. */
  41830. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41831. /**
  41832. * Increments the number of references (ie. the number of Texture that point to it)
  41833. */
  41834. incrementReferences(): void;
  41835. /**
  41836. * Change the size of the texture (not the size of the content)
  41837. * @param width defines the new width
  41838. * @param height defines the new height
  41839. * @param depth defines the new depth (1 by default)
  41840. */
  41841. updateSize(width: int, height: int, depth?: int): void;
  41842. /** @hidden */
  41843. _rebuild(): void;
  41844. /** @hidden */
  41845. _swapAndDie(target: InternalTexture): void;
  41846. /**
  41847. * Dispose the current allocated resources
  41848. */
  41849. dispose(): void;
  41850. }
  41851. }
  41852. declare module "babylonjs/Loading/loadingScreen" {
  41853. /**
  41854. * Interface used to present a loading screen while loading a scene
  41855. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41856. */
  41857. export interface ILoadingScreen {
  41858. /**
  41859. * Function called to display the loading screen
  41860. */
  41861. displayLoadingUI: () => void;
  41862. /**
  41863. * Function called to hide the loading screen
  41864. */
  41865. hideLoadingUI: () => void;
  41866. /**
  41867. * Gets or sets the color to use for the background
  41868. */
  41869. loadingUIBackgroundColor: string;
  41870. /**
  41871. * Gets or sets the text to display while loading
  41872. */
  41873. loadingUIText: string;
  41874. }
  41875. /**
  41876. * Class used for the default loading screen
  41877. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41878. */
  41879. export class DefaultLoadingScreen implements ILoadingScreen {
  41880. private _renderingCanvas;
  41881. private _loadingText;
  41882. private _loadingDivBackgroundColor;
  41883. private _loadingDiv;
  41884. private _loadingTextDiv;
  41885. /** Gets or sets the logo url to use for the default loading screen */
  41886. static DefaultLogoUrl: string;
  41887. /** Gets or sets the spinner url to use for the default loading screen */
  41888. static DefaultSpinnerUrl: string;
  41889. /**
  41890. * Creates a new default loading screen
  41891. * @param _renderingCanvas defines the canvas used to render the scene
  41892. * @param _loadingText defines the default text to display
  41893. * @param _loadingDivBackgroundColor defines the default background color
  41894. */
  41895. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41896. /**
  41897. * Function called to display the loading screen
  41898. */
  41899. displayLoadingUI(): void;
  41900. /**
  41901. * Function called to hide the loading screen
  41902. */
  41903. hideLoadingUI(): void;
  41904. /**
  41905. * Gets or sets the text to display while loading
  41906. */
  41907. set loadingUIText(text: string);
  41908. get loadingUIText(): string;
  41909. /**
  41910. * Gets or sets the color to use for the background
  41911. */
  41912. get loadingUIBackgroundColor(): string;
  41913. set loadingUIBackgroundColor(color: string);
  41914. private _resizeLoadingUI;
  41915. }
  41916. }
  41917. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41918. /**
  41919. * Interface for any object that can request an animation frame
  41920. */
  41921. export interface ICustomAnimationFrameRequester {
  41922. /**
  41923. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41924. */
  41925. renderFunction?: Function;
  41926. /**
  41927. * Called to request the next frame to render to
  41928. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41929. */
  41930. requestAnimationFrame: Function;
  41931. /**
  41932. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41933. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41934. */
  41935. requestID?: number;
  41936. }
  41937. }
  41938. declare module "babylonjs/Misc/performanceMonitor" {
  41939. /**
  41940. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41941. */
  41942. export class PerformanceMonitor {
  41943. private _enabled;
  41944. private _rollingFrameTime;
  41945. private _lastFrameTimeMs;
  41946. /**
  41947. * constructor
  41948. * @param frameSampleSize The number of samples required to saturate the sliding window
  41949. */
  41950. constructor(frameSampleSize?: number);
  41951. /**
  41952. * Samples current frame
  41953. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41954. */
  41955. sampleFrame(timeMs?: number): void;
  41956. /**
  41957. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41958. */
  41959. get averageFrameTime(): number;
  41960. /**
  41961. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41962. */
  41963. get averageFrameTimeVariance(): number;
  41964. /**
  41965. * Returns the frame time of the most recent frame
  41966. */
  41967. get instantaneousFrameTime(): number;
  41968. /**
  41969. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41970. */
  41971. get averageFPS(): number;
  41972. /**
  41973. * Returns the average framerate in frames per second using the most recent frame time
  41974. */
  41975. get instantaneousFPS(): number;
  41976. /**
  41977. * Returns true if enough samples have been taken to completely fill the sliding window
  41978. */
  41979. get isSaturated(): boolean;
  41980. /**
  41981. * Enables contributions to the sliding window sample set
  41982. */
  41983. enable(): void;
  41984. /**
  41985. * Disables contributions to the sliding window sample set
  41986. * Samples will not be interpolated over the disabled period
  41987. */
  41988. disable(): void;
  41989. /**
  41990. * Returns true if sampling is enabled
  41991. */
  41992. get isEnabled(): boolean;
  41993. /**
  41994. * Resets performance monitor
  41995. */
  41996. reset(): void;
  41997. }
  41998. /**
  41999. * RollingAverage
  42000. *
  42001. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  42002. */
  42003. export class RollingAverage {
  42004. /**
  42005. * Current average
  42006. */
  42007. average: number;
  42008. /**
  42009. * Current variance
  42010. */
  42011. variance: number;
  42012. protected _samples: Array<number>;
  42013. protected _sampleCount: number;
  42014. protected _pos: number;
  42015. protected _m2: number;
  42016. /**
  42017. * constructor
  42018. * @param length The number of samples required to saturate the sliding window
  42019. */
  42020. constructor(length: number);
  42021. /**
  42022. * Adds a sample to the sample set
  42023. * @param v The sample value
  42024. */
  42025. add(v: number): void;
  42026. /**
  42027. * Returns previously added values or null if outside of history or outside the sliding window domain
  42028. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  42029. * @return Value previously recorded with add() or null if outside of range
  42030. */
  42031. history(i: number): number;
  42032. /**
  42033. * Returns true if enough samples have been taken to completely fill the sliding window
  42034. * @return true if sample-set saturated
  42035. */
  42036. isSaturated(): boolean;
  42037. /**
  42038. * Resets the rolling average (equivalent to 0 samples taken so far)
  42039. */
  42040. reset(): void;
  42041. /**
  42042. * Wraps a value around the sample range boundaries
  42043. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  42044. * @return Wrapped position in sample range
  42045. */
  42046. protected _wrapPosition(i: number): number;
  42047. }
  42048. }
  42049. declare module "babylonjs/Misc/perfCounter" {
  42050. /**
  42051. * This class is used to track a performance counter which is number based.
  42052. * The user has access to many properties which give statistics of different nature.
  42053. *
  42054. * The implementer can track two kinds of Performance Counter: time and count.
  42055. * 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.
  42056. * 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.
  42057. */
  42058. export class PerfCounter {
  42059. /**
  42060. * Gets or sets a global boolean to turn on and off all the counters
  42061. */
  42062. static Enabled: boolean;
  42063. /**
  42064. * Returns the smallest value ever
  42065. */
  42066. get min(): number;
  42067. /**
  42068. * Returns the biggest value ever
  42069. */
  42070. get max(): number;
  42071. /**
  42072. * Returns the average value since the performance counter is running
  42073. */
  42074. get average(): number;
  42075. /**
  42076. * Returns the average value of the last second the counter was monitored
  42077. */
  42078. get lastSecAverage(): number;
  42079. /**
  42080. * Returns the current value
  42081. */
  42082. get current(): number;
  42083. /**
  42084. * Gets the accumulated total
  42085. */
  42086. get total(): number;
  42087. /**
  42088. * Gets the total value count
  42089. */
  42090. get count(): number;
  42091. /**
  42092. * Creates a new counter
  42093. */
  42094. constructor();
  42095. /**
  42096. * Call this method to start monitoring a new frame.
  42097. * 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.
  42098. */
  42099. fetchNewFrame(): void;
  42100. /**
  42101. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  42102. * @param newCount the count value to add to the monitored count
  42103. * @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.
  42104. */
  42105. addCount(newCount: number, fetchResult: boolean): void;
  42106. /**
  42107. * Start monitoring this performance counter
  42108. */
  42109. beginMonitoring(): void;
  42110. /**
  42111. * Compute the time lapsed since the previous beginMonitoring() call.
  42112. * @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
  42113. */
  42114. endMonitoring(newFrame?: boolean): void;
  42115. private _fetchResult;
  42116. private _startMonitoringTime;
  42117. private _min;
  42118. private _max;
  42119. private _average;
  42120. private _current;
  42121. private _totalValueCount;
  42122. private _totalAccumulated;
  42123. private _lastSecAverage;
  42124. private _lastSecAccumulated;
  42125. private _lastSecTime;
  42126. private _lastSecValueCount;
  42127. }
  42128. }
  42129. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  42130. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42131. import { Nullable } from "babylonjs/types";
  42132. module "babylonjs/Engines/thinEngine" {
  42133. interface ThinEngine {
  42134. /** @hidden */
  42135. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  42136. }
  42137. }
  42138. }
  42139. declare module "babylonjs/Audio/analyser" {
  42140. import { Scene } from "babylonjs/scene";
  42141. /**
  42142. * Class used to work with sound analyzer using fast fourier transform (FFT)
  42143. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42144. */
  42145. export class Analyser {
  42146. /**
  42147. * Gets or sets the smoothing
  42148. * @ignorenaming
  42149. */
  42150. SMOOTHING: number;
  42151. /**
  42152. * Gets or sets the FFT table size
  42153. * @ignorenaming
  42154. */
  42155. FFT_SIZE: number;
  42156. /**
  42157. * Gets or sets the bar graph amplitude
  42158. * @ignorenaming
  42159. */
  42160. BARGRAPHAMPLITUDE: number;
  42161. /**
  42162. * Gets or sets the position of the debug canvas
  42163. * @ignorenaming
  42164. */
  42165. DEBUGCANVASPOS: {
  42166. x: number;
  42167. y: number;
  42168. };
  42169. /**
  42170. * Gets or sets the debug canvas size
  42171. * @ignorenaming
  42172. */
  42173. DEBUGCANVASSIZE: {
  42174. width: number;
  42175. height: number;
  42176. };
  42177. private _byteFreqs;
  42178. private _byteTime;
  42179. private _floatFreqs;
  42180. private _webAudioAnalyser;
  42181. private _debugCanvas;
  42182. private _debugCanvasContext;
  42183. private _scene;
  42184. private _registerFunc;
  42185. private _audioEngine;
  42186. /**
  42187. * Creates a new analyser
  42188. * @param scene defines hosting scene
  42189. */
  42190. constructor(scene: Scene);
  42191. /**
  42192. * Get the number of data values you will have to play with for the visualization
  42193. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  42194. * @returns a number
  42195. */
  42196. getFrequencyBinCount(): number;
  42197. /**
  42198. * Gets the current frequency data as a byte array
  42199. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42200. * @returns a Uint8Array
  42201. */
  42202. getByteFrequencyData(): Uint8Array;
  42203. /**
  42204. * Gets the current waveform as a byte array
  42205. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  42206. * @returns a Uint8Array
  42207. */
  42208. getByteTimeDomainData(): Uint8Array;
  42209. /**
  42210. * Gets the current frequency data as a float array
  42211. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42212. * @returns a Float32Array
  42213. */
  42214. getFloatFrequencyData(): Float32Array;
  42215. /**
  42216. * Renders the debug canvas
  42217. */
  42218. drawDebugCanvas(): void;
  42219. /**
  42220. * Stops rendering the debug canvas and removes it
  42221. */
  42222. stopDebugCanvas(): void;
  42223. /**
  42224. * Connects two audio nodes
  42225. * @param inputAudioNode defines first node to connect
  42226. * @param outputAudioNode defines second node to connect
  42227. */
  42228. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  42229. /**
  42230. * Releases all associated resources
  42231. */
  42232. dispose(): void;
  42233. }
  42234. }
  42235. declare module "babylonjs/Audio/Interfaces/IAudioEngine" {
  42236. import { Observable } from "babylonjs/Misc/observable";
  42237. import { IDisposable } from "babylonjs/scene";
  42238. import { Nullable } from "babylonjs/types";
  42239. import { Analyser } from "babylonjs/Audio/analyser";
  42240. /**
  42241. * This represents an audio engine and it is responsible
  42242. * to play, synchronize and analyse sounds throughout the application.
  42243. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42244. */
  42245. export interface IAudioEngine extends IDisposable {
  42246. /**
  42247. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  42248. */
  42249. readonly canUseWebAudio: boolean;
  42250. /**
  42251. * Gets the current AudioContext if available.
  42252. */
  42253. readonly audioContext: Nullable<AudioContext>;
  42254. /**
  42255. * The master gain node defines the global audio volume of your audio engine.
  42256. */
  42257. readonly masterGain: GainNode;
  42258. /**
  42259. * Gets whether or not mp3 are supported by your browser.
  42260. */
  42261. readonly isMP3supported: boolean;
  42262. /**
  42263. * Gets whether or not ogg are supported by your browser.
  42264. */
  42265. readonly isOGGsupported: boolean;
  42266. /**
  42267. * Defines if Babylon should emit a warning if WebAudio is not supported.
  42268. * @ignoreNaming
  42269. */
  42270. WarnedWebAudioUnsupported: boolean;
  42271. /**
  42272. * Defines if the audio engine relies on a custom unlocked button.
  42273. * In this case, the embedded button will not be displayed.
  42274. */
  42275. useCustomUnlockedButton: boolean;
  42276. /**
  42277. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42278. */
  42279. readonly unlocked: boolean;
  42280. /**
  42281. * Event raised when audio has been unlocked on the browser.
  42282. */
  42283. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42284. /**
  42285. * Event raised when audio has been locked on the browser.
  42286. */
  42287. onAudioLockedObservable: Observable<IAudioEngine>;
  42288. /**
  42289. * Flags the audio engine in Locked state.
  42290. * This happens due to new browser policies preventing audio to autoplay.
  42291. */
  42292. lock(): void;
  42293. /**
  42294. * Unlocks the audio engine once a user action has been done on the dom.
  42295. * This is helpful to resume play once browser policies have been satisfied.
  42296. */
  42297. unlock(): void;
  42298. /**
  42299. * Gets the global volume sets on the master gain.
  42300. * @returns the global volume if set or -1 otherwise
  42301. */
  42302. getGlobalVolume(): number;
  42303. /**
  42304. * Sets the global volume of your experience (sets on the master gain).
  42305. * @param newVolume Defines the new global volume of the application
  42306. */
  42307. setGlobalVolume(newVolume: number): void;
  42308. /**
  42309. * Connect the audio engine to an audio analyser allowing some amazing
  42310. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42311. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42312. * @param analyser The analyser to connect to the engine
  42313. */
  42314. connectToAnalyser(analyser: Analyser): void;
  42315. }
  42316. }
  42317. declare module "babylonjs/Engines/engine" {
  42318. import { Observable } from "babylonjs/Misc/observable";
  42319. import { Nullable } from "babylonjs/types";
  42320. import { Scene } from "babylonjs/scene";
  42321. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42322. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42323. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  42324. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  42325. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42326. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  42327. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  42328. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  42329. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42330. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  42331. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42332. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  42333. import "babylonjs/Engines/Extensions/engine.alpha";
  42334. import "babylonjs/Engines/Extensions/engine.readTexture";
  42335. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  42336. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  42337. import { Material } from "babylonjs/Materials/material";
  42338. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42339. /**
  42340. * Defines the interface used by display changed events
  42341. */
  42342. export interface IDisplayChangedEventArgs {
  42343. /** Gets the vrDisplay object (if any) */
  42344. vrDisplay: Nullable<any>;
  42345. /** Gets a boolean indicating if webVR is supported */
  42346. vrSupported: boolean;
  42347. }
  42348. /**
  42349. * Defines the interface used by objects containing a viewport (like a camera)
  42350. */
  42351. interface IViewportOwnerLike {
  42352. /**
  42353. * Gets or sets the viewport
  42354. */
  42355. viewport: IViewportLike;
  42356. }
  42357. /**
  42358. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42359. */
  42360. export class Engine extends ThinEngine {
  42361. /** Defines that alpha blending is disabled */
  42362. static readonly ALPHA_DISABLE: number;
  42363. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42364. static readonly ALPHA_ADD: number;
  42365. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42366. static readonly ALPHA_COMBINE: number;
  42367. /** Defines that alpha blending to DEST - SRC * DEST */
  42368. static readonly ALPHA_SUBTRACT: number;
  42369. /** Defines that alpha blending to SRC * DEST */
  42370. static readonly ALPHA_MULTIPLY: number;
  42371. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42372. static readonly ALPHA_MAXIMIZED: number;
  42373. /** Defines that alpha blending to SRC + DEST */
  42374. static readonly ALPHA_ONEONE: number;
  42375. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42376. static readonly ALPHA_PREMULTIPLIED: number;
  42377. /**
  42378. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42379. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42380. */
  42381. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42382. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42383. static readonly ALPHA_INTERPOLATE: number;
  42384. /**
  42385. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42386. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42387. */
  42388. static readonly ALPHA_SCREENMODE: number;
  42389. /** Defines that the ressource is not delayed*/
  42390. static readonly DELAYLOADSTATE_NONE: number;
  42391. /** Defines that the ressource was successfully delay loaded */
  42392. static readonly DELAYLOADSTATE_LOADED: number;
  42393. /** Defines that the ressource is currently delay loading */
  42394. static readonly DELAYLOADSTATE_LOADING: number;
  42395. /** Defines that the ressource is delayed and has not started loading */
  42396. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42397. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42398. static readonly NEVER: number;
  42399. /** 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 */
  42400. static readonly ALWAYS: number;
  42401. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42402. static readonly LESS: number;
  42403. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42404. static readonly EQUAL: number;
  42405. /** 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 */
  42406. static readonly LEQUAL: number;
  42407. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42408. static readonly GREATER: number;
  42409. /** 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 */
  42410. static readonly GEQUAL: number;
  42411. /** 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 */
  42412. static readonly NOTEQUAL: number;
  42413. /** Passed to stencilOperation to specify that stencil value must be kept */
  42414. static readonly KEEP: number;
  42415. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42416. static readonly REPLACE: number;
  42417. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42418. static readonly INCR: number;
  42419. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42420. static readonly DECR: number;
  42421. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42422. static readonly INVERT: number;
  42423. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42424. static readonly INCR_WRAP: number;
  42425. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42426. static readonly DECR_WRAP: number;
  42427. /** Texture is not repeating outside of 0..1 UVs */
  42428. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42429. /** Texture is repeating outside of 0..1 UVs */
  42430. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42431. /** Texture is repeating and mirrored */
  42432. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42433. /** ALPHA */
  42434. static readonly TEXTUREFORMAT_ALPHA: number;
  42435. /** LUMINANCE */
  42436. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42437. /** LUMINANCE_ALPHA */
  42438. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42439. /** RGB */
  42440. static readonly TEXTUREFORMAT_RGB: number;
  42441. /** RGBA */
  42442. static readonly TEXTUREFORMAT_RGBA: number;
  42443. /** RED */
  42444. static readonly TEXTUREFORMAT_RED: number;
  42445. /** RED (2nd reference) */
  42446. static readonly TEXTUREFORMAT_R: number;
  42447. /** RG */
  42448. static readonly TEXTUREFORMAT_RG: number;
  42449. /** RED_INTEGER */
  42450. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42451. /** RED_INTEGER (2nd reference) */
  42452. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42453. /** RG_INTEGER */
  42454. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42455. /** RGB_INTEGER */
  42456. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42457. /** RGBA_INTEGER */
  42458. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42459. /** UNSIGNED_BYTE */
  42460. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42461. /** UNSIGNED_BYTE (2nd reference) */
  42462. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42463. /** FLOAT */
  42464. static readonly TEXTURETYPE_FLOAT: number;
  42465. /** HALF_FLOAT */
  42466. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42467. /** BYTE */
  42468. static readonly TEXTURETYPE_BYTE: number;
  42469. /** SHORT */
  42470. static readonly TEXTURETYPE_SHORT: number;
  42471. /** UNSIGNED_SHORT */
  42472. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42473. /** INT */
  42474. static readonly TEXTURETYPE_INT: number;
  42475. /** UNSIGNED_INT */
  42476. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42477. /** UNSIGNED_SHORT_4_4_4_4 */
  42478. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42479. /** UNSIGNED_SHORT_5_5_5_1 */
  42480. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42481. /** UNSIGNED_SHORT_5_6_5 */
  42482. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42483. /** UNSIGNED_INT_2_10_10_10_REV */
  42484. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42485. /** UNSIGNED_INT_24_8 */
  42486. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42487. /** UNSIGNED_INT_10F_11F_11F_REV */
  42488. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42489. /** UNSIGNED_INT_5_9_9_9_REV */
  42490. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42491. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42492. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42493. /** nearest is mag = nearest and min = nearest and mip = linear */
  42494. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42495. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42496. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42497. /** Trilinear is mag = linear and min = linear and mip = linear */
  42498. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42499. /** nearest is mag = nearest and min = nearest and mip = linear */
  42500. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42501. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42502. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42503. /** Trilinear is mag = linear and min = linear and mip = linear */
  42504. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42505. /** mag = nearest and min = nearest and mip = nearest */
  42506. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42507. /** mag = nearest and min = linear and mip = nearest */
  42508. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42509. /** mag = nearest and min = linear and mip = linear */
  42510. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42511. /** mag = nearest and min = linear and mip = none */
  42512. static readonly TEXTURE_NEAREST_LINEAR: number;
  42513. /** mag = nearest and min = nearest and mip = none */
  42514. static readonly TEXTURE_NEAREST_NEAREST: number;
  42515. /** mag = linear and min = nearest and mip = nearest */
  42516. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42517. /** mag = linear and min = nearest and mip = linear */
  42518. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42519. /** mag = linear and min = linear and mip = none */
  42520. static readonly TEXTURE_LINEAR_LINEAR: number;
  42521. /** mag = linear and min = nearest and mip = none */
  42522. static readonly TEXTURE_LINEAR_NEAREST: number;
  42523. /** Explicit coordinates mode */
  42524. static readonly TEXTURE_EXPLICIT_MODE: number;
  42525. /** Spherical coordinates mode */
  42526. static readonly TEXTURE_SPHERICAL_MODE: number;
  42527. /** Planar coordinates mode */
  42528. static readonly TEXTURE_PLANAR_MODE: number;
  42529. /** Cubic coordinates mode */
  42530. static readonly TEXTURE_CUBIC_MODE: number;
  42531. /** Projection coordinates mode */
  42532. static readonly TEXTURE_PROJECTION_MODE: number;
  42533. /** Skybox coordinates mode */
  42534. static readonly TEXTURE_SKYBOX_MODE: number;
  42535. /** Inverse Cubic coordinates mode */
  42536. static readonly TEXTURE_INVCUBIC_MODE: number;
  42537. /** Equirectangular coordinates mode */
  42538. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42539. /** Equirectangular Fixed coordinates mode */
  42540. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42541. /** Equirectangular Fixed Mirrored coordinates mode */
  42542. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42543. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42544. static readonly SCALEMODE_FLOOR: number;
  42545. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42546. static readonly SCALEMODE_NEAREST: number;
  42547. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42548. static readonly SCALEMODE_CEILING: number;
  42549. /**
  42550. * Returns the current npm package of the sdk
  42551. */
  42552. static get NpmPackage(): string;
  42553. /**
  42554. * Returns the current version of the framework
  42555. */
  42556. static get Version(): string;
  42557. /** Gets the list of created engines */
  42558. static get Instances(): Engine[];
  42559. /**
  42560. * Gets the latest created engine
  42561. */
  42562. static get LastCreatedEngine(): Nullable<Engine>;
  42563. /**
  42564. * Gets the latest created scene
  42565. */
  42566. static get LastCreatedScene(): Nullable<Scene>;
  42567. /**
  42568. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42569. * @param flag defines which part of the materials must be marked as dirty
  42570. * @param predicate defines a predicate used to filter which materials should be affected
  42571. */
  42572. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42573. /**
  42574. * Method called to create the default loading screen.
  42575. * This can be overriden in your own app.
  42576. * @param canvas The rendering canvas element
  42577. * @returns The loading screen
  42578. */
  42579. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42580. /**
  42581. * Method called to create the default rescale post process on each engine.
  42582. */
  42583. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42584. /**
  42585. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42586. **/
  42587. enableOfflineSupport: boolean;
  42588. /**
  42589. * 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)
  42590. **/
  42591. disableManifestCheck: boolean;
  42592. /**
  42593. * Gets the list of created scenes
  42594. */
  42595. scenes: Scene[];
  42596. /**
  42597. * Event raised when a new scene is created
  42598. */
  42599. onNewSceneAddedObservable: Observable<Scene>;
  42600. /**
  42601. * Gets the list of created postprocesses
  42602. */
  42603. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42604. /**
  42605. * Gets a boolean indicating if the pointer is currently locked
  42606. */
  42607. isPointerLock: boolean;
  42608. /**
  42609. * Observable event triggered each time the rendering canvas is resized
  42610. */
  42611. onResizeObservable: Observable<Engine>;
  42612. /**
  42613. * Observable event triggered each time the canvas loses focus
  42614. */
  42615. onCanvasBlurObservable: Observable<Engine>;
  42616. /**
  42617. * Observable event triggered each time the canvas gains focus
  42618. */
  42619. onCanvasFocusObservable: Observable<Engine>;
  42620. /**
  42621. * Observable event triggered each time the canvas receives pointerout event
  42622. */
  42623. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42624. /**
  42625. * Observable raised when the engine begins a new frame
  42626. */
  42627. onBeginFrameObservable: Observable<Engine>;
  42628. /**
  42629. * If set, will be used to request the next animation frame for the render loop
  42630. */
  42631. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42632. /**
  42633. * Observable raised when the engine ends the current frame
  42634. */
  42635. onEndFrameObservable: Observable<Engine>;
  42636. /**
  42637. * Observable raised when the engine is about to compile a shader
  42638. */
  42639. onBeforeShaderCompilationObservable: Observable<Engine>;
  42640. /**
  42641. * Observable raised when the engine has jsut compiled a shader
  42642. */
  42643. onAfterShaderCompilationObservable: Observable<Engine>;
  42644. /**
  42645. * Gets the audio engine
  42646. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42647. * @ignorenaming
  42648. */
  42649. static audioEngine: IAudioEngine;
  42650. /**
  42651. * Default AudioEngine factory responsible of creating the Audio Engine.
  42652. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42653. */
  42654. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42655. /**
  42656. * Default offline support factory responsible of creating a tool used to store data locally.
  42657. * By default, this will create a Database object if the workload has been embedded.
  42658. */
  42659. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42660. private _loadingScreen;
  42661. private _pointerLockRequested;
  42662. private _rescalePostProcess;
  42663. private _deterministicLockstep;
  42664. private _lockstepMaxSteps;
  42665. private _timeStep;
  42666. protected get _supportsHardwareTextureRescaling(): boolean;
  42667. private _fps;
  42668. private _deltaTime;
  42669. /** @hidden */
  42670. _drawCalls: PerfCounter;
  42671. /** 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 */
  42672. canvasTabIndex: number;
  42673. /**
  42674. * Turn this value on if you want to pause FPS computation when in background
  42675. */
  42676. disablePerformanceMonitorInBackground: boolean;
  42677. private _performanceMonitor;
  42678. /**
  42679. * Gets the performance monitor attached to this engine
  42680. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42681. */
  42682. get performanceMonitor(): PerformanceMonitor;
  42683. private _onFocus;
  42684. private _onBlur;
  42685. private _onCanvasPointerOut;
  42686. private _onCanvasBlur;
  42687. private _onCanvasFocus;
  42688. private _onFullscreenChange;
  42689. private _onPointerLockChange;
  42690. /**
  42691. * Gets the HTML element used to attach event listeners
  42692. * @returns a HTML element
  42693. */
  42694. getInputElement(): Nullable<HTMLElement>;
  42695. /**
  42696. * Creates a new engine
  42697. * @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
  42698. * @param antialias defines enable antialiasing (default: false)
  42699. * @param options defines further options to be sent to the getContext() function
  42700. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42701. */
  42702. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42703. /**
  42704. * Gets current aspect ratio
  42705. * @param viewportOwner defines the camera to use to get the aspect ratio
  42706. * @param useScreen defines if screen size must be used (or the current render target if any)
  42707. * @returns a number defining the aspect ratio
  42708. */
  42709. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42710. /**
  42711. * Gets current screen aspect ratio
  42712. * @returns a number defining the aspect ratio
  42713. */
  42714. getScreenAspectRatio(): number;
  42715. /**
  42716. * Gets the client rect of the HTML canvas attached with the current webGL context
  42717. * @returns a client rectanglee
  42718. */
  42719. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42720. /**
  42721. * Gets the client rect of the HTML element used for events
  42722. * @returns a client rectanglee
  42723. */
  42724. getInputElementClientRect(): Nullable<ClientRect>;
  42725. /**
  42726. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42727. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42728. * @returns true if engine is in deterministic lock step mode
  42729. */
  42730. isDeterministicLockStep(): boolean;
  42731. /**
  42732. * Gets the max steps when engine is running in deterministic lock step
  42733. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42734. * @returns the max steps
  42735. */
  42736. getLockstepMaxSteps(): number;
  42737. /**
  42738. * Returns the time in ms between steps when using deterministic lock step.
  42739. * @returns time step in (ms)
  42740. */
  42741. getTimeStep(): number;
  42742. /**
  42743. * Force the mipmap generation for the given render target texture
  42744. * @param texture defines the render target texture to use
  42745. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42746. */
  42747. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42748. /** States */
  42749. /**
  42750. * Set various states to the webGL context
  42751. * @param culling defines backface culling state
  42752. * @param zOffset defines the value to apply to zOffset (0 by default)
  42753. * @param force defines if states must be applied even if cache is up to date
  42754. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42755. */
  42756. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42757. /**
  42758. * Set the z offset to apply to current rendering
  42759. * @param value defines the offset to apply
  42760. */
  42761. setZOffset(value: number): void;
  42762. /**
  42763. * Gets the current value of the zOffset
  42764. * @returns the current zOffset state
  42765. */
  42766. getZOffset(): number;
  42767. /**
  42768. * Enable or disable depth buffering
  42769. * @param enable defines the state to set
  42770. */
  42771. setDepthBuffer(enable: boolean): void;
  42772. /**
  42773. * Gets a boolean indicating if depth writing is enabled
  42774. * @returns the current depth writing state
  42775. */
  42776. getDepthWrite(): boolean;
  42777. /**
  42778. * Enable or disable depth writing
  42779. * @param enable defines the state to set
  42780. */
  42781. setDepthWrite(enable: boolean): void;
  42782. /**
  42783. * Gets a boolean indicating if stencil buffer is enabled
  42784. * @returns the current stencil buffer state
  42785. */
  42786. getStencilBuffer(): boolean;
  42787. /**
  42788. * Enable or disable the stencil buffer
  42789. * @param enable defines if the stencil buffer must be enabled or disabled
  42790. */
  42791. setStencilBuffer(enable: boolean): void;
  42792. /**
  42793. * Gets the current stencil mask
  42794. * @returns a number defining the new stencil mask to use
  42795. */
  42796. getStencilMask(): number;
  42797. /**
  42798. * Sets the current stencil mask
  42799. * @param mask defines the new stencil mask to use
  42800. */
  42801. setStencilMask(mask: number): void;
  42802. /**
  42803. * Gets the current stencil function
  42804. * @returns a number defining the stencil function to use
  42805. */
  42806. getStencilFunction(): number;
  42807. /**
  42808. * Gets the current stencil reference value
  42809. * @returns a number defining the stencil reference value to use
  42810. */
  42811. getStencilFunctionReference(): number;
  42812. /**
  42813. * Gets the current stencil mask
  42814. * @returns a number defining the stencil mask to use
  42815. */
  42816. getStencilFunctionMask(): number;
  42817. /**
  42818. * Sets the current stencil function
  42819. * @param stencilFunc defines the new stencil function to use
  42820. */
  42821. setStencilFunction(stencilFunc: number): void;
  42822. /**
  42823. * Sets the current stencil reference
  42824. * @param reference defines the new stencil reference to use
  42825. */
  42826. setStencilFunctionReference(reference: number): void;
  42827. /**
  42828. * Sets the current stencil mask
  42829. * @param mask defines the new stencil mask to use
  42830. */
  42831. setStencilFunctionMask(mask: number): void;
  42832. /**
  42833. * Gets the current stencil operation when stencil fails
  42834. * @returns a number defining stencil operation to use when stencil fails
  42835. */
  42836. getStencilOperationFail(): number;
  42837. /**
  42838. * Gets the current stencil operation when depth fails
  42839. * @returns a number defining stencil operation to use when depth fails
  42840. */
  42841. getStencilOperationDepthFail(): number;
  42842. /**
  42843. * Gets the current stencil operation when stencil passes
  42844. * @returns a number defining stencil operation to use when stencil passes
  42845. */
  42846. getStencilOperationPass(): number;
  42847. /**
  42848. * Sets the stencil operation to use when stencil fails
  42849. * @param operation defines the stencil operation to use when stencil fails
  42850. */
  42851. setStencilOperationFail(operation: number): void;
  42852. /**
  42853. * Sets the stencil operation to use when depth fails
  42854. * @param operation defines the stencil operation to use when depth fails
  42855. */
  42856. setStencilOperationDepthFail(operation: number): void;
  42857. /**
  42858. * Sets the stencil operation to use when stencil passes
  42859. * @param operation defines the stencil operation to use when stencil passes
  42860. */
  42861. setStencilOperationPass(operation: number): void;
  42862. /**
  42863. * Sets a boolean indicating if the dithering state is enabled or disabled
  42864. * @param value defines the dithering state
  42865. */
  42866. setDitheringState(value: boolean): void;
  42867. /**
  42868. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42869. * @param value defines the rasterizer state
  42870. */
  42871. setRasterizerState(value: boolean): void;
  42872. /**
  42873. * Gets the current depth function
  42874. * @returns a number defining the depth function
  42875. */
  42876. getDepthFunction(): Nullable<number>;
  42877. /**
  42878. * Sets the current depth function
  42879. * @param depthFunc defines the function to use
  42880. */
  42881. setDepthFunction(depthFunc: number): void;
  42882. /**
  42883. * Sets the current depth function to GREATER
  42884. */
  42885. setDepthFunctionToGreater(): void;
  42886. /**
  42887. * Sets the current depth function to GEQUAL
  42888. */
  42889. setDepthFunctionToGreaterOrEqual(): void;
  42890. /**
  42891. * Sets the current depth function to LESS
  42892. */
  42893. setDepthFunctionToLess(): void;
  42894. /**
  42895. * Sets the current depth function to LEQUAL
  42896. */
  42897. setDepthFunctionToLessOrEqual(): void;
  42898. private _cachedStencilBuffer;
  42899. private _cachedStencilFunction;
  42900. private _cachedStencilMask;
  42901. private _cachedStencilOperationPass;
  42902. private _cachedStencilOperationFail;
  42903. private _cachedStencilOperationDepthFail;
  42904. private _cachedStencilReference;
  42905. /**
  42906. * Caches the the state of the stencil buffer
  42907. */
  42908. cacheStencilState(): void;
  42909. /**
  42910. * Restores the state of the stencil buffer
  42911. */
  42912. restoreStencilState(): void;
  42913. /**
  42914. * Directly set the WebGL Viewport
  42915. * @param x defines the x coordinate of the viewport (in screen space)
  42916. * @param y defines the y coordinate of the viewport (in screen space)
  42917. * @param width defines the width of the viewport (in screen space)
  42918. * @param height defines the height of the viewport (in screen space)
  42919. * @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
  42920. */
  42921. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42922. /**
  42923. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42924. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42925. * @param y defines the y-coordinate of the corner of the clear rectangle
  42926. * @param width defines the width of the clear rectangle
  42927. * @param height defines the height of the clear rectangle
  42928. * @param clearColor defines the clear color
  42929. */
  42930. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42931. /**
  42932. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42933. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42934. * @param y defines the y-coordinate of the corner of the clear rectangle
  42935. * @param width defines the width of the clear rectangle
  42936. * @param height defines the height of the clear rectangle
  42937. */
  42938. enableScissor(x: number, y: number, width: number, height: number): void;
  42939. /**
  42940. * Disable previously set scissor test rectangle
  42941. */
  42942. disableScissor(): void;
  42943. protected _reportDrawCall(): void;
  42944. /**
  42945. * Initializes a webVR display and starts listening to display change events
  42946. * The onVRDisplayChangedObservable will be notified upon these changes
  42947. * @returns The onVRDisplayChangedObservable
  42948. */
  42949. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42950. /** @hidden */
  42951. _prepareVRComponent(): void;
  42952. /** @hidden */
  42953. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42954. /** @hidden */
  42955. _submitVRFrame(): void;
  42956. /**
  42957. * Call this function to leave webVR mode
  42958. * Will do nothing if webVR is not supported or if there is no webVR device
  42959. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42960. */
  42961. disableVR(): void;
  42962. /**
  42963. * Gets a boolean indicating that the system is in VR mode and is presenting
  42964. * @returns true if VR mode is engaged
  42965. */
  42966. isVRPresenting(): boolean;
  42967. /** @hidden */
  42968. _requestVRFrame(): void;
  42969. /** @hidden */
  42970. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42971. /**
  42972. * Gets the source code of the vertex shader associated with a specific webGL program
  42973. * @param program defines the program to use
  42974. * @returns a string containing the source code of the vertex shader associated with the program
  42975. */
  42976. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42977. /**
  42978. * Gets the source code of the fragment shader associated with a specific webGL program
  42979. * @param program defines the program to use
  42980. * @returns a string containing the source code of the fragment shader associated with the program
  42981. */
  42982. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42983. /**
  42984. * Sets a depth stencil texture from a render target to the according uniform.
  42985. * @param channel The texture channel
  42986. * @param uniform The uniform to set
  42987. * @param texture The render target texture containing the depth stencil texture to apply
  42988. */
  42989. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42990. /**
  42991. * Sets a texture to the webGL context from a postprocess
  42992. * @param channel defines the channel to use
  42993. * @param postProcess defines the source postprocess
  42994. */
  42995. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42996. /**
  42997. * Binds the output of the passed in post process to the texture channel specified
  42998. * @param channel The channel the texture should be bound to
  42999. * @param postProcess The post process which's output should be bound
  43000. */
  43001. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  43002. protected _rebuildBuffers(): void;
  43003. /** @hidden */
  43004. _renderFrame(): void;
  43005. _renderLoop(): void;
  43006. /** @hidden */
  43007. _renderViews(): boolean;
  43008. /**
  43009. * Toggle full screen mode
  43010. * @param requestPointerLock defines if a pointer lock should be requested from the user
  43011. */
  43012. switchFullscreen(requestPointerLock: boolean): void;
  43013. /**
  43014. * Enters full screen mode
  43015. * @param requestPointerLock defines if a pointer lock should be requested from the user
  43016. */
  43017. enterFullscreen(requestPointerLock: boolean): void;
  43018. /**
  43019. * Exits full screen mode
  43020. */
  43021. exitFullscreen(): void;
  43022. /**
  43023. * Enters Pointerlock mode
  43024. */
  43025. enterPointerlock(): void;
  43026. /**
  43027. * Exits Pointerlock mode
  43028. */
  43029. exitPointerlock(): void;
  43030. /**
  43031. * Begin a new frame
  43032. */
  43033. beginFrame(): void;
  43034. /**
  43035. * Enf the current frame
  43036. */
  43037. endFrame(): void;
  43038. resize(): void;
  43039. /**
  43040. * Force a specific size of the canvas
  43041. * @param width defines the new canvas' width
  43042. * @param height defines the new canvas' height
  43043. * @returns true if the size was changed
  43044. */
  43045. setSize(width: number, height: number): boolean;
  43046. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43047. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43048. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43049. _releaseTexture(texture: InternalTexture): void;
  43050. /**
  43051. * @hidden
  43052. * Rescales a texture
  43053. * @param source input texutre
  43054. * @param destination destination texture
  43055. * @param scene scene to use to render the resize
  43056. * @param internalFormat format to use when resizing
  43057. * @param onComplete callback to be called when resize has completed
  43058. */
  43059. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  43060. /**
  43061. * Gets the current framerate
  43062. * @returns a number representing the framerate
  43063. */
  43064. getFps(): number;
  43065. /**
  43066. * Gets the time spent between current and previous frame
  43067. * @returns a number representing the delta time in ms
  43068. */
  43069. getDeltaTime(): number;
  43070. private _measureFps;
  43071. /** @hidden */
  43072. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  43073. /**
  43074. * Updates the sample count of a render target texture
  43075. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43076. * @param texture defines the texture to update
  43077. * @param samples defines the sample count to set
  43078. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43079. */
  43080. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  43081. /**
  43082. * Updates a depth texture Comparison Mode and Function.
  43083. * If the comparison Function is equal to 0, the mode will be set to none.
  43084. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  43085. * @param texture The texture to set the comparison function for
  43086. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  43087. */
  43088. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  43089. /**
  43090. * Creates a webGL buffer to use with instanciation
  43091. * @param capacity defines the size of the buffer
  43092. * @returns the webGL buffer
  43093. */
  43094. createInstancesBuffer(capacity: number): DataBuffer;
  43095. /**
  43096. * Delete a webGL buffer used with instanciation
  43097. * @param buffer defines the webGL buffer to delete
  43098. */
  43099. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  43100. private _clientWaitAsync;
  43101. /** @hidden */
  43102. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  43103. dispose(): void;
  43104. private _disableTouchAction;
  43105. /**
  43106. * Display the loading screen
  43107. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43108. */
  43109. displayLoadingUI(): void;
  43110. /**
  43111. * Hide the loading screen
  43112. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43113. */
  43114. hideLoadingUI(): void;
  43115. /**
  43116. * Gets the current loading screen object
  43117. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43118. */
  43119. get loadingScreen(): ILoadingScreen;
  43120. /**
  43121. * Sets the current loading screen object
  43122. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43123. */
  43124. set loadingScreen(loadingScreen: ILoadingScreen);
  43125. /**
  43126. * Sets the current loading screen text
  43127. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43128. */
  43129. set loadingUIText(text: string);
  43130. /**
  43131. * Sets the current loading screen background color
  43132. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43133. */
  43134. set loadingUIBackgroundColor(color: string);
  43135. /** Pointerlock and fullscreen */
  43136. /**
  43137. * Ask the browser to promote the current element to pointerlock mode
  43138. * @param element defines the DOM element to promote
  43139. */
  43140. static _RequestPointerlock(element: HTMLElement): void;
  43141. /**
  43142. * Asks the browser to exit pointerlock mode
  43143. */
  43144. static _ExitPointerlock(): void;
  43145. /**
  43146. * Ask the browser to promote the current element to fullscreen rendering mode
  43147. * @param element defines the DOM element to promote
  43148. */
  43149. static _RequestFullscreen(element: HTMLElement): void;
  43150. /**
  43151. * Asks the browser to exit fullscreen mode
  43152. */
  43153. static _ExitFullscreen(): void;
  43154. }
  43155. }
  43156. declare module "babylonjs/Engines/engineStore" {
  43157. import { Nullable } from "babylonjs/types";
  43158. import { Engine } from "babylonjs/Engines/engine";
  43159. import { Scene } from "babylonjs/scene";
  43160. /**
  43161. * The engine store class is responsible to hold all the instances of Engine and Scene created
  43162. * during the life time of the application.
  43163. */
  43164. export class EngineStore {
  43165. /** Gets the list of created engines */
  43166. static Instances: import("babylonjs/Engines/engine").Engine[];
  43167. /** @hidden */
  43168. static _LastCreatedScene: Nullable<Scene>;
  43169. /**
  43170. * Gets the latest created engine
  43171. */
  43172. static get LastCreatedEngine(): Nullable<Engine>;
  43173. /**
  43174. * Gets the latest created scene
  43175. */
  43176. static get LastCreatedScene(): Nullable<Scene>;
  43177. /**
  43178. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43179. * @ignorenaming
  43180. */
  43181. static UseFallbackTexture: boolean;
  43182. /**
  43183. * Texture content used if a texture cannot loaded
  43184. * @ignorenaming
  43185. */
  43186. static FallbackTexture: string;
  43187. }
  43188. }
  43189. declare module "babylonjs/Misc/promise" {
  43190. /**
  43191. * Helper class that provides a small promise polyfill
  43192. */
  43193. export class PromisePolyfill {
  43194. /**
  43195. * Static function used to check if the polyfill is required
  43196. * If this is the case then the function will inject the polyfill to window.Promise
  43197. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43198. */
  43199. static Apply(force?: boolean): void;
  43200. }
  43201. }
  43202. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  43203. /**
  43204. * Interface for screenshot methods with describe argument called `size` as object with options
  43205. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43206. */
  43207. export interface IScreenshotSize {
  43208. /**
  43209. * number in pixels for canvas height
  43210. */
  43211. height?: number;
  43212. /**
  43213. * multiplier allowing render at a higher or lower resolution
  43214. * If value is defined then height and width will be ignored and taken from camera
  43215. */
  43216. precision?: number;
  43217. /**
  43218. * number in pixels for canvas width
  43219. */
  43220. width?: number;
  43221. }
  43222. }
  43223. declare module "babylonjs/Misc/tools" {
  43224. import { Nullable, float } from "babylonjs/types";
  43225. import { DomManagement } from "babylonjs/Misc/domManagement";
  43226. import { WebRequest } from "babylonjs/Misc/webRequest";
  43227. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43228. import { ReadFileError } from "babylonjs/Misc/fileTools";
  43229. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43230. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  43231. import { Camera } from "babylonjs/Cameras/camera";
  43232. import { Engine } from "babylonjs/Engines/engine";
  43233. interface IColor4Like {
  43234. r: float;
  43235. g: float;
  43236. b: float;
  43237. a: float;
  43238. }
  43239. /**
  43240. * Class containing a set of static utilities functions
  43241. */
  43242. export class Tools {
  43243. /**
  43244. * Gets or sets the base URL to use to load assets
  43245. */
  43246. static get BaseUrl(): string;
  43247. static set BaseUrl(value: string);
  43248. /**
  43249. * Enable/Disable Custom HTTP Request Headers globally.
  43250. * default = false
  43251. * @see CustomRequestHeaders
  43252. */
  43253. static UseCustomRequestHeaders: boolean;
  43254. /**
  43255. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43256. * i.e. when loading files, where the server/service expects an Authorization header
  43257. */
  43258. static CustomRequestHeaders: {
  43259. [key: string]: string;
  43260. };
  43261. /**
  43262. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43263. */
  43264. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43265. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43266. /**
  43267. * Default behaviour for cors in the application.
  43268. * It can be a string if the expected behavior is identical in the entire app.
  43269. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43270. */
  43271. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43272. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43273. /**
  43274. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43275. * @ignorenaming
  43276. */
  43277. static get UseFallbackTexture(): boolean;
  43278. static set UseFallbackTexture(value: boolean);
  43279. /**
  43280. * Use this object to register external classes like custom textures or material
  43281. * to allow the laoders to instantiate them
  43282. */
  43283. static get RegisteredExternalClasses(): {
  43284. [key: string]: Object;
  43285. };
  43286. static set RegisteredExternalClasses(classes: {
  43287. [key: string]: Object;
  43288. });
  43289. /**
  43290. * Texture content used if a texture cannot loaded
  43291. * @ignorenaming
  43292. */
  43293. static get fallbackTexture(): string;
  43294. static set fallbackTexture(value: string);
  43295. /**
  43296. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43297. * @param u defines the coordinate on X axis
  43298. * @param v defines the coordinate on Y axis
  43299. * @param width defines the width of the source data
  43300. * @param height defines the height of the source data
  43301. * @param pixels defines the source byte array
  43302. * @param color defines the output color
  43303. */
  43304. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43305. /**
  43306. * Interpolates between a and b via alpha
  43307. * @param a The lower value (returned when alpha = 0)
  43308. * @param b The upper value (returned when alpha = 1)
  43309. * @param alpha The interpolation-factor
  43310. * @return The mixed value
  43311. */
  43312. static Mix(a: number, b: number, alpha: number): number;
  43313. /**
  43314. * Tries to instantiate a new object from a given class name
  43315. * @param className defines the class name to instantiate
  43316. * @returns the new object or null if the system was not able to do the instantiation
  43317. */
  43318. static Instantiate(className: string): any;
  43319. /**
  43320. * Provides a slice function that will work even on IE
  43321. * @param data defines the array to slice
  43322. * @param start defines the start of the data (optional)
  43323. * @param end defines the end of the data (optional)
  43324. * @returns the new sliced array
  43325. */
  43326. static Slice<T>(data: T, start?: number, end?: number): T;
  43327. /**
  43328. * Provides a slice function that will work even on IE
  43329. * The difference between this and Slice is that this will force-convert to array
  43330. * @param data defines the array to slice
  43331. * @param start defines the start of the data (optional)
  43332. * @param end defines the end of the data (optional)
  43333. * @returns the new sliced array
  43334. */
  43335. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43336. /**
  43337. * Polyfill for setImmediate
  43338. * @param action defines the action to execute after the current execution block
  43339. */
  43340. static SetImmediate(action: () => void): void;
  43341. /**
  43342. * Function indicating if a number is an exponent of 2
  43343. * @param value defines the value to test
  43344. * @returns true if the value is an exponent of 2
  43345. */
  43346. static IsExponentOfTwo(value: number): boolean;
  43347. private static _tmpFloatArray;
  43348. /**
  43349. * Returns the nearest 32-bit single precision float representation of a Number
  43350. * @param value A Number. If the parameter is of a different type, it will get converted
  43351. * to a number or to NaN if it cannot be converted
  43352. * @returns number
  43353. */
  43354. static FloatRound(value: number): number;
  43355. /**
  43356. * Extracts the filename from a path
  43357. * @param path defines the path to use
  43358. * @returns the filename
  43359. */
  43360. static GetFilename(path: string): string;
  43361. /**
  43362. * Extracts the "folder" part of a path (everything before the filename).
  43363. * @param uri The URI to extract the info from
  43364. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43365. * @returns The "folder" part of the path
  43366. */
  43367. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43368. /**
  43369. * Extracts text content from a DOM element hierarchy
  43370. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43371. */
  43372. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43373. /**
  43374. * Convert an angle in radians to degrees
  43375. * @param angle defines the angle to convert
  43376. * @returns the angle in degrees
  43377. */
  43378. static ToDegrees(angle: number): number;
  43379. /**
  43380. * Convert an angle in degrees to radians
  43381. * @param angle defines the angle to convert
  43382. * @returns the angle in radians
  43383. */
  43384. static ToRadians(angle: number): number;
  43385. /**
  43386. * Returns an array if obj is not an array
  43387. * @param obj defines the object to evaluate as an array
  43388. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43389. * @returns either obj directly if obj is an array or a new array containing obj
  43390. */
  43391. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43392. /**
  43393. * Gets the pointer prefix to use
  43394. * @param engine defines the engine we are finding the prefix for
  43395. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43396. */
  43397. static GetPointerPrefix(engine: Engine): string;
  43398. /**
  43399. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43400. * @param url define the url we are trying
  43401. * @param element define the dom element where to configure the cors policy
  43402. */
  43403. static SetCorsBehavior(url: string | string[], element: {
  43404. crossOrigin: string | null;
  43405. }): void;
  43406. /**
  43407. * Removes unwanted characters from an url
  43408. * @param url defines the url to clean
  43409. * @returns the cleaned url
  43410. */
  43411. static CleanUrl(url: string): string;
  43412. /**
  43413. * Gets or sets a function used to pre-process url before using them to load assets
  43414. */
  43415. static get PreprocessUrl(): (url: string) => string;
  43416. static set PreprocessUrl(processor: (url: string) => string);
  43417. /**
  43418. * Loads an image as an HTMLImageElement.
  43419. * @param input url string, ArrayBuffer, or Blob to load
  43420. * @param onLoad callback called when the image successfully loads
  43421. * @param onError callback called when the image fails to load
  43422. * @param offlineProvider offline provider for caching
  43423. * @param mimeType optional mime type
  43424. * @returns the HTMLImageElement of the loaded image
  43425. */
  43426. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43427. /**
  43428. * Loads a file from a url
  43429. * @param url url string, ArrayBuffer, or Blob to load
  43430. * @param onSuccess callback called when the file successfully loads
  43431. * @param onProgress callback called while file is loading (if the server supports this mode)
  43432. * @param offlineProvider defines the offline provider for caching
  43433. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43434. * @param onError callback called when the file fails to load
  43435. * @returns a file request object
  43436. */
  43437. 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;
  43438. /**
  43439. * Loads a file from a url
  43440. * @param url the file url to load
  43441. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43442. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43443. */
  43444. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43445. /**
  43446. * Load a script (identified by an url). When the url returns, the
  43447. * content of this file is added into a new script element, attached to the DOM (body element)
  43448. * @param scriptUrl defines the url of the script to laod
  43449. * @param onSuccess defines the callback called when the script is loaded
  43450. * @param onError defines the callback to call if an error occurs
  43451. * @param scriptId defines the id of the script element
  43452. */
  43453. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43454. /**
  43455. * Load an asynchronous script (identified by an url). When the url returns, the
  43456. * content of this file is added into a new script element, attached to the DOM (body element)
  43457. * @param scriptUrl defines the url of the script to laod
  43458. * @param scriptId defines the id of the script element
  43459. * @returns a promise request object
  43460. */
  43461. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43462. /**
  43463. * Loads a file from a blob
  43464. * @param fileToLoad defines the blob to use
  43465. * @param callback defines the callback to call when data is loaded
  43466. * @param progressCallback defines the callback to call during loading process
  43467. * @returns a file request object
  43468. */
  43469. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43470. /**
  43471. * Reads a file from a File object
  43472. * @param file defines the file to load
  43473. * @param onSuccess defines the callback to call when data is loaded
  43474. * @param onProgress defines the callback to call during loading process
  43475. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43476. * @param onError defines the callback to call when an error occurs
  43477. * @returns a file request object
  43478. */
  43479. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43480. /**
  43481. * Creates a data url from a given string content
  43482. * @param content defines the content to convert
  43483. * @returns the new data url link
  43484. */
  43485. static FileAsURL(content: string): string;
  43486. /**
  43487. * Format the given number to a specific decimal format
  43488. * @param value defines the number to format
  43489. * @param decimals defines the number of decimals to use
  43490. * @returns the formatted string
  43491. */
  43492. static Format(value: number, decimals?: number): string;
  43493. /**
  43494. * Tries to copy an object by duplicating every property
  43495. * @param source defines the source object
  43496. * @param destination defines the target object
  43497. * @param doNotCopyList defines a list of properties to avoid
  43498. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43499. */
  43500. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43501. /**
  43502. * Gets a boolean indicating if the given object has no own property
  43503. * @param obj defines the object to test
  43504. * @returns true if object has no own property
  43505. */
  43506. static IsEmpty(obj: any): boolean;
  43507. /**
  43508. * Function used to register events at window level
  43509. * @param windowElement defines the Window object to use
  43510. * @param events defines the events to register
  43511. */
  43512. static RegisterTopRootEvents(windowElement: Window, events: {
  43513. name: string;
  43514. handler: Nullable<(e: FocusEvent) => any>;
  43515. }[]): void;
  43516. /**
  43517. * Function used to unregister events from window level
  43518. * @param windowElement defines the Window object to use
  43519. * @param events defines the events to unregister
  43520. */
  43521. static UnregisterTopRootEvents(windowElement: Window, events: {
  43522. name: string;
  43523. handler: Nullable<(e: FocusEvent) => any>;
  43524. }[]): void;
  43525. /**
  43526. * @ignore
  43527. */
  43528. static _ScreenshotCanvas: HTMLCanvasElement;
  43529. /**
  43530. * Dumps the current bound framebuffer
  43531. * @param width defines the rendering width
  43532. * @param height defines the rendering height
  43533. * @param engine defines the hosting engine
  43534. * @param successCallback defines the callback triggered once the data are available
  43535. * @param mimeType defines the mime type of the result
  43536. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43537. */
  43538. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43539. /**
  43540. * Converts the canvas data to blob.
  43541. * This acts as a polyfill for browsers not supporting the to blob function.
  43542. * @param canvas Defines the canvas to extract the data from
  43543. * @param successCallback Defines the callback triggered once the data are available
  43544. * @param mimeType Defines the mime type of the result
  43545. */
  43546. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43547. /**
  43548. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43549. * @param successCallback defines the callback triggered once the data are available
  43550. * @param mimeType defines the mime type of the result
  43551. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43552. */
  43553. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43554. /**
  43555. * Downloads a blob in the browser
  43556. * @param blob defines the blob to download
  43557. * @param fileName defines the name of the downloaded file
  43558. */
  43559. static Download(blob: Blob, fileName: string): void;
  43560. /**
  43561. * Will return the right value of the noPreventDefault variable
  43562. * Needed to keep backwards compatibility to the old API.
  43563. *
  43564. * @param args arguments passed to the attachControl function
  43565. * @returns the correct value for noPreventDefault
  43566. */
  43567. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43568. /**
  43569. * Captures a screenshot of the current rendering
  43570. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43571. * @param engine defines the rendering engine
  43572. * @param camera defines the source camera
  43573. * @param size This parameter can be set to a single number or to an object with the
  43574. * following (optional) properties: precision, width, height. If a single number is passed,
  43575. * it will be used for both width and height. If an object is passed, the screenshot size
  43576. * will be derived from the parameters. The precision property is a multiplier allowing
  43577. * rendering at a higher or lower resolution
  43578. * @param successCallback defines the callback receives a single parameter which contains the
  43579. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43580. * src parameter of an <img> to display it
  43581. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43582. * Check your browser for supported MIME types
  43583. */
  43584. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43585. /**
  43586. * Captures a screenshot of the current rendering
  43587. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43588. * @param engine defines the rendering engine
  43589. * @param camera defines the source camera
  43590. * @param size This parameter can be set to a single number or to an object with the
  43591. * following (optional) properties: precision, width, height. If a single number is passed,
  43592. * it will be used for both width and height. If an object is passed, the screenshot size
  43593. * will be derived from the parameters. The precision property is a multiplier allowing
  43594. * rendering at a higher or lower resolution
  43595. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43596. * Check your browser for supported MIME types
  43597. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43598. * to the src parameter of an <img> to display it
  43599. */
  43600. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43601. /**
  43602. * Generates an image screenshot from the specified camera.
  43603. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43604. * @param engine The engine to use for rendering
  43605. * @param camera The camera to use for rendering
  43606. * @param size This parameter can be set to a single number or to an object with the
  43607. * following (optional) properties: precision, width, height. If a single number is passed,
  43608. * it will be used for both width and height. If an object is passed, the screenshot size
  43609. * will be derived from the parameters. The precision property is a multiplier allowing
  43610. * rendering at a higher or lower resolution
  43611. * @param successCallback The callback receives a single parameter which contains the
  43612. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43613. * src parameter of an <img> to display it
  43614. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43615. * Check your browser for supported MIME types
  43616. * @param samples Texture samples (default: 1)
  43617. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43618. * @param fileName A name for for the downloaded file.
  43619. */
  43620. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43621. /**
  43622. * Generates an image screenshot from the specified camera.
  43623. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43624. * @param engine The engine to use for rendering
  43625. * @param camera The camera to use for rendering
  43626. * @param size This parameter can be set to a single number or to an object with the
  43627. * following (optional) properties: precision, width, height. If a single number is passed,
  43628. * it will be used for both width and height. If an object is passed, the screenshot size
  43629. * will be derived from the parameters. The precision property is a multiplier allowing
  43630. * rendering at a higher or lower resolution
  43631. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43632. * Check your browser for supported MIME types
  43633. * @param samples Texture samples (default: 1)
  43634. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43635. * @param fileName A name for for the downloaded file.
  43636. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43637. * to the src parameter of an <img> to display it
  43638. */
  43639. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43640. /**
  43641. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43642. * Be aware Math.random() could cause collisions, but:
  43643. * "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"
  43644. * @returns a pseudo random id
  43645. */
  43646. static RandomId(): string;
  43647. /**
  43648. * Test if the given uri is a base64 string
  43649. * @param uri The uri to test
  43650. * @return True if the uri is a base64 string or false otherwise
  43651. */
  43652. static IsBase64(uri: string): boolean;
  43653. /**
  43654. * Decode the given base64 uri.
  43655. * @param uri The uri to decode
  43656. * @return The decoded base64 data.
  43657. */
  43658. static DecodeBase64(uri: string): ArrayBuffer;
  43659. /**
  43660. * Gets the absolute url.
  43661. * @param url the input url
  43662. * @return the absolute url
  43663. */
  43664. static GetAbsoluteUrl(url: string): string;
  43665. /**
  43666. * No log
  43667. */
  43668. static readonly NoneLogLevel: number;
  43669. /**
  43670. * Only message logs
  43671. */
  43672. static readonly MessageLogLevel: number;
  43673. /**
  43674. * Only warning logs
  43675. */
  43676. static readonly WarningLogLevel: number;
  43677. /**
  43678. * Only error logs
  43679. */
  43680. static readonly ErrorLogLevel: number;
  43681. /**
  43682. * All logs
  43683. */
  43684. static readonly AllLogLevel: number;
  43685. /**
  43686. * Gets a value indicating the number of loading errors
  43687. * @ignorenaming
  43688. */
  43689. static get errorsCount(): number;
  43690. /**
  43691. * Callback called when a new log is added
  43692. */
  43693. static OnNewCacheEntry: (entry: string) => void;
  43694. /**
  43695. * Log a message to the console
  43696. * @param message defines the message to log
  43697. */
  43698. static Log(message: string): void;
  43699. /**
  43700. * Write a warning message to the console
  43701. * @param message defines the message to log
  43702. */
  43703. static Warn(message: string): void;
  43704. /**
  43705. * Write an error message to the console
  43706. * @param message defines the message to log
  43707. */
  43708. static Error(message: string): void;
  43709. /**
  43710. * Gets current log cache (list of logs)
  43711. */
  43712. static get LogCache(): string;
  43713. /**
  43714. * Clears the log cache
  43715. */
  43716. static ClearLogCache(): void;
  43717. /**
  43718. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43719. */
  43720. static set LogLevels(level: number);
  43721. /**
  43722. * Checks if the window object exists
  43723. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43724. */
  43725. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43726. /**
  43727. * No performance log
  43728. */
  43729. static readonly PerformanceNoneLogLevel: number;
  43730. /**
  43731. * Use user marks to log performance
  43732. */
  43733. static readonly PerformanceUserMarkLogLevel: number;
  43734. /**
  43735. * Log performance to the console
  43736. */
  43737. static readonly PerformanceConsoleLogLevel: number;
  43738. private static _performance;
  43739. /**
  43740. * Sets the current performance log level
  43741. */
  43742. static set PerformanceLogLevel(level: number);
  43743. private static _StartPerformanceCounterDisabled;
  43744. private static _EndPerformanceCounterDisabled;
  43745. private static _StartUserMark;
  43746. private static _EndUserMark;
  43747. private static _StartPerformanceConsole;
  43748. private static _EndPerformanceConsole;
  43749. /**
  43750. * Starts a performance counter
  43751. */
  43752. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43753. /**
  43754. * Ends a specific performance coutner
  43755. */
  43756. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43757. /**
  43758. * Gets either window.performance.now() if supported or Date.now() else
  43759. */
  43760. static get Now(): number;
  43761. /**
  43762. * This method will return the name of the class used to create the instance of the given object.
  43763. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43764. * @param object the object to get the class name from
  43765. * @param isType defines if the object is actually a type
  43766. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43767. */
  43768. static GetClassName(object: any, isType?: boolean): string;
  43769. /**
  43770. * Gets the first element of an array satisfying a given predicate
  43771. * @param array defines the array to browse
  43772. * @param predicate defines the predicate to use
  43773. * @returns null if not found or the element
  43774. */
  43775. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43776. /**
  43777. * This method will return the name of the full name of the class, including its owning module (if any).
  43778. * 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).
  43779. * @param object the object to get the class name from
  43780. * @param isType defines if the object is actually a type
  43781. * @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.
  43782. * @ignorenaming
  43783. */
  43784. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43785. /**
  43786. * Returns a promise that resolves after the given amount of time.
  43787. * @param delay Number of milliseconds to delay
  43788. * @returns Promise that resolves after the given amount of time
  43789. */
  43790. static DelayAsync(delay: number): Promise<void>;
  43791. /**
  43792. * Utility function to detect if the current user agent is Safari
  43793. * @returns whether or not the current user agent is safari
  43794. */
  43795. static IsSafari(): boolean;
  43796. }
  43797. /**
  43798. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43799. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43800. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43801. * @param name The name of the class, case should be preserved
  43802. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43803. */
  43804. export function className(name: string, module?: string): (target: Object) => void;
  43805. /**
  43806. * An implementation of a loop for asynchronous functions.
  43807. */
  43808. export class AsyncLoop {
  43809. /**
  43810. * Defines the number of iterations for the loop
  43811. */
  43812. iterations: number;
  43813. /**
  43814. * Defines the current index of the loop.
  43815. */
  43816. index: number;
  43817. private _done;
  43818. private _fn;
  43819. private _successCallback;
  43820. /**
  43821. * Constructor.
  43822. * @param iterations the number of iterations.
  43823. * @param func the function to run each iteration
  43824. * @param successCallback the callback that will be called upon succesful execution
  43825. * @param offset starting offset.
  43826. */
  43827. constructor(
  43828. /**
  43829. * Defines the number of iterations for the loop
  43830. */
  43831. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43832. /**
  43833. * Execute the next iteration. Must be called after the last iteration was finished.
  43834. */
  43835. executeNext(): void;
  43836. /**
  43837. * Break the loop and run the success callback.
  43838. */
  43839. breakLoop(): void;
  43840. /**
  43841. * Create and run an async loop.
  43842. * @param iterations the number of iterations.
  43843. * @param fn the function to run each iteration
  43844. * @param successCallback the callback that will be called upon succesful execution
  43845. * @param offset starting offset.
  43846. * @returns the created async loop object
  43847. */
  43848. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43849. /**
  43850. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43851. * @param iterations total number of iterations
  43852. * @param syncedIterations number of synchronous iterations in each async iteration.
  43853. * @param fn the function to call each iteration.
  43854. * @param callback a success call back that will be called when iterating stops.
  43855. * @param breakFunction a break condition (optional)
  43856. * @param timeout timeout settings for the setTimeout function. default - 0.
  43857. * @returns the created async loop object
  43858. */
  43859. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43860. }
  43861. }
  43862. declare module "babylonjs/Misc/stringDictionary" {
  43863. import { Nullable } from "babylonjs/types";
  43864. /**
  43865. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43866. * The underlying implementation relies on an associative array to ensure the best performances.
  43867. * The value can be anything including 'null' but except 'undefined'
  43868. */
  43869. export class StringDictionary<T> {
  43870. /**
  43871. * This will clear this dictionary and copy the content from the 'source' one.
  43872. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43873. * @param source the dictionary to take the content from and copy to this dictionary
  43874. */
  43875. copyFrom(source: StringDictionary<T>): void;
  43876. /**
  43877. * Get a value based from its key
  43878. * @param key the given key to get the matching value from
  43879. * @return the value if found, otherwise undefined is returned
  43880. */
  43881. get(key: string): T | undefined;
  43882. /**
  43883. * Get a value from its key or add it if it doesn't exist.
  43884. * This method will ensure you that a given key/data will be present in the dictionary.
  43885. * @param key the given key to get the matching value from
  43886. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43887. * The factory will only be invoked if there's no data for the given key.
  43888. * @return the value corresponding to the key.
  43889. */
  43890. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43891. /**
  43892. * Get a value from its key if present in the dictionary otherwise add it
  43893. * @param key the key to get the value from
  43894. * @param val if there's no such key/value pair in the dictionary add it with this value
  43895. * @return the value corresponding to the key
  43896. */
  43897. getOrAdd(key: string, val: T): T;
  43898. /**
  43899. * Check if there's a given key in the dictionary
  43900. * @param key the key to check for
  43901. * @return true if the key is present, false otherwise
  43902. */
  43903. contains(key: string): boolean;
  43904. /**
  43905. * Add a new key and its corresponding value
  43906. * @param key the key to add
  43907. * @param value the value corresponding to the key
  43908. * @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
  43909. */
  43910. add(key: string, value: T): boolean;
  43911. /**
  43912. * Update a specific value associated to a key
  43913. * @param key defines the key to use
  43914. * @param value defines the value to store
  43915. * @returns true if the value was updated (or false if the key was not found)
  43916. */
  43917. set(key: string, value: T): boolean;
  43918. /**
  43919. * Get the element of the given key and remove it from the dictionary
  43920. * @param key defines the key to search
  43921. * @returns the value associated with the key or null if not found
  43922. */
  43923. getAndRemove(key: string): Nullable<T>;
  43924. /**
  43925. * Remove a key/value from the dictionary.
  43926. * @param key the key to remove
  43927. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43928. */
  43929. remove(key: string): boolean;
  43930. /**
  43931. * Clear the whole content of the dictionary
  43932. */
  43933. clear(): void;
  43934. /**
  43935. * Gets the current count
  43936. */
  43937. get count(): number;
  43938. /**
  43939. * Execute a callback on each key/val of the dictionary.
  43940. * Note that you can remove any element in this dictionary in the callback implementation
  43941. * @param callback the callback to execute on a given key/value pair
  43942. */
  43943. forEach(callback: (key: string, val: T) => void): void;
  43944. /**
  43945. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43946. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43947. * Note that you can remove any element in this dictionary in the callback implementation
  43948. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43949. * @returns the first item
  43950. */
  43951. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43952. private _count;
  43953. private _data;
  43954. }
  43955. }
  43956. declare module "babylonjs/Collisions/collisionCoordinator" {
  43957. import { Nullable } from "babylonjs/types";
  43958. import { Scene } from "babylonjs/scene";
  43959. import { Vector3 } from "babylonjs/Maths/math.vector";
  43960. import { Collider } from "babylonjs/Collisions/collider";
  43961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43962. /** @hidden */
  43963. export interface ICollisionCoordinator {
  43964. createCollider(): Collider;
  43965. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43966. init(scene: Scene): void;
  43967. }
  43968. /** @hidden */
  43969. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43970. private _scene;
  43971. private _scaledPosition;
  43972. private _scaledVelocity;
  43973. private _finalPosition;
  43974. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43975. createCollider(): Collider;
  43976. init(scene: Scene): void;
  43977. private _collideWithWorld;
  43978. }
  43979. }
  43980. declare module "babylonjs/Inputs/scene.inputManager" {
  43981. import { Nullable } from "babylonjs/types";
  43982. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43983. import { Vector2 } from "babylonjs/Maths/math.vector";
  43984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43985. import { Scene } from "babylonjs/scene";
  43986. /**
  43987. * Class used to manage all inputs for the scene.
  43988. */
  43989. export class InputManager {
  43990. /** The distance in pixel that you have to move to prevent some events */
  43991. static DragMovementThreshold: number;
  43992. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43993. static LongPressDelay: number;
  43994. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43995. static DoubleClickDelay: number;
  43996. /** If you need to check double click without raising a single click at first click, enable this flag */
  43997. static ExclusiveDoubleClickMode: boolean;
  43998. /** 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. */
  43999. private _alreadyAttached;
  44000. private _alreadyAttachedTo;
  44001. private _wheelEventName;
  44002. private _onPointerMove;
  44003. private _onPointerDown;
  44004. private _onPointerUp;
  44005. private _initClickEvent;
  44006. private _initActionManager;
  44007. private _delayedSimpleClick;
  44008. private _delayedSimpleClickTimeout;
  44009. private _previousDelayedSimpleClickTimeout;
  44010. private _meshPickProceed;
  44011. private _previousButtonPressed;
  44012. private _currentPickResult;
  44013. private _previousPickResult;
  44014. private _totalPointersPressed;
  44015. private _doubleClickOccured;
  44016. private _pointerOverMesh;
  44017. private _pickedDownMesh;
  44018. private _pickedUpMesh;
  44019. private _pointerX;
  44020. private _pointerY;
  44021. private _unTranslatedPointerX;
  44022. private _unTranslatedPointerY;
  44023. private _startingPointerPosition;
  44024. private _previousStartingPointerPosition;
  44025. private _startingPointerTime;
  44026. private _previousStartingPointerTime;
  44027. private _pointerCaptures;
  44028. private _meshUnderPointerId;
  44029. private _onKeyDown;
  44030. private _onKeyUp;
  44031. private _keyboardIsAttached;
  44032. private _onCanvasFocusObserver;
  44033. private _onCanvasBlurObserver;
  44034. private _scene;
  44035. /**
  44036. * Creates a new InputManager
  44037. * @param scene defines the hosting scene
  44038. */
  44039. constructor(scene: Scene);
  44040. /**
  44041. * Gets the mesh that is currently under the pointer
  44042. */
  44043. get meshUnderPointer(): Nullable<AbstractMesh>;
  44044. /**
  44045. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  44046. * @param pointerId the pointer id to use
  44047. * @returns The mesh under this pointer id or null if not found
  44048. */
  44049. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  44050. /**
  44051. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  44052. */
  44053. get unTranslatedPointer(): Vector2;
  44054. /**
  44055. * Gets or sets the current on-screen X position of the pointer
  44056. */
  44057. get pointerX(): number;
  44058. set pointerX(value: number);
  44059. /**
  44060. * Gets or sets the current on-screen Y position of the pointer
  44061. */
  44062. get pointerY(): number;
  44063. set pointerY(value: number);
  44064. private _updatePointerPosition;
  44065. private _processPointerMove;
  44066. private _setRayOnPointerInfo;
  44067. private _checkPrePointerObservable;
  44068. /**
  44069. * Use this method to simulate a pointer move on a mesh
  44070. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44071. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44072. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44073. */
  44074. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44075. /**
  44076. * Use this method to simulate a pointer down on a mesh
  44077. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44078. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44079. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44080. */
  44081. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44082. private _processPointerDown;
  44083. /** @hidden */
  44084. _isPointerSwiping(): boolean;
  44085. /**
  44086. * Use this method to simulate a pointer up on a mesh
  44087. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44088. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44089. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44090. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44091. */
  44092. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  44093. private _processPointerUp;
  44094. /**
  44095. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44096. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44097. * @returns true if the pointer was captured
  44098. */
  44099. isPointerCaptured(pointerId?: number): boolean;
  44100. /**
  44101. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44102. * @param attachUp defines if you want to attach events to pointerup
  44103. * @param attachDown defines if you want to attach events to pointerdown
  44104. * @param attachMove defines if you want to attach events to pointermove
  44105. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  44106. */
  44107. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  44108. /**
  44109. * Detaches all event handlers
  44110. */
  44111. detachControl(): void;
  44112. /**
  44113. * Force the value of meshUnderPointer
  44114. * @param mesh defines the mesh to use
  44115. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  44116. */
  44117. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44118. /**
  44119. * Gets the mesh under the pointer
  44120. * @returns a Mesh or null if no mesh is under the pointer
  44121. */
  44122. getPointerOverMesh(): Nullable<AbstractMesh>;
  44123. }
  44124. }
  44125. declare module "babylonjs/Animations/animationGroup" {
  44126. import { Animatable } from "babylonjs/Animations/animatable";
  44127. import { Animation } from "babylonjs/Animations/animation";
  44128. import { Scene, IDisposable } from "babylonjs/scene";
  44129. import { Observable } from "babylonjs/Misc/observable";
  44130. import { Nullable } from "babylonjs/types";
  44131. import "babylonjs/Animations/animatable";
  44132. /**
  44133. * This class defines the direct association between an animation and a target
  44134. */
  44135. export class TargetedAnimation {
  44136. /**
  44137. * Animation to perform
  44138. */
  44139. animation: Animation;
  44140. /**
  44141. * Target to animate
  44142. */
  44143. target: any;
  44144. /**
  44145. * Returns the string "TargetedAnimation"
  44146. * @returns "TargetedAnimation"
  44147. */
  44148. getClassName(): string;
  44149. /**
  44150. * Serialize the object
  44151. * @returns the JSON object representing the current entity
  44152. */
  44153. serialize(): any;
  44154. }
  44155. /**
  44156. * Use this class to create coordinated animations on multiple targets
  44157. */
  44158. export class AnimationGroup implements IDisposable {
  44159. /** The name of the animation group */
  44160. name: string;
  44161. private _scene;
  44162. private _targetedAnimations;
  44163. private _animatables;
  44164. private _from;
  44165. private _to;
  44166. private _isStarted;
  44167. private _isPaused;
  44168. private _speedRatio;
  44169. private _loopAnimation;
  44170. private _isAdditive;
  44171. /**
  44172. * Gets or sets the unique id of the node
  44173. */
  44174. uniqueId: number;
  44175. /**
  44176. * This observable will notify when one animation have ended
  44177. */
  44178. onAnimationEndObservable: Observable<TargetedAnimation>;
  44179. /**
  44180. * Observer raised when one animation loops
  44181. */
  44182. onAnimationLoopObservable: Observable<TargetedAnimation>;
  44183. /**
  44184. * Observer raised when all animations have looped
  44185. */
  44186. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  44187. /**
  44188. * This observable will notify when all animations have ended.
  44189. */
  44190. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  44191. /**
  44192. * This observable will notify when all animations have paused.
  44193. */
  44194. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  44195. /**
  44196. * This observable will notify when all animations are playing.
  44197. */
  44198. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44199. /**
  44200. * Gets the first frame
  44201. */
  44202. get from(): number;
  44203. /**
  44204. * Gets the last frame
  44205. */
  44206. get to(): number;
  44207. /**
  44208. * Define if the animations are started
  44209. */
  44210. get isStarted(): boolean;
  44211. /**
  44212. * Gets a value indicating that the current group is playing
  44213. */
  44214. get isPlaying(): boolean;
  44215. /**
  44216. * Gets or sets the speed ratio to use for all animations
  44217. */
  44218. get speedRatio(): number;
  44219. /**
  44220. * Gets or sets the speed ratio to use for all animations
  44221. */
  44222. set speedRatio(value: number);
  44223. /**
  44224. * Gets or sets if all animations should loop or not
  44225. */
  44226. get loopAnimation(): boolean;
  44227. set loopAnimation(value: boolean);
  44228. /**
  44229. * Gets or sets if all animations should be evaluated additively
  44230. */
  44231. get isAdditive(): boolean;
  44232. set isAdditive(value: boolean);
  44233. /**
  44234. * Gets the targeted animations for this animation group
  44235. */
  44236. get targetedAnimations(): Array<TargetedAnimation>;
  44237. /**
  44238. * returning the list of animatables controlled by this animation group.
  44239. */
  44240. get animatables(): Array<Animatable>;
  44241. /**
  44242. * Gets the list of target animations
  44243. */
  44244. get children(): TargetedAnimation[];
  44245. /**
  44246. * Instantiates a new Animation Group.
  44247. * This helps managing several animations at once.
  44248. * @see https://doc.babylonjs.com/how_to/group
  44249. * @param name Defines the name of the group
  44250. * @param scene Defines the scene the group belongs to
  44251. */
  44252. constructor(
  44253. /** The name of the animation group */
  44254. name: string, scene?: Nullable<Scene>);
  44255. /**
  44256. * Add an animation (with its target) in the group
  44257. * @param animation defines the animation we want to add
  44258. * @param target defines the target of the animation
  44259. * @returns the TargetedAnimation object
  44260. */
  44261. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44262. /**
  44263. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44264. * It can add constant keys at begin or end
  44265. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44266. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44267. * @returns the animation group
  44268. */
  44269. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44270. private _animationLoopCount;
  44271. private _animationLoopFlags;
  44272. private _processLoop;
  44273. /**
  44274. * Start all animations on given targets
  44275. * @param loop defines if animations must loop
  44276. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44277. * @param from defines the from key (optional)
  44278. * @param to defines the to key (optional)
  44279. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44280. * @returns the current animation group
  44281. */
  44282. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44283. /**
  44284. * Pause all animations
  44285. * @returns the animation group
  44286. */
  44287. pause(): AnimationGroup;
  44288. /**
  44289. * Play all animations to initial state
  44290. * This function will start() the animations if they were not started or will restart() them if they were paused
  44291. * @param loop defines if animations must loop
  44292. * @returns the animation group
  44293. */
  44294. play(loop?: boolean): AnimationGroup;
  44295. /**
  44296. * Reset all animations to initial state
  44297. * @returns the animation group
  44298. */
  44299. reset(): AnimationGroup;
  44300. /**
  44301. * Restart animations from key 0
  44302. * @returns the animation group
  44303. */
  44304. restart(): AnimationGroup;
  44305. /**
  44306. * Stop all animations
  44307. * @returns the animation group
  44308. */
  44309. stop(): AnimationGroup;
  44310. /**
  44311. * Set animation weight for all animatables
  44312. * @param weight defines the weight to use
  44313. * @return the animationGroup
  44314. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44315. */
  44316. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44317. /**
  44318. * Synchronize and normalize all animatables with a source animatable
  44319. * @param root defines the root animatable to synchronize with
  44320. * @return the animationGroup
  44321. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44322. */
  44323. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44324. /**
  44325. * Goes to a specific frame in this animation group
  44326. * @param frame the frame number to go to
  44327. * @return the animationGroup
  44328. */
  44329. goToFrame(frame: number): AnimationGroup;
  44330. /**
  44331. * Dispose all associated resources
  44332. */
  44333. dispose(): void;
  44334. private _checkAnimationGroupEnded;
  44335. /**
  44336. * Clone the current animation group and returns a copy
  44337. * @param newName defines the name of the new group
  44338. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44339. * @returns the new aniamtion group
  44340. */
  44341. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44342. /**
  44343. * Serializes the animationGroup to an object
  44344. * @returns Serialized object
  44345. */
  44346. serialize(): any;
  44347. /**
  44348. * Returns a new AnimationGroup object parsed from the source provided.
  44349. * @param parsedAnimationGroup defines the source
  44350. * @param scene defines the scene that will receive the animationGroup
  44351. * @returns a new AnimationGroup
  44352. */
  44353. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44354. /**
  44355. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44356. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44357. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44358. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44359. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44360. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44361. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44362. */
  44363. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44364. /**
  44365. * Returns the string "AnimationGroup"
  44366. * @returns "AnimationGroup"
  44367. */
  44368. getClassName(): string;
  44369. /**
  44370. * Creates a detailled string about the object
  44371. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44372. * @returns a string representing the object
  44373. */
  44374. toString(fullDetails?: boolean): string;
  44375. }
  44376. }
  44377. declare module "babylonjs/scene" {
  44378. import { Nullable } from "babylonjs/types";
  44379. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  44380. import { Observable } from "babylonjs/Misc/observable";
  44381. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44382. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  44383. import { Geometry } from "babylonjs/Meshes/geometry";
  44384. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44385. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44387. import { Mesh } from "babylonjs/Meshes/mesh";
  44388. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44389. import { Bone } from "babylonjs/Bones/bone";
  44390. import { Skeleton } from "babylonjs/Bones/skeleton";
  44391. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  44392. import { Camera } from "babylonjs/Cameras/camera";
  44393. import { AbstractScene } from "babylonjs/abstractScene";
  44394. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44395. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44396. import { Material } from "babylonjs/Materials/material";
  44397. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44398. import { Effect } from "babylonjs/Materials/effect";
  44399. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44400. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  44401. import { Light } from "babylonjs/Lights/light";
  44402. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44403. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  44404. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  44405. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  44406. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  44407. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  44408. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  44409. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  44410. import { Engine } from "babylonjs/Engines/engine";
  44411. import { Node } from "babylonjs/node";
  44412. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  44413. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  44414. import { WebRequest } from "babylonjs/Misc/webRequest";
  44415. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  44416. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  44417. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44418. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  44419. import { Plane } from "babylonjs/Maths/math.plane";
  44420. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  44421. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  44422. import { Ray } from "babylonjs/Culling/ray";
  44423. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  44424. import { Animation } from "babylonjs/Animations/animation";
  44425. import { Animatable } from "babylonjs/Animations/animatable";
  44426. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44427. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  44428. import { Collider } from "babylonjs/Collisions/collider";
  44429. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44430. /**
  44431. * Define an interface for all classes that will hold resources
  44432. */
  44433. export interface IDisposable {
  44434. /**
  44435. * Releases all held resources
  44436. */
  44437. dispose(): void;
  44438. }
  44439. /** Interface defining initialization parameters for Scene class */
  44440. export interface SceneOptions {
  44441. /**
  44442. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  44443. * It will improve performance when the number of geometries becomes important.
  44444. */
  44445. useGeometryUniqueIdsMap?: boolean;
  44446. /**
  44447. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  44448. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44449. */
  44450. useMaterialMeshMap?: boolean;
  44451. /**
  44452. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  44453. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44454. */
  44455. useClonedMeshMap?: boolean;
  44456. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  44457. virtual?: boolean;
  44458. }
  44459. /**
  44460. * Represents a scene to be rendered by the engine.
  44461. * @see https://doc.babylonjs.com/features/scene
  44462. */
  44463. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  44464. /** The fog is deactivated */
  44465. static readonly FOGMODE_NONE: number;
  44466. /** The fog density is following an exponential function */
  44467. static readonly FOGMODE_EXP: number;
  44468. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  44469. static readonly FOGMODE_EXP2: number;
  44470. /** The fog density is following a linear function. */
  44471. static readonly FOGMODE_LINEAR: number;
  44472. /**
  44473. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  44474. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44475. */
  44476. static MinDeltaTime: number;
  44477. /**
  44478. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  44479. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44480. */
  44481. static MaxDeltaTime: number;
  44482. /**
  44483. * Factory used to create the default material.
  44484. * @param name The name of the material to create
  44485. * @param scene The scene to create the material for
  44486. * @returns The default material
  44487. */
  44488. static DefaultMaterialFactory(scene: Scene): Material;
  44489. /**
  44490. * Factory used to create the a collision coordinator.
  44491. * @returns The collision coordinator
  44492. */
  44493. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  44494. /** @hidden */
  44495. _inputManager: InputManager;
  44496. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  44497. cameraToUseForPointers: Nullable<Camera>;
  44498. /** @hidden */
  44499. readonly _isScene: boolean;
  44500. /** @hidden */
  44501. _blockEntityCollection: boolean;
  44502. /**
  44503. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  44504. */
  44505. autoClear: boolean;
  44506. /**
  44507. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  44508. */
  44509. autoClearDepthAndStencil: boolean;
  44510. /**
  44511. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  44512. */
  44513. clearColor: Color4;
  44514. /**
  44515. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  44516. */
  44517. ambientColor: Color3;
  44518. /**
  44519. * This is use to store the default BRDF lookup for PBR materials in your scene.
  44520. * It should only be one of the following (if not the default embedded one):
  44521. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44522. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  44523. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44524. * The material properties need to be setup according to the type of texture in use.
  44525. */
  44526. environmentBRDFTexture: BaseTexture;
  44527. /**
  44528. * Texture used in all pbr material as the reflection texture.
  44529. * As in the majority of the scene they are the same (exception for multi room and so on),
  44530. * this is easier to reference from here than from all the materials.
  44531. */
  44532. get environmentTexture(): Nullable<BaseTexture>;
  44533. /**
  44534. * Texture used in all pbr material as the reflection texture.
  44535. * As in the majority of the scene they are the same (exception for multi room and so on),
  44536. * this is easier to set here than in all the materials.
  44537. */
  44538. set environmentTexture(value: Nullable<BaseTexture>);
  44539. /** @hidden */
  44540. protected _environmentIntensity: number;
  44541. /**
  44542. * Intensity of the environment in all pbr material.
  44543. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44544. * As in the majority of the scene they are the same (exception for multi room and so on),
  44545. * this is easier to reference from here than from all the materials.
  44546. */
  44547. get environmentIntensity(): number;
  44548. /**
  44549. * Intensity of the environment in all pbr material.
  44550. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44551. * As in the majority of the scene they are the same (exception for multi room and so on),
  44552. * this is easier to set here than in all the materials.
  44553. */
  44554. set environmentIntensity(value: number);
  44555. /** @hidden */
  44556. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44557. /**
  44558. * Default image processing configuration used either in the rendering
  44559. * Forward main pass or through the imageProcessingPostProcess if present.
  44560. * As in the majority of the scene they are the same (exception for multi camera),
  44561. * this is easier to reference from here than from all the materials and post process.
  44562. *
  44563. * No setter as we it is a shared configuration, you can set the values instead.
  44564. */
  44565. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44566. private _forceWireframe;
  44567. /**
  44568. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44569. */
  44570. set forceWireframe(value: boolean);
  44571. get forceWireframe(): boolean;
  44572. private _skipFrustumClipping;
  44573. /**
  44574. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44575. */
  44576. set skipFrustumClipping(value: boolean);
  44577. get skipFrustumClipping(): boolean;
  44578. private _forcePointsCloud;
  44579. /**
  44580. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44581. */
  44582. set forcePointsCloud(value: boolean);
  44583. get forcePointsCloud(): boolean;
  44584. /**
  44585. * Gets or sets the active clipplane 1
  44586. */
  44587. clipPlane: Nullable<Plane>;
  44588. /**
  44589. * Gets or sets the active clipplane 2
  44590. */
  44591. clipPlane2: Nullable<Plane>;
  44592. /**
  44593. * Gets or sets the active clipplane 3
  44594. */
  44595. clipPlane3: Nullable<Plane>;
  44596. /**
  44597. * Gets or sets the active clipplane 4
  44598. */
  44599. clipPlane4: Nullable<Plane>;
  44600. /**
  44601. * Gets or sets the active clipplane 5
  44602. */
  44603. clipPlane5: Nullable<Plane>;
  44604. /**
  44605. * Gets or sets the active clipplane 6
  44606. */
  44607. clipPlane6: Nullable<Plane>;
  44608. /**
  44609. * Gets or sets a boolean indicating if animations are enabled
  44610. */
  44611. animationsEnabled: boolean;
  44612. private _animationPropertiesOverride;
  44613. /**
  44614. * Gets or sets the animation properties override
  44615. */
  44616. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44617. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44618. /**
  44619. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44620. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44621. */
  44622. useConstantAnimationDeltaTime: boolean;
  44623. /**
  44624. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44625. * Please note that it requires to run a ray cast through the scene on every frame
  44626. */
  44627. constantlyUpdateMeshUnderPointer: boolean;
  44628. /**
  44629. * Defines the HTML cursor to use when hovering over interactive elements
  44630. */
  44631. hoverCursor: string;
  44632. /**
  44633. * Defines the HTML default cursor to use (empty by default)
  44634. */
  44635. defaultCursor: string;
  44636. /**
  44637. * Defines whether cursors are handled by the scene.
  44638. */
  44639. doNotHandleCursors: boolean;
  44640. /**
  44641. * This is used to call preventDefault() on pointer down
  44642. * in order to block unwanted artifacts like system double clicks
  44643. */
  44644. preventDefaultOnPointerDown: boolean;
  44645. /**
  44646. * This is used to call preventDefault() on pointer up
  44647. * in order to block unwanted artifacts like system double clicks
  44648. */
  44649. preventDefaultOnPointerUp: boolean;
  44650. /**
  44651. * Gets or sets user defined metadata
  44652. */
  44653. metadata: any;
  44654. /**
  44655. * For internal use only. Please do not use.
  44656. */
  44657. reservedDataStore: any;
  44658. /**
  44659. * Gets the name of the plugin used to load this scene (null by default)
  44660. */
  44661. loadingPluginName: string;
  44662. /**
  44663. * Use this array to add regular expressions used to disable offline support for specific urls
  44664. */
  44665. disableOfflineSupportExceptionRules: RegExp[];
  44666. /**
  44667. * An event triggered when the scene is disposed.
  44668. */
  44669. onDisposeObservable: Observable<Scene>;
  44670. private _onDisposeObserver;
  44671. /** Sets a function to be executed when this scene is disposed. */
  44672. set onDispose(callback: () => void);
  44673. /**
  44674. * An event triggered before rendering the scene (right after animations and physics)
  44675. */
  44676. onBeforeRenderObservable: Observable<Scene>;
  44677. private _onBeforeRenderObserver;
  44678. /** Sets a function to be executed before rendering this scene */
  44679. set beforeRender(callback: Nullable<() => void>);
  44680. /**
  44681. * An event triggered after rendering the scene
  44682. */
  44683. onAfterRenderObservable: Observable<Scene>;
  44684. /**
  44685. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44686. */
  44687. onAfterRenderCameraObservable: Observable<Camera>;
  44688. private _onAfterRenderObserver;
  44689. /** Sets a function to be executed after rendering this scene */
  44690. set afterRender(callback: Nullable<() => void>);
  44691. /**
  44692. * An event triggered before animating the scene
  44693. */
  44694. onBeforeAnimationsObservable: Observable<Scene>;
  44695. /**
  44696. * An event triggered after animations processing
  44697. */
  44698. onAfterAnimationsObservable: Observable<Scene>;
  44699. /**
  44700. * An event triggered before draw calls are ready to be sent
  44701. */
  44702. onBeforeDrawPhaseObservable: Observable<Scene>;
  44703. /**
  44704. * An event triggered after draw calls have been sent
  44705. */
  44706. onAfterDrawPhaseObservable: Observable<Scene>;
  44707. /**
  44708. * An event triggered when the scene is ready
  44709. */
  44710. onReadyObservable: Observable<Scene>;
  44711. /**
  44712. * An event triggered before rendering a camera
  44713. */
  44714. onBeforeCameraRenderObservable: Observable<Camera>;
  44715. private _onBeforeCameraRenderObserver;
  44716. /** Sets a function to be executed before rendering a camera*/
  44717. set beforeCameraRender(callback: () => void);
  44718. /**
  44719. * An event triggered after rendering a camera
  44720. */
  44721. onAfterCameraRenderObservable: Observable<Camera>;
  44722. private _onAfterCameraRenderObserver;
  44723. /** Sets a function to be executed after rendering a camera*/
  44724. set afterCameraRender(callback: () => void);
  44725. /**
  44726. * An event triggered when active meshes evaluation is about to start
  44727. */
  44728. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44729. /**
  44730. * An event triggered when active meshes evaluation is done
  44731. */
  44732. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44733. /**
  44734. * An event triggered when particles rendering is about to start
  44735. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44736. */
  44737. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44738. /**
  44739. * An event triggered when particles rendering is done
  44740. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44741. */
  44742. onAfterParticlesRenderingObservable: Observable<Scene>;
  44743. /**
  44744. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44745. */
  44746. onDataLoadedObservable: Observable<Scene>;
  44747. /**
  44748. * An event triggered when a camera is created
  44749. */
  44750. onNewCameraAddedObservable: Observable<Camera>;
  44751. /**
  44752. * An event triggered when a camera is removed
  44753. */
  44754. onCameraRemovedObservable: Observable<Camera>;
  44755. /**
  44756. * An event triggered when a light is created
  44757. */
  44758. onNewLightAddedObservable: Observable<Light>;
  44759. /**
  44760. * An event triggered when a light is removed
  44761. */
  44762. onLightRemovedObservable: Observable<Light>;
  44763. /**
  44764. * An event triggered when a geometry is created
  44765. */
  44766. onNewGeometryAddedObservable: Observable<Geometry>;
  44767. /**
  44768. * An event triggered when a geometry is removed
  44769. */
  44770. onGeometryRemovedObservable: Observable<Geometry>;
  44771. /**
  44772. * An event triggered when a transform node is created
  44773. */
  44774. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44775. /**
  44776. * An event triggered when a transform node is removed
  44777. */
  44778. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44779. /**
  44780. * An event triggered when a mesh is created
  44781. */
  44782. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44783. /**
  44784. * An event triggered when a mesh is removed
  44785. */
  44786. onMeshRemovedObservable: Observable<AbstractMesh>;
  44787. /**
  44788. * An event triggered when a skeleton is created
  44789. */
  44790. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44791. /**
  44792. * An event triggered when a skeleton is removed
  44793. */
  44794. onSkeletonRemovedObservable: Observable<Skeleton>;
  44795. /**
  44796. * An event triggered when a material is created
  44797. */
  44798. onNewMaterialAddedObservable: Observable<Material>;
  44799. /**
  44800. * An event triggered when a multi material is created
  44801. */
  44802. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  44803. /**
  44804. * An event triggered when a material is removed
  44805. */
  44806. onMaterialRemovedObservable: Observable<Material>;
  44807. /**
  44808. * An event triggered when a multi material is removed
  44809. */
  44810. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  44811. /**
  44812. * An event triggered when a texture is created
  44813. */
  44814. onNewTextureAddedObservable: Observable<BaseTexture>;
  44815. /**
  44816. * An event triggered when a texture is removed
  44817. */
  44818. onTextureRemovedObservable: Observable<BaseTexture>;
  44819. /**
  44820. * An event triggered when render targets are about to be rendered
  44821. * Can happen multiple times per frame.
  44822. */
  44823. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44824. /**
  44825. * An event triggered when render targets were rendered.
  44826. * Can happen multiple times per frame.
  44827. */
  44828. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44829. /**
  44830. * An event triggered before calculating deterministic simulation step
  44831. */
  44832. onBeforeStepObservable: Observable<Scene>;
  44833. /**
  44834. * An event triggered after calculating deterministic simulation step
  44835. */
  44836. onAfterStepObservable: Observable<Scene>;
  44837. /**
  44838. * An event triggered when the activeCamera property is updated
  44839. */
  44840. onActiveCameraChanged: Observable<Scene>;
  44841. /**
  44842. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44843. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44844. * 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)
  44845. */
  44846. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44847. /**
  44848. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44849. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44850. * 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)
  44851. */
  44852. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44853. /**
  44854. * This Observable will when a mesh has been imported into the scene.
  44855. */
  44856. onMeshImportedObservable: Observable<AbstractMesh>;
  44857. /**
  44858. * This Observable will when an animation file has been imported into the scene.
  44859. */
  44860. onAnimationFileImportedObservable: Observable<Scene>;
  44861. /**
  44862. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44863. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44864. */
  44865. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44866. /** @hidden */
  44867. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44868. /**
  44869. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44870. */
  44871. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44872. /**
  44873. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44874. */
  44875. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44876. /**
  44877. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44878. */
  44879. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44880. /** Callback called when a pointer move is detected */
  44881. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44882. /** Callback called when a pointer down is detected */
  44883. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44884. /** Callback called when a pointer up is detected */
  44885. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44886. /** Callback called when a pointer pick is detected */
  44887. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44888. /**
  44889. * 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).
  44890. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44891. */
  44892. onPrePointerObservable: Observable<PointerInfoPre>;
  44893. /**
  44894. * Observable event triggered each time an input event is received from the rendering canvas
  44895. */
  44896. onPointerObservable: Observable<PointerInfo>;
  44897. /**
  44898. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44899. */
  44900. get unTranslatedPointer(): Vector2;
  44901. /**
  44902. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44903. */
  44904. static get DragMovementThreshold(): number;
  44905. static set DragMovementThreshold(value: number);
  44906. /**
  44907. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44908. */
  44909. static get LongPressDelay(): number;
  44910. static set LongPressDelay(value: number);
  44911. /**
  44912. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44913. */
  44914. static get DoubleClickDelay(): number;
  44915. static set DoubleClickDelay(value: number);
  44916. /** If you need to check double click without raising a single click at first click, enable this flag */
  44917. static get ExclusiveDoubleClickMode(): boolean;
  44918. static set ExclusiveDoubleClickMode(value: boolean);
  44919. /** @hidden */
  44920. _mirroredCameraPosition: Nullable<Vector3>;
  44921. /**
  44922. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44923. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44924. */
  44925. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44926. /**
  44927. * Observable event triggered each time an keyboard event is received from the hosting window
  44928. */
  44929. onKeyboardObservable: Observable<KeyboardInfo>;
  44930. private _useRightHandedSystem;
  44931. /**
  44932. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44933. */
  44934. set useRightHandedSystem(value: boolean);
  44935. get useRightHandedSystem(): boolean;
  44936. private _timeAccumulator;
  44937. private _currentStepId;
  44938. private _currentInternalStep;
  44939. /**
  44940. * Sets the step Id used by deterministic lock step
  44941. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44942. * @param newStepId defines the step Id
  44943. */
  44944. setStepId(newStepId: number): void;
  44945. /**
  44946. * Gets the step Id used by deterministic lock step
  44947. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44948. * @returns the step Id
  44949. */
  44950. getStepId(): number;
  44951. /**
  44952. * Gets the internal step used by deterministic lock step
  44953. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44954. * @returns the internal step
  44955. */
  44956. getInternalStep(): number;
  44957. private _fogEnabled;
  44958. /**
  44959. * Gets or sets a boolean indicating if fog is enabled on this scene
  44960. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44961. * (Default is true)
  44962. */
  44963. set fogEnabled(value: boolean);
  44964. get fogEnabled(): boolean;
  44965. private _fogMode;
  44966. /**
  44967. * Gets or sets the fog mode to use
  44968. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44969. * | mode | value |
  44970. * | --- | --- |
  44971. * | FOGMODE_NONE | 0 |
  44972. * | FOGMODE_EXP | 1 |
  44973. * | FOGMODE_EXP2 | 2 |
  44974. * | FOGMODE_LINEAR | 3 |
  44975. */
  44976. set fogMode(value: number);
  44977. get fogMode(): number;
  44978. /**
  44979. * Gets or sets the fog color to use
  44980. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44981. * (Default is Color3(0.2, 0.2, 0.3))
  44982. */
  44983. fogColor: Color3;
  44984. /**
  44985. * Gets or sets the fog density to use
  44986. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44987. * (Default is 0.1)
  44988. */
  44989. fogDensity: number;
  44990. /**
  44991. * Gets or sets the fog start distance to use
  44992. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44993. * (Default is 0)
  44994. */
  44995. fogStart: number;
  44996. /**
  44997. * Gets or sets the fog end distance to use
  44998. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44999. * (Default is 1000)
  45000. */
  45001. fogEnd: number;
  45002. /**
  45003. * Flag indicating that the frame buffer binding is handled by another component
  45004. */
  45005. prePass: boolean;
  45006. private _shadowsEnabled;
  45007. /**
  45008. * Gets or sets a boolean indicating if shadows are enabled on this scene
  45009. */
  45010. set shadowsEnabled(value: boolean);
  45011. get shadowsEnabled(): boolean;
  45012. private _lightsEnabled;
  45013. /**
  45014. * Gets or sets a boolean indicating if lights are enabled on this scene
  45015. */
  45016. set lightsEnabled(value: boolean);
  45017. get lightsEnabled(): boolean;
  45018. /** All of the active cameras added to this scene. */
  45019. activeCameras: Camera[];
  45020. /** @hidden */
  45021. _activeCamera: Nullable<Camera>;
  45022. /** Gets or sets the current active camera */
  45023. get activeCamera(): Nullable<Camera>;
  45024. set activeCamera(value: Nullable<Camera>);
  45025. private _defaultMaterial;
  45026. /** The default material used on meshes when no material is affected */
  45027. get defaultMaterial(): Material;
  45028. /** The default material used on meshes when no material is affected */
  45029. set defaultMaterial(value: Material);
  45030. private _texturesEnabled;
  45031. /**
  45032. * Gets or sets a boolean indicating if textures are enabled on this scene
  45033. */
  45034. set texturesEnabled(value: boolean);
  45035. get texturesEnabled(): boolean;
  45036. /**
  45037. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  45038. */
  45039. physicsEnabled: boolean;
  45040. /**
  45041. * Gets or sets a boolean indicating if particles are enabled on this scene
  45042. */
  45043. particlesEnabled: boolean;
  45044. /**
  45045. * Gets or sets a boolean indicating if sprites are enabled on this scene
  45046. */
  45047. spritesEnabled: boolean;
  45048. private _skeletonsEnabled;
  45049. /**
  45050. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  45051. */
  45052. set skeletonsEnabled(value: boolean);
  45053. get skeletonsEnabled(): boolean;
  45054. /**
  45055. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  45056. */
  45057. lensFlaresEnabled: boolean;
  45058. /**
  45059. * Gets or sets a boolean indicating if collisions are enabled on this scene
  45060. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  45061. */
  45062. collisionsEnabled: boolean;
  45063. private _collisionCoordinator;
  45064. /** @hidden */
  45065. get collisionCoordinator(): ICollisionCoordinator;
  45066. /**
  45067. * Defines the gravity applied to this scene (used only for collisions)
  45068. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  45069. */
  45070. gravity: Vector3;
  45071. /**
  45072. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  45073. */
  45074. postProcessesEnabled: boolean;
  45075. /**
  45076. * Gets the current postprocess manager
  45077. */
  45078. postProcessManager: PostProcessManager;
  45079. /**
  45080. * Gets or sets a boolean indicating if render targets are enabled on this scene
  45081. */
  45082. renderTargetsEnabled: boolean;
  45083. /**
  45084. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  45085. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  45086. */
  45087. dumpNextRenderTargets: boolean;
  45088. /**
  45089. * The list of user defined render targets added to the scene
  45090. */
  45091. customRenderTargets: RenderTargetTexture[];
  45092. /**
  45093. * Defines if texture loading must be delayed
  45094. * If true, textures will only be loaded when they need to be rendered
  45095. */
  45096. useDelayedTextureLoading: boolean;
  45097. /**
  45098. * Gets the list of meshes imported to the scene through SceneLoader
  45099. */
  45100. importedMeshesFiles: String[];
  45101. /**
  45102. * Gets or sets a boolean indicating if probes are enabled on this scene
  45103. */
  45104. probesEnabled: boolean;
  45105. /**
  45106. * Gets or sets the current offline provider to use to store scene data
  45107. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  45108. */
  45109. offlineProvider: IOfflineProvider;
  45110. /**
  45111. * Gets or sets the action manager associated with the scene
  45112. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45113. */
  45114. actionManager: AbstractActionManager;
  45115. private _meshesForIntersections;
  45116. /**
  45117. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  45118. */
  45119. proceduralTexturesEnabled: boolean;
  45120. private _engine;
  45121. private _totalVertices;
  45122. /** @hidden */
  45123. _activeIndices: PerfCounter;
  45124. /** @hidden */
  45125. _activeParticles: PerfCounter;
  45126. /** @hidden */
  45127. _activeBones: PerfCounter;
  45128. private _animationRatio;
  45129. /** @hidden */
  45130. _animationTimeLast: number;
  45131. /** @hidden */
  45132. _animationTime: number;
  45133. /**
  45134. * Gets or sets a general scale for animation speed
  45135. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  45136. */
  45137. animationTimeScale: number;
  45138. /** @hidden */
  45139. _cachedMaterial: Nullable<Material>;
  45140. /** @hidden */
  45141. _cachedEffect: Nullable<Effect>;
  45142. /** @hidden */
  45143. _cachedVisibility: Nullable<number>;
  45144. private _renderId;
  45145. private _frameId;
  45146. private _executeWhenReadyTimeoutId;
  45147. private _intermediateRendering;
  45148. private _viewUpdateFlag;
  45149. private _projectionUpdateFlag;
  45150. /** @hidden */
  45151. _toBeDisposed: Nullable<IDisposable>[];
  45152. private _activeRequests;
  45153. /** @hidden */
  45154. _pendingData: any[];
  45155. private _isDisposed;
  45156. /**
  45157. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  45158. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  45159. */
  45160. dispatchAllSubMeshesOfActiveMeshes: boolean;
  45161. private _activeMeshes;
  45162. private _processedMaterials;
  45163. private _renderTargets;
  45164. /** @hidden */
  45165. _activeParticleSystems: SmartArray<IParticleSystem>;
  45166. private _activeSkeletons;
  45167. private _softwareSkinnedMeshes;
  45168. private _renderingManager;
  45169. /** @hidden */
  45170. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  45171. private _transformMatrix;
  45172. private _sceneUbo;
  45173. /** @hidden */
  45174. _viewMatrix: Matrix;
  45175. private _projectionMatrix;
  45176. /** @hidden */
  45177. _forcedViewPosition: Nullable<Vector3>;
  45178. /** @hidden */
  45179. _frustumPlanes: Plane[];
  45180. /**
  45181. * Gets the list of frustum planes (built from the active camera)
  45182. */
  45183. get frustumPlanes(): Plane[];
  45184. /**
  45185. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  45186. * This is useful if there are more lights that the maximum simulteanous authorized
  45187. */
  45188. requireLightSorting: boolean;
  45189. /** @hidden */
  45190. readonly useMaterialMeshMap: boolean;
  45191. /** @hidden */
  45192. readonly useClonedMeshMap: boolean;
  45193. private _externalData;
  45194. private _uid;
  45195. /**
  45196. * @hidden
  45197. * Backing store of defined scene components.
  45198. */
  45199. _components: ISceneComponent[];
  45200. /**
  45201. * @hidden
  45202. * Backing store of defined scene components.
  45203. */
  45204. _serializableComponents: ISceneSerializableComponent[];
  45205. /**
  45206. * List of components to register on the next registration step.
  45207. */
  45208. private _transientComponents;
  45209. /**
  45210. * Registers the transient components if needed.
  45211. */
  45212. private _registerTransientComponents;
  45213. /**
  45214. * @hidden
  45215. * Add a component to the scene.
  45216. * Note that the ccomponent could be registered on th next frame if this is called after
  45217. * the register component stage.
  45218. * @param component Defines the component to add to the scene
  45219. */
  45220. _addComponent(component: ISceneComponent): void;
  45221. /**
  45222. * @hidden
  45223. * Gets a component from the scene.
  45224. * @param name defines the name of the component to retrieve
  45225. * @returns the component or null if not present
  45226. */
  45227. _getComponent(name: string): Nullable<ISceneComponent>;
  45228. /**
  45229. * @hidden
  45230. * Defines the actions happening before camera updates.
  45231. */
  45232. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  45233. /**
  45234. * @hidden
  45235. * Defines the actions happening before clear the canvas.
  45236. */
  45237. _beforeClearStage: Stage<SimpleStageAction>;
  45238. /**
  45239. * @hidden
  45240. * Defines the actions when collecting render targets for the frame.
  45241. */
  45242. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  45243. /**
  45244. * @hidden
  45245. * Defines the actions happening for one camera in the frame.
  45246. */
  45247. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  45248. /**
  45249. * @hidden
  45250. * Defines the actions happening during the per mesh ready checks.
  45251. */
  45252. _isReadyForMeshStage: Stage<MeshStageAction>;
  45253. /**
  45254. * @hidden
  45255. * Defines the actions happening before evaluate active mesh checks.
  45256. */
  45257. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  45258. /**
  45259. * @hidden
  45260. * Defines the actions happening during the evaluate sub mesh checks.
  45261. */
  45262. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  45263. /**
  45264. * @hidden
  45265. * Defines the actions happening during the active mesh stage.
  45266. */
  45267. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  45268. /**
  45269. * @hidden
  45270. * Defines the actions happening during the per camera render target step.
  45271. */
  45272. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  45273. /**
  45274. * @hidden
  45275. * Defines the actions happening just before the active camera is drawing.
  45276. */
  45277. _beforeCameraDrawStage: Stage<CameraStageAction>;
  45278. /**
  45279. * @hidden
  45280. * Defines the actions happening just before a render target is drawing.
  45281. */
  45282. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45283. /**
  45284. * @hidden
  45285. * Defines the actions happening just before a rendering group is drawing.
  45286. */
  45287. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45288. /**
  45289. * @hidden
  45290. * Defines the actions happening just before a mesh is drawing.
  45291. */
  45292. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45293. /**
  45294. * @hidden
  45295. * Defines the actions happening just after a mesh has been drawn.
  45296. */
  45297. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45298. /**
  45299. * @hidden
  45300. * Defines the actions happening just after a rendering group has been drawn.
  45301. */
  45302. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45303. /**
  45304. * @hidden
  45305. * Defines the actions happening just after the active camera has been drawn.
  45306. */
  45307. _afterCameraDrawStage: Stage<CameraStageAction>;
  45308. /**
  45309. * @hidden
  45310. * Defines the actions happening just after a render target has been drawn.
  45311. */
  45312. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45313. /**
  45314. * @hidden
  45315. * Defines the actions happening just after rendering all cameras and computing intersections.
  45316. */
  45317. _afterRenderStage: Stage<SimpleStageAction>;
  45318. /**
  45319. * @hidden
  45320. * Defines the actions happening when a pointer move event happens.
  45321. */
  45322. _pointerMoveStage: Stage<PointerMoveStageAction>;
  45323. /**
  45324. * @hidden
  45325. * Defines the actions happening when a pointer down event happens.
  45326. */
  45327. _pointerDownStage: Stage<PointerUpDownStageAction>;
  45328. /**
  45329. * @hidden
  45330. * Defines the actions happening when a pointer up event happens.
  45331. */
  45332. _pointerUpStage: Stage<PointerUpDownStageAction>;
  45333. /**
  45334. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  45335. */
  45336. private geometriesByUniqueId;
  45337. /**
  45338. * Creates a new Scene
  45339. * @param engine defines the engine to use to render this scene
  45340. * @param options defines the scene options
  45341. */
  45342. constructor(engine: Engine, options?: SceneOptions);
  45343. /**
  45344. * Gets a string identifying the name of the class
  45345. * @returns "Scene" string
  45346. */
  45347. getClassName(): string;
  45348. private _defaultMeshCandidates;
  45349. /**
  45350. * @hidden
  45351. */
  45352. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45353. private _defaultSubMeshCandidates;
  45354. /**
  45355. * @hidden
  45356. */
  45357. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45358. /**
  45359. * Sets the default candidate providers for the scene.
  45360. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  45361. * and getCollidingSubMeshCandidates to their default function
  45362. */
  45363. setDefaultCandidateProviders(): void;
  45364. /**
  45365. * Gets the mesh that is currently under the pointer
  45366. */
  45367. get meshUnderPointer(): Nullable<AbstractMesh>;
  45368. /**
  45369. * Gets or sets the current on-screen X position of the pointer
  45370. */
  45371. get pointerX(): number;
  45372. set pointerX(value: number);
  45373. /**
  45374. * Gets or sets the current on-screen Y position of the pointer
  45375. */
  45376. get pointerY(): number;
  45377. set pointerY(value: number);
  45378. /**
  45379. * Gets the cached material (ie. the latest rendered one)
  45380. * @returns the cached material
  45381. */
  45382. getCachedMaterial(): Nullable<Material>;
  45383. /**
  45384. * Gets the cached effect (ie. the latest rendered one)
  45385. * @returns the cached effect
  45386. */
  45387. getCachedEffect(): Nullable<Effect>;
  45388. /**
  45389. * Gets the cached visibility state (ie. the latest rendered one)
  45390. * @returns the cached visibility state
  45391. */
  45392. getCachedVisibility(): Nullable<number>;
  45393. /**
  45394. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  45395. * @param material defines the current material
  45396. * @param effect defines the current effect
  45397. * @param visibility defines the current visibility state
  45398. * @returns true if one parameter is not cached
  45399. */
  45400. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  45401. /**
  45402. * Gets the engine associated with the scene
  45403. * @returns an Engine
  45404. */
  45405. getEngine(): Engine;
  45406. /**
  45407. * Gets the total number of vertices rendered per frame
  45408. * @returns the total number of vertices rendered per frame
  45409. */
  45410. getTotalVertices(): number;
  45411. /**
  45412. * Gets the performance counter for total vertices
  45413. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45414. */
  45415. get totalVerticesPerfCounter(): PerfCounter;
  45416. /**
  45417. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  45418. * @returns the total number of active indices rendered per frame
  45419. */
  45420. getActiveIndices(): number;
  45421. /**
  45422. * Gets the performance counter for active indices
  45423. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45424. */
  45425. get totalActiveIndicesPerfCounter(): PerfCounter;
  45426. /**
  45427. * Gets the total number of active particles rendered per frame
  45428. * @returns the total number of active particles rendered per frame
  45429. */
  45430. getActiveParticles(): number;
  45431. /**
  45432. * Gets the performance counter for active particles
  45433. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45434. */
  45435. get activeParticlesPerfCounter(): PerfCounter;
  45436. /**
  45437. * Gets the total number of active bones rendered per frame
  45438. * @returns the total number of active bones rendered per frame
  45439. */
  45440. getActiveBones(): number;
  45441. /**
  45442. * Gets the performance counter for active bones
  45443. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45444. */
  45445. get activeBonesPerfCounter(): PerfCounter;
  45446. /**
  45447. * Gets the array of active meshes
  45448. * @returns an array of AbstractMesh
  45449. */
  45450. getActiveMeshes(): SmartArray<AbstractMesh>;
  45451. /**
  45452. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  45453. * @returns a number
  45454. */
  45455. getAnimationRatio(): number;
  45456. /**
  45457. * Gets an unique Id for the current render phase
  45458. * @returns a number
  45459. */
  45460. getRenderId(): number;
  45461. /**
  45462. * Gets an unique Id for the current frame
  45463. * @returns a number
  45464. */
  45465. getFrameId(): number;
  45466. /** Call this function if you want to manually increment the render Id*/
  45467. incrementRenderId(): void;
  45468. private _createUbo;
  45469. /**
  45470. * Use this method to simulate a pointer move on a mesh
  45471. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45472. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45473. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45474. * @returns the current scene
  45475. */
  45476. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45477. /**
  45478. * Use this method to simulate a pointer down on a mesh
  45479. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45480. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45481. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45482. * @returns the current scene
  45483. */
  45484. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45485. /**
  45486. * Use this method to simulate a pointer up on a mesh
  45487. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45488. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45489. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45490. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45491. * @returns the current scene
  45492. */
  45493. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  45494. /**
  45495. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45496. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45497. * @returns true if the pointer was captured
  45498. */
  45499. isPointerCaptured(pointerId?: number): boolean;
  45500. /**
  45501. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45502. * @param attachUp defines if you want to attach events to pointerup
  45503. * @param attachDown defines if you want to attach events to pointerdown
  45504. * @param attachMove defines if you want to attach events to pointermove
  45505. */
  45506. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  45507. /** Detaches all event handlers*/
  45508. detachControl(): void;
  45509. /**
  45510. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  45511. * Delay loaded resources are not taking in account
  45512. * @return true if all required resources are ready
  45513. */
  45514. isReady(): boolean;
  45515. /** Resets all cached information relative to material (including effect and visibility) */
  45516. resetCachedMaterial(): void;
  45517. /**
  45518. * Registers a function to be called before every frame render
  45519. * @param func defines the function to register
  45520. */
  45521. registerBeforeRender(func: () => void): void;
  45522. /**
  45523. * Unregisters a function called before every frame render
  45524. * @param func defines the function to unregister
  45525. */
  45526. unregisterBeforeRender(func: () => void): void;
  45527. /**
  45528. * Registers a function to be called after every frame render
  45529. * @param func defines the function to register
  45530. */
  45531. registerAfterRender(func: () => void): void;
  45532. /**
  45533. * Unregisters a function called after every frame render
  45534. * @param func defines the function to unregister
  45535. */
  45536. unregisterAfterRender(func: () => void): void;
  45537. private _executeOnceBeforeRender;
  45538. /**
  45539. * The provided function will run before render once and will be disposed afterwards.
  45540. * A timeout delay can be provided so that the function will be executed in N ms.
  45541. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45542. * @param func The function to be executed.
  45543. * @param timeout optional delay in ms
  45544. */
  45545. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45546. /** @hidden */
  45547. _addPendingData(data: any): void;
  45548. /** @hidden */
  45549. _removePendingData(data: any): void;
  45550. /**
  45551. * Returns the number of items waiting to be loaded
  45552. * @returns the number of items waiting to be loaded
  45553. */
  45554. getWaitingItemsCount(): number;
  45555. /**
  45556. * Returns a boolean indicating if the scene is still loading data
  45557. */
  45558. get isLoading(): boolean;
  45559. /**
  45560. * Registers a function to be executed when the scene is ready
  45561. * @param {Function} func - the function to be executed
  45562. */
  45563. executeWhenReady(func: () => void): void;
  45564. /**
  45565. * Returns a promise that resolves when the scene is ready
  45566. * @returns A promise that resolves when the scene is ready
  45567. */
  45568. whenReadyAsync(): Promise<void>;
  45569. /** @hidden */
  45570. _checkIsReady(): void;
  45571. /**
  45572. * Gets all animatable attached to the scene
  45573. */
  45574. get animatables(): Animatable[];
  45575. /**
  45576. * Resets the last animation time frame.
  45577. * Useful to override when animations start running when loading a scene for the first time.
  45578. */
  45579. resetLastAnimationTimeFrame(): void;
  45580. /**
  45581. * Gets the current view matrix
  45582. * @returns a Matrix
  45583. */
  45584. getViewMatrix(): Matrix;
  45585. /**
  45586. * Gets the current projection matrix
  45587. * @returns a Matrix
  45588. */
  45589. getProjectionMatrix(): Matrix;
  45590. /**
  45591. * Gets the current transform matrix
  45592. * @returns a Matrix made of View * Projection
  45593. */
  45594. getTransformMatrix(): Matrix;
  45595. /**
  45596. * Sets the current transform matrix
  45597. * @param viewL defines the View matrix to use
  45598. * @param projectionL defines the Projection matrix to use
  45599. * @param viewR defines the right View matrix to use (if provided)
  45600. * @param projectionR defines the right Projection matrix to use (if provided)
  45601. */
  45602. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45603. /**
  45604. * Gets the uniform buffer used to store scene data
  45605. * @returns a UniformBuffer
  45606. */
  45607. getSceneUniformBuffer(): UniformBuffer;
  45608. /**
  45609. * Gets an unique (relatively to the current scene) Id
  45610. * @returns an unique number for the scene
  45611. */
  45612. getUniqueId(): number;
  45613. /**
  45614. * Add a mesh to the list of scene's meshes
  45615. * @param newMesh defines the mesh to add
  45616. * @param recursive if all child meshes should also be added to the scene
  45617. */
  45618. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45619. /**
  45620. * Remove a mesh for the list of scene's meshes
  45621. * @param toRemove defines the mesh to remove
  45622. * @param recursive if all child meshes should also be removed from the scene
  45623. * @returns the index where the mesh was in the mesh list
  45624. */
  45625. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45626. /**
  45627. * Add a transform node to the list of scene's transform nodes
  45628. * @param newTransformNode defines the transform node to add
  45629. */
  45630. addTransformNode(newTransformNode: TransformNode): void;
  45631. /**
  45632. * Remove a transform node for the list of scene's transform nodes
  45633. * @param toRemove defines the transform node to remove
  45634. * @returns the index where the transform node was in the transform node list
  45635. */
  45636. removeTransformNode(toRemove: TransformNode): number;
  45637. /**
  45638. * Remove a skeleton for the list of scene's skeletons
  45639. * @param toRemove defines the skeleton to remove
  45640. * @returns the index where the skeleton was in the skeleton list
  45641. */
  45642. removeSkeleton(toRemove: Skeleton): number;
  45643. /**
  45644. * Remove a morph target for the list of scene's morph targets
  45645. * @param toRemove defines the morph target to remove
  45646. * @returns the index where the morph target was in the morph target list
  45647. */
  45648. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45649. /**
  45650. * Remove a light for the list of scene's lights
  45651. * @param toRemove defines the light to remove
  45652. * @returns the index where the light was in the light list
  45653. */
  45654. removeLight(toRemove: Light): number;
  45655. /**
  45656. * Remove a camera for the list of scene's cameras
  45657. * @param toRemove defines the camera to remove
  45658. * @returns the index where the camera was in the camera list
  45659. */
  45660. removeCamera(toRemove: Camera): number;
  45661. /**
  45662. * Remove a particle system for the list of scene's particle systems
  45663. * @param toRemove defines the particle system to remove
  45664. * @returns the index where the particle system was in the particle system list
  45665. */
  45666. removeParticleSystem(toRemove: IParticleSystem): number;
  45667. /**
  45668. * Remove a animation for the list of scene's animations
  45669. * @param toRemove defines the animation to remove
  45670. * @returns the index where the animation was in the animation list
  45671. */
  45672. removeAnimation(toRemove: Animation): number;
  45673. /**
  45674. * Will stop the animation of the given target
  45675. * @param target - the target
  45676. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45677. * @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)
  45678. */
  45679. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45680. /**
  45681. * Removes the given animation group from this scene.
  45682. * @param toRemove The animation group to remove
  45683. * @returns The index of the removed animation group
  45684. */
  45685. removeAnimationGroup(toRemove: AnimationGroup): number;
  45686. /**
  45687. * Removes the given multi-material from this scene.
  45688. * @param toRemove The multi-material to remove
  45689. * @returns The index of the removed multi-material
  45690. */
  45691. removeMultiMaterial(toRemove: MultiMaterial): number;
  45692. /**
  45693. * Removes the given material from this scene.
  45694. * @param toRemove The material to remove
  45695. * @returns The index of the removed material
  45696. */
  45697. removeMaterial(toRemove: Material): number;
  45698. /**
  45699. * Removes the given action manager from this scene.
  45700. * @param toRemove The action manager to remove
  45701. * @returns The index of the removed action manager
  45702. */
  45703. removeActionManager(toRemove: AbstractActionManager): number;
  45704. /**
  45705. * Removes the given texture from this scene.
  45706. * @param toRemove The texture to remove
  45707. * @returns The index of the removed texture
  45708. */
  45709. removeTexture(toRemove: BaseTexture): number;
  45710. /**
  45711. * Adds the given light to this scene
  45712. * @param newLight The light to add
  45713. */
  45714. addLight(newLight: Light): void;
  45715. /**
  45716. * Sorts the list list based on light priorities
  45717. */
  45718. sortLightsByPriority(): void;
  45719. /**
  45720. * Adds the given camera to this scene
  45721. * @param newCamera The camera to add
  45722. */
  45723. addCamera(newCamera: Camera): void;
  45724. /**
  45725. * Adds the given skeleton to this scene
  45726. * @param newSkeleton The skeleton to add
  45727. */
  45728. addSkeleton(newSkeleton: Skeleton): void;
  45729. /**
  45730. * Adds the given particle system to this scene
  45731. * @param newParticleSystem The particle system to add
  45732. */
  45733. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45734. /**
  45735. * Adds the given animation to this scene
  45736. * @param newAnimation The animation to add
  45737. */
  45738. addAnimation(newAnimation: Animation): void;
  45739. /**
  45740. * Adds the given animation group to this scene.
  45741. * @param newAnimationGroup The animation group to add
  45742. */
  45743. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45744. /**
  45745. * Adds the given multi-material to this scene
  45746. * @param newMultiMaterial The multi-material to add
  45747. */
  45748. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45749. /**
  45750. * Adds the given material to this scene
  45751. * @param newMaterial The material to add
  45752. */
  45753. addMaterial(newMaterial: Material): void;
  45754. /**
  45755. * Adds the given morph target to this scene
  45756. * @param newMorphTargetManager The morph target to add
  45757. */
  45758. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45759. /**
  45760. * Adds the given geometry to this scene
  45761. * @param newGeometry The geometry to add
  45762. */
  45763. addGeometry(newGeometry: Geometry): void;
  45764. /**
  45765. * Adds the given action manager to this scene
  45766. * @param newActionManager The action manager to add
  45767. */
  45768. addActionManager(newActionManager: AbstractActionManager): void;
  45769. /**
  45770. * Adds the given texture to this scene.
  45771. * @param newTexture The texture to add
  45772. */
  45773. addTexture(newTexture: BaseTexture): void;
  45774. /**
  45775. * Switch active camera
  45776. * @param newCamera defines the new active camera
  45777. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45778. */
  45779. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45780. /**
  45781. * sets the active camera of the scene using its ID
  45782. * @param id defines the camera's ID
  45783. * @return the new active camera or null if none found.
  45784. */
  45785. setActiveCameraByID(id: string): Nullable<Camera>;
  45786. /**
  45787. * sets the active camera of the scene using its name
  45788. * @param name defines the camera's name
  45789. * @returns the new active camera or null if none found.
  45790. */
  45791. setActiveCameraByName(name: string): Nullable<Camera>;
  45792. /**
  45793. * get an animation group using its name
  45794. * @param name defines the material's name
  45795. * @return the animation group or null if none found.
  45796. */
  45797. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45798. /**
  45799. * Get a material using its unique id
  45800. * @param uniqueId defines the material's unique id
  45801. * @return the material or null if none found.
  45802. */
  45803. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45804. /**
  45805. * get a material using its id
  45806. * @param id defines the material's ID
  45807. * @return the material or null if none found.
  45808. */
  45809. getMaterialByID(id: string): Nullable<Material>;
  45810. /**
  45811. * Gets a the last added material using a given id
  45812. * @param id defines the material's ID
  45813. * @return the last material with the given id or null if none found.
  45814. */
  45815. getLastMaterialByID(id: string): Nullable<Material>;
  45816. /**
  45817. * Gets a material using its name
  45818. * @param name defines the material's name
  45819. * @return the material or null if none found.
  45820. */
  45821. getMaterialByName(name: string): Nullable<Material>;
  45822. /**
  45823. * Get a texture using its unique id
  45824. * @param uniqueId defines the texture's unique id
  45825. * @return the texture or null if none found.
  45826. */
  45827. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45828. /**
  45829. * Gets a camera using its id
  45830. * @param id defines the id to look for
  45831. * @returns the camera or null if not found
  45832. */
  45833. getCameraByID(id: string): Nullable<Camera>;
  45834. /**
  45835. * Gets a camera using its unique id
  45836. * @param uniqueId defines the unique id to look for
  45837. * @returns the camera or null if not found
  45838. */
  45839. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45840. /**
  45841. * Gets a camera using its name
  45842. * @param name defines the camera's name
  45843. * @return the camera or null if none found.
  45844. */
  45845. getCameraByName(name: string): Nullable<Camera>;
  45846. /**
  45847. * Gets a bone using its id
  45848. * @param id defines the bone's id
  45849. * @return the bone or null if not found
  45850. */
  45851. getBoneByID(id: string): Nullable<Bone>;
  45852. /**
  45853. * Gets a bone using its id
  45854. * @param name defines the bone's name
  45855. * @return the bone or null if not found
  45856. */
  45857. getBoneByName(name: string): Nullable<Bone>;
  45858. /**
  45859. * Gets a light node using its name
  45860. * @param name defines the the light's name
  45861. * @return the light or null if none found.
  45862. */
  45863. getLightByName(name: string): Nullable<Light>;
  45864. /**
  45865. * Gets a light node using its id
  45866. * @param id defines the light's id
  45867. * @return the light or null if none found.
  45868. */
  45869. getLightByID(id: string): Nullable<Light>;
  45870. /**
  45871. * Gets a light node using its scene-generated unique ID
  45872. * @param uniqueId defines the light's unique id
  45873. * @return the light or null if none found.
  45874. */
  45875. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45876. /**
  45877. * Gets a particle system by id
  45878. * @param id defines the particle system id
  45879. * @return the corresponding system or null if none found
  45880. */
  45881. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45882. /**
  45883. * Gets a geometry using its ID
  45884. * @param id defines the geometry's id
  45885. * @return the geometry or null if none found.
  45886. */
  45887. getGeometryByID(id: string): Nullable<Geometry>;
  45888. private _getGeometryByUniqueID;
  45889. /**
  45890. * Add a new geometry to this scene
  45891. * @param geometry defines the geometry to be added to the scene.
  45892. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45893. * @return a boolean defining if the geometry was added or not
  45894. */
  45895. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45896. /**
  45897. * Removes an existing geometry
  45898. * @param geometry defines the geometry to be removed from the scene
  45899. * @return a boolean defining if the geometry was removed or not
  45900. */
  45901. removeGeometry(geometry: Geometry): boolean;
  45902. /**
  45903. * Gets the list of geometries attached to the scene
  45904. * @returns an array of Geometry
  45905. */
  45906. getGeometries(): Geometry[];
  45907. /**
  45908. * Gets the first added mesh found of a given ID
  45909. * @param id defines the id to search for
  45910. * @return the mesh found or null if not found at all
  45911. */
  45912. getMeshByID(id: string): Nullable<AbstractMesh>;
  45913. /**
  45914. * Gets a list of meshes using their id
  45915. * @param id defines the id to search for
  45916. * @returns a list of meshes
  45917. */
  45918. getMeshesByID(id: string): Array<AbstractMesh>;
  45919. /**
  45920. * Gets the first added transform node found of a given ID
  45921. * @param id defines the id to search for
  45922. * @return the found transform node or null if not found at all.
  45923. */
  45924. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45925. /**
  45926. * Gets a transform node with its auto-generated unique id
  45927. * @param uniqueId efines the unique id to search for
  45928. * @return the found transform node or null if not found at all.
  45929. */
  45930. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45931. /**
  45932. * Gets a list of transform nodes using their id
  45933. * @param id defines the id to search for
  45934. * @returns a list of transform nodes
  45935. */
  45936. getTransformNodesByID(id: string): Array<TransformNode>;
  45937. /**
  45938. * Gets a mesh with its auto-generated unique id
  45939. * @param uniqueId defines the unique id to search for
  45940. * @return the found mesh or null if not found at all.
  45941. */
  45942. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45943. /**
  45944. * Gets a the last added mesh using a given id
  45945. * @param id defines the id to search for
  45946. * @return the found mesh or null if not found at all.
  45947. */
  45948. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45949. /**
  45950. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45951. * @param id defines the id to search for
  45952. * @return the found node or null if not found at all
  45953. */
  45954. getLastEntryByID(id: string): Nullable<Node>;
  45955. /**
  45956. * Gets a node (Mesh, Camera, Light) using a given id
  45957. * @param id defines the id to search for
  45958. * @return the found node or null if not found at all
  45959. */
  45960. getNodeByID(id: string): Nullable<Node>;
  45961. /**
  45962. * Gets a node (Mesh, Camera, Light) using a given name
  45963. * @param name defines the name to search for
  45964. * @return the found node or null if not found at all.
  45965. */
  45966. getNodeByName(name: string): Nullable<Node>;
  45967. /**
  45968. * Gets a mesh using a given name
  45969. * @param name defines the name to search for
  45970. * @return the found mesh or null if not found at all.
  45971. */
  45972. getMeshByName(name: string): Nullable<AbstractMesh>;
  45973. /**
  45974. * Gets a transform node using a given name
  45975. * @param name defines the name to search for
  45976. * @return the found transform node or null if not found at all.
  45977. */
  45978. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45979. /**
  45980. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45981. * @param id defines the id to search for
  45982. * @return the found skeleton or null if not found at all.
  45983. */
  45984. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45985. /**
  45986. * Gets a skeleton using a given auto generated unique id
  45987. * @param uniqueId defines the unique id to search for
  45988. * @return the found skeleton or null if not found at all.
  45989. */
  45990. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45991. /**
  45992. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45993. * @param id defines the id to search for
  45994. * @return the found skeleton or null if not found at all.
  45995. */
  45996. getSkeletonById(id: string): Nullable<Skeleton>;
  45997. /**
  45998. * Gets a skeleton using a given name
  45999. * @param name defines the name to search for
  46000. * @return the found skeleton or null if not found at all.
  46001. */
  46002. getSkeletonByName(name: string): Nullable<Skeleton>;
  46003. /**
  46004. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  46005. * @param id defines the id to search for
  46006. * @return the found morph target manager or null if not found at all.
  46007. */
  46008. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  46009. /**
  46010. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  46011. * @param id defines the id to search for
  46012. * @return the found morph target or null if not found at all.
  46013. */
  46014. getMorphTargetById(id: string): Nullable<MorphTarget>;
  46015. /**
  46016. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  46017. * @param name defines the name to search for
  46018. * @return the found morph target or null if not found at all.
  46019. */
  46020. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  46021. /**
  46022. * Gets a post process using a given name (if many are found, this function will pick the first one)
  46023. * @param name defines the name to search for
  46024. * @return the found post process or null if not found at all.
  46025. */
  46026. getPostProcessByName(name: string): Nullable<PostProcess>;
  46027. /**
  46028. * Gets a boolean indicating if the given mesh is active
  46029. * @param mesh defines the mesh to look for
  46030. * @returns true if the mesh is in the active list
  46031. */
  46032. isActiveMesh(mesh: AbstractMesh): boolean;
  46033. /**
  46034. * Return a unique id as a string which can serve as an identifier for the scene
  46035. */
  46036. get uid(): string;
  46037. /**
  46038. * Add an externaly attached data from its key.
  46039. * This method call will fail and return false, if such key already exists.
  46040. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  46041. * @param key the unique key that identifies the data
  46042. * @param data the data object to associate to the key for this Engine instance
  46043. * @return true if no such key were already present and the data was added successfully, false otherwise
  46044. */
  46045. addExternalData<T>(key: string, data: T): boolean;
  46046. /**
  46047. * Get an externaly attached data from its key
  46048. * @param key the unique key that identifies the data
  46049. * @return the associated data, if present (can be null), or undefined if not present
  46050. */
  46051. getExternalData<T>(key: string): Nullable<T>;
  46052. /**
  46053. * Get an externaly attached data from its key, create it using a factory if it's not already present
  46054. * @param key the unique key that identifies the data
  46055. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  46056. * @return the associated data, can be null if the factory returned null.
  46057. */
  46058. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  46059. /**
  46060. * Remove an externaly attached data from the Engine instance
  46061. * @param key the unique key that identifies the data
  46062. * @return true if the data was successfully removed, false if it doesn't exist
  46063. */
  46064. removeExternalData(key: string): boolean;
  46065. private _evaluateSubMesh;
  46066. /**
  46067. * Clear the processed materials smart array preventing retention point in material dispose.
  46068. */
  46069. freeProcessedMaterials(): void;
  46070. private _preventFreeActiveMeshesAndRenderingGroups;
  46071. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  46072. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  46073. * when disposing several meshes in a row or a hierarchy of meshes.
  46074. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  46075. */
  46076. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  46077. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  46078. /**
  46079. * Clear the active meshes smart array preventing retention point in mesh dispose.
  46080. */
  46081. freeActiveMeshes(): void;
  46082. /**
  46083. * Clear the info related to rendering groups preventing retention points during dispose.
  46084. */
  46085. freeRenderingGroups(): void;
  46086. /** @hidden */
  46087. _isInIntermediateRendering(): boolean;
  46088. /**
  46089. * Lambda returning the list of potentially active meshes.
  46090. */
  46091. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  46092. /**
  46093. * Lambda returning the list of potentially active sub meshes.
  46094. */
  46095. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  46096. /**
  46097. * Lambda returning the list of potentially intersecting sub meshes.
  46098. */
  46099. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  46100. /**
  46101. * Lambda returning the list of potentially colliding sub meshes.
  46102. */
  46103. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  46104. /** @hidden */
  46105. _activeMeshesFrozen: boolean;
  46106. private _skipEvaluateActiveMeshesCompletely;
  46107. /**
  46108. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  46109. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  46110. * @param onSuccess optional success callback
  46111. * @param onError optional error callback
  46112. * @returns the current scene
  46113. */
  46114. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  46115. /**
  46116. * Use this function to restart evaluating active meshes on every frame
  46117. * @returns the current scene
  46118. */
  46119. unfreezeActiveMeshes(): Scene;
  46120. private _evaluateActiveMeshes;
  46121. private _activeMesh;
  46122. /**
  46123. * Update the transform matrix to update from the current active camera
  46124. * @param force defines a boolean used to force the update even if cache is up to date
  46125. */
  46126. updateTransformMatrix(force?: boolean): void;
  46127. private _bindFrameBuffer;
  46128. /** @hidden */
  46129. _allowPostProcessClearColor: boolean;
  46130. /** @hidden */
  46131. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  46132. private _processSubCameras;
  46133. private _checkIntersections;
  46134. /** @hidden */
  46135. _advancePhysicsEngineStep(step: number): void;
  46136. /**
  46137. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  46138. */
  46139. getDeterministicFrameTime: () => number;
  46140. /** @hidden */
  46141. _animate(): void;
  46142. /** Execute all animations (for a frame) */
  46143. animate(): void;
  46144. /**
  46145. * Render the scene
  46146. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  46147. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  46148. */
  46149. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  46150. /**
  46151. * Freeze all materials
  46152. * A frozen material will not be updatable but should be faster to render
  46153. */
  46154. freezeMaterials(): void;
  46155. /**
  46156. * Unfreeze all materials
  46157. * A frozen material will not be updatable but should be faster to render
  46158. */
  46159. unfreezeMaterials(): void;
  46160. /**
  46161. * Releases all held ressources
  46162. */
  46163. dispose(): void;
  46164. /**
  46165. * Gets if the scene is already disposed
  46166. */
  46167. get isDisposed(): boolean;
  46168. /**
  46169. * Call this function to reduce memory footprint of the scene.
  46170. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  46171. */
  46172. clearCachedVertexData(): void;
  46173. /**
  46174. * This function will remove the local cached buffer data from texture.
  46175. * It will save memory but will prevent the texture from being rebuilt
  46176. */
  46177. cleanCachedTextureBuffer(): void;
  46178. /**
  46179. * Get the world extend vectors with an optional filter
  46180. *
  46181. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  46182. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  46183. */
  46184. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  46185. min: Vector3;
  46186. max: Vector3;
  46187. };
  46188. /**
  46189. * Creates a ray that can be used to pick in the scene
  46190. * @param x defines the x coordinate of the origin (on-screen)
  46191. * @param y defines the y coordinate of the origin (on-screen)
  46192. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  46193. * @param camera defines the camera to use for the picking
  46194. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  46195. * @returns a Ray
  46196. */
  46197. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  46198. /**
  46199. * Creates a ray that can be used to pick in the scene
  46200. * @param x defines the x coordinate of the origin (on-screen)
  46201. * @param y defines the y coordinate of the origin (on-screen)
  46202. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  46203. * @param result defines the ray where to store the picking ray
  46204. * @param camera defines the camera to use for the picking
  46205. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  46206. * @returns the current scene
  46207. */
  46208. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  46209. /**
  46210. * Creates a ray that can be used to pick in the scene
  46211. * @param x defines the x coordinate of the origin (on-screen)
  46212. * @param y defines the y coordinate of the origin (on-screen)
  46213. * @param camera defines the camera to use for the picking
  46214. * @returns a Ray
  46215. */
  46216. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  46217. /**
  46218. * Creates a ray that can be used to pick in the scene
  46219. * @param x defines the x coordinate of the origin (on-screen)
  46220. * @param y defines the y coordinate of the origin (on-screen)
  46221. * @param result defines the ray where to store the picking ray
  46222. * @param camera defines the camera to use for the picking
  46223. * @returns the current scene
  46224. */
  46225. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  46226. /** Launch a ray to try to pick a mesh in the scene
  46227. * @param x position on screen
  46228. * @param y position on screen
  46229. * @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
  46230. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46231. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46232. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46233. * @returns a PickingInfo
  46234. */
  46235. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  46236. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  46237. * @param x position on screen
  46238. * @param y position on screen
  46239. * @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
  46240. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46241. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46242. * @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)
  46243. */
  46244. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  46245. /** Use the given ray to pick a mesh in the scene
  46246. * @param ray The ray to use to pick meshes
  46247. * @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
  46248. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46249. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46250. * @returns a PickingInfo
  46251. */
  46252. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  46253. /**
  46254. * Launch a ray to try to pick a mesh in the scene
  46255. * @param x X position on screen
  46256. * @param y Y position on screen
  46257. * @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
  46258. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46259. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46260. * @returns an array of PickingInfo
  46261. */
  46262. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  46263. /**
  46264. * Launch a ray to try to pick a mesh in the scene
  46265. * @param ray Ray to use
  46266. * @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
  46267. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46268. * @returns an array of PickingInfo
  46269. */
  46270. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  46271. /**
  46272. * Force the value of meshUnderPointer
  46273. * @param mesh defines the mesh to use
  46274. * @param pointerId optional pointer id when using more than one pointer
  46275. */
  46276. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  46277. /**
  46278. * Gets the mesh under the pointer
  46279. * @returns a Mesh or null if no mesh is under the pointer
  46280. */
  46281. getPointerOverMesh(): Nullable<AbstractMesh>;
  46282. /** @hidden */
  46283. _rebuildGeometries(): void;
  46284. /** @hidden */
  46285. _rebuildTextures(): void;
  46286. private _getByTags;
  46287. /**
  46288. * Get a list of meshes by tags
  46289. * @param tagsQuery defines the tags query to use
  46290. * @param forEach defines a predicate used to filter results
  46291. * @returns an array of Mesh
  46292. */
  46293. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  46294. /**
  46295. * Get a list of cameras by tags
  46296. * @param tagsQuery defines the tags query to use
  46297. * @param forEach defines a predicate used to filter results
  46298. * @returns an array of Camera
  46299. */
  46300. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  46301. /**
  46302. * Get a list of lights by tags
  46303. * @param tagsQuery defines the tags query to use
  46304. * @param forEach defines a predicate used to filter results
  46305. * @returns an array of Light
  46306. */
  46307. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  46308. /**
  46309. * Get a list of materials by tags
  46310. * @param tagsQuery defines the tags query to use
  46311. * @param forEach defines a predicate used to filter results
  46312. * @returns an array of Material
  46313. */
  46314. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  46315. /**
  46316. * Get a list of transform nodes by tags
  46317. * @param tagsQuery defines the tags query to use
  46318. * @param forEach defines a predicate used to filter results
  46319. * @returns an array of TransformNode
  46320. */
  46321. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  46322. /**
  46323. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  46324. * This allowed control for front to back rendering or reversly depending of the special needs.
  46325. *
  46326. * @param renderingGroupId The rendering group id corresponding to its index
  46327. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  46328. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  46329. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  46330. */
  46331. 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;
  46332. /**
  46333. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  46334. *
  46335. * @param renderingGroupId The rendering group id corresponding to its index
  46336. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46337. * @param depth Automatically clears depth between groups if true and autoClear is true.
  46338. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  46339. */
  46340. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  46341. /**
  46342. * Gets the current auto clear configuration for one rendering group of the rendering
  46343. * manager.
  46344. * @param index the rendering group index to get the information for
  46345. * @returns The auto clear setup for the requested rendering group
  46346. */
  46347. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  46348. private _blockMaterialDirtyMechanism;
  46349. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  46350. get blockMaterialDirtyMechanism(): boolean;
  46351. set blockMaterialDirtyMechanism(value: boolean);
  46352. /**
  46353. * Will flag all materials as dirty to trigger new shader compilation
  46354. * @param flag defines the flag used to specify which material part must be marked as dirty
  46355. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  46356. */
  46357. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  46358. /** @hidden */
  46359. _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;
  46360. /** @hidden */
  46361. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46362. /** @hidden */
  46363. _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;
  46364. /** @hidden */
  46365. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  46366. /** @hidden */
  46367. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  46368. /** @hidden */
  46369. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46370. }
  46371. }
  46372. declare module "babylonjs/assetContainer" {
  46373. import { AbstractScene } from "babylonjs/abstractScene";
  46374. import { Scene } from "babylonjs/scene";
  46375. import { Mesh } from "babylonjs/Meshes/mesh";
  46376. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46377. import { Skeleton } from "babylonjs/Bones/skeleton";
  46378. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46379. import { Animatable } from "babylonjs/Animations/animatable";
  46380. import { Nullable } from "babylonjs/types";
  46381. import { Node } from "babylonjs/node";
  46382. /**
  46383. * Set of assets to keep when moving a scene into an asset container.
  46384. */
  46385. export class KeepAssets extends AbstractScene {
  46386. }
  46387. /**
  46388. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  46389. */
  46390. export class InstantiatedEntries {
  46391. /**
  46392. * List of new root nodes (eg. nodes with no parent)
  46393. */
  46394. rootNodes: TransformNode[];
  46395. /**
  46396. * List of new skeletons
  46397. */
  46398. skeletons: Skeleton[];
  46399. /**
  46400. * List of new animation groups
  46401. */
  46402. animationGroups: AnimationGroup[];
  46403. }
  46404. /**
  46405. * Container with a set of assets that can be added or removed from a scene.
  46406. */
  46407. export class AssetContainer extends AbstractScene {
  46408. private _wasAddedToScene;
  46409. /**
  46410. * The scene the AssetContainer belongs to.
  46411. */
  46412. scene: Scene;
  46413. /**
  46414. * Instantiates an AssetContainer.
  46415. * @param scene The scene the AssetContainer belongs to.
  46416. */
  46417. constructor(scene: Scene);
  46418. /**
  46419. * Instantiate or clone all meshes and add the new ones to the scene.
  46420. * Skeletons and animation groups will all be cloned
  46421. * @param nameFunction defines an optional function used to get new names for clones
  46422. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  46423. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  46424. */
  46425. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  46426. /**
  46427. * Adds all the assets from the container to the scene.
  46428. */
  46429. addAllToScene(): void;
  46430. /**
  46431. * Removes all the assets in the container from the scene
  46432. */
  46433. removeAllFromScene(): void;
  46434. /**
  46435. * Disposes all the assets in the container
  46436. */
  46437. dispose(): void;
  46438. private _moveAssets;
  46439. /**
  46440. * Removes all the assets contained in the scene and adds them to the container.
  46441. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  46442. */
  46443. moveAllFromScene(keepAssets?: KeepAssets): void;
  46444. /**
  46445. * 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.
  46446. * @returns the root mesh
  46447. */
  46448. createRootMesh(): Mesh;
  46449. /**
  46450. * Merge animations (direct and animation groups) from this asset container into a scene
  46451. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46452. * @param animatables set of animatables to retarget to a node from the scene
  46453. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  46454. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  46455. */
  46456. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  46457. }
  46458. }
  46459. declare module "babylonjs/abstractScene" {
  46460. import { Scene } from "babylonjs/scene";
  46461. import { Nullable } from "babylonjs/types";
  46462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46463. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46464. import { Geometry } from "babylonjs/Meshes/geometry";
  46465. import { Skeleton } from "babylonjs/Bones/skeleton";
  46466. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  46467. import { AssetContainer } from "babylonjs/assetContainer";
  46468. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  46469. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46470. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46471. import { Material } from "babylonjs/Materials/material";
  46472. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  46473. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  46474. import { Camera } from "babylonjs/Cameras/camera";
  46475. import { Light } from "babylonjs/Lights/light";
  46476. import { Node } from "babylonjs/node";
  46477. import { Animation } from "babylonjs/Animations/animation";
  46478. /**
  46479. * Defines how the parser contract is defined.
  46480. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  46481. */
  46482. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  46483. /**
  46484. * Defines how the individual parser contract is defined.
  46485. * These parser can parse an individual asset
  46486. */
  46487. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  46488. /**
  46489. * Base class of the scene acting as a container for the different elements composing a scene.
  46490. * This class is dynamically extended by the different components of the scene increasing
  46491. * flexibility and reducing coupling
  46492. */
  46493. export abstract class AbstractScene {
  46494. /**
  46495. * Stores the list of available parsers in the application.
  46496. */
  46497. private static _BabylonFileParsers;
  46498. /**
  46499. * Stores the list of available individual parsers in the application.
  46500. */
  46501. private static _IndividualBabylonFileParsers;
  46502. /**
  46503. * Adds a parser in the list of available ones
  46504. * @param name Defines the name of the parser
  46505. * @param parser Defines the parser to add
  46506. */
  46507. static AddParser(name: string, parser: BabylonFileParser): void;
  46508. /**
  46509. * Gets a general parser from the list of avaialble ones
  46510. * @param name Defines the name of the parser
  46511. * @returns the requested parser or null
  46512. */
  46513. static GetParser(name: string): Nullable<BabylonFileParser>;
  46514. /**
  46515. * Adds n individual parser in the list of available ones
  46516. * @param name Defines the name of the parser
  46517. * @param parser Defines the parser to add
  46518. */
  46519. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  46520. /**
  46521. * Gets an individual parser from the list of avaialble ones
  46522. * @param name Defines the name of the parser
  46523. * @returns the requested parser or null
  46524. */
  46525. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  46526. /**
  46527. * Parser json data and populate both a scene and its associated container object
  46528. * @param jsonData Defines the data to parse
  46529. * @param scene Defines the scene to parse the data for
  46530. * @param container Defines the container attached to the parsing sequence
  46531. * @param rootUrl Defines the root url of the data
  46532. */
  46533. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  46534. /**
  46535. * Gets the list of root nodes (ie. nodes with no parent)
  46536. */
  46537. rootNodes: Node[];
  46538. /** All of the cameras added to this scene
  46539. * @see https://doc.babylonjs.com/babylon101/cameras
  46540. */
  46541. cameras: Camera[];
  46542. /**
  46543. * All of the lights added to this scene
  46544. * @see https://doc.babylonjs.com/babylon101/lights
  46545. */
  46546. lights: Light[];
  46547. /**
  46548. * All of the (abstract) meshes added to this scene
  46549. */
  46550. meshes: AbstractMesh[];
  46551. /**
  46552. * The list of skeletons added to the scene
  46553. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46554. */
  46555. skeletons: Skeleton[];
  46556. /**
  46557. * All of the particle systems added to this scene
  46558. * @see https://doc.babylonjs.com/babylon101/particles
  46559. */
  46560. particleSystems: IParticleSystem[];
  46561. /**
  46562. * Gets a list of Animations associated with the scene
  46563. */
  46564. animations: Animation[];
  46565. /**
  46566. * All of the animation groups added to this scene
  46567. * @see https://doc.babylonjs.com/how_to/group
  46568. */
  46569. animationGroups: AnimationGroup[];
  46570. /**
  46571. * All of the multi-materials added to this scene
  46572. * @see https://doc.babylonjs.com/how_to/multi_materials
  46573. */
  46574. multiMaterials: MultiMaterial[];
  46575. /**
  46576. * All of the materials added to this scene
  46577. * In the context of a Scene, it is not supposed to be modified manually.
  46578. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46579. * Note also that the order of the Material within the array is not significant and might change.
  46580. * @see https://doc.babylonjs.com/babylon101/materials
  46581. */
  46582. materials: Material[];
  46583. /**
  46584. * The list of morph target managers added to the scene
  46585. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46586. */
  46587. morphTargetManagers: MorphTargetManager[];
  46588. /**
  46589. * The list of geometries used in the scene.
  46590. */
  46591. geometries: Geometry[];
  46592. /**
  46593. * All of the tranform nodes added to this scene
  46594. * In the context of a Scene, it is not supposed to be modified manually.
  46595. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46596. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46597. * @see https://doc.babylonjs.com/how_to/transformnode
  46598. */
  46599. transformNodes: TransformNode[];
  46600. /**
  46601. * ActionManagers available on the scene.
  46602. */
  46603. actionManagers: AbstractActionManager[];
  46604. /**
  46605. * Textures to keep.
  46606. */
  46607. textures: BaseTexture[];
  46608. /** @hidden */
  46609. protected _environmentTexture: Nullable<BaseTexture>;
  46610. /**
  46611. * Texture used in all pbr material as the reflection texture.
  46612. * As in the majority of the scene they are the same (exception for multi room and so on),
  46613. * this is easier to reference from here than from all the materials.
  46614. */
  46615. get environmentTexture(): Nullable<BaseTexture>;
  46616. set environmentTexture(value: Nullable<BaseTexture>);
  46617. /**
  46618. * The list of postprocesses added to the scene
  46619. */
  46620. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46621. /**
  46622. * @returns all meshes, lights, cameras, transformNodes and bones
  46623. */
  46624. getNodes(): Array<Node>;
  46625. }
  46626. }
  46627. declare module "babylonjs/Audio/Interfaces/ISoundOptions" {
  46628. /**
  46629. * Interface used to define options for Sound class
  46630. */
  46631. export interface ISoundOptions {
  46632. /**
  46633. * Does the sound autoplay once loaded.
  46634. */
  46635. autoplay?: boolean;
  46636. /**
  46637. * Does the sound loop after it finishes playing once.
  46638. */
  46639. loop?: boolean;
  46640. /**
  46641. * Sound's volume
  46642. */
  46643. volume?: number;
  46644. /**
  46645. * Is it a spatial sound?
  46646. */
  46647. spatialSound?: boolean;
  46648. /**
  46649. * Maximum distance to hear that sound
  46650. */
  46651. maxDistance?: number;
  46652. /**
  46653. * Uses user defined attenuation function
  46654. */
  46655. useCustomAttenuation?: boolean;
  46656. /**
  46657. * Define the roll off factor of spatial sounds.
  46658. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46659. */
  46660. rolloffFactor?: number;
  46661. /**
  46662. * Define the reference distance the sound should be heard perfectly.
  46663. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46664. */
  46665. refDistance?: number;
  46666. /**
  46667. * Define the distance attenuation model the sound will follow.
  46668. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46669. */
  46670. distanceModel?: string;
  46671. /**
  46672. * Defines the playback speed (1 by default)
  46673. */
  46674. playbackRate?: number;
  46675. /**
  46676. * Defines if the sound is from a streaming source
  46677. */
  46678. streaming?: boolean;
  46679. /**
  46680. * Defines an optional length (in seconds) inside the sound file
  46681. */
  46682. length?: number;
  46683. /**
  46684. * Defines an optional offset (in seconds) inside the sound file
  46685. */
  46686. offset?: number;
  46687. /**
  46688. * If true, URLs will not be required to state the audio file codec to use.
  46689. */
  46690. skipCodecCheck?: boolean;
  46691. }
  46692. }
  46693. declare module "babylonjs/Audio/sound" {
  46694. import { Observable } from "babylonjs/Misc/observable";
  46695. import { Vector3 } from "babylonjs/Maths/math.vector";
  46696. import { Nullable } from "babylonjs/types";
  46697. import { Scene } from "babylonjs/scene";
  46698. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46699. import { ISoundOptions } from "babylonjs/Audio/Interfaces/ISoundOptions";
  46700. /**
  46701. * Defines a sound that can be played in the application.
  46702. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46703. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46704. */
  46705. export class Sound {
  46706. /**
  46707. * The name of the sound in the scene.
  46708. */
  46709. name: string;
  46710. /**
  46711. * Does the sound autoplay once loaded.
  46712. */
  46713. autoplay: boolean;
  46714. /**
  46715. * Does the sound loop after it finishes playing once.
  46716. */
  46717. loop: boolean;
  46718. /**
  46719. * Does the sound use a custom attenuation curve to simulate the falloff
  46720. * happening when the source gets further away from the camera.
  46721. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46722. */
  46723. useCustomAttenuation: boolean;
  46724. /**
  46725. * The sound track id this sound belongs to.
  46726. */
  46727. soundTrackId: number;
  46728. /**
  46729. * Is this sound currently played.
  46730. */
  46731. isPlaying: boolean;
  46732. /**
  46733. * Is this sound currently paused.
  46734. */
  46735. isPaused: boolean;
  46736. /**
  46737. * Does this sound enables spatial sound.
  46738. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46739. */
  46740. spatialSound: boolean;
  46741. /**
  46742. * Define the reference distance the sound should be heard perfectly.
  46743. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46744. */
  46745. refDistance: number;
  46746. /**
  46747. * Define the roll off factor of spatial sounds.
  46748. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46749. */
  46750. rolloffFactor: number;
  46751. /**
  46752. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46753. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46754. */
  46755. maxDistance: number;
  46756. /**
  46757. * Define the distance attenuation model the sound will follow.
  46758. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46759. */
  46760. distanceModel: string;
  46761. /**
  46762. * @hidden
  46763. * Back Compat
  46764. **/
  46765. onended: () => any;
  46766. /**
  46767. * Gets or sets an object used to store user defined information for the sound.
  46768. */
  46769. metadata: any;
  46770. /**
  46771. * Observable event when the current playing sound finishes.
  46772. */
  46773. onEndedObservable: Observable<Sound>;
  46774. /**
  46775. * Gets the current time for the sound.
  46776. */
  46777. get currentTime(): number;
  46778. private _panningModel;
  46779. private _playbackRate;
  46780. private _streaming;
  46781. private _startTime;
  46782. private _startOffset;
  46783. private _position;
  46784. /** @hidden */
  46785. _positionInEmitterSpace: boolean;
  46786. private _localDirection;
  46787. private _volume;
  46788. private _isReadyToPlay;
  46789. private _isDirectional;
  46790. private _readyToPlayCallback;
  46791. private _audioBuffer;
  46792. private _soundSource;
  46793. private _streamingSource;
  46794. private _soundPanner;
  46795. private _soundGain;
  46796. private _inputAudioNode;
  46797. private _outputAudioNode;
  46798. private _coneInnerAngle;
  46799. private _coneOuterAngle;
  46800. private _coneOuterGain;
  46801. private _scene;
  46802. private _connectedTransformNode;
  46803. private _customAttenuationFunction;
  46804. private _registerFunc;
  46805. private _isOutputConnected;
  46806. private _htmlAudioElement;
  46807. private _urlType;
  46808. private _length?;
  46809. private _offset?;
  46810. /** @hidden */
  46811. static _SceneComponentInitialization: (scene: Scene) => void;
  46812. /**
  46813. * Create a sound and attach it to a scene
  46814. * @param name Name of your sound
  46815. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46816. * @param scene defines the scene the sound belongs to
  46817. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46818. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46819. */
  46820. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46821. /**
  46822. * Release the sound and its associated resources
  46823. */
  46824. dispose(): void;
  46825. /**
  46826. * Gets if the sounds is ready to be played or not.
  46827. * @returns true if ready, otherwise false
  46828. */
  46829. isReady(): boolean;
  46830. private _soundLoaded;
  46831. /**
  46832. * Sets the data of the sound from an audiobuffer
  46833. * @param audioBuffer The audioBuffer containing the data
  46834. */
  46835. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46836. /**
  46837. * Updates the current sounds options such as maxdistance, loop...
  46838. * @param options A JSON object containing values named as the object properties
  46839. */
  46840. updateOptions(options: ISoundOptions): void;
  46841. private _createSpatialParameters;
  46842. private _updateSpatialParameters;
  46843. /**
  46844. * Switch the panning model to HRTF:
  46845. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46846. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46847. */
  46848. switchPanningModelToHRTF(): void;
  46849. /**
  46850. * Switch the panning model to Equal Power:
  46851. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46852. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46853. */
  46854. switchPanningModelToEqualPower(): void;
  46855. private _switchPanningModel;
  46856. /**
  46857. * Connect this sound to a sound track audio node like gain...
  46858. * @param soundTrackAudioNode the sound track audio node to connect to
  46859. */
  46860. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46861. /**
  46862. * Transform this sound into a directional source
  46863. * @param coneInnerAngle Size of the inner cone in degree
  46864. * @param coneOuterAngle Size of the outer cone in degree
  46865. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46866. */
  46867. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46868. /**
  46869. * Gets or sets the inner angle for the directional cone.
  46870. */
  46871. get directionalConeInnerAngle(): number;
  46872. /**
  46873. * Gets or sets the inner angle for the directional cone.
  46874. */
  46875. set directionalConeInnerAngle(value: number);
  46876. /**
  46877. * Gets or sets the outer angle for the directional cone.
  46878. */
  46879. get directionalConeOuterAngle(): number;
  46880. /**
  46881. * Gets or sets the outer angle for the directional cone.
  46882. */
  46883. set directionalConeOuterAngle(value: number);
  46884. /**
  46885. * Sets the position of the emitter if spatial sound is enabled
  46886. * @param newPosition Defines the new posisiton
  46887. */
  46888. setPosition(newPosition: Vector3): void;
  46889. /**
  46890. * Sets the local direction of the emitter if spatial sound is enabled
  46891. * @param newLocalDirection Defines the new local direction
  46892. */
  46893. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46894. private _updateDirection;
  46895. /** @hidden */
  46896. updateDistanceFromListener(): void;
  46897. /**
  46898. * Sets a new custom attenuation function for the sound.
  46899. * @param callback Defines the function used for the attenuation
  46900. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46901. */
  46902. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46903. /**
  46904. * Play the sound
  46905. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46906. * @param offset (optional) Start the sound at a specific time in seconds
  46907. * @param length (optional) Sound duration (in seconds)
  46908. */
  46909. play(time?: number, offset?: number, length?: number): void;
  46910. private _onended;
  46911. /**
  46912. * Stop the sound
  46913. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46914. */
  46915. stop(time?: number): void;
  46916. /**
  46917. * Put the sound in pause
  46918. */
  46919. pause(): void;
  46920. /**
  46921. * Sets a dedicated volume for this sounds
  46922. * @param newVolume Define the new volume of the sound
  46923. * @param time Define time for gradual change to new volume
  46924. */
  46925. setVolume(newVolume: number, time?: number): void;
  46926. /**
  46927. * Set the sound play back rate
  46928. * @param newPlaybackRate Define the playback rate the sound should be played at
  46929. */
  46930. setPlaybackRate(newPlaybackRate: number): void;
  46931. /**
  46932. * Gets the volume of the sound.
  46933. * @returns the volume of the sound
  46934. */
  46935. getVolume(): number;
  46936. /**
  46937. * Attach the sound to a dedicated mesh
  46938. * @param transformNode The transform node to connect the sound with
  46939. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46940. */
  46941. attachToMesh(transformNode: TransformNode): void;
  46942. /**
  46943. * Detach the sound from the previously attached mesh
  46944. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46945. */
  46946. detachFromMesh(): void;
  46947. private _onRegisterAfterWorldMatrixUpdate;
  46948. /**
  46949. * Clone the current sound in the scene.
  46950. * @returns the new sound clone
  46951. */
  46952. clone(): Nullable<Sound>;
  46953. /**
  46954. * Gets the current underlying audio buffer containing the data
  46955. * @returns the audio buffer
  46956. */
  46957. getAudioBuffer(): Nullable<AudioBuffer>;
  46958. /**
  46959. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46960. * @returns the source node
  46961. */
  46962. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46963. /**
  46964. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46965. * @returns the gain node
  46966. */
  46967. getSoundGain(): Nullable<GainNode>;
  46968. /**
  46969. * Serializes the Sound in a JSON representation
  46970. * @returns the JSON representation of the sound
  46971. */
  46972. serialize(): any;
  46973. /**
  46974. * Parse a JSON representation of a sound to innstantiate in a given scene
  46975. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46976. * @param scene Define the scene the new parsed sound should be created in
  46977. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46978. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46979. * @returns the newly parsed sound
  46980. */
  46981. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46982. }
  46983. }
  46984. declare module "babylonjs/Actions/directAudioActions" {
  46985. import { Action } from "babylonjs/Actions/action";
  46986. import { Condition } from "babylonjs/Actions/condition";
  46987. import { Sound } from "babylonjs/Audio/sound";
  46988. /**
  46989. * This defines an action helpful to play a defined sound on a triggered action.
  46990. */
  46991. export class PlaySoundAction extends Action {
  46992. private _sound;
  46993. /**
  46994. * Instantiate the action
  46995. * @param triggerOptions defines the trigger options
  46996. * @param sound defines the sound to play
  46997. * @param condition defines the trigger related conditions
  46998. */
  46999. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  47000. /** @hidden */
  47001. _prepare(): void;
  47002. /**
  47003. * Execute the action and play the sound.
  47004. */
  47005. execute(): void;
  47006. /**
  47007. * Serializes the actions and its related information.
  47008. * @param parent defines the object to serialize in
  47009. * @returns the serialized object
  47010. */
  47011. serialize(parent: any): any;
  47012. }
  47013. /**
  47014. * This defines an action helpful to stop a defined sound on a triggered action.
  47015. */
  47016. export class StopSoundAction extends Action {
  47017. private _sound;
  47018. /**
  47019. * Instantiate the action
  47020. * @param triggerOptions defines the trigger options
  47021. * @param sound defines the sound to stop
  47022. * @param condition defines the trigger related conditions
  47023. */
  47024. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  47025. /** @hidden */
  47026. _prepare(): void;
  47027. /**
  47028. * Execute the action and stop the sound.
  47029. */
  47030. execute(): void;
  47031. /**
  47032. * Serializes the actions and its related information.
  47033. * @param parent defines the object to serialize in
  47034. * @returns the serialized object
  47035. */
  47036. serialize(parent: any): any;
  47037. }
  47038. }
  47039. declare module "babylonjs/Actions/interpolateValueAction" {
  47040. import { Action } from "babylonjs/Actions/action";
  47041. import { Condition } from "babylonjs/Actions/condition";
  47042. import { Observable } from "babylonjs/Misc/observable";
  47043. /**
  47044. * This defines an action responsible to change the value of a property
  47045. * by interpolating between its current value and the newly set one once triggered.
  47046. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  47047. */
  47048. export class InterpolateValueAction extends Action {
  47049. /**
  47050. * Defines the path of the property where the value should be interpolated
  47051. */
  47052. propertyPath: string;
  47053. /**
  47054. * Defines the target value at the end of the interpolation.
  47055. */
  47056. value: any;
  47057. /**
  47058. * Defines the time it will take for the property to interpolate to the value.
  47059. */
  47060. duration: number;
  47061. /**
  47062. * Defines if the other scene animations should be stopped when the action has been triggered
  47063. */
  47064. stopOtherAnimations?: boolean;
  47065. /**
  47066. * Defines a callback raised once the interpolation animation has been done.
  47067. */
  47068. onInterpolationDone?: () => void;
  47069. /**
  47070. * Observable triggered once the interpolation animation has been done.
  47071. */
  47072. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  47073. private _target;
  47074. private _effectiveTarget;
  47075. private _property;
  47076. /**
  47077. * Instantiate the action
  47078. * @param triggerOptions defines the trigger options
  47079. * @param target defines the object containing the value to interpolate
  47080. * @param propertyPath defines the path to the property in the target object
  47081. * @param value defines the target value at the end of the interpolation
  47082. * @param duration deines the time it will take for the property to interpolate to the value.
  47083. * @param condition defines the trigger related conditions
  47084. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  47085. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  47086. */
  47087. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  47088. /** @hidden */
  47089. _prepare(): void;
  47090. /**
  47091. * Execute the action starts the value interpolation.
  47092. */
  47093. execute(): void;
  47094. /**
  47095. * Serializes the actions and its related information.
  47096. * @param parent defines the object to serialize in
  47097. * @returns the serialized object
  47098. */
  47099. serialize(parent: any): any;
  47100. }
  47101. }
  47102. declare module "babylonjs/Actions/index" {
  47103. export * from "babylonjs/Actions/abstractActionManager";
  47104. export * from "babylonjs/Actions/action";
  47105. export * from "babylonjs/Actions/actionEvent";
  47106. export * from "babylonjs/Actions/actionManager";
  47107. export * from "babylonjs/Actions/condition";
  47108. export * from "babylonjs/Actions/directActions";
  47109. export * from "babylonjs/Actions/directAudioActions";
  47110. export * from "babylonjs/Actions/interpolateValueAction";
  47111. }
  47112. declare module "babylonjs/Animations/index" {
  47113. export * from "babylonjs/Animations/animatable";
  47114. export * from "babylonjs/Animations/animation";
  47115. export * from "babylonjs/Animations/animationGroup";
  47116. export * from "babylonjs/Animations/animationPropertiesOverride";
  47117. export * from "babylonjs/Animations/easing";
  47118. export * from "babylonjs/Animations/runtimeAnimation";
  47119. export * from "babylonjs/Animations/animationEvent";
  47120. export * from "babylonjs/Animations/animationGroup";
  47121. export * from "babylonjs/Animations/animationKey";
  47122. export * from "babylonjs/Animations/animationRange";
  47123. export * from "babylonjs/Animations/animatable.interface";
  47124. }
  47125. declare module "babylonjs/Audio/audioEngine" {
  47126. import { Analyser } from "babylonjs/Audio/analyser";
  47127. import { Nullable } from "babylonjs/types";
  47128. import { Observable } from "babylonjs/Misc/observable";
  47129. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  47130. /**
  47131. * This represents the default audio engine used in babylon.
  47132. * It is responsible to play, synchronize and analyse sounds throughout the application.
  47133. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47134. */
  47135. export class AudioEngine implements IAudioEngine {
  47136. private _audioContext;
  47137. private _audioContextInitialized;
  47138. private _muteButton;
  47139. private _hostElement;
  47140. /**
  47141. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  47142. */
  47143. canUseWebAudio: boolean;
  47144. /**
  47145. * The master gain node defines the global audio volume of your audio engine.
  47146. */
  47147. masterGain: GainNode;
  47148. /**
  47149. * Defines if Babylon should emit a warning if WebAudio is not supported.
  47150. * @ignoreNaming
  47151. */
  47152. WarnedWebAudioUnsupported: boolean;
  47153. /**
  47154. * Gets whether or not mp3 are supported by your browser.
  47155. */
  47156. isMP3supported: boolean;
  47157. /**
  47158. * Gets whether or not ogg are supported by your browser.
  47159. */
  47160. isOGGsupported: boolean;
  47161. /**
  47162. * Gets whether audio has been unlocked on the device.
  47163. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  47164. * a user interaction has happened.
  47165. */
  47166. unlocked: boolean;
  47167. /**
  47168. * Defines if the audio engine relies on a custom unlocked button.
  47169. * In this case, the embedded button will not be displayed.
  47170. */
  47171. useCustomUnlockedButton: boolean;
  47172. /**
  47173. * Event raised when audio has been unlocked on the browser.
  47174. */
  47175. onAudioUnlockedObservable: Observable<IAudioEngine>;
  47176. /**
  47177. * Event raised when audio has been locked on the browser.
  47178. */
  47179. onAudioLockedObservable: Observable<IAudioEngine>;
  47180. /**
  47181. * Gets the current AudioContext if available.
  47182. */
  47183. get audioContext(): Nullable<AudioContext>;
  47184. private _connectedAnalyser;
  47185. /**
  47186. * Instantiates a new audio engine.
  47187. *
  47188. * There should be only one per page as some browsers restrict the number
  47189. * of audio contexts you can create.
  47190. * @param hostElement defines the host element where to display the mute icon if necessary
  47191. */
  47192. constructor(hostElement?: Nullable<HTMLElement>);
  47193. /**
  47194. * Flags the audio engine in Locked state.
  47195. * This happens due to new browser policies preventing audio to autoplay.
  47196. */
  47197. lock(): void;
  47198. /**
  47199. * Unlocks the audio engine once a user action has been done on the dom.
  47200. * This is helpful to resume play once browser policies have been satisfied.
  47201. */
  47202. unlock(): void;
  47203. private _resumeAudioContext;
  47204. private _initializeAudioContext;
  47205. private _tryToRun;
  47206. private _triggerRunningState;
  47207. private _triggerSuspendedState;
  47208. private _displayMuteButton;
  47209. private _moveButtonToTopLeft;
  47210. private _onResize;
  47211. private _hideMuteButton;
  47212. /**
  47213. * Destroy and release the resources associated with the audio ccontext.
  47214. */
  47215. dispose(): void;
  47216. /**
  47217. * Gets the global volume sets on the master gain.
  47218. * @returns the global volume if set or -1 otherwise
  47219. */
  47220. getGlobalVolume(): number;
  47221. /**
  47222. * Sets the global volume of your experience (sets on the master gain).
  47223. * @param newVolume Defines the new global volume of the application
  47224. */
  47225. setGlobalVolume(newVolume: number): void;
  47226. /**
  47227. * Connect the audio engine to an audio analyser allowing some amazing
  47228. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  47229. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  47230. * @param analyser The analyser to connect to the engine
  47231. */
  47232. connectToAnalyser(analyser: Analyser): void;
  47233. }
  47234. }
  47235. declare module "babylonjs/Audio/soundTrack" {
  47236. import { Sound } from "babylonjs/Audio/sound";
  47237. import { Analyser } from "babylonjs/Audio/analyser";
  47238. import { Scene } from "babylonjs/scene";
  47239. /**
  47240. * Options allowed during the creation of a sound track.
  47241. */
  47242. export interface ISoundTrackOptions {
  47243. /**
  47244. * The volume the sound track should take during creation
  47245. */
  47246. volume?: number;
  47247. /**
  47248. * Define if the sound track is the main sound track of the scene
  47249. */
  47250. mainTrack?: boolean;
  47251. }
  47252. /**
  47253. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  47254. * It will be also used in a future release to apply effects on a specific track.
  47255. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  47256. */
  47257. export class SoundTrack {
  47258. /**
  47259. * The unique identifier of the sound track in the scene.
  47260. */
  47261. id: number;
  47262. /**
  47263. * The list of sounds included in the sound track.
  47264. */
  47265. soundCollection: Array<Sound>;
  47266. private _outputAudioNode;
  47267. private _scene;
  47268. private _connectedAnalyser;
  47269. private _options;
  47270. private _isInitialized;
  47271. /**
  47272. * Creates a new sound track.
  47273. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  47274. * @param scene Define the scene the sound track belongs to
  47275. * @param options
  47276. */
  47277. constructor(scene: Scene, options?: ISoundTrackOptions);
  47278. private _initializeSoundTrackAudioGraph;
  47279. /**
  47280. * Release the sound track and its associated resources
  47281. */
  47282. dispose(): void;
  47283. /**
  47284. * Adds a sound to this sound track
  47285. * @param sound define the cound to add
  47286. * @ignoreNaming
  47287. */
  47288. addSound(sound: Sound): void;
  47289. /**
  47290. * Removes a sound to this sound track
  47291. * @param sound define the cound to remove
  47292. * @ignoreNaming
  47293. */
  47294. removeSound(sound: Sound): void;
  47295. /**
  47296. * Set a global volume for the full sound track.
  47297. * @param newVolume Define the new volume of the sound track
  47298. */
  47299. setVolume(newVolume: number): void;
  47300. /**
  47301. * Switch the panning model to HRTF:
  47302. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  47303. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47304. */
  47305. switchPanningModelToHRTF(): void;
  47306. /**
  47307. * Switch the panning model to Equal Power:
  47308. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  47309. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47310. */
  47311. switchPanningModelToEqualPower(): void;
  47312. /**
  47313. * Connect the sound track to an audio analyser allowing some amazing
  47314. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  47315. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  47316. * @param analyser The analyser to connect to the engine
  47317. */
  47318. connectToAnalyser(analyser: Analyser): void;
  47319. }
  47320. }
  47321. declare module "babylonjs/Audio/audioSceneComponent" {
  47322. import { Sound } from "babylonjs/Audio/sound";
  47323. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  47324. import { Nullable } from "babylonjs/types";
  47325. import { Vector3 } from "babylonjs/Maths/math.vector";
  47326. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47327. import { Scene } from "babylonjs/scene";
  47328. import { AbstractScene } from "babylonjs/abstractScene";
  47329. import "babylonjs/Audio/audioEngine";
  47330. module "babylonjs/abstractScene" {
  47331. interface AbstractScene {
  47332. /**
  47333. * The list of sounds used in the scene.
  47334. */
  47335. sounds: Nullable<Array<Sound>>;
  47336. }
  47337. }
  47338. module "babylonjs/scene" {
  47339. interface Scene {
  47340. /**
  47341. * @hidden
  47342. * Backing field
  47343. */
  47344. _mainSoundTrack: SoundTrack;
  47345. /**
  47346. * The main sound track played by the scene.
  47347. * It cotains your primary collection of sounds.
  47348. */
  47349. mainSoundTrack: SoundTrack;
  47350. /**
  47351. * The list of sound tracks added to the scene
  47352. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47353. */
  47354. soundTracks: Nullable<Array<SoundTrack>>;
  47355. /**
  47356. * Gets a sound using a given name
  47357. * @param name defines the name to search for
  47358. * @return the found sound or null if not found at all.
  47359. */
  47360. getSoundByName(name: string): Nullable<Sound>;
  47361. /**
  47362. * Gets or sets if audio support is enabled
  47363. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47364. */
  47365. audioEnabled: boolean;
  47366. /**
  47367. * Gets or sets if audio will be output to headphones
  47368. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47369. */
  47370. headphone: boolean;
  47371. /**
  47372. * Gets or sets custom audio listener position provider
  47373. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47374. */
  47375. audioListenerPositionProvider: Nullable<() => Vector3>;
  47376. /**
  47377. * Gets or sets a refresh rate when using 3D audio positioning
  47378. */
  47379. audioPositioningRefreshRate: number;
  47380. }
  47381. }
  47382. /**
  47383. * Defines the sound scene component responsible to manage any sounds
  47384. * in a given scene.
  47385. */
  47386. export class AudioSceneComponent implements ISceneSerializableComponent {
  47387. private static _CameraDirectionLH;
  47388. private static _CameraDirectionRH;
  47389. /**
  47390. * The component name helpfull to identify the component in the list of scene components.
  47391. */
  47392. readonly name: string;
  47393. /**
  47394. * The scene the component belongs to.
  47395. */
  47396. scene: Scene;
  47397. private _audioEnabled;
  47398. /**
  47399. * Gets whether audio is enabled or not.
  47400. * Please use related enable/disable method to switch state.
  47401. */
  47402. get audioEnabled(): boolean;
  47403. private _headphone;
  47404. /**
  47405. * Gets whether audio is outputing to headphone or not.
  47406. * Please use the according Switch methods to change output.
  47407. */
  47408. get headphone(): boolean;
  47409. /**
  47410. * Gets or sets a refresh rate when using 3D audio positioning
  47411. */
  47412. audioPositioningRefreshRate: number;
  47413. private _audioListenerPositionProvider;
  47414. /**
  47415. * Gets the current audio listener position provider
  47416. */
  47417. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  47418. /**
  47419. * Sets a custom listener position for all sounds in the scene
  47420. * By default, this is the position of the first active camera
  47421. */
  47422. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  47423. /**
  47424. * Creates a new instance of the component for the given scene
  47425. * @param scene Defines the scene to register the component in
  47426. */
  47427. constructor(scene: Scene);
  47428. /**
  47429. * Registers the component in a given scene
  47430. */
  47431. register(): void;
  47432. /**
  47433. * Rebuilds the elements related to this component in case of
  47434. * context lost for instance.
  47435. */
  47436. rebuild(): void;
  47437. /**
  47438. * Serializes the component data to the specified json object
  47439. * @param serializationObject The object to serialize to
  47440. */
  47441. serialize(serializationObject: any): void;
  47442. /**
  47443. * Adds all the elements from the container to the scene
  47444. * @param container the container holding the elements
  47445. */
  47446. addFromContainer(container: AbstractScene): void;
  47447. /**
  47448. * Removes all the elements in the container from the scene
  47449. * @param container contains the elements to remove
  47450. * @param dispose if the removed element should be disposed (default: false)
  47451. */
  47452. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47453. /**
  47454. * Disposes the component and the associated ressources.
  47455. */
  47456. dispose(): void;
  47457. /**
  47458. * Disables audio in the associated scene.
  47459. */
  47460. disableAudio(): void;
  47461. /**
  47462. * Enables audio in the associated scene.
  47463. */
  47464. enableAudio(): void;
  47465. /**
  47466. * Switch audio to headphone output.
  47467. */
  47468. switchAudioModeForHeadphones(): void;
  47469. /**
  47470. * Switch audio to normal speakers.
  47471. */
  47472. switchAudioModeForNormalSpeakers(): void;
  47473. private _cachedCameraDirection;
  47474. private _cachedCameraPosition;
  47475. private _lastCheck;
  47476. private _afterRender;
  47477. }
  47478. }
  47479. declare module "babylonjs/Audio/weightedsound" {
  47480. import { Sound } from "babylonjs/Audio/sound";
  47481. /**
  47482. * Wraps one or more Sound objects and selects one with random weight for playback.
  47483. */
  47484. export class WeightedSound {
  47485. /** When true a Sound will be selected and played when the current playing Sound completes. */
  47486. loop: boolean;
  47487. private _coneInnerAngle;
  47488. private _coneOuterAngle;
  47489. private _volume;
  47490. /** A Sound is currently playing. */
  47491. isPlaying: boolean;
  47492. /** A Sound is currently paused. */
  47493. isPaused: boolean;
  47494. private _sounds;
  47495. private _weights;
  47496. private _currentIndex?;
  47497. /**
  47498. * Creates a new WeightedSound from the list of sounds given.
  47499. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  47500. * @param sounds Array of Sounds that will be selected from.
  47501. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  47502. */
  47503. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  47504. /**
  47505. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  47506. */
  47507. get directionalConeInnerAngle(): number;
  47508. /**
  47509. * The size of cone in degress for a directional sound in which there will be no attenuation.
  47510. */
  47511. set directionalConeInnerAngle(value: number);
  47512. /**
  47513. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47514. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47515. */
  47516. get directionalConeOuterAngle(): number;
  47517. /**
  47518. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47519. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47520. */
  47521. set directionalConeOuterAngle(value: number);
  47522. /**
  47523. * Playback volume.
  47524. */
  47525. get volume(): number;
  47526. /**
  47527. * Playback volume.
  47528. */
  47529. set volume(value: number);
  47530. private _onended;
  47531. /**
  47532. * Suspend playback
  47533. */
  47534. pause(): void;
  47535. /**
  47536. * Stop playback
  47537. */
  47538. stop(): void;
  47539. /**
  47540. * Start playback.
  47541. * @param startOffset Position the clip head at a specific time in seconds.
  47542. */
  47543. play(startOffset?: number): void;
  47544. }
  47545. }
  47546. declare module "babylonjs/Audio/index" {
  47547. export * from "babylonjs/Audio/Interfaces/IAudioEngine";
  47548. export * from "babylonjs/Audio/Interfaces/ISoundOptions";
  47549. export * from "babylonjs/Audio/analyser";
  47550. export * from "babylonjs/Audio/audioEngine";
  47551. export * from "babylonjs/Audio/audioSceneComponent";
  47552. export * from "babylonjs/Audio/sound";
  47553. export * from "babylonjs/Audio/soundTrack";
  47554. export * from "babylonjs/Audio/weightedsound";
  47555. }
  47556. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  47557. import { Behavior } from "babylonjs/Behaviors/behavior";
  47558. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47559. import { BackEase } from "babylonjs/Animations/easing";
  47560. /**
  47561. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  47562. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47563. */
  47564. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  47565. /**
  47566. * Gets the name of the behavior.
  47567. */
  47568. get name(): string;
  47569. /**
  47570. * The easing function used by animations
  47571. */
  47572. static EasingFunction: BackEase;
  47573. /**
  47574. * The easing mode used by animations
  47575. */
  47576. static EasingMode: number;
  47577. /**
  47578. * The duration of the animation, in milliseconds
  47579. */
  47580. transitionDuration: number;
  47581. /**
  47582. * Length of the distance animated by the transition when lower radius is reached
  47583. */
  47584. lowerRadiusTransitionRange: number;
  47585. /**
  47586. * Length of the distance animated by the transition when upper radius is reached
  47587. */
  47588. upperRadiusTransitionRange: number;
  47589. private _autoTransitionRange;
  47590. /**
  47591. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47592. */
  47593. get autoTransitionRange(): boolean;
  47594. /**
  47595. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47596. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  47597. */
  47598. set autoTransitionRange(value: boolean);
  47599. private _attachedCamera;
  47600. private _onAfterCheckInputsObserver;
  47601. private _onMeshTargetChangedObserver;
  47602. /**
  47603. * Initializes the behavior.
  47604. */
  47605. init(): void;
  47606. /**
  47607. * Attaches the behavior to its arc rotate camera.
  47608. * @param camera Defines the camera to attach the behavior to
  47609. */
  47610. attach(camera: ArcRotateCamera): void;
  47611. /**
  47612. * Detaches the behavior from its current arc rotate camera.
  47613. */
  47614. detach(): void;
  47615. private _radiusIsAnimating;
  47616. private _radiusBounceTransition;
  47617. private _animatables;
  47618. private _cachedWheelPrecision;
  47619. /**
  47620. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  47621. * @param radiusLimit The limit to check against.
  47622. * @return Bool to indicate if at limit.
  47623. */
  47624. private _isRadiusAtLimit;
  47625. /**
  47626. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  47627. * @param radiusDelta The delta by which to animate to. Can be negative.
  47628. */
  47629. private _applyBoundRadiusAnimation;
  47630. /**
  47631. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  47632. */
  47633. protected _clearAnimationLocks(): void;
  47634. /**
  47635. * Stops and removes all animations that have been applied to the camera
  47636. */
  47637. stopAllAnimations(): void;
  47638. }
  47639. }
  47640. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  47641. import { Behavior } from "babylonjs/Behaviors/behavior";
  47642. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47643. import { ExponentialEase } from "babylonjs/Animations/easing";
  47644. import { Nullable } from "babylonjs/types";
  47645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47646. import { Vector3 } from "babylonjs/Maths/math.vector";
  47647. /**
  47648. * 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.
  47649. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47650. */
  47651. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  47652. /**
  47653. * Gets the name of the behavior.
  47654. */
  47655. get name(): string;
  47656. private _mode;
  47657. private _radiusScale;
  47658. private _positionScale;
  47659. private _defaultElevation;
  47660. private _elevationReturnTime;
  47661. private _elevationReturnWaitTime;
  47662. private _zoomStopsAnimation;
  47663. private _framingTime;
  47664. /**
  47665. * The easing function used by animations
  47666. */
  47667. static EasingFunction: ExponentialEase;
  47668. /**
  47669. * The easing mode used by animations
  47670. */
  47671. static EasingMode: number;
  47672. /**
  47673. * Sets the current mode used by the behavior
  47674. */
  47675. set mode(mode: number);
  47676. /**
  47677. * Gets current mode used by the behavior.
  47678. */
  47679. get mode(): number;
  47680. /**
  47681. * Sets the scale applied to the radius (1 by default)
  47682. */
  47683. set radiusScale(radius: number);
  47684. /**
  47685. * Gets the scale applied to the radius
  47686. */
  47687. get radiusScale(): number;
  47688. /**
  47689. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47690. */
  47691. set positionScale(scale: number);
  47692. /**
  47693. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47694. */
  47695. get positionScale(): number;
  47696. /**
  47697. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47698. * behaviour is triggered, in radians.
  47699. */
  47700. set defaultElevation(elevation: number);
  47701. /**
  47702. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47703. * behaviour is triggered, in radians.
  47704. */
  47705. get defaultElevation(): number;
  47706. /**
  47707. * Sets the time (in milliseconds) taken to return to the default beta position.
  47708. * Negative value indicates camera should not return to default.
  47709. */
  47710. set elevationReturnTime(speed: number);
  47711. /**
  47712. * Gets the time (in milliseconds) taken to return to the default beta position.
  47713. * Negative value indicates camera should not return to default.
  47714. */
  47715. get elevationReturnTime(): number;
  47716. /**
  47717. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47718. */
  47719. set elevationReturnWaitTime(time: number);
  47720. /**
  47721. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47722. */
  47723. get elevationReturnWaitTime(): number;
  47724. /**
  47725. * Sets the flag that indicates if user zooming should stop animation.
  47726. */
  47727. set zoomStopsAnimation(flag: boolean);
  47728. /**
  47729. * Gets the flag that indicates if user zooming should stop animation.
  47730. */
  47731. get zoomStopsAnimation(): boolean;
  47732. /**
  47733. * Sets the transition time when framing the mesh, in milliseconds
  47734. */
  47735. set framingTime(time: number);
  47736. /**
  47737. * Gets the transition time when framing the mesh, in milliseconds
  47738. */
  47739. get framingTime(): number;
  47740. /**
  47741. * Define if the behavior should automatically change the configured
  47742. * camera limits and sensibilities.
  47743. */
  47744. autoCorrectCameraLimitsAndSensibility: boolean;
  47745. private _onPrePointerObservableObserver;
  47746. private _onAfterCheckInputsObserver;
  47747. private _onMeshTargetChangedObserver;
  47748. private _attachedCamera;
  47749. private _isPointerDown;
  47750. private _lastInteractionTime;
  47751. /**
  47752. * Initializes the behavior.
  47753. */
  47754. init(): void;
  47755. /**
  47756. * Attaches the behavior to its arc rotate camera.
  47757. * @param camera Defines the camera to attach the behavior to
  47758. */
  47759. attach(camera: ArcRotateCamera): void;
  47760. /**
  47761. * Detaches the behavior from its current arc rotate camera.
  47762. */
  47763. detach(): void;
  47764. private _animatables;
  47765. private _betaIsAnimating;
  47766. private _betaTransition;
  47767. private _radiusTransition;
  47768. private _vectorTransition;
  47769. /**
  47770. * Targets the given mesh and updates zoom level accordingly.
  47771. * @param mesh The mesh to target.
  47772. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47773. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47774. */
  47775. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47776. /**
  47777. * Targets the given mesh with its children and updates zoom level accordingly.
  47778. * @param mesh The mesh to target.
  47779. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47780. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47781. */
  47782. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47783. /**
  47784. * Targets the given meshes with their children and updates zoom level accordingly.
  47785. * @param meshes The mesh to target.
  47786. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47787. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47788. */
  47789. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47790. /**
  47791. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47792. * @param minimumWorld Determines the smaller position of the bounding box extend
  47793. * @param maximumWorld Determines the bigger position of the bounding box extend
  47794. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47795. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47796. */
  47797. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47798. /**
  47799. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47800. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47801. * frustum width.
  47802. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47803. * to fully enclose the mesh in the viewing frustum.
  47804. */
  47805. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47806. /**
  47807. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47808. * is automatically returned to its default position (expected to be above ground plane).
  47809. */
  47810. private _maintainCameraAboveGround;
  47811. /**
  47812. * Returns the frustum slope based on the canvas ratio and camera FOV
  47813. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47814. */
  47815. private _getFrustumSlope;
  47816. /**
  47817. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47818. */
  47819. private _clearAnimationLocks;
  47820. /**
  47821. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47822. */
  47823. private _applyUserInteraction;
  47824. /**
  47825. * Stops and removes all animations that have been applied to the camera
  47826. */
  47827. stopAllAnimations(): void;
  47828. /**
  47829. * Gets a value indicating if the user is moving the camera
  47830. */
  47831. get isUserIsMoving(): boolean;
  47832. /**
  47833. * The camera can move all the way towards the mesh.
  47834. */
  47835. static IgnoreBoundsSizeMode: number;
  47836. /**
  47837. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47838. */
  47839. static FitFrustumSidesMode: number;
  47840. }
  47841. }
  47842. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47843. import { Nullable } from "babylonjs/types";
  47844. import { Camera } from "babylonjs/Cameras/camera";
  47845. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47846. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47847. /**
  47848. * Base class for Camera Pointer Inputs.
  47849. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47850. * for example usage.
  47851. */
  47852. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47853. /**
  47854. * Defines the camera the input is attached to.
  47855. */
  47856. abstract camera: Camera;
  47857. /**
  47858. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47859. */
  47860. protected _altKey: boolean;
  47861. protected _ctrlKey: boolean;
  47862. protected _metaKey: boolean;
  47863. protected _shiftKey: boolean;
  47864. /**
  47865. * Which mouse buttons were pressed at time of last mouse event.
  47866. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47867. */
  47868. protected _buttonsPressed: number;
  47869. /**
  47870. * Defines the buttons associated with the input to handle camera move.
  47871. */
  47872. buttons: number[];
  47873. /**
  47874. * Attach the input controls to a specific dom element to get the input from.
  47875. * @param element Defines the element the controls should be listened from
  47876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47877. */
  47878. attachControl(noPreventDefault?: boolean): void;
  47879. /**
  47880. * Detach the current controls from the specified dom element.
  47881. */
  47882. detachControl(): void;
  47883. /**
  47884. * Gets the class name of the current input.
  47885. * @returns the class name
  47886. */
  47887. getClassName(): string;
  47888. /**
  47889. * Get the friendly name associated with the input class.
  47890. * @returns the input friendly name
  47891. */
  47892. getSimpleName(): string;
  47893. /**
  47894. * Called on pointer POINTERDOUBLETAP event.
  47895. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47896. */
  47897. protected onDoubleTap(type: string): void;
  47898. /**
  47899. * Called on pointer POINTERMOVE event if only a single touch is active.
  47900. * Override this method to provide functionality.
  47901. */
  47902. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47903. /**
  47904. * Called on pointer POINTERMOVE event if multiple touches are active.
  47905. * Override this method to provide functionality.
  47906. */
  47907. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47908. /**
  47909. * Called on JS contextmenu event.
  47910. * Override this method to provide functionality.
  47911. */
  47912. protected onContextMenu(evt: PointerEvent): void;
  47913. /**
  47914. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47915. * press.
  47916. * Override this method to provide functionality.
  47917. */
  47918. protected onButtonDown(evt: PointerEvent): void;
  47919. /**
  47920. * Called each time a new POINTERUP event occurs. Ie, for each button
  47921. * release.
  47922. * Override this method to provide functionality.
  47923. */
  47924. protected onButtonUp(evt: PointerEvent): void;
  47925. /**
  47926. * Called when window becomes inactive.
  47927. * Override this method to provide functionality.
  47928. */
  47929. protected onLostFocus(): void;
  47930. private _pointerInput;
  47931. private _observer;
  47932. private _onLostFocus;
  47933. private pointA;
  47934. private pointB;
  47935. }
  47936. }
  47937. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47938. import { Nullable } from "babylonjs/types";
  47939. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47940. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47941. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47942. /**
  47943. * Manage the pointers inputs to control an arc rotate camera.
  47944. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47945. */
  47946. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47947. /**
  47948. * Defines the camera the input is attached to.
  47949. */
  47950. camera: ArcRotateCamera;
  47951. /**
  47952. * Gets the class name of the current input.
  47953. * @returns the class name
  47954. */
  47955. getClassName(): string;
  47956. /**
  47957. * Defines the buttons associated with the input to handle camera move.
  47958. */
  47959. buttons: number[];
  47960. /**
  47961. * Defines the pointer angular sensibility along the X axis or how fast is
  47962. * the camera rotating.
  47963. */
  47964. angularSensibilityX: number;
  47965. /**
  47966. * Defines the pointer angular sensibility along the Y axis or how fast is
  47967. * the camera rotating.
  47968. */
  47969. angularSensibilityY: number;
  47970. /**
  47971. * Defines the pointer pinch precision or how fast is the camera zooming.
  47972. */
  47973. pinchPrecision: number;
  47974. /**
  47975. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47976. * from 0.
  47977. * It defines the percentage of current camera.radius to use as delta when
  47978. * pinch zoom is used.
  47979. */
  47980. pinchDeltaPercentage: number;
  47981. /**
  47982. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47983. * that any object in the plane at the camera's target point will scale
  47984. * perfectly with finger motion.
  47985. * Overrides pinchDeltaPercentage and pinchPrecision.
  47986. */
  47987. useNaturalPinchZoom: boolean;
  47988. /**
  47989. * Defines the pointer panning sensibility or how fast is the camera moving.
  47990. */
  47991. panningSensibility: number;
  47992. /**
  47993. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47994. */
  47995. multiTouchPanning: boolean;
  47996. /**
  47997. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47998. * zoom (pinch) through multitouch.
  47999. */
  48000. multiTouchPanAndZoom: boolean;
  48001. /**
  48002. * Revers pinch action direction.
  48003. */
  48004. pinchInwards: boolean;
  48005. private _isPanClick;
  48006. private _twoFingerActivityCount;
  48007. private _isPinching;
  48008. /**
  48009. * Called on pointer POINTERMOVE event if only a single touch is active.
  48010. */
  48011. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48012. /**
  48013. * Called on pointer POINTERDOUBLETAP event.
  48014. */
  48015. protected onDoubleTap(type: string): void;
  48016. /**
  48017. * Called on pointer POINTERMOVE event if multiple touches are active.
  48018. */
  48019. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48020. /**
  48021. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  48022. * press.
  48023. */
  48024. protected onButtonDown(evt: PointerEvent): void;
  48025. /**
  48026. * Called each time a new POINTERUP event occurs. Ie, for each button
  48027. * release.
  48028. */
  48029. protected onButtonUp(evt: PointerEvent): void;
  48030. /**
  48031. * Called when window becomes inactive.
  48032. */
  48033. protected onLostFocus(): void;
  48034. }
  48035. }
  48036. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  48037. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48038. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48039. /**
  48040. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  48041. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48042. */
  48043. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  48044. /**
  48045. * Defines the camera the input is attached to.
  48046. */
  48047. camera: ArcRotateCamera;
  48048. /**
  48049. * Defines the list of key codes associated with the up action (increase alpha)
  48050. */
  48051. keysUp: number[];
  48052. /**
  48053. * Defines the list of key codes associated with the down action (decrease alpha)
  48054. */
  48055. keysDown: number[];
  48056. /**
  48057. * Defines the list of key codes associated with the left action (increase beta)
  48058. */
  48059. keysLeft: number[];
  48060. /**
  48061. * Defines the list of key codes associated with the right action (decrease beta)
  48062. */
  48063. keysRight: number[];
  48064. /**
  48065. * Defines the list of key codes associated with the reset action.
  48066. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  48067. */
  48068. keysReset: number[];
  48069. /**
  48070. * Defines the panning sensibility of the inputs.
  48071. * (How fast is the camera panning)
  48072. */
  48073. panningSensibility: number;
  48074. /**
  48075. * Defines the zooming sensibility of the inputs.
  48076. * (How fast is the camera zooming)
  48077. */
  48078. zoomingSensibility: number;
  48079. /**
  48080. * Defines whether maintaining the alt key down switch the movement mode from
  48081. * orientation to zoom.
  48082. */
  48083. useAltToZoom: boolean;
  48084. /**
  48085. * Rotation speed of the camera
  48086. */
  48087. angularSpeed: number;
  48088. private _keys;
  48089. private _ctrlPressed;
  48090. private _altPressed;
  48091. private _onCanvasBlurObserver;
  48092. private _onKeyboardObserver;
  48093. private _engine;
  48094. private _scene;
  48095. /**
  48096. * Attach the input controls to a specific dom element to get the input from.
  48097. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48098. */
  48099. attachControl(noPreventDefault?: boolean): void;
  48100. /**
  48101. * Detach the current controls from the specified dom element.
  48102. */
  48103. detachControl(): void;
  48104. /**
  48105. * Update the current camera state depending on the inputs that have been used this frame.
  48106. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48107. */
  48108. checkInputs(): void;
  48109. /**
  48110. * Gets the class name of the current intput.
  48111. * @returns the class name
  48112. */
  48113. getClassName(): string;
  48114. /**
  48115. * Get the friendly name associated with the input class.
  48116. * @returns the input friendly name
  48117. */
  48118. getSimpleName(): string;
  48119. }
  48120. }
  48121. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  48122. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48123. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48124. /**
  48125. * Manage the mouse wheel inputs to control an arc rotate camera.
  48126. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48127. */
  48128. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  48129. /**
  48130. * Defines the camera the input is attached to.
  48131. */
  48132. camera: ArcRotateCamera;
  48133. /**
  48134. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48135. */
  48136. wheelPrecision: number;
  48137. /**
  48138. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48139. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48140. */
  48141. wheelDeltaPercentage: number;
  48142. private _wheel;
  48143. private _observer;
  48144. private computeDeltaFromMouseWheelLegacyEvent;
  48145. /**
  48146. * Attach the input controls to a specific dom element to get the input from.
  48147. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48148. */
  48149. attachControl(noPreventDefault?: boolean): void;
  48150. /**
  48151. * Detach the current controls from the specified dom element.
  48152. */
  48153. detachControl(): void;
  48154. /**
  48155. * Gets the class name of the current intput.
  48156. * @returns the class name
  48157. */
  48158. getClassName(): string;
  48159. /**
  48160. * Get the friendly name associated with the input class.
  48161. * @returns the input friendly name
  48162. */
  48163. getSimpleName(): string;
  48164. }
  48165. }
  48166. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  48167. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48168. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  48169. /**
  48170. * Default Inputs manager for the ArcRotateCamera.
  48171. * It groups all the default supported inputs for ease of use.
  48172. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48173. */
  48174. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  48175. /**
  48176. * Instantiates a new ArcRotateCameraInputsManager.
  48177. * @param camera Defines the camera the inputs belong to
  48178. */
  48179. constructor(camera: ArcRotateCamera);
  48180. /**
  48181. * Add mouse wheel input support to the input manager.
  48182. * @returns the current input manager
  48183. */
  48184. addMouseWheel(): ArcRotateCameraInputsManager;
  48185. /**
  48186. * Add pointers input support to the input manager.
  48187. * @returns the current input manager
  48188. */
  48189. addPointers(): ArcRotateCameraInputsManager;
  48190. /**
  48191. * Add keyboard input support to the input manager.
  48192. * @returns the current input manager
  48193. */
  48194. addKeyboard(): ArcRotateCameraInputsManager;
  48195. }
  48196. }
  48197. declare module "babylonjs/Cameras/arcRotateCamera" {
  48198. import { Observable } from "babylonjs/Misc/observable";
  48199. import { Nullable } from "babylonjs/types";
  48200. import { Scene } from "babylonjs/scene";
  48201. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  48202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48203. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48204. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48205. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  48206. import { Camera } from "babylonjs/Cameras/camera";
  48207. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  48208. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  48209. import { Collider } from "babylonjs/Collisions/collider";
  48210. /**
  48211. * This represents an orbital type of camera.
  48212. *
  48213. * 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.
  48214. * 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.
  48215. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  48216. */
  48217. export class ArcRotateCamera extends TargetCamera {
  48218. /**
  48219. * Defines the rotation angle of the camera along the longitudinal axis.
  48220. */
  48221. alpha: number;
  48222. /**
  48223. * Defines the rotation angle of the camera along the latitudinal axis.
  48224. */
  48225. beta: number;
  48226. /**
  48227. * Defines the radius of the camera from it s target point.
  48228. */
  48229. radius: number;
  48230. protected _target: Vector3;
  48231. protected _targetHost: Nullable<AbstractMesh>;
  48232. /**
  48233. * Defines the target point of the camera.
  48234. * The camera looks towards it form the radius distance.
  48235. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  48236. */
  48237. get target(): Vector3;
  48238. set target(value: Vector3);
  48239. /**
  48240. * Define the current local position of the camera in the scene
  48241. */
  48242. get position(): Vector3;
  48243. set position(newPosition: Vector3);
  48244. protected _upToYMatrix: Matrix;
  48245. protected _YToUpMatrix: Matrix;
  48246. /**
  48247. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  48248. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  48249. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  48250. */
  48251. set upVector(vec: Vector3);
  48252. get upVector(): Vector3;
  48253. /**
  48254. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  48255. */
  48256. setMatUp(): void;
  48257. /**
  48258. * Current inertia value on the longitudinal axis.
  48259. * The bigger this number the longer it will take for the camera to stop.
  48260. */
  48261. inertialAlphaOffset: number;
  48262. /**
  48263. * Current inertia value on the latitudinal axis.
  48264. * The bigger this number the longer it will take for the camera to stop.
  48265. */
  48266. inertialBetaOffset: number;
  48267. /**
  48268. * Current inertia value on the radius axis.
  48269. * The bigger this number the longer it will take for the camera to stop.
  48270. */
  48271. inertialRadiusOffset: number;
  48272. /**
  48273. * Minimum allowed angle on the longitudinal axis.
  48274. * This can help limiting how the Camera is able to move in the scene.
  48275. */
  48276. lowerAlphaLimit: Nullable<number>;
  48277. /**
  48278. * Maximum allowed angle on the longitudinal axis.
  48279. * This can help limiting how the Camera is able to move in the scene.
  48280. */
  48281. upperAlphaLimit: Nullable<number>;
  48282. /**
  48283. * Minimum allowed angle on the latitudinal axis.
  48284. * This can help limiting how the Camera is able to move in the scene.
  48285. */
  48286. lowerBetaLimit: number;
  48287. /**
  48288. * Maximum allowed angle on the latitudinal axis.
  48289. * This can help limiting how the Camera is able to move in the scene.
  48290. */
  48291. upperBetaLimit: number;
  48292. /**
  48293. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  48294. * This can help limiting how the Camera is able to move in the scene.
  48295. */
  48296. lowerRadiusLimit: Nullable<number>;
  48297. /**
  48298. * Maximum allowed distance of the camera to the target (The camera can not get further).
  48299. * This can help limiting how the Camera is able to move in the scene.
  48300. */
  48301. upperRadiusLimit: Nullable<number>;
  48302. /**
  48303. * Defines the current inertia value used during panning of the camera along the X axis.
  48304. */
  48305. inertialPanningX: number;
  48306. /**
  48307. * Defines the current inertia value used during panning of the camera along the Y axis.
  48308. */
  48309. inertialPanningY: number;
  48310. /**
  48311. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  48312. * Basically if your fingers moves away from more than this distance you will be considered
  48313. * in pinch mode.
  48314. */
  48315. pinchToPanMaxDistance: number;
  48316. /**
  48317. * Defines the maximum distance the camera can pan.
  48318. * This could help keeping the cammera always in your scene.
  48319. */
  48320. panningDistanceLimit: Nullable<number>;
  48321. /**
  48322. * Defines the target of the camera before paning.
  48323. */
  48324. panningOriginTarget: Vector3;
  48325. /**
  48326. * Defines the value of the inertia used during panning.
  48327. * 0 would mean stop inertia and one would mean no decelleration at all.
  48328. */
  48329. panningInertia: number;
  48330. /**
  48331. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  48332. */
  48333. get angularSensibilityX(): number;
  48334. set angularSensibilityX(value: number);
  48335. /**
  48336. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  48337. */
  48338. get angularSensibilityY(): number;
  48339. set angularSensibilityY(value: number);
  48340. /**
  48341. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  48342. */
  48343. get pinchPrecision(): number;
  48344. set pinchPrecision(value: number);
  48345. /**
  48346. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  48347. * It will be used instead of pinchDeltaPrecision if different from 0.
  48348. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48349. */
  48350. get pinchDeltaPercentage(): number;
  48351. set pinchDeltaPercentage(value: number);
  48352. /**
  48353. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  48354. * and pinch delta percentage.
  48355. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  48356. * that any object in the plane at the camera's target point will scale
  48357. * perfectly with finger motion.
  48358. */
  48359. get useNaturalPinchZoom(): boolean;
  48360. set useNaturalPinchZoom(value: boolean);
  48361. /**
  48362. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  48363. */
  48364. get panningSensibility(): number;
  48365. set panningSensibility(value: number);
  48366. /**
  48367. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  48368. */
  48369. get keysUp(): number[];
  48370. set keysUp(value: number[]);
  48371. /**
  48372. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  48373. */
  48374. get keysDown(): number[];
  48375. set keysDown(value: number[]);
  48376. /**
  48377. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  48378. */
  48379. get keysLeft(): number[];
  48380. set keysLeft(value: number[]);
  48381. /**
  48382. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  48383. */
  48384. get keysRight(): number[];
  48385. set keysRight(value: number[]);
  48386. /**
  48387. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48388. */
  48389. get wheelPrecision(): number;
  48390. set wheelPrecision(value: number);
  48391. /**
  48392. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  48393. * It will be used instead of pinchDeltaPrecision if different from 0.
  48394. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48395. */
  48396. get wheelDeltaPercentage(): number;
  48397. set wheelDeltaPercentage(value: number);
  48398. /**
  48399. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  48400. */
  48401. zoomOnFactor: number;
  48402. /**
  48403. * Defines a screen offset for the camera position.
  48404. */
  48405. targetScreenOffset: Vector2;
  48406. /**
  48407. * Allows the camera to be completely reversed.
  48408. * If false the camera can not arrive upside down.
  48409. */
  48410. allowUpsideDown: boolean;
  48411. /**
  48412. * Define if double tap/click is used to restore the previously saved state of the camera.
  48413. */
  48414. useInputToRestoreState: boolean;
  48415. /** @hidden */
  48416. _viewMatrix: Matrix;
  48417. /** @hidden */
  48418. _useCtrlForPanning: boolean;
  48419. /** @hidden */
  48420. _panningMouseButton: number;
  48421. /**
  48422. * Defines the input associated to the camera.
  48423. */
  48424. inputs: ArcRotateCameraInputsManager;
  48425. /** @hidden */
  48426. _reset: () => void;
  48427. /**
  48428. * Defines the allowed panning axis.
  48429. */
  48430. panningAxis: Vector3;
  48431. protected _localDirection: Vector3;
  48432. protected _transformedDirection: Vector3;
  48433. private _bouncingBehavior;
  48434. /**
  48435. * Gets the bouncing behavior of the camera if it has been enabled.
  48436. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48437. */
  48438. get bouncingBehavior(): Nullable<BouncingBehavior>;
  48439. /**
  48440. * Defines if the bouncing behavior of the camera is enabled on the camera.
  48441. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48442. */
  48443. get useBouncingBehavior(): boolean;
  48444. set useBouncingBehavior(value: boolean);
  48445. private _framingBehavior;
  48446. /**
  48447. * Gets the framing behavior of the camera if it has been enabled.
  48448. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48449. */
  48450. get framingBehavior(): Nullable<FramingBehavior>;
  48451. /**
  48452. * Defines if the framing behavior of the camera is enabled on the camera.
  48453. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48454. */
  48455. get useFramingBehavior(): boolean;
  48456. set useFramingBehavior(value: boolean);
  48457. private _autoRotationBehavior;
  48458. /**
  48459. * Gets the auto rotation behavior of the camera if it has been enabled.
  48460. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48461. */
  48462. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  48463. /**
  48464. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  48465. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48466. */
  48467. get useAutoRotationBehavior(): boolean;
  48468. set useAutoRotationBehavior(value: boolean);
  48469. /**
  48470. * Observable triggered when the mesh target has been changed on the camera.
  48471. */
  48472. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  48473. /**
  48474. * Event raised when the camera is colliding with a mesh.
  48475. */
  48476. onCollide: (collidedMesh: AbstractMesh) => void;
  48477. /**
  48478. * Defines whether the camera should check collision with the objects oh the scene.
  48479. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  48480. */
  48481. checkCollisions: boolean;
  48482. /**
  48483. * Defines the collision radius of the camera.
  48484. * This simulates a sphere around the camera.
  48485. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  48486. */
  48487. collisionRadius: Vector3;
  48488. protected _collider: Collider;
  48489. protected _previousPosition: Vector3;
  48490. protected _collisionVelocity: Vector3;
  48491. protected _newPosition: Vector3;
  48492. protected _previousAlpha: number;
  48493. protected _previousBeta: number;
  48494. protected _previousRadius: number;
  48495. protected _collisionTriggered: boolean;
  48496. protected _targetBoundingCenter: Nullable<Vector3>;
  48497. private _computationVector;
  48498. /**
  48499. * Instantiates a new ArcRotateCamera in a given scene
  48500. * @param name Defines the name of the camera
  48501. * @param alpha Defines the camera rotation along the logitudinal axis
  48502. * @param beta Defines the camera rotation along the latitudinal axis
  48503. * @param radius Defines the camera distance from its target
  48504. * @param target Defines the camera target
  48505. * @param scene Defines the scene the camera belongs to
  48506. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  48507. */
  48508. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48509. /** @hidden */
  48510. _initCache(): void;
  48511. /** @hidden */
  48512. _updateCache(ignoreParentClass?: boolean): void;
  48513. protected _getTargetPosition(): Vector3;
  48514. private _storedAlpha;
  48515. private _storedBeta;
  48516. private _storedRadius;
  48517. private _storedTarget;
  48518. private _storedTargetScreenOffset;
  48519. /**
  48520. * Stores the current state of the camera (alpha, beta, radius and target)
  48521. * @returns the camera itself
  48522. */
  48523. storeState(): Camera;
  48524. /**
  48525. * @hidden
  48526. * Restored camera state. You must call storeState() first
  48527. */
  48528. _restoreStateValues(): boolean;
  48529. /** @hidden */
  48530. _isSynchronizedViewMatrix(): boolean;
  48531. /**
  48532. * Attach the input controls to a specific dom element to get the input from.
  48533. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48534. */
  48535. attachControl(noPreventDefault?: boolean): void;
  48536. /**
  48537. * Attach the input controls to a specific dom element to get the input from.
  48538. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  48539. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48540. */
  48541. attachControl(ignored: any, noPreventDefault?: boolean): void;
  48542. /**
  48543. * Attached controls to the current camera.
  48544. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48545. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48546. */
  48547. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48548. /**
  48549. * Attached controls to the current camera.
  48550. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  48551. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48552. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48553. */
  48554. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48555. /**
  48556. * Attached controls to the current camera.
  48557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48558. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48559. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  48560. */
  48561. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  48562. /**
  48563. * Detach the current controls from the specified dom element.
  48564. */
  48565. detachControl(): void;
  48566. /**
  48567. * Detach the current controls from the specified dom element.
  48568. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  48569. */
  48570. detachControl(ignored: any): void;
  48571. /** @hidden */
  48572. _checkInputs(): void;
  48573. protected _checkLimits(): void;
  48574. /**
  48575. * Rebuilds angles (alpha, beta) and radius from the give position and target
  48576. */
  48577. rebuildAnglesAndRadius(): void;
  48578. /**
  48579. * Use a position to define the current camera related information like alpha, beta and radius
  48580. * @param position Defines the position to set the camera at
  48581. */
  48582. setPosition(position: Vector3): void;
  48583. /**
  48584. * Defines the target the camera should look at.
  48585. * This will automatically adapt alpha beta and radius to fit within the new target.
  48586. * @param target Defines the new target as a Vector or a mesh
  48587. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  48588. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  48589. */
  48590. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  48591. /** @hidden */
  48592. _getViewMatrix(): Matrix;
  48593. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  48594. /**
  48595. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  48596. * @param meshes Defines the mesh to zoom on
  48597. * @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)
  48598. */
  48599. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  48600. /**
  48601. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  48602. * The target will be changed but the radius
  48603. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  48604. * @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)
  48605. */
  48606. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  48607. min: Vector3;
  48608. max: Vector3;
  48609. distance: number;
  48610. }, doNotUpdateMaxZ?: boolean): void;
  48611. /**
  48612. * @override
  48613. * Override Camera.createRigCamera
  48614. */
  48615. createRigCamera(name: string, cameraIndex: number): Camera;
  48616. /**
  48617. * @hidden
  48618. * @override
  48619. * Override Camera._updateRigCameras
  48620. */
  48621. _updateRigCameras(): void;
  48622. /**
  48623. * Destroy the camera and release the current resources hold by it.
  48624. */
  48625. dispose(): void;
  48626. /**
  48627. * Gets the current object class name.
  48628. * @return the class name
  48629. */
  48630. getClassName(): string;
  48631. }
  48632. }
  48633. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  48634. import { Behavior } from "babylonjs/Behaviors/behavior";
  48635. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48636. /**
  48637. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  48638. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48639. */
  48640. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  48641. /**
  48642. * Gets the name of the behavior.
  48643. */
  48644. get name(): string;
  48645. private _zoomStopsAnimation;
  48646. private _idleRotationSpeed;
  48647. private _idleRotationWaitTime;
  48648. private _idleRotationSpinupTime;
  48649. /**
  48650. * Sets the flag that indicates if user zooming should stop animation.
  48651. */
  48652. set zoomStopsAnimation(flag: boolean);
  48653. /**
  48654. * Gets the flag that indicates if user zooming should stop animation.
  48655. */
  48656. get zoomStopsAnimation(): boolean;
  48657. /**
  48658. * Sets the default speed at which the camera rotates around the model.
  48659. */
  48660. set idleRotationSpeed(speed: number);
  48661. /**
  48662. * Gets the default speed at which the camera rotates around the model.
  48663. */
  48664. get idleRotationSpeed(): number;
  48665. /**
  48666. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  48667. */
  48668. set idleRotationWaitTime(time: number);
  48669. /**
  48670. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  48671. */
  48672. get idleRotationWaitTime(): number;
  48673. /**
  48674. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48675. */
  48676. set idleRotationSpinupTime(time: number);
  48677. /**
  48678. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48679. */
  48680. get idleRotationSpinupTime(): number;
  48681. /**
  48682. * Gets a value indicating if the camera is currently rotating because of this behavior
  48683. */
  48684. get rotationInProgress(): boolean;
  48685. private _onPrePointerObservableObserver;
  48686. private _onAfterCheckInputsObserver;
  48687. private _attachedCamera;
  48688. private _isPointerDown;
  48689. private _lastFrameTime;
  48690. private _lastInteractionTime;
  48691. private _cameraRotationSpeed;
  48692. /**
  48693. * Initializes the behavior.
  48694. */
  48695. init(): void;
  48696. /**
  48697. * Attaches the behavior to its arc rotate camera.
  48698. * @param camera Defines the camera to attach the behavior to
  48699. */
  48700. attach(camera: ArcRotateCamera): void;
  48701. /**
  48702. * Detaches the behavior from its current arc rotate camera.
  48703. */
  48704. detach(): void;
  48705. /**
  48706. * Returns true if user is scrolling.
  48707. * @return true if user is scrolling.
  48708. */
  48709. private _userIsZooming;
  48710. private _lastFrameRadius;
  48711. private _shouldAnimationStopForInteraction;
  48712. /**
  48713. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48714. */
  48715. private _applyUserInteraction;
  48716. private _userIsMoving;
  48717. }
  48718. }
  48719. declare module "babylonjs/Behaviors/Cameras/index" {
  48720. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48721. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48722. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48723. }
  48724. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48725. import { Mesh } from "babylonjs/Meshes/mesh";
  48726. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48727. import { Behavior } from "babylonjs/Behaviors/behavior";
  48728. /**
  48729. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48730. */
  48731. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48732. private ui;
  48733. /**
  48734. * The name of the behavior
  48735. */
  48736. name: string;
  48737. /**
  48738. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48739. */
  48740. distanceAwayFromFace: number;
  48741. /**
  48742. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48743. */
  48744. distanceAwayFromBottomOfFace: number;
  48745. private _faceVectors;
  48746. private _target;
  48747. private _scene;
  48748. private _onRenderObserver;
  48749. private _tmpMatrix;
  48750. private _tmpVector;
  48751. /**
  48752. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48753. * @param ui The transform node that should be attched to the mesh
  48754. */
  48755. constructor(ui: TransformNode);
  48756. /**
  48757. * Initializes the behavior
  48758. */
  48759. init(): void;
  48760. private _closestFace;
  48761. private _zeroVector;
  48762. private _lookAtTmpMatrix;
  48763. private _lookAtToRef;
  48764. /**
  48765. * Attaches the AttachToBoxBehavior to the passed in mesh
  48766. * @param target The mesh that the specified node will be attached to
  48767. */
  48768. attach(target: Mesh): void;
  48769. /**
  48770. * Detaches the behavior from the mesh
  48771. */
  48772. detach(): void;
  48773. }
  48774. }
  48775. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48776. import { Behavior } from "babylonjs/Behaviors/behavior";
  48777. import { Mesh } from "babylonjs/Meshes/mesh";
  48778. /**
  48779. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48780. */
  48781. export class FadeInOutBehavior implements Behavior<Mesh> {
  48782. /**
  48783. * Time in milliseconds to delay before fading in (Default: 0)
  48784. */
  48785. delay: number;
  48786. /**
  48787. * Time in milliseconds for the mesh to fade in (Default: 300)
  48788. */
  48789. fadeInTime: number;
  48790. private _millisecondsPerFrame;
  48791. private _hovered;
  48792. private _hoverValue;
  48793. private _ownerNode;
  48794. /**
  48795. * Instatiates the FadeInOutBehavior
  48796. */
  48797. constructor();
  48798. /**
  48799. * The name of the behavior
  48800. */
  48801. get name(): string;
  48802. /**
  48803. * Initializes the behavior
  48804. */
  48805. init(): void;
  48806. /**
  48807. * Attaches the fade behavior on the passed in mesh
  48808. * @param ownerNode The mesh that will be faded in/out once attached
  48809. */
  48810. attach(ownerNode: Mesh): void;
  48811. /**
  48812. * Detaches the behavior from the mesh
  48813. */
  48814. detach(): void;
  48815. /**
  48816. * Triggers the mesh to begin fading in or out
  48817. * @param value if the object should fade in or out (true to fade in)
  48818. */
  48819. fadeIn(value: boolean): void;
  48820. private _update;
  48821. private _setAllVisibility;
  48822. }
  48823. }
  48824. declare module "babylonjs/Misc/pivotTools" {
  48825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48826. /**
  48827. * Class containing a set of static utilities functions for managing Pivots
  48828. * @hidden
  48829. */
  48830. export class PivotTools {
  48831. private static _PivotCached;
  48832. private static _OldPivotPoint;
  48833. private static _PivotTranslation;
  48834. private static _PivotTmpVector;
  48835. private static _PivotPostMultiplyPivotMatrix;
  48836. /** @hidden */
  48837. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48838. /** @hidden */
  48839. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48840. }
  48841. }
  48842. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48843. import { Scene } from "babylonjs/scene";
  48844. import { Vector4 } from "babylonjs/Maths/math.vector";
  48845. import { Mesh } from "babylonjs/Meshes/mesh";
  48846. import { Nullable } from "babylonjs/types";
  48847. import { Plane } from "babylonjs/Maths/math.plane";
  48848. /**
  48849. * Class containing static functions to help procedurally build meshes
  48850. */
  48851. export class PlaneBuilder {
  48852. /**
  48853. * Creates a plane mesh
  48854. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48855. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48856. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48858. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48860. * @param name defines the name of the mesh
  48861. * @param options defines the options used to create the mesh
  48862. * @param scene defines the hosting scene
  48863. * @returns the plane mesh
  48864. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48865. */
  48866. static CreatePlane(name: string, options: {
  48867. size?: number;
  48868. width?: number;
  48869. height?: number;
  48870. sideOrientation?: number;
  48871. frontUVs?: Vector4;
  48872. backUVs?: Vector4;
  48873. updatable?: boolean;
  48874. sourcePlane?: Plane;
  48875. }, scene?: Nullable<Scene>): Mesh;
  48876. }
  48877. }
  48878. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48879. import { Behavior } from "babylonjs/Behaviors/behavior";
  48880. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48881. import { Observable } from "babylonjs/Misc/observable";
  48882. import { Vector3 } from "babylonjs/Maths/math.vector";
  48883. import { Ray } from "babylonjs/Culling/ray";
  48884. import "babylonjs/Meshes/Builders/planeBuilder";
  48885. /**
  48886. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48887. */
  48888. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48889. private static _AnyMouseID;
  48890. /**
  48891. * Abstract mesh the behavior is set on
  48892. */
  48893. attachedNode: AbstractMesh;
  48894. private _dragPlane;
  48895. private _scene;
  48896. private _pointerObserver;
  48897. private _beforeRenderObserver;
  48898. private static _planeScene;
  48899. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48900. /**
  48901. * 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)
  48902. */
  48903. maxDragAngle: number;
  48904. /**
  48905. * @hidden
  48906. */
  48907. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48908. /**
  48909. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48910. */
  48911. currentDraggingPointerID: number;
  48912. /**
  48913. * The last position where the pointer hit the drag plane in world space
  48914. */
  48915. lastDragPosition: Vector3;
  48916. /**
  48917. * If the behavior is currently in a dragging state
  48918. */
  48919. dragging: boolean;
  48920. /**
  48921. * 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)
  48922. */
  48923. dragDeltaRatio: number;
  48924. /**
  48925. * If the drag plane orientation should be updated during the dragging (Default: true)
  48926. */
  48927. updateDragPlane: boolean;
  48928. private _debugMode;
  48929. private _moving;
  48930. /**
  48931. * Fires each time the attached mesh is dragged with the pointer
  48932. * * delta between last drag position and current drag position in world space
  48933. * * dragDistance along the drag axis
  48934. * * dragPlaneNormal normal of the current drag plane used during the drag
  48935. * * dragPlanePoint in world space where the drag intersects the drag plane
  48936. */
  48937. onDragObservable: Observable<{
  48938. delta: Vector3;
  48939. dragPlanePoint: Vector3;
  48940. dragPlaneNormal: Vector3;
  48941. dragDistance: number;
  48942. pointerId: number;
  48943. }>;
  48944. /**
  48945. * Fires each time a drag begins (eg. mouse down on mesh)
  48946. */
  48947. onDragStartObservable: Observable<{
  48948. dragPlanePoint: Vector3;
  48949. pointerId: number;
  48950. }>;
  48951. /**
  48952. * Fires each time a drag ends (eg. mouse release after drag)
  48953. */
  48954. onDragEndObservable: Observable<{
  48955. dragPlanePoint: Vector3;
  48956. pointerId: number;
  48957. }>;
  48958. /**
  48959. * If the attached mesh should be moved when dragged
  48960. */
  48961. moveAttached: boolean;
  48962. /**
  48963. * If the drag behavior will react to drag events (Default: true)
  48964. */
  48965. enabled: boolean;
  48966. /**
  48967. * If pointer events should start and release the drag (Default: true)
  48968. */
  48969. startAndReleaseDragOnPointerEvents: boolean;
  48970. /**
  48971. * If camera controls should be detached during the drag
  48972. */
  48973. detachCameraControls: boolean;
  48974. /**
  48975. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48976. */
  48977. useObjectOrientationForDragging: boolean;
  48978. private _options;
  48979. /**
  48980. * Gets the options used by the behavior
  48981. */
  48982. get options(): {
  48983. dragAxis?: Vector3;
  48984. dragPlaneNormal?: Vector3;
  48985. };
  48986. /**
  48987. * Sets the options used by the behavior
  48988. */
  48989. set options(options: {
  48990. dragAxis?: Vector3;
  48991. dragPlaneNormal?: Vector3;
  48992. });
  48993. /**
  48994. * Creates a pointer drag behavior that can be attached to a mesh
  48995. * @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)
  48996. */
  48997. constructor(options?: {
  48998. dragAxis?: Vector3;
  48999. dragPlaneNormal?: Vector3;
  49000. });
  49001. /**
  49002. * Predicate to determine if it is valid to move the object to a new position when it is moved
  49003. */
  49004. validateDrag: (targetPosition: Vector3) => boolean;
  49005. /**
  49006. * The name of the behavior
  49007. */
  49008. get name(): string;
  49009. /**
  49010. * Initializes the behavior
  49011. */
  49012. init(): void;
  49013. private _tmpVector;
  49014. private _alternatePickedPoint;
  49015. private _worldDragAxis;
  49016. private _targetPosition;
  49017. private _attachedToElement;
  49018. /**
  49019. * Attaches the drag behavior the passed in mesh
  49020. * @param ownerNode The mesh that will be dragged around once attached
  49021. * @param predicate Predicate to use for pick filtering
  49022. */
  49023. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  49024. /**
  49025. * Force relase the drag action by code.
  49026. */
  49027. releaseDrag(): void;
  49028. private _startDragRay;
  49029. private _lastPointerRay;
  49030. /**
  49031. * Simulates the start of a pointer drag event on the behavior
  49032. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  49033. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  49034. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  49035. */
  49036. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  49037. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  49038. private _dragDelta;
  49039. protected _moveDrag(ray: Ray): void;
  49040. private _pickWithRayOnDragPlane;
  49041. private _pointA;
  49042. private _pointC;
  49043. private _localAxis;
  49044. private _lookAt;
  49045. private _updateDragPlanePosition;
  49046. /**
  49047. * Detaches the behavior from the mesh
  49048. */
  49049. detach(): void;
  49050. }
  49051. }
  49052. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  49053. import { Mesh } from "babylonjs/Meshes/mesh";
  49054. import { Behavior } from "babylonjs/Behaviors/behavior";
  49055. /**
  49056. * A behavior that when attached to a mesh will allow the mesh to be scaled
  49057. */
  49058. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  49059. private _dragBehaviorA;
  49060. private _dragBehaviorB;
  49061. private _startDistance;
  49062. private _initialScale;
  49063. private _targetScale;
  49064. private _ownerNode;
  49065. private _sceneRenderObserver;
  49066. /**
  49067. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  49068. */
  49069. constructor();
  49070. /**
  49071. * The name of the behavior
  49072. */
  49073. get name(): string;
  49074. /**
  49075. * Initializes the behavior
  49076. */
  49077. init(): void;
  49078. private _getCurrentDistance;
  49079. /**
  49080. * Attaches the scale behavior the passed in mesh
  49081. * @param ownerNode The mesh that will be scaled around once attached
  49082. */
  49083. attach(ownerNode: Mesh): void;
  49084. /**
  49085. * Detaches the behavior from the mesh
  49086. */
  49087. detach(): void;
  49088. }
  49089. }
  49090. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  49091. import { Behavior } from "babylonjs/Behaviors/behavior";
  49092. import { Mesh } from "babylonjs/Meshes/mesh";
  49093. import { Observable } from "babylonjs/Misc/observable";
  49094. /**
  49095. * 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
  49096. */
  49097. export class SixDofDragBehavior implements Behavior<Mesh> {
  49098. private static _virtualScene;
  49099. private _ownerNode;
  49100. private _sceneRenderObserver;
  49101. private _scene;
  49102. private _targetPosition;
  49103. private _virtualOriginMesh;
  49104. private _virtualDragMesh;
  49105. private _pointerObserver;
  49106. private _moving;
  49107. private _startingOrientation;
  49108. private _attachedToElement;
  49109. /**
  49110. * 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)
  49111. */
  49112. private zDragFactor;
  49113. /**
  49114. * If the object should rotate to face the drag origin
  49115. */
  49116. rotateDraggedObject: boolean;
  49117. /**
  49118. * If the behavior is currently in a dragging state
  49119. */
  49120. dragging: boolean;
  49121. /**
  49122. * 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)
  49123. */
  49124. dragDeltaRatio: number;
  49125. /**
  49126. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  49127. */
  49128. currentDraggingPointerID: number;
  49129. /**
  49130. * If camera controls should be detached during the drag
  49131. */
  49132. detachCameraControls: boolean;
  49133. /**
  49134. * Fires each time a drag starts
  49135. */
  49136. onDragStartObservable: Observable<{}>;
  49137. /**
  49138. * Fires each time a drag happens
  49139. */
  49140. onDragObservable: Observable<void>;
  49141. /**
  49142. * Fires each time a drag ends (eg. mouse release after drag)
  49143. */
  49144. onDragEndObservable: Observable<{}>;
  49145. /**
  49146. * 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
  49147. */
  49148. constructor();
  49149. /**
  49150. * The name of the behavior
  49151. */
  49152. get name(): string;
  49153. /**
  49154. * Initializes the behavior
  49155. */
  49156. init(): void;
  49157. /**
  49158. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  49159. */
  49160. private get _pointerCamera();
  49161. /**
  49162. * Attaches the scale behavior the passed in mesh
  49163. * @param ownerNode The mesh that will be scaled around once attached
  49164. */
  49165. attach(ownerNode: Mesh): void;
  49166. /**
  49167. * Detaches the behavior from the mesh
  49168. */
  49169. detach(): void;
  49170. }
  49171. }
  49172. declare module "babylonjs/Behaviors/Meshes/index" {
  49173. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  49174. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  49175. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  49176. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49177. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  49178. }
  49179. declare module "babylonjs/Behaviors/index" {
  49180. export * from "babylonjs/Behaviors/behavior";
  49181. export * from "babylonjs/Behaviors/Cameras/index";
  49182. export * from "babylonjs/Behaviors/Meshes/index";
  49183. }
  49184. declare module "babylonjs/Bones/boneIKController" {
  49185. import { Bone } from "babylonjs/Bones/bone";
  49186. import { Vector3 } from "babylonjs/Maths/math.vector";
  49187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49188. import { Nullable } from "babylonjs/types";
  49189. /**
  49190. * Class used to apply inverse kinematics to bones
  49191. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  49192. */
  49193. export class BoneIKController {
  49194. private static _tmpVecs;
  49195. private static _tmpQuat;
  49196. private static _tmpMats;
  49197. /**
  49198. * Gets or sets the target mesh
  49199. */
  49200. targetMesh: AbstractMesh;
  49201. /** Gets or sets the mesh used as pole */
  49202. poleTargetMesh: AbstractMesh;
  49203. /**
  49204. * Gets or sets the bone used as pole
  49205. */
  49206. poleTargetBone: Nullable<Bone>;
  49207. /**
  49208. * Gets or sets the target position
  49209. */
  49210. targetPosition: Vector3;
  49211. /**
  49212. * Gets or sets the pole target position
  49213. */
  49214. poleTargetPosition: Vector3;
  49215. /**
  49216. * Gets or sets the pole target local offset
  49217. */
  49218. poleTargetLocalOffset: Vector3;
  49219. /**
  49220. * Gets or sets the pole angle
  49221. */
  49222. poleAngle: number;
  49223. /**
  49224. * Gets or sets the mesh associated with the controller
  49225. */
  49226. mesh: AbstractMesh;
  49227. /**
  49228. * 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)
  49229. */
  49230. slerpAmount: number;
  49231. private _bone1Quat;
  49232. private _bone1Mat;
  49233. private _bone2Ang;
  49234. private _bone1;
  49235. private _bone2;
  49236. private _bone1Length;
  49237. private _bone2Length;
  49238. private _maxAngle;
  49239. private _maxReach;
  49240. private _rightHandedSystem;
  49241. private _bendAxis;
  49242. private _slerping;
  49243. private _adjustRoll;
  49244. /**
  49245. * Gets or sets maximum allowed angle
  49246. */
  49247. get maxAngle(): number;
  49248. set maxAngle(value: number);
  49249. /**
  49250. * Creates a new BoneIKController
  49251. * @param mesh defines the mesh to control
  49252. * @param bone defines the bone to control
  49253. * @param options defines options to set up the controller
  49254. */
  49255. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  49256. targetMesh?: AbstractMesh;
  49257. poleTargetMesh?: AbstractMesh;
  49258. poleTargetBone?: Bone;
  49259. poleTargetLocalOffset?: Vector3;
  49260. poleAngle?: number;
  49261. bendAxis?: Vector3;
  49262. maxAngle?: number;
  49263. slerpAmount?: number;
  49264. });
  49265. private _setMaxAngle;
  49266. /**
  49267. * Force the controller to update the bones
  49268. */
  49269. update(): void;
  49270. }
  49271. }
  49272. declare module "babylonjs/Bones/boneLookController" {
  49273. import { Vector3 } from "babylonjs/Maths/math.vector";
  49274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49275. import { Bone } from "babylonjs/Bones/bone";
  49276. import { Space } from "babylonjs/Maths/math.axis";
  49277. /**
  49278. * Class used to make a bone look toward a point in space
  49279. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  49280. */
  49281. export class BoneLookController {
  49282. private static _tmpVecs;
  49283. private static _tmpQuat;
  49284. private static _tmpMats;
  49285. /**
  49286. * The target Vector3 that the bone will look at
  49287. */
  49288. target: Vector3;
  49289. /**
  49290. * The mesh that the bone is attached to
  49291. */
  49292. mesh: AbstractMesh;
  49293. /**
  49294. * The bone that will be looking to the target
  49295. */
  49296. bone: Bone;
  49297. /**
  49298. * The up axis of the coordinate system that is used when the bone is rotated
  49299. */
  49300. upAxis: Vector3;
  49301. /**
  49302. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  49303. */
  49304. upAxisSpace: Space;
  49305. /**
  49306. * Used to make an adjustment to the yaw of the bone
  49307. */
  49308. adjustYaw: number;
  49309. /**
  49310. * Used to make an adjustment to the pitch of the bone
  49311. */
  49312. adjustPitch: number;
  49313. /**
  49314. * Used to make an adjustment to the roll of the bone
  49315. */
  49316. adjustRoll: number;
  49317. /**
  49318. * 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)
  49319. */
  49320. slerpAmount: number;
  49321. private _minYaw;
  49322. private _maxYaw;
  49323. private _minPitch;
  49324. private _maxPitch;
  49325. private _minYawSin;
  49326. private _minYawCos;
  49327. private _maxYawSin;
  49328. private _maxYawCos;
  49329. private _midYawConstraint;
  49330. private _minPitchTan;
  49331. private _maxPitchTan;
  49332. private _boneQuat;
  49333. private _slerping;
  49334. private _transformYawPitch;
  49335. private _transformYawPitchInv;
  49336. private _firstFrameSkipped;
  49337. private _yawRange;
  49338. private _fowardAxis;
  49339. /**
  49340. * Gets or sets the minimum yaw angle that the bone can look to
  49341. */
  49342. get minYaw(): number;
  49343. set minYaw(value: number);
  49344. /**
  49345. * Gets or sets the maximum yaw angle that the bone can look to
  49346. */
  49347. get maxYaw(): number;
  49348. set maxYaw(value: number);
  49349. /**
  49350. * Gets or sets the minimum pitch angle that the bone can look to
  49351. */
  49352. get minPitch(): number;
  49353. set minPitch(value: number);
  49354. /**
  49355. * Gets or sets the maximum pitch angle that the bone can look to
  49356. */
  49357. get maxPitch(): number;
  49358. set maxPitch(value: number);
  49359. /**
  49360. * Create a BoneLookController
  49361. * @param mesh the mesh that the bone belongs to
  49362. * @param bone the bone that will be looking to the target
  49363. * @param target the target Vector3 to look at
  49364. * @param options optional settings:
  49365. * * maxYaw: the maximum angle the bone will yaw to
  49366. * * minYaw: the minimum angle the bone will yaw to
  49367. * * maxPitch: the maximum angle the bone will pitch to
  49368. * * minPitch: the minimum angle the bone will yaw to
  49369. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  49370. * * upAxis: the up axis of the coordinate system
  49371. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  49372. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  49373. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  49374. * * adjustYaw: used to make an adjustment to the yaw of the bone
  49375. * * adjustPitch: used to make an adjustment to the pitch of the bone
  49376. * * adjustRoll: used to make an adjustment to the roll of the bone
  49377. **/
  49378. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  49379. maxYaw?: number;
  49380. minYaw?: number;
  49381. maxPitch?: number;
  49382. minPitch?: number;
  49383. slerpAmount?: number;
  49384. upAxis?: Vector3;
  49385. upAxisSpace?: Space;
  49386. yawAxis?: Vector3;
  49387. pitchAxis?: Vector3;
  49388. adjustYaw?: number;
  49389. adjustPitch?: number;
  49390. adjustRoll?: number;
  49391. });
  49392. /**
  49393. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  49394. */
  49395. update(): void;
  49396. private _getAngleDiff;
  49397. private _getAngleBetween;
  49398. private _isAngleBetween;
  49399. }
  49400. }
  49401. declare module "babylonjs/Bones/index" {
  49402. export * from "babylonjs/Bones/bone";
  49403. export * from "babylonjs/Bones/boneIKController";
  49404. export * from "babylonjs/Bones/boneLookController";
  49405. export * from "babylonjs/Bones/skeleton";
  49406. }
  49407. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  49408. import { Nullable } from "babylonjs/types";
  49409. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49410. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49411. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49412. /**
  49413. * Manage the gamepad inputs to control an arc rotate camera.
  49414. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49415. */
  49416. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  49417. /**
  49418. * Defines the camera the input is attached to.
  49419. */
  49420. camera: ArcRotateCamera;
  49421. /**
  49422. * Defines the gamepad the input is gathering event from.
  49423. */
  49424. gamepad: Nullable<Gamepad>;
  49425. /**
  49426. * Defines the gamepad rotation sensiblity.
  49427. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49428. */
  49429. gamepadRotationSensibility: number;
  49430. /**
  49431. * Defines the gamepad move sensiblity.
  49432. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49433. */
  49434. gamepadMoveSensibility: number;
  49435. private _yAxisScale;
  49436. /**
  49437. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49438. */
  49439. get invertYAxis(): boolean;
  49440. set invertYAxis(value: boolean);
  49441. private _onGamepadConnectedObserver;
  49442. private _onGamepadDisconnectedObserver;
  49443. /**
  49444. * Attach the input controls to a specific dom element to get the input from.
  49445. */
  49446. attachControl(): void;
  49447. /**
  49448. * Detach the current controls from the specified dom element.
  49449. */
  49450. detachControl(): void;
  49451. /**
  49452. * Update the current camera state depending on the inputs that have been used this frame.
  49453. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49454. */
  49455. checkInputs(): void;
  49456. /**
  49457. * Gets the class name of the current intput.
  49458. * @returns the class name
  49459. */
  49460. getClassName(): string;
  49461. /**
  49462. * Get the friendly name associated with the input class.
  49463. * @returns the input friendly name
  49464. */
  49465. getSimpleName(): string;
  49466. }
  49467. }
  49468. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  49469. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49470. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49471. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  49472. interface ArcRotateCameraInputsManager {
  49473. /**
  49474. * Add orientation input support to the input manager.
  49475. * @returns the current input manager
  49476. */
  49477. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  49478. }
  49479. }
  49480. /**
  49481. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  49482. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49483. */
  49484. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  49485. /**
  49486. * Defines the camera the input is attached to.
  49487. */
  49488. camera: ArcRotateCamera;
  49489. /**
  49490. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  49491. */
  49492. alphaCorrection: number;
  49493. /**
  49494. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  49495. */
  49496. gammaCorrection: number;
  49497. private _alpha;
  49498. private _gamma;
  49499. private _dirty;
  49500. private _deviceOrientationHandler;
  49501. /**
  49502. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  49503. */
  49504. constructor();
  49505. /**
  49506. * Attach the input controls to a specific dom element to get the input from.
  49507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49508. */
  49509. attachControl(noPreventDefault?: boolean): void;
  49510. /** @hidden */
  49511. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  49512. /**
  49513. * Update the current camera state depending on the inputs that have been used this frame.
  49514. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49515. */
  49516. checkInputs(): void;
  49517. /**
  49518. * Detach the current controls from the specified dom element.
  49519. */
  49520. detachControl(): void;
  49521. /**
  49522. * Gets the class name of the current intput.
  49523. * @returns the class name
  49524. */
  49525. getClassName(): string;
  49526. /**
  49527. * Get the friendly name associated with the input class.
  49528. * @returns the input friendly name
  49529. */
  49530. getSimpleName(): string;
  49531. }
  49532. }
  49533. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  49534. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49535. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49536. /**
  49537. * Listen to mouse events to control the camera.
  49538. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49539. */
  49540. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  49541. /**
  49542. * Defines the camera the input is attached to.
  49543. */
  49544. camera: FlyCamera;
  49545. /**
  49546. * Defines if touch is enabled. (Default is true.)
  49547. */
  49548. touchEnabled: boolean;
  49549. /**
  49550. * Defines the buttons associated with the input to handle camera rotation.
  49551. */
  49552. buttons: number[];
  49553. /**
  49554. * Assign buttons for Yaw control.
  49555. */
  49556. buttonsYaw: number[];
  49557. /**
  49558. * Assign buttons for Pitch control.
  49559. */
  49560. buttonsPitch: number[];
  49561. /**
  49562. * Assign buttons for Roll control.
  49563. */
  49564. buttonsRoll: number[];
  49565. /**
  49566. * Detect if any button is being pressed while mouse is moved.
  49567. * -1 = Mouse locked.
  49568. * 0 = Left button.
  49569. * 1 = Middle Button.
  49570. * 2 = Right Button.
  49571. */
  49572. activeButton: number;
  49573. /**
  49574. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  49575. * Higher values reduce its sensitivity.
  49576. */
  49577. angularSensibility: number;
  49578. private _observer;
  49579. private _rollObserver;
  49580. private previousPosition;
  49581. private noPreventDefault;
  49582. private element;
  49583. /**
  49584. * Listen to mouse events to control the camera.
  49585. * @param touchEnabled Define if touch is enabled. (Default is true.)
  49586. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49587. */
  49588. constructor(touchEnabled?: boolean);
  49589. /**
  49590. * Attach the mouse control to the HTML DOM element.
  49591. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  49592. */
  49593. attachControl(noPreventDefault?: boolean): void;
  49594. /**
  49595. * Detach the current controls from the specified dom element.
  49596. */
  49597. detachControl(): void;
  49598. /**
  49599. * Gets the class name of the current input.
  49600. * @returns the class name.
  49601. */
  49602. getClassName(): string;
  49603. /**
  49604. * Get the friendly name associated with the input class.
  49605. * @returns the input's friendly name.
  49606. */
  49607. getSimpleName(): string;
  49608. private _pointerInput;
  49609. private _onMouseMove;
  49610. /**
  49611. * Rotate camera by mouse offset.
  49612. */
  49613. private rotateCamera;
  49614. }
  49615. }
  49616. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  49617. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49618. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49619. /**
  49620. * Default Inputs manager for the FlyCamera.
  49621. * It groups all the default supported inputs for ease of use.
  49622. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49623. */
  49624. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  49625. /**
  49626. * Instantiates a new FlyCameraInputsManager.
  49627. * @param camera Defines the camera the inputs belong to.
  49628. */
  49629. constructor(camera: FlyCamera);
  49630. /**
  49631. * Add keyboard input support to the input manager.
  49632. * @returns the new FlyCameraKeyboardMoveInput().
  49633. */
  49634. addKeyboard(): FlyCameraInputsManager;
  49635. /**
  49636. * Add mouse input support to the input manager.
  49637. * @param touchEnabled Enable touch screen support.
  49638. * @returns the new FlyCameraMouseInput().
  49639. */
  49640. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  49641. }
  49642. }
  49643. declare module "babylonjs/Cameras/flyCamera" {
  49644. import { Scene } from "babylonjs/scene";
  49645. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  49646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49647. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49648. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  49649. /**
  49650. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49651. * such as in a 3D Space Shooter or a Flight Simulator.
  49652. */
  49653. export class FlyCamera extends TargetCamera {
  49654. /**
  49655. * Define the collision ellipsoid of the camera.
  49656. * This is helpful for simulating a camera body, like a player's body.
  49657. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49658. */
  49659. ellipsoid: Vector3;
  49660. /**
  49661. * Define an offset for the position of the ellipsoid around the camera.
  49662. * This can be helpful if the camera is attached away from the player's body center,
  49663. * such as at its head.
  49664. */
  49665. ellipsoidOffset: Vector3;
  49666. /**
  49667. * Enable or disable collisions of the camera with the rest of the scene objects.
  49668. */
  49669. checkCollisions: boolean;
  49670. /**
  49671. * Enable or disable gravity on the camera.
  49672. */
  49673. applyGravity: boolean;
  49674. /**
  49675. * Define the current direction the camera is moving to.
  49676. */
  49677. cameraDirection: Vector3;
  49678. /**
  49679. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49680. * This overrides and empties cameraRotation.
  49681. */
  49682. rotationQuaternion: Quaternion;
  49683. /**
  49684. * Track Roll to maintain the wanted Rolling when looking around.
  49685. */
  49686. _trackRoll: number;
  49687. /**
  49688. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49689. */
  49690. rollCorrect: number;
  49691. /**
  49692. * Mimic a banked turn, Rolling the camera when Yawing.
  49693. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49694. */
  49695. bankedTurn: boolean;
  49696. /**
  49697. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49698. */
  49699. bankedTurnLimit: number;
  49700. /**
  49701. * Value of 0 disables the banked Roll.
  49702. * Value of 1 is equal to the Yaw angle in radians.
  49703. */
  49704. bankedTurnMultiplier: number;
  49705. /**
  49706. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49707. */
  49708. inputs: FlyCameraInputsManager;
  49709. /**
  49710. * Gets the input sensibility for mouse input.
  49711. * Higher values reduce sensitivity.
  49712. */
  49713. get angularSensibility(): number;
  49714. /**
  49715. * Sets the input sensibility for a mouse input.
  49716. * Higher values reduce sensitivity.
  49717. */
  49718. set angularSensibility(value: number);
  49719. /**
  49720. * Get the keys for camera movement forward.
  49721. */
  49722. get keysForward(): number[];
  49723. /**
  49724. * Set the keys for camera movement forward.
  49725. */
  49726. set keysForward(value: number[]);
  49727. /**
  49728. * Get the keys for camera movement backward.
  49729. */
  49730. get keysBackward(): number[];
  49731. set keysBackward(value: number[]);
  49732. /**
  49733. * Get the keys for camera movement up.
  49734. */
  49735. get keysUp(): number[];
  49736. /**
  49737. * Set the keys for camera movement up.
  49738. */
  49739. set keysUp(value: number[]);
  49740. /**
  49741. * Get the keys for camera movement down.
  49742. */
  49743. get keysDown(): number[];
  49744. /**
  49745. * Set the keys for camera movement down.
  49746. */
  49747. set keysDown(value: number[]);
  49748. /**
  49749. * Get the keys for camera movement left.
  49750. */
  49751. get keysLeft(): number[];
  49752. /**
  49753. * Set the keys for camera movement left.
  49754. */
  49755. set keysLeft(value: number[]);
  49756. /**
  49757. * Set the keys for camera movement right.
  49758. */
  49759. get keysRight(): number[];
  49760. /**
  49761. * Set the keys for camera movement right.
  49762. */
  49763. set keysRight(value: number[]);
  49764. /**
  49765. * Event raised when the camera collides with a mesh in the scene.
  49766. */
  49767. onCollide: (collidedMesh: AbstractMesh) => void;
  49768. private _collider;
  49769. private _needMoveForGravity;
  49770. private _oldPosition;
  49771. private _diffPosition;
  49772. private _newPosition;
  49773. /** @hidden */
  49774. _localDirection: Vector3;
  49775. /** @hidden */
  49776. _transformedDirection: Vector3;
  49777. /**
  49778. * Instantiates a FlyCamera.
  49779. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49780. * such as in a 3D Space Shooter or a Flight Simulator.
  49781. * @param name Define the name of the camera in the scene.
  49782. * @param position Define the starting position of the camera in the scene.
  49783. * @param scene Define the scene the camera belongs to.
  49784. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49785. */
  49786. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49787. /**
  49788. * Attach the input controls to a specific dom element to get the input from.
  49789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49790. */
  49791. attachControl(noPreventDefault?: boolean): void;
  49792. /**
  49793. * Detach a control from the HTML DOM element.
  49794. * The camera will stop reacting to that input.
  49795. */
  49796. detachControl(): void;
  49797. private _collisionMask;
  49798. /**
  49799. * Get the mask that the camera ignores in collision events.
  49800. */
  49801. get collisionMask(): number;
  49802. /**
  49803. * Set the mask that the camera ignores in collision events.
  49804. */
  49805. set collisionMask(mask: number);
  49806. /** @hidden */
  49807. _collideWithWorld(displacement: Vector3): void;
  49808. /** @hidden */
  49809. private _onCollisionPositionChange;
  49810. /** @hidden */
  49811. _checkInputs(): void;
  49812. /** @hidden */
  49813. _decideIfNeedsToMove(): boolean;
  49814. /** @hidden */
  49815. _updatePosition(): void;
  49816. /**
  49817. * Restore the Roll to its target value at the rate specified.
  49818. * @param rate - Higher means slower restoring.
  49819. * @hidden
  49820. */
  49821. restoreRoll(rate: number): void;
  49822. /**
  49823. * Destroy the camera and release the current resources held by it.
  49824. */
  49825. dispose(): void;
  49826. /**
  49827. * Get the current object class name.
  49828. * @returns the class name.
  49829. */
  49830. getClassName(): string;
  49831. }
  49832. }
  49833. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49834. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49835. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49836. /**
  49837. * Listen to keyboard events to control the camera.
  49838. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49839. */
  49840. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49841. /**
  49842. * Defines the camera the input is attached to.
  49843. */
  49844. camera: FlyCamera;
  49845. /**
  49846. * The list of keyboard keys used to control the forward move of the camera.
  49847. */
  49848. keysForward: number[];
  49849. /**
  49850. * The list of keyboard keys used to control the backward move of the camera.
  49851. */
  49852. keysBackward: number[];
  49853. /**
  49854. * The list of keyboard keys used to control the forward move of the camera.
  49855. */
  49856. keysUp: number[];
  49857. /**
  49858. * The list of keyboard keys used to control the backward move of the camera.
  49859. */
  49860. keysDown: number[];
  49861. /**
  49862. * The list of keyboard keys used to control the right strafe move of the camera.
  49863. */
  49864. keysRight: number[];
  49865. /**
  49866. * The list of keyboard keys used to control the left strafe move of the camera.
  49867. */
  49868. keysLeft: number[];
  49869. private _keys;
  49870. private _onCanvasBlurObserver;
  49871. private _onKeyboardObserver;
  49872. private _engine;
  49873. private _scene;
  49874. /**
  49875. * Attach the input controls to a specific dom element to get the input from.
  49876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49877. */
  49878. attachControl(noPreventDefault?: boolean): void;
  49879. /**
  49880. * Detach the current controls from the specified dom element.
  49881. */
  49882. detachControl(): void;
  49883. /**
  49884. * Gets the class name of the current intput.
  49885. * @returns the class name
  49886. */
  49887. getClassName(): string;
  49888. /** @hidden */
  49889. _onLostFocus(e: FocusEvent): void;
  49890. /**
  49891. * Get the friendly name associated with the input class.
  49892. * @returns the input friendly name
  49893. */
  49894. getSimpleName(): string;
  49895. /**
  49896. * Update the current camera state depending on the inputs that have been used this frame.
  49897. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49898. */
  49899. checkInputs(): void;
  49900. }
  49901. }
  49902. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49903. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49904. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49905. /**
  49906. * Manage the mouse wheel inputs to control a follow camera.
  49907. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49908. */
  49909. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49910. /**
  49911. * Defines the camera the input is attached to.
  49912. */
  49913. camera: FollowCamera;
  49914. /**
  49915. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49916. */
  49917. axisControlRadius: boolean;
  49918. /**
  49919. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49920. */
  49921. axisControlHeight: boolean;
  49922. /**
  49923. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49924. */
  49925. axisControlRotation: boolean;
  49926. /**
  49927. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49928. * relation to mouseWheel events.
  49929. */
  49930. wheelPrecision: number;
  49931. /**
  49932. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49933. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49934. */
  49935. wheelDeltaPercentage: number;
  49936. private _wheel;
  49937. private _observer;
  49938. /**
  49939. * Attach the input controls to a specific dom element to get the input from.
  49940. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49941. */
  49942. attachControl(noPreventDefault?: boolean): void;
  49943. /**
  49944. * Detach the current controls from the specified dom element.
  49945. */
  49946. detachControl(): void;
  49947. /**
  49948. * Gets the class name of the current intput.
  49949. * @returns the class name
  49950. */
  49951. getClassName(): string;
  49952. /**
  49953. * Get the friendly name associated with the input class.
  49954. * @returns the input friendly name
  49955. */
  49956. getSimpleName(): string;
  49957. }
  49958. }
  49959. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49960. import { Nullable } from "babylonjs/types";
  49961. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49962. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49963. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49964. /**
  49965. * Manage the pointers inputs to control an follow camera.
  49966. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49967. */
  49968. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49969. /**
  49970. * Defines the camera the input is attached to.
  49971. */
  49972. camera: FollowCamera;
  49973. /**
  49974. * Gets the class name of the current input.
  49975. * @returns the class name
  49976. */
  49977. getClassName(): string;
  49978. /**
  49979. * Defines the pointer angular sensibility along the X axis or how fast is
  49980. * the camera rotating.
  49981. * A negative number will reverse the axis direction.
  49982. */
  49983. angularSensibilityX: number;
  49984. /**
  49985. * Defines the pointer angular sensibility along the Y axis or how fast is
  49986. * the camera rotating.
  49987. * A negative number will reverse the axis direction.
  49988. */
  49989. angularSensibilityY: number;
  49990. /**
  49991. * Defines the pointer pinch precision or how fast is the camera zooming.
  49992. * A negative number will reverse the axis direction.
  49993. */
  49994. pinchPrecision: number;
  49995. /**
  49996. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49997. * from 0.
  49998. * It defines the percentage of current camera.radius to use as delta when
  49999. * pinch zoom is used.
  50000. */
  50001. pinchDeltaPercentage: number;
  50002. /**
  50003. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  50004. */
  50005. axisXControlRadius: boolean;
  50006. /**
  50007. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  50008. */
  50009. axisXControlHeight: boolean;
  50010. /**
  50011. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  50012. */
  50013. axisXControlRotation: boolean;
  50014. /**
  50015. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  50016. */
  50017. axisYControlRadius: boolean;
  50018. /**
  50019. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  50020. */
  50021. axisYControlHeight: boolean;
  50022. /**
  50023. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  50024. */
  50025. axisYControlRotation: boolean;
  50026. /**
  50027. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  50028. */
  50029. axisPinchControlRadius: boolean;
  50030. /**
  50031. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  50032. */
  50033. axisPinchControlHeight: boolean;
  50034. /**
  50035. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  50036. */
  50037. axisPinchControlRotation: boolean;
  50038. /**
  50039. * Log error messages if basic misconfiguration has occurred.
  50040. */
  50041. warningEnable: boolean;
  50042. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50043. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50044. private _warningCounter;
  50045. private _warning;
  50046. }
  50047. }
  50048. declare module "babylonjs/Cameras/followCameraInputsManager" {
  50049. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  50050. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  50051. /**
  50052. * Default Inputs manager for the FollowCamera.
  50053. * It groups all the default supported inputs for ease of use.
  50054. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50055. */
  50056. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  50057. /**
  50058. * Instantiates a new FollowCameraInputsManager.
  50059. * @param camera Defines the camera the inputs belong to
  50060. */
  50061. constructor(camera: FollowCamera);
  50062. /**
  50063. * Add keyboard input support to the input manager.
  50064. * @returns the current input manager
  50065. */
  50066. addKeyboard(): FollowCameraInputsManager;
  50067. /**
  50068. * Add mouse wheel input support to the input manager.
  50069. * @returns the current input manager
  50070. */
  50071. addMouseWheel(): FollowCameraInputsManager;
  50072. /**
  50073. * Add pointers input support to the input manager.
  50074. * @returns the current input manager
  50075. */
  50076. addPointers(): FollowCameraInputsManager;
  50077. /**
  50078. * Add orientation input support to the input manager.
  50079. * @returns the current input manager
  50080. */
  50081. addVRDeviceOrientation(): FollowCameraInputsManager;
  50082. }
  50083. }
  50084. declare module "babylonjs/Cameras/followCamera" {
  50085. import { Nullable } from "babylonjs/types";
  50086. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  50087. import { Scene } from "babylonjs/scene";
  50088. import { Vector3 } from "babylonjs/Maths/math.vector";
  50089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50090. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  50091. /**
  50092. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  50093. * an arc rotate version arcFollowCamera are available.
  50094. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50095. */
  50096. export class FollowCamera extends TargetCamera {
  50097. /**
  50098. * Distance the follow camera should follow an object at
  50099. */
  50100. radius: number;
  50101. /**
  50102. * Minimum allowed distance of the camera to the axis of rotation
  50103. * (The camera can not get closer).
  50104. * This can help limiting how the Camera is able to move in the scene.
  50105. */
  50106. lowerRadiusLimit: Nullable<number>;
  50107. /**
  50108. * Maximum allowed distance of the camera to the axis of rotation
  50109. * (The camera can not get further).
  50110. * This can help limiting how the Camera is able to move in the scene.
  50111. */
  50112. upperRadiusLimit: Nullable<number>;
  50113. /**
  50114. * Define a rotation offset between the camera and the object it follows
  50115. */
  50116. rotationOffset: number;
  50117. /**
  50118. * Minimum allowed angle to camera position relative to target object.
  50119. * This can help limiting how the Camera is able to move in the scene.
  50120. */
  50121. lowerRotationOffsetLimit: Nullable<number>;
  50122. /**
  50123. * Maximum allowed angle to camera position relative to target object.
  50124. * This can help limiting how the Camera is able to move in the scene.
  50125. */
  50126. upperRotationOffsetLimit: Nullable<number>;
  50127. /**
  50128. * Define a height offset between the camera and the object it follows.
  50129. * It can help following an object from the top (like a car chaing a plane)
  50130. */
  50131. heightOffset: number;
  50132. /**
  50133. * Minimum allowed height of camera position relative to target object.
  50134. * This can help limiting how the Camera is able to move in the scene.
  50135. */
  50136. lowerHeightOffsetLimit: Nullable<number>;
  50137. /**
  50138. * Maximum allowed height of camera position relative to target object.
  50139. * This can help limiting how the Camera is able to move in the scene.
  50140. */
  50141. upperHeightOffsetLimit: Nullable<number>;
  50142. /**
  50143. * Define how fast the camera can accelerate to follow it s target.
  50144. */
  50145. cameraAcceleration: number;
  50146. /**
  50147. * Define the speed limit of the camera following an object.
  50148. */
  50149. maxCameraSpeed: number;
  50150. /**
  50151. * Define the target of the camera.
  50152. */
  50153. lockedTarget: Nullable<AbstractMesh>;
  50154. /**
  50155. * Defines the input associated with the camera.
  50156. */
  50157. inputs: FollowCameraInputsManager;
  50158. /**
  50159. * Instantiates the follow camera.
  50160. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50161. * @param name Define the name of the camera in the scene
  50162. * @param position Define the position of the camera
  50163. * @param scene Define the scene the camera belong to
  50164. * @param lockedTarget Define the target of the camera
  50165. */
  50166. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  50167. private _follow;
  50168. /**
  50169. * Attach the input controls to a specific dom element to get the input from.
  50170. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50171. */
  50172. attachControl(noPreventDefault?: boolean): void;
  50173. /**
  50174. * Detach the current controls from the specified dom element.
  50175. */
  50176. detachControl(): void;
  50177. /** @hidden */
  50178. _checkInputs(): void;
  50179. private _checkLimits;
  50180. /**
  50181. * Gets the camera class name.
  50182. * @returns the class name
  50183. */
  50184. getClassName(): string;
  50185. }
  50186. /**
  50187. * Arc Rotate version of the follow camera.
  50188. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  50189. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50190. */
  50191. export class ArcFollowCamera extends TargetCamera {
  50192. /** The longitudinal angle of the camera */
  50193. alpha: number;
  50194. /** The latitudinal angle of the camera */
  50195. beta: number;
  50196. /** The radius of the camera from its target */
  50197. radius: number;
  50198. private _cartesianCoordinates;
  50199. /** Define the camera target (the mesh it should follow) */
  50200. private _meshTarget;
  50201. /**
  50202. * Instantiates a new ArcFollowCamera
  50203. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50204. * @param name Define the name of the camera
  50205. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  50206. * @param beta Define the rotation angle of the camera around the elevation axis
  50207. * @param radius Define the radius of the camera from its target point
  50208. * @param target Define the target of the camera
  50209. * @param scene Define the scene the camera belongs to
  50210. */
  50211. constructor(name: string,
  50212. /** The longitudinal angle of the camera */
  50213. alpha: number,
  50214. /** The latitudinal angle of the camera */
  50215. beta: number,
  50216. /** The radius of the camera from its target */
  50217. radius: number,
  50218. /** Define the camera target (the mesh it should follow) */
  50219. target: Nullable<AbstractMesh>, scene: Scene);
  50220. private _follow;
  50221. /** @hidden */
  50222. _checkInputs(): void;
  50223. /**
  50224. * Returns the class name of the object.
  50225. * It is mostly used internally for serialization purposes.
  50226. */
  50227. getClassName(): string;
  50228. }
  50229. }
  50230. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  50231. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50232. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  50233. /**
  50234. * Manage the keyboard inputs to control the movement of a follow camera.
  50235. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50236. */
  50237. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  50238. /**
  50239. * Defines the camera the input is attached to.
  50240. */
  50241. camera: FollowCamera;
  50242. /**
  50243. * Defines the list of key codes associated with the up action (increase heightOffset)
  50244. */
  50245. keysHeightOffsetIncr: number[];
  50246. /**
  50247. * Defines the list of key codes associated with the down action (decrease heightOffset)
  50248. */
  50249. keysHeightOffsetDecr: number[];
  50250. /**
  50251. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  50252. */
  50253. keysHeightOffsetModifierAlt: boolean;
  50254. /**
  50255. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  50256. */
  50257. keysHeightOffsetModifierCtrl: boolean;
  50258. /**
  50259. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  50260. */
  50261. keysHeightOffsetModifierShift: boolean;
  50262. /**
  50263. * Defines the list of key codes associated with the left action (increase rotationOffset)
  50264. */
  50265. keysRotationOffsetIncr: number[];
  50266. /**
  50267. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  50268. */
  50269. keysRotationOffsetDecr: number[];
  50270. /**
  50271. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  50272. */
  50273. keysRotationOffsetModifierAlt: boolean;
  50274. /**
  50275. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  50276. */
  50277. keysRotationOffsetModifierCtrl: boolean;
  50278. /**
  50279. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  50280. */
  50281. keysRotationOffsetModifierShift: boolean;
  50282. /**
  50283. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  50284. */
  50285. keysRadiusIncr: number[];
  50286. /**
  50287. * Defines the list of key codes associated with the zoom-out action (increase radius)
  50288. */
  50289. keysRadiusDecr: number[];
  50290. /**
  50291. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  50292. */
  50293. keysRadiusModifierAlt: boolean;
  50294. /**
  50295. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  50296. */
  50297. keysRadiusModifierCtrl: boolean;
  50298. /**
  50299. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  50300. */
  50301. keysRadiusModifierShift: boolean;
  50302. /**
  50303. * Defines the rate of change of heightOffset.
  50304. */
  50305. heightSensibility: number;
  50306. /**
  50307. * Defines the rate of change of rotationOffset.
  50308. */
  50309. rotationSensibility: number;
  50310. /**
  50311. * Defines the rate of change of radius.
  50312. */
  50313. radiusSensibility: number;
  50314. private _keys;
  50315. private _ctrlPressed;
  50316. private _altPressed;
  50317. private _shiftPressed;
  50318. private _onCanvasBlurObserver;
  50319. private _onKeyboardObserver;
  50320. private _engine;
  50321. private _scene;
  50322. /**
  50323. * Attach the input controls to a specific dom element to get the input from.
  50324. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50325. */
  50326. attachControl(noPreventDefault?: boolean): void;
  50327. /**
  50328. * Detach the current controls from the specified dom element.
  50329. */
  50330. detachControl(): void;
  50331. /**
  50332. * Update the current camera state depending on the inputs that have been used this frame.
  50333. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50334. */
  50335. checkInputs(): void;
  50336. /**
  50337. * Gets the class name of the current input.
  50338. * @returns the class name
  50339. */
  50340. getClassName(): string;
  50341. /**
  50342. * Get the friendly name associated with the input class.
  50343. * @returns the input friendly name
  50344. */
  50345. getSimpleName(): string;
  50346. /**
  50347. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50348. * allow modification of the heightOffset value.
  50349. */
  50350. private _modifierHeightOffset;
  50351. /**
  50352. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50353. * allow modification of the rotationOffset value.
  50354. */
  50355. private _modifierRotationOffset;
  50356. /**
  50357. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50358. * allow modification of the radius value.
  50359. */
  50360. private _modifierRadius;
  50361. }
  50362. }
  50363. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  50364. import { Nullable } from "babylonjs/types";
  50365. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50366. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50367. import { Observable } from "babylonjs/Misc/observable";
  50368. module "babylonjs/Cameras/freeCameraInputsManager" {
  50369. interface FreeCameraInputsManager {
  50370. /**
  50371. * @hidden
  50372. */
  50373. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  50374. /**
  50375. * Add orientation input support to the input manager.
  50376. * @returns the current input manager
  50377. */
  50378. addDeviceOrientation(): FreeCameraInputsManager;
  50379. }
  50380. }
  50381. /**
  50382. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  50383. * Screen rotation is taken into account.
  50384. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50385. */
  50386. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  50387. private _camera;
  50388. private _screenOrientationAngle;
  50389. private _constantTranform;
  50390. private _screenQuaternion;
  50391. private _alpha;
  50392. private _beta;
  50393. private _gamma;
  50394. /**
  50395. * Can be used to detect if a device orientation sensor is available on a device
  50396. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  50397. * @returns a promise that will resolve on orientation change
  50398. */
  50399. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  50400. /**
  50401. * @hidden
  50402. */
  50403. _onDeviceOrientationChangedObservable: Observable<void>;
  50404. /**
  50405. * Instantiates a new input
  50406. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50407. */
  50408. constructor();
  50409. /**
  50410. * Define the camera controlled by the input.
  50411. */
  50412. get camera(): FreeCamera;
  50413. set camera(camera: FreeCamera);
  50414. /**
  50415. * Attach the input controls to a specific dom element to get the input from.
  50416. */
  50417. attachControl(): void;
  50418. private _orientationChanged;
  50419. private _deviceOrientation;
  50420. /**
  50421. * Detach the current controls from the specified dom element.
  50422. */
  50423. detachControl(): void;
  50424. /**
  50425. * Update the current camera state depending on the inputs that have been used this frame.
  50426. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50427. */
  50428. checkInputs(): void;
  50429. /**
  50430. * Gets the class name of the current intput.
  50431. * @returns the class name
  50432. */
  50433. getClassName(): string;
  50434. /**
  50435. * Get the friendly name associated with the input class.
  50436. * @returns the input friendly name
  50437. */
  50438. getSimpleName(): string;
  50439. }
  50440. }
  50441. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  50442. import { Nullable } from "babylonjs/types";
  50443. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50444. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50445. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50446. /**
  50447. * Manage the gamepad inputs to control a free camera.
  50448. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50449. */
  50450. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  50451. /**
  50452. * Define the camera the input is attached to.
  50453. */
  50454. camera: FreeCamera;
  50455. /**
  50456. * Define the Gamepad controlling the input
  50457. */
  50458. gamepad: Nullable<Gamepad>;
  50459. /**
  50460. * Defines the gamepad rotation sensiblity.
  50461. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50462. */
  50463. gamepadAngularSensibility: number;
  50464. /**
  50465. * Defines the gamepad move sensiblity.
  50466. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50467. */
  50468. gamepadMoveSensibility: number;
  50469. private _yAxisScale;
  50470. /**
  50471. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50472. */
  50473. get invertYAxis(): boolean;
  50474. set invertYAxis(value: boolean);
  50475. private _onGamepadConnectedObserver;
  50476. private _onGamepadDisconnectedObserver;
  50477. private _cameraTransform;
  50478. private _deltaTransform;
  50479. private _vector3;
  50480. private _vector2;
  50481. /**
  50482. * Attach the input controls to a specific dom element to get the input from.
  50483. */
  50484. attachControl(): void;
  50485. /**
  50486. * Detach the current controls from the specified dom element.
  50487. */
  50488. detachControl(): void;
  50489. /**
  50490. * Update the current camera state depending on the inputs that have been used this frame.
  50491. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50492. */
  50493. checkInputs(): void;
  50494. /**
  50495. * Gets the class name of the current intput.
  50496. * @returns the class name
  50497. */
  50498. getClassName(): string;
  50499. /**
  50500. * Get the friendly name associated with the input class.
  50501. * @returns the input friendly name
  50502. */
  50503. getSimpleName(): string;
  50504. }
  50505. }
  50506. declare module "babylonjs/Misc/virtualJoystick" {
  50507. import { Nullable } from "babylonjs/types";
  50508. import { Vector3 } from "babylonjs/Maths/math.vector";
  50509. /**
  50510. * Defines the potential axis of a Joystick
  50511. */
  50512. export enum JoystickAxis {
  50513. /** X axis */
  50514. X = 0,
  50515. /** Y axis */
  50516. Y = 1,
  50517. /** Z axis */
  50518. Z = 2
  50519. }
  50520. /**
  50521. * Represents the different customization options available
  50522. * for VirtualJoystick
  50523. */
  50524. interface VirtualJoystickCustomizations {
  50525. /**
  50526. * Size of the joystick's puck
  50527. */
  50528. puckSize: number;
  50529. /**
  50530. * Size of the joystick's container
  50531. */
  50532. containerSize: number;
  50533. /**
  50534. * Color of the joystick && puck
  50535. */
  50536. color: string;
  50537. /**
  50538. * Image URL for the joystick's puck
  50539. */
  50540. puckImage?: string;
  50541. /**
  50542. * Image URL for the joystick's container
  50543. */
  50544. containerImage?: string;
  50545. /**
  50546. * Defines the unmoving position of the joystick container
  50547. */
  50548. position?: {
  50549. x: number;
  50550. y: number;
  50551. };
  50552. /**
  50553. * Defines whether or not the joystick container is always visible
  50554. */
  50555. alwaysVisible: boolean;
  50556. /**
  50557. * Defines whether or not to limit the movement of the puck to the joystick's container
  50558. */
  50559. limitToContainer: boolean;
  50560. }
  50561. /**
  50562. * Class used to define virtual joystick (used in touch mode)
  50563. */
  50564. export class VirtualJoystick {
  50565. /**
  50566. * Gets or sets a boolean indicating that left and right values must be inverted
  50567. */
  50568. reverseLeftRight: boolean;
  50569. /**
  50570. * Gets or sets a boolean indicating that up and down values must be inverted
  50571. */
  50572. reverseUpDown: boolean;
  50573. /**
  50574. * Gets the offset value for the position (ie. the change of the position value)
  50575. */
  50576. deltaPosition: Vector3;
  50577. /**
  50578. * Gets a boolean indicating if the virtual joystick was pressed
  50579. */
  50580. pressed: boolean;
  50581. /**
  50582. * Canvas the virtual joystick will render onto, default z-index of this is 5
  50583. */
  50584. static Canvas: Nullable<HTMLCanvasElement>;
  50585. /**
  50586. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  50587. */
  50588. limitToContainer: boolean;
  50589. private static _globalJoystickIndex;
  50590. private static _alwaysVisibleSticks;
  50591. private static vjCanvasContext;
  50592. private static vjCanvasWidth;
  50593. private static vjCanvasHeight;
  50594. private static halfWidth;
  50595. private static _GetDefaultOptions;
  50596. private _action;
  50597. private _axisTargetedByLeftAndRight;
  50598. private _axisTargetedByUpAndDown;
  50599. private _joystickSensibility;
  50600. private _inversedSensibility;
  50601. private _joystickPointerID;
  50602. private _joystickColor;
  50603. private _joystickPointerPos;
  50604. private _joystickPreviousPointerPos;
  50605. private _joystickPointerStartPos;
  50606. private _deltaJoystickVector;
  50607. private _leftJoystick;
  50608. private _touches;
  50609. private _joystickPosition;
  50610. private _alwaysVisible;
  50611. private _puckImage;
  50612. private _containerImage;
  50613. private _joystickPuckSize;
  50614. private _joystickContainerSize;
  50615. private _clearPuckSize;
  50616. private _clearContainerSize;
  50617. private _clearPuckSizeOffset;
  50618. private _clearContainerSizeOffset;
  50619. private _onPointerDownHandlerRef;
  50620. private _onPointerMoveHandlerRef;
  50621. private _onPointerUpHandlerRef;
  50622. private _onResize;
  50623. /**
  50624. * Creates a new virtual joystick
  50625. * @param leftJoystick defines that the joystick is for left hand (false by default)
  50626. * @param customizations Defines the options we want to customize the VirtualJoystick
  50627. */
  50628. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  50629. /**
  50630. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  50631. * @param newJoystickSensibility defines the new sensibility
  50632. */
  50633. setJoystickSensibility(newJoystickSensibility: number): void;
  50634. private _onPointerDown;
  50635. private _onPointerMove;
  50636. private _onPointerUp;
  50637. /**
  50638. * Change the color of the virtual joystick
  50639. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  50640. */
  50641. setJoystickColor(newColor: string): void;
  50642. /**
  50643. * Size of the joystick's container
  50644. */
  50645. set containerSize(newSize: number);
  50646. get containerSize(): number;
  50647. /**
  50648. * Size of the joystick's puck
  50649. */
  50650. set puckSize(newSize: number);
  50651. get puckSize(): number;
  50652. /**
  50653. * Clears the set position of the joystick
  50654. */
  50655. clearPosition(): void;
  50656. /**
  50657. * Defines whether or not the joystick container is always visible
  50658. */
  50659. set alwaysVisible(value: boolean);
  50660. get alwaysVisible(): boolean;
  50661. /**
  50662. * Sets the constant position of the Joystick container
  50663. * @param x X axis coordinate
  50664. * @param y Y axis coordinate
  50665. */
  50666. setPosition(x: number, y: number): void;
  50667. /**
  50668. * Defines a callback to call when the joystick is touched
  50669. * @param action defines the callback
  50670. */
  50671. setActionOnTouch(action: () => any): void;
  50672. /**
  50673. * Defines which axis you'd like to control for left & right
  50674. * @param axis defines the axis to use
  50675. */
  50676. setAxisForLeftRight(axis: JoystickAxis): void;
  50677. /**
  50678. * Defines which axis you'd like to control for up & down
  50679. * @param axis defines the axis to use
  50680. */
  50681. setAxisForUpDown(axis: JoystickAxis): void;
  50682. /**
  50683. * Clears the canvas from the previous puck / container draw
  50684. */
  50685. private _clearPreviousDraw;
  50686. /**
  50687. * Loads `urlPath` to be used for the container's image
  50688. * @param urlPath defines the urlPath of an image to use
  50689. */
  50690. setContainerImage(urlPath: string): void;
  50691. /**
  50692. * Loads `urlPath` to be used for the puck's image
  50693. * @param urlPath defines the urlPath of an image to use
  50694. */
  50695. setPuckImage(urlPath: string): void;
  50696. /**
  50697. * Draws the Virtual Joystick's container
  50698. */
  50699. private _drawContainer;
  50700. /**
  50701. * Draws the Virtual Joystick's puck
  50702. */
  50703. private _drawPuck;
  50704. private _drawVirtualJoystick;
  50705. /**
  50706. * Release internal HTML canvas
  50707. */
  50708. releaseCanvas(): void;
  50709. }
  50710. }
  50711. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50712. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50713. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50714. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50715. module "babylonjs/Cameras/freeCameraInputsManager" {
  50716. interface FreeCameraInputsManager {
  50717. /**
  50718. * Add virtual joystick input support to the input manager.
  50719. * @returns the current input manager
  50720. */
  50721. addVirtualJoystick(): FreeCameraInputsManager;
  50722. }
  50723. }
  50724. /**
  50725. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50726. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50727. */
  50728. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50729. /**
  50730. * Defines the camera the input is attached to.
  50731. */
  50732. camera: FreeCamera;
  50733. private _leftjoystick;
  50734. private _rightjoystick;
  50735. /**
  50736. * Gets the left stick of the virtual joystick.
  50737. * @returns The virtual Joystick
  50738. */
  50739. getLeftJoystick(): VirtualJoystick;
  50740. /**
  50741. * Gets the right stick of the virtual joystick.
  50742. * @returns The virtual Joystick
  50743. */
  50744. getRightJoystick(): VirtualJoystick;
  50745. /**
  50746. * Update the current camera state depending on the inputs that have been used this frame.
  50747. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50748. */
  50749. checkInputs(): void;
  50750. /**
  50751. * Attach the input controls to a specific dom element to get the input from.
  50752. */
  50753. attachControl(): void;
  50754. /**
  50755. * Detach the current controls from the specified dom element.
  50756. */
  50757. detachControl(): void;
  50758. /**
  50759. * Gets the class name of the current intput.
  50760. * @returns the class name
  50761. */
  50762. getClassName(): string;
  50763. /**
  50764. * Get the friendly name associated with the input class.
  50765. * @returns the input friendly name
  50766. */
  50767. getSimpleName(): string;
  50768. }
  50769. }
  50770. declare module "babylonjs/Cameras/Inputs/index" {
  50771. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50772. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50773. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50774. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50775. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50776. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50777. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50778. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50779. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50780. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50781. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50782. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50783. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50784. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50785. export * from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  50786. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50787. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50788. }
  50789. declare module "babylonjs/Cameras/touchCamera" {
  50790. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50791. import { Scene } from "babylonjs/scene";
  50792. import { Vector3 } from "babylonjs/Maths/math.vector";
  50793. /**
  50794. * This represents a FPS type of camera controlled by touch.
  50795. * This is like a universal camera minus the Gamepad controls.
  50796. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50797. */
  50798. export class TouchCamera extends FreeCamera {
  50799. /**
  50800. * Defines the touch sensibility for rotation.
  50801. * The higher the faster.
  50802. */
  50803. get touchAngularSensibility(): number;
  50804. set touchAngularSensibility(value: number);
  50805. /**
  50806. * Defines the touch sensibility for move.
  50807. * The higher the faster.
  50808. */
  50809. get touchMoveSensibility(): number;
  50810. set touchMoveSensibility(value: number);
  50811. /**
  50812. * Instantiates a new touch camera.
  50813. * This represents a FPS type of camera controlled by touch.
  50814. * This is like a universal camera minus the Gamepad controls.
  50815. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50816. * @param name Define the name of the camera in the scene
  50817. * @param position Define the start position of the camera in the scene
  50818. * @param scene Define the scene the camera belongs to
  50819. */
  50820. constructor(name: string, position: Vector3, scene: Scene);
  50821. /**
  50822. * Gets the current object class name.
  50823. * @return the class name
  50824. */
  50825. getClassName(): string;
  50826. /** @hidden */
  50827. _setupInputs(): void;
  50828. }
  50829. }
  50830. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50831. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50832. import { Scene } from "babylonjs/scene";
  50833. import { Vector3 } from "babylonjs/Maths/math.vector";
  50834. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50835. import { Axis } from "babylonjs/Maths/math.axis";
  50836. /**
  50837. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50838. * being tilted forward or back and left or right.
  50839. */
  50840. export class DeviceOrientationCamera extends FreeCamera {
  50841. private _initialQuaternion;
  50842. private _quaternionCache;
  50843. private _tmpDragQuaternion;
  50844. private _disablePointerInputWhenUsingDeviceOrientation;
  50845. /**
  50846. * Creates a new device orientation camera
  50847. * @param name The name of the camera
  50848. * @param position The start position camera
  50849. * @param scene The scene the camera belongs to
  50850. */
  50851. constructor(name: string, position: Vector3, scene: Scene);
  50852. /**
  50853. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50854. */
  50855. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50856. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50857. private _dragFactor;
  50858. /**
  50859. * Enabled turning on the y axis when the orientation sensor is active
  50860. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50861. */
  50862. enableHorizontalDragging(dragFactor?: number): void;
  50863. /**
  50864. * Gets the current instance class name ("DeviceOrientationCamera").
  50865. * This helps avoiding instanceof at run time.
  50866. * @returns the class name
  50867. */
  50868. getClassName(): string;
  50869. /**
  50870. * @hidden
  50871. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50872. */
  50873. _checkInputs(): void;
  50874. /**
  50875. * Reset the camera to its default orientation on the specified axis only.
  50876. * @param axis The axis to reset
  50877. */
  50878. resetToCurrentRotation(axis?: Axis): void;
  50879. }
  50880. }
  50881. declare module "babylonjs/Gamepads/xboxGamepad" {
  50882. import { Observable } from "babylonjs/Misc/observable";
  50883. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50884. /**
  50885. * Defines supported buttons for XBox360 compatible gamepads
  50886. */
  50887. export enum Xbox360Button {
  50888. /** A */
  50889. A = 0,
  50890. /** B */
  50891. B = 1,
  50892. /** X */
  50893. X = 2,
  50894. /** Y */
  50895. Y = 3,
  50896. /** Left button */
  50897. LB = 4,
  50898. /** Right button */
  50899. RB = 5,
  50900. /** Back */
  50901. Back = 8,
  50902. /** Start */
  50903. Start = 9,
  50904. /** Left stick */
  50905. LeftStick = 10,
  50906. /** Right stick */
  50907. RightStick = 11
  50908. }
  50909. /** Defines values for XBox360 DPad */
  50910. export enum Xbox360Dpad {
  50911. /** Up */
  50912. Up = 12,
  50913. /** Down */
  50914. Down = 13,
  50915. /** Left */
  50916. Left = 14,
  50917. /** Right */
  50918. Right = 15
  50919. }
  50920. /**
  50921. * Defines a XBox360 gamepad
  50922. */
  50923. export class Xbox360Pad extends Gamepad {
  50924. private _leftTrigger;
  50925. private _rightTrigger;
  50926. private _onlefttriggerchanged;
  50927. private _onrighttriggerchanged;
  50928. private _onbuttondown;
  50929. private _onbuttonup;
  50930. private _ondpaddown;
  50931. private _ondpadup;
  50932. /** Observable raised when a button is pressed */
  50933. onButtonDownObservable: Observable<Xbox360Button>;
  50934. /** Observable raised when a button is released */
  50935. onButtonUpObservable: Observable<Xbox360Button>;
  50936. /** Observable raised when a pad is pressed */
  50937. onPadDownObservable: Observable<Xbox360Dpad>;
  50938. /** Observable raised when a pad is released */
  50939. onPadUpObservable: Observable<Xbox360Dpad>;
  50940. private _buttonA;
  50941. private _buttonB;
  50942. private _buttonX;
  50943. private _buttonY;
  50944. private _buttonBack;
  50945. private _buttonStart;
  50946. private _buttonLB;
  50947. private _buttonRB;
  50948. private _buttonLeftStick;
  50949. private _buttonRightStick;
  50950. private _dPadUp;
  50951. private _dPadDown;
  50952. private _dPadLeft;
  50953. private _dPadRight;
  50954. private _isXboxOnePad;
  50955. /**
  50956. * Creates a new XBox360 gamepad object
  50957. * @param id defines the id of this gamepad
  50958. * @param index defines its index
  50959. * @param gamepad defines the internal HTML gamepad object
  50960. * @param xboxOne defines if it is a XBox One gamepad
  50961. */
  50962. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50963. /**
  50964. * Defines the callback to call when left trigger is pressed
  50965. * @param callback defines the callback to use
  50966. */
  50967. onlefttriggerchanged(callback: (value: number) => void): void;
  50968. /**
  50969. * Defines the callback to call when right trigger is pressed
  50970. * @param callback defines the callback to use
  50971. */
  50972. onrighttriggerchanged(callback: (value: number) => void): void;
  50973. /**
  50974. * Gets the left trigger value
  50975. */
  50976. get leftTrigger(): number;
  50977. /**
  50978. * Sets the left trigger value
  50979. */
  50980. set leftTrigger(newValue: number);
  50981. /**
  50982. * Gets the right trigger value
  50983. */
  50984. get rightTrigger(): number;
  50985. /**
  50986. * Sets the right trigger value
  50987. */
  50988. set rightTrigger(newValue: number);
  50989. /**
  50990. * Defines the callback to call when a button is pressed
  50991. * @param callback defines the callback to use
  50992. */
  50993. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50994. /**
  50995. * Defines the callback to call when a button is released
  50996. * @param callback defines the callback to use
  50997. */
  50998. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50999. /**
  51000. * Defines the callback to call when a pad is pressed
  51001. * @param callback defines the callback to use
  51002. */
  51003. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  51004. /**
  51005. * Defines the callback to call when a pad is released
  51006. * @param callback defines the callback to use
  51007. */
  51008. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  51009. private _setButtonValue;
  51010. private _setDPadValue;
  51011. /**
  51012. * Gets the value of the `A` button
  51013. */
  51014. get buttonA(): number;
  51015. /**
  51016. * Sets the value of the `A` button
  51017. */
  51018. set buttonA(value: number);
  51019. /**
  51020. * Gets the value of the `B` button
  51021. */
  51022. get buttonB(): number;
  51023. /**
  51024. * Sets the value of the `B` button
  51025. */
  51026. set buttonB(value: number);
  51027. /**
  51028. * Gets the value of the `X` button
  51029. */
  51030. get buttonX(): number;
  51031. /**
  51032. * Sets the value of the `X` button
  51033. */
  51034. set buttonX(value: number);
  51035. /**
  51036. * Gets the value of the `Y` button
  51037. */
  51038. get buttonY(): number;
  51039. /**
  51040. * Sets the value of the `Y` button
  51041. */
  51042. set buttonY(value: number);
  51043. /**
  51044. * Gets the value of the `Start` button
  51045. */
  51046. get buttonStart(): number;
  51047. /**
  51048. * Sets the value of the `Start` button
  51049. */
  51050. set buttonStart(value: number);
  51051. /**
  51052. * Gets the value of the `Back` button
  51053. */
  51054. get buttonBack(): number;
  51055. /**
  51056. * Sets the value of the `Back` button
  51057. */
  51058. set buttonBack(value: number);
  51059. /**
  51060. * Gets the value of the `Left` button
  51061. */
  51062. get buttonLB(): number;
  51063. /**
  51064. * Sets the value of the `Left` button
  51065. */
  51066. set buttonLB(value: number);
  51067. /**
  51068. * Gets the value of the `Right` button
  51069. */
  51070. get buttonRB(): number;
  51071. /**
  51072. * Sets the value of the `Right` button
  51073. */
  51074. set buttonRB(value: number);
  51075. /**
  51076. * Gets the value of the Left joystick
  51077. */
  51078. get buttonLeftStick(): number;
  51079. /**
  51080. * Sets the value of the Left joystick
  51081. */
  51082. set buttonLeftStick(value: number);
  51083. /**
  51084. * Gets the value of the Right joystick
  51085. */
  51086. get buttonRightStick(): number;
  51087. /**
  51088. * Sets the value of the Right joystick
  51089. */
  51090. set buttonRightStick(value: number);
  51091. /**
  51092. * Gets the value of D-pad up
  51093. */
  51094. get dPadUp(): number;
  51095. /**
  51096. * Sets the value of D-pad up
  51097. */
  51098. set dPadUp(value: number);
  51099. /**
  51100. * Gets the value of D-pad down
  51101. */
  51102. get dPadDown(): number;
  51103. /**
  51104. * Sets the value of D-pad down
  51105. */
  51106. set dPadDown(value: number);
  51107. /**
  51108. * Gets the value of D-pad left
  51109. */
  51110. get dPadLeft(): number;
  51111. /**
  51112. * Sets the value of D-pad left
  51113. */
  51114. set dPadLeft(value: number);
  51115. /**
  51116. * Gets the value of D-pad right
  51117. */
  51118. get dPadRight(): number;
  51119. /**
  51120. * Sets the value of D-pad right
  51121. */
  51122. set dPadRight(value: number);
  51123. /**
  51124. * Force the gamepad to synchronize with device values
  51125. */
  51126. update(): void;
  51127. /**
  51128. * Disposes the gamepad
  51129. */
  51130. dispose(): void;
  51131. }
  51132. }
  51133. declare module "babylonjs/Gamepads/dualShockGamepad" {
  51134. import { Observable } from "babylonjs/Misc/observable";
  51135. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51136. /**
  51137. * Defines supported buttons for DualShock compatible gamepads
  51138. */
  51139. export enum DualShockButton {
  51140. /** Cross */
  51141. Cross = 0,
  51142. /** Circle */
  51143. Circle = 1,
  51144. /** Square */
  51145. Square = 2,
  51146. /** Triangle */
  51147. Triangle = 3,
  51148. /** L1 */
  51149. L1 = 4,
  51150. /** R1 */
  51151. R1 = 5,
  51152. /** Share */
  51153. Share = 8,
  51154. /** Options */
  51155. Options = 9,
  51156. /** Left stick */
  51157. LeftStick = 10,
  51158. /** Right stick */
  51159. RightStick = 11
  51160. }
  51161. /** Defines values for DualShock DPad */
  51162. export enum DualShockDpad {
  51163. /** Up */
  51164. Up = 12,
  51165. /** Down */
  51166. Down = 13,
  51167. /** Left */
  51168. Left = 14,
  51169. /** Right */
  51170. Right = 15
  51171. }
  51172. /**
  51173. * Defines a DualShock gamepad
  51174. */
  51175. export class DualShockPad extends Gamepad {
  51176. private _leftTrigger;
  51177. private _rightTrigger;
  51178. private _onlefttriggerchanged;
  51179. private _onrighttriggerchanged;
  51180. private _onbuttondown;
  51181. private _onbuttonup;
  51182. private _ondpaddown;
  51183. private _ondpadup;
  51184. /** Observable raised when a button is pressed */
  51185. onButtonDownObservable: Observable<DualShockButton>;
  51186. /** Observable raised when a button is released */
  51187. onButtonUpObservable: Observable<DualShockButton>;
  51188. /** Observable raised when a pad is pressed */
  51189. onPadDownObservable: Observable<DualShockDpad>;
  51190. /** Observable raised when a pad is released */
  51191. onPadUpObservable: Observable<DualShockDpad>;
  51192. private _buttonCross;
  51193. private _buttonCircle;
  51194. private _buttonSquare;
  51195. private _buttonTriangle;
  51196. private _buttonShare;
  51197. private _buttonOptions;
  51198. private _buttonL1;
  51199. private _buttonR1;
  51200. private _buttonLeftStick;
  51201. private _buttonRightStick;
  51202. private _dPadUp;
  51203. private _dPadDown;
  51204. private _dPadLeft;
  51205. private _dPadRight;
  51206. /**
  51207. * Creates a new DualShock gamepad object
  51208. * @param id defines the id of this gamepad
  51209. * @param index defines its index
  51210. * @param gamepad defines the internal HTML gamepad object
  51211. */
  51212. constructor(id: string, index: number, gamepad: any);
  51213. /**
  51214. * Defines the callback to call when left trigger is pressed
  51215. * @param callback defines the callback to use
  51216. */
  51217. onlefttriggerchanged(callback: (value: number) => void): void;
  51218. /**
  51219. * Defines the callback to call when right trigger is pressed
  51220. * @param callback defines the callback to use
  51221. */
  51222. onrighttriggerchanged(callback: (value: number) => void): void;
  51223. /**
  51224. * Gets the left trigger value
  51225. */
  51226. get leftTrigger(): number;
  51227. /**
  51228. * Sets the left trigger value
  51229. */
  51230. set leftTrigger(newValue: number);
  51231. /**
  51232. * Gets the right trigger value
  51233. */
  51234. get rightTrigger(): number;
  51235. /**
  51236. * Sets the right trigger value
  51237. */
  51238. set rightTrigger(newValue: number);
  51239. /**
  51240. * Defines the callback to call when a button is pressed
  51241. * @param callback defines the callback to use
  51242. */
  51243. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  51244. /**
  51245. * Defines the callback to call when a button is released
  51246. * @param callback defines the callback to use
  51247. */
  51248. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  51249. /**
  51250. * Defines the callback to call when a pad is pressed
  51251. * @param callback defines the callback to use
  51252. */
  51253. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  51254. /**
  51255. * Defines the callback to call when a pad is released
  51256. * @param callback defines the callback to use
  51257. */
  51258. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  51259. private _setButtonValue;
  51260. private _setDPadValue;
  51261. /**
  51262. * Gets the value of the `Cross` button
  51263. */
  51264. get buttonCross(): number;
  51265. /**
  51266. * Sets the value of the `Cross` button
  51267. */
  51268. set buttonCross(value: number);
  51269. /**
  51270. * Gets the value of the `Circle` button
  51271. */
  51272. get buttonCircle(): number;
  51273. /**
  51274. * Sets the value of the `Circle` button
  51275. */
  51276. set buttonCircle(value: number);
  51277. /**
  51278. * Gets the value of the `Square` button
  51279. */
  51280. get buttonSquare(): number;
  51281. /**
  51282. * Sets the value of the `Square` button
  51283. */
  51284. set buttonSquare(value: number);
  51285. /**
  51286. * Gets the value of the `Triangle` button
  51287. */
  51288. get buttonTriangle(): number;
  51289. /**
  51290. * Sets the value of the `Triangle` button
  51291. */
  51292. set buttonTriangle(value: number);
  51293. /**
  51294. * Gets the value of the `Options` button
  51295. */
  51296. get buttonOptions(): number;
  51297. /**
  51298. * Sets the value of the `Options` button
  51299. */
  51300. set buttonOptions(value: number);
  51301. /**
  51302. * Gets the value of the `Share` button
  51303. */
  51304. get buttonShare(): number;
  51305. /**
  51306. * Sets the value of the `Share` button
  51307. */
  51308. set buttonShare(value: number);
  51309. /**
  51310. * Gets the value of the `L1` button
  51311. */
  51312. get buttonL1(): number;
  51313. /**
  51314. * Sets the value of the `L1` button
  51315. */
  51316. set buttonL1(value: number);
  51317. /**
  51318. * Gets the value of the `R1` button
  51319. */
  51320. get buttonR1(): number;
  51321. /**
  51322. * Sets the value of the `R1` button
  51323. */
  51324. set buttonR1(value: number);
  51325. /**
  51326. * Gets the value of the Left joystick
  51327. */
  51328. get buttonLeftStick(): number;
  51329. /**
  51330. * Sets the value of the Left joystick
  51331. */
  51332. set buttonLeftStick(value: number);
  51333. /**
  51334. * Gets the value of the Right joystick
  51335. */
  51336. get buttonRightStick(): number;
  51337. /**
  51338. * Sets the value of the Right joystick
  51339. */
  51340. set buttonRightStick(value: number);
  51341. /**
  51342. * Gets the value of D-pad up
  51343. */
  51344. get dPadUp(): number;
  51345. /**
  51346. * Sets the value of D-pad up
  51347. */
  51348. set dPadUp(value: number);
  51349. /**
  51350. * Gets the value of D-pad down
  51351. */
  51352. get dPadDown(): number;
  51353. /**
  51354. * Sets the value of D-pad down
  51355. */
  51356. set dPadDown(value: number);
  51357. /**
  51358. * Gets the value of D-pad left
  51359. */
  51360. get dPadLeft(): number;
  51361. /**
  51362. * Sets the value of D-pad left
  51363. */
  51364. set dPadLeft(value: number);
  51365. /**
  51366. * Gets the value of D-pad right
  51367. */
  51368. get dPadRight(): number;
  51369. /**
  51370. * Sets the value of D-pad right
  51371. */
  51372. set dPadRight(value: number);
  51373. /**
  51374. * Force the gamepad to synchronize with device values
  51375. */
  51376. update(): void;
  51377. /**
  51378. * Disposes the gamepad
  51379. */
  51380. dispose(): void;
  51381. }
  51382. }
  51383. declare module "babylonjs/Gamepads/gamepadManager" {
  51384. import { Observable } from "babylonjs/Misc/observable";
  51385. import { Nullable } from "babylonjs/types";
  51386. import { Scene } from "babylonjs/scene";
  51387. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51388. /**
  51389. * Manager for handling gamepads
  51390. */
  51391. export class GamepadManager {
  51392. private _scene?;
  51393. private _babylonGamepads;
  51394. private _oneGamepadConnected;
  51395. /** @hidden */
  51396. _isMonitoring: boolean;
  51397. private _gamepadEventSupported;
  51398. private _gamepadSupport?;
  51399. /**
  51400. * observable to be triggered when the gamepad controller has been connected
  51401. */
  51402. onGamepadConnectedObservable: Observable<Gamepad>;
  51403. /**
  51404. * observable to be triggered when the gamepad controller has been disconnected
  51405. */
  51406. onGamepadDisconnectedObservable: Observable<Gamepad>;
  51407. private _onGamepadConnectedEvent;
  51408. private _onGamepadDisconnectedEvent;
  51409. /**
  51410. * Initializes the gamepad manager
  51411. * @param _scene BabylonJS scene
  51412. */
  51413. constructor(_scene?: Scene | undefined);
  51414. /**
  51415. * The gamepads in the game pad manager
  51416. */
  51417. get gamepads(): Gamepad[];
  51418. /**
  51419. * Get the gamepad controllers based on type
  51420. * @param type The type of gamepad controller
  51421. * @returns Nullable gamepad
  51422. */
  51423. getGamepadByType(type?: number): Nullable<Gamepad>;
  51424. /**
  51425. * Disposes the gamepad manager
  51426. */
  51427. dispose(): void;
  51428. private _addNewGamepad;
  51429. private _startMonitoringGamepads;
  51430. private _stopMonitoringGamepads;
  51431. /** @hidden */
  51432. _checkGamepadsStatus(): void;
  51433. private _updateGamepadObjects;
  51434. }
  51435. }
  51436. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  51437. import { Nullable } from "babylonjs/types";
  51438. import { Scene } from "babylonjs/scene";
  51439. import { ISceneComponent } from "babylonjs/sceneComponent";
  51440. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  51441. module "babylonjs/scene" {
  51442. interface Scene {
  51443. /** @hidden */
  51444. _gamepadManager: Nullable<GamepadManager>;
  51445. /**
  51446. * Gets the gamepad manager associated with the scene
  51447. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  51448. */
  51449. gamepadManager: GamepadManager;
  51450. }
  51451. }
  51452. module "babylonjs/Cameras/freeCameraInputsManager" {
  51453. /**
  51454. * Interface representing a free camera inputs manager
  51455. */
  51456. interface FreeCameraInputsManager {
  51457. /**
  51458. * Adds gamepad input support to the FreeCameraInputsManager.
  51459. * @returns the FreeCameraInputsManager
  51460. */
  51461. addGamepad(): FreeCameraInputsManager;
  51462. }
  51463. }
  51464. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  51465. /**
  51466. * Interface representing an arc rotate camera inputs manager
  51467. */
  51468. interface ArcRotateCameraInputsManager {
  51469. /**
  51470. * Adds gamepad input support to the ArcRotateCamera InputManager.
  51471. * @returns the camera inputs manager
  51472. */
  51473. addGamepad(): ArcRotateCameraInputsManager;
  51474. }
  51475. }
  51476. /**
  51477. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  51478. */
  51479. export class GamepadSystemSceneComponent implements ISceneComponent {
  51480. /**
  51481. * The component name helpfull to identify the component in the list of scene components.
  51482. */
  51483. readonly name: string;
  51484. /**
  51485. * The scene the component belongs to.
  51486. */
  51487. scene: Scene;
  51488. /**
  51489. * Creates a new instance of the component for the given scene
  51490. * @param scene Defines the scene to register the component in
  51491. */
  51492. constructor(scene: Scene);
  51493. /**
  51494. * Registers the component in a given scene
  51495. */
  51496. register(): void;
  51497. /**
  51498. * Rebuilds the elements related to this component in case of
  51499. * context lost for instance.
  51500. */
  51501. rebuild(): void;
  51502. /**
  51503. * Disposes the component and the associated ressources
  51504. */
  51505. dispose(): void;
  51506. private _beforeCameraUpdate;
  51507. }
  51508. }
  51509. declare module "babylonjs/Cameras/universalCamera" {
  51510. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  51511. import { Scene } from "babylonjs/scene";
  51512. import { Vector3 } from "babylonjs/Maths/math.vector";
  51513. import "babylonjs/Gamepads/gamepadSceneComponent";
  51514. /**
  51515. * 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,
  51516. * which still works and will still be found in many Playgrounds.
  51517. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51518. */
  51519. export class UniversalCamera extends TouchCamera {
  51520. /**
  51521. * Defines the gamepad rotation sensiblity.
  51522. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51523. */
  51524. get gamepadAngularSensibility(): number;
  51525. set gamepadAngularSensibility(value: number);
  51526. /**
  51527. * Defines the gamepad move sensiblity.
  51528. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51529. */
  51530. get gamepadMoveSensibility(): number;
  51531. set gamepadMoveSensibility(value: number);
  51532. /**
  51533. * 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,
  51534. * which still works and will still be found in many Playgrounds.
  51535. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51536. * @param name Define the name of the camera in the scene
  51537. * @param position Define the start position of the camera in the scene
  51538. * @param scene Define the scene the camera belongs to
  51539. */
  51540. constructor(name: string, position: Vector3, scene: Scene);
  51541. /**
  51542. * Gets the current object class name.
  51543. * @return the class name
  51544. */
  51545. getClassName(): string;
  51546. }
  51547. }
  51548. declare module "babylonjs/Cameras/gamepadCamera" {
  51549. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51550. import { Scene } from "babylonjs/scene";
  51551. import { Vector3 } from "babylonjs/Maths/math.vector";
  51552. /**
  51553. * This represents a FPS type of camera. This is only here for back compat purpose.
  51554. * Please use the UniversalCamera instead as both are identical.
  51555. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51556. */
  51557. export class GamepadCamera extends UniversalCamera {
  51558. /**
  51559. * Instantiates a new Gamepad Camera
  51560. * This represents a FPS type of camera. This is only here for back compat purpose.
  51561. * Please use the UniversalCamera instead as both are identical.
  51562. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51563. * @param name Define the name of the camera in the scene
  51564. * @param position Define the start position of the camera in the scene
  51565. * @param scene Define the scene the camera belongs to
  51566. */
  51567. constructor(name: string, position: Vector3, scene: Scene);
  51568. /**
  51569. * Gets the current object class name.
  51570. * @return the class name
  51571. */
  51572. getClassName(): string;
  51573. }
  51574. }
  51575. declare module "babylonjs/Shaders/pass.fragment" {
  51576. /** @hidden */
  51577. export var passPixelShader: {
  51578. name: string;
  51579. shader: string;
  51580. };
  51581. }
  51582. declare module "babylonjs/Shaders/passCube.fragment" {
  51583. /** @hidden */
  51584. export var passCubePixelShader: {
  51585. name: string;
  51586. shader: string;
  51587. };
  51588. }
  51589. declare module "babylonjs/PostProcesses/passPostProcess" {
  51590. import { Nullable } from "babylonjs/types";
  51591. import { Camera } from "babylonjs/Cameras/camera";
  51592. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51593. import { Engine } from "babylonjs/Engines/engine";
  51594. import "babylonjs/Shaders/pass.fragment";
  51595. import "babylonjs/Shaders/passCube.fragment";
  51596. import { Scene } from "babylonjs/scene";
  51597. /**
  51598. * PassPostProcess which produces an output the same as it's input
  51599. */
  51600. export class PassPostProcess extends PostProcess {
  51601. /**
  51602. * Gets a string identifying the name of the class
  51603. * @returns "PassPostProcess" string
  51604. */
  51605. getClassName(): string;
  51606. /**
  51607. * Creates the PassPostProcess
  51608. * @param name The name of the effect.
  51609. * @param options The required width/height ratio to downsize to before computing the render pass.
  51610. * @param camera The camera to apply the render pass to.
  51611. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51612. * @param engine The engine which the post process will be applied. (default: current engine)
  51613. * @param reusable If the post process can be reused on the same frame. (default: false)
  51614. * @param textureType The type of texture to be used when performing the post processing.
  51615. * @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)
  51616. */
  51617. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51618. /** @hidden */
  51619. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  51620. }
  51621. /**
  51622. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  51623. */
  51624. export class PassCubePostProcess extends PostProcess {
  51625. private _face;
  51626. /**
  51627. * Gets or sets the cube face to display.
  51628. * * 0 is +X
  51629. * * 1 is -X
  51630. * * 2 is +Y
  51631. * * 3 is -Y
  51632. * * 4 is +Z
  51633. * * 5 is -Z
  51634. */
  51635. get face(): number;
  51636. set face(value: number);
  51637. /**
  51638. * Gets a string identifying the name of the class
  51639. * @returns "PassCubePostProcess" string
  51640. */
  51641. getClassName(): string;
  51642. /**
  51643. * Creates the PassCubePostProcess
  51644. * @param name The name of the effect.
  51645. * @param options The required width/height ratio to downsize to before computing the render pass.
  51646. * @param camera The camera to apply the render pass to.
  51647. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51648. * @param engine The engine which the post process will be applied. (default: current engine)
  51649. * @param reusable If the post process can be reused on the same frame. (default: false)
  51650. * @param textureType The type of texture to be used when performing the post processing.
  51651. * @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)
  51652. */
  51653. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51654. /** @hidden */
  51655. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51656. }
  51657. }
  51658. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51659. /** @hidden */
  51660. export var anaglyphPixelShader: {
  51661. name: string;
  51662. shader: string;
  51663. };
  51664. }
  51665. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51666. import { Engine } from "babylonjs/Engines/engine";
  51667. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51668. import { Camera } from "babylonjs/Cameras/camera";
  51669. import "babylonjs/Shaders/anaglyph.fragment";
  51670. /**
  51671. * Postprocess used to generate anaglyphic rendering
  51672. */
  51673. export class AnaglyphPostProcess extends PostProcess {
  51674. private _passedProcess;
  51675. /**
  51676. * Gets a string identifying the name of the class
  51677. * @returns "AnaglyphPostProcess" string
  51678. */
  51679. getClassName(): string;
  51680. /**
  51681. * Creates a new AnaglyphPostProcess
  51682. * @param name defines postprocess name
  51683. * @param options defines creation options or target ratio scale
  51684. * @param rigCameras defines cameras using this postprocess
  51685. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51686. * @param engine defines hosting engine
  51687. * @param reusable defines if the postprocess will be reused multiple times per frame
  51688. */
  51689. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51690. }
  51691. }
  51692. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51693. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51694. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51695. import { Scene } from "babylonjs/scene";
  51696. import { Vector3 } from "babylonjs/Maths/math.vector";
  51697. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51698. /**
  51699. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51700. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51701. */
  51702. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51703. /**
  51704. * Creates a new AnaglyphArcRotateCamera
  51705. * @param name defines camera name
  51706. * @param alpha defines alpha angle (in radians)
  51707. * @param beta defines beta angle (in radians)
  51708. * @param radius defines radius
  51709. * @param target defines camera target
  51710. * @param interaxialDistance defines distance between each color axis
  51711. * @param scene defines the hosting scene
  51712. */
  51713. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51714. /**
  51715. * Gets camera class name
  51716. * @returns AnaglyphArcRotateCamera
  51717. */
  51718. getClassName(): string;
  51719. }
  51720. }
  51721. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51722. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51723. import { Scene } from "babylonjs/scene";
  51724. import { Vector3 } from "babylonjs/Maths/math.vector";
  51725. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51726. /**
  51727. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51728. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51729. */
  51730. export class AnaglyphFreeCamera extends FreeCamera {
  51731. /**
  51732. * Creates a new AnaglyphFreeCamera
  51733. * @param name defines camera name
  51734. * @param position defines initial position
  51735. * @param interaxialDistance defines distance between each color axis
  51736. * @param scene defines the hosting scene
  51737. */
  51738. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51739. /**
  51740. * Gets camera class name
  51741. * @returns AnaglyphFreeCamera
  51742. */
  51743. getClassName(): string;
  51744. }
  51745. }
  51746. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51747. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51748. import { Scene } from "babylonjs/scene";
  51749. import { Vector3 } from "babylonjs/Maths/math.vector";
  51750. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51751. /**
  51752. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51753. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51754. */
  51755. export class AnaglyphGamepadCamera extends GamepadCamera {
  51756. /**
  51757. * Creates a new AnaglyphGamepadCamera
  51758. * @param name defines camera name
  51759. * @param position defines initial position
  51760. * @param interaxialDistance defines distance between each color axis
  51761. * @param scene defines the hosting scene
  51762. */
  51763. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51764. /**
  51765. * Gets camera class name
  51766. * @returns AnaglyphGamepadCamera
  51767. */
  51768. getClassName(): string;
  51769. }
  51770. }
  51771. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51772. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51773. import { Scene } from "babylonjs/scene";
  51774. import { Vector3 } from "babylonjs/Maths/math.vector";
  51775. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51776. /**
  51777. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51778. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51779. */
  51780. export class AnaglyphUniversalCamera extends UniversalCamera {
  51781. /**
  51782. * Creates a new AnaglyphUniversalCamera
  51783. * @param name defines camera name
  51784. * @param position defines initial position
  51785. * @param interaxialDistance defines distance between each color axis
  51786. * @param scene defines the hosting scene
  51787. */
  51788. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51789. /**
  51790. * Gets camera class name
  51791. * @returns AnaglyphUniversalCamera
  51792. */
  51793. getClassName(): string;
  51794. }
  51795. }
  51796. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51797. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51798. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51799. import { Scene } from "babylonjs/scene";
  51800. import { Vector3 } from "babylonjs/Maths/math.vector";
  51801. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51802. /**
  51803. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51804. * @see https://doc.babylonjs.com/features/cameras
  51805. */
  51806. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51807. /**
  51808. * Creates a new StereoscopicArcRotateCamera
  51809. * @param name defines camera name
  51810. * @param alpha defines alpha angle (in radians)
  51811. * @param beta defines beta angle (in radians)
  51812. * @param radius defines radius
  51813. * @param target defines camera target
  51814. * @param interaxialDistance defines distance between each color axis
  51815. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51816. * @param scene defines the hosting scene
  51817. */
  51818. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51819. /**
  51820. * Gets camera class name
  51821. * @returns StereoscopicArcRotateCamera
  51822. */
  51823. getClassName(): string;
  51824. }
  51825. }
  51826. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51827. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51828. import { Scene } from "babylonjs/scene";
  51829. import { Vector3 } from "babylonjs/Maths/math.vector";
  51830. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51831. /**
  51832. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51833. * @see https://doc.babylonjs.com/features/cameras
  51834. */
  51835. export class StereoscopicFreeCamera extends FreeCamera {
  51836. /**
  51837. * Creates a new StereoscopicFreeCamera
  51838. * @param name defines camera name
  51839. * @param position defines initial position
  51840. * @param interaxialDistance defines distance between each color axis
  51841. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51842. * @param scene defines the hosting scene
  51843. */
  51844. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51845. /**
  51846. * Gets camera class name
  51847. * @returns StereoscopicFreeCamera
  51848. */
  51849. getClassName(): string;
  51850. }
  51851. }
  51852. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51853. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51854. import { Scene } from "babylonjs/scene";
  51855. import { Vector3 } from "babylonjs/Maths/math.vector";
  51856. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51857. /**
  51858. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51859. * @see https://doc.babylonjs.com/features/cameras
  51860. */
  51861. export class StereoscopicGamepadCamera extends GamepadCamera {
  51862. /**
  51863. * Creates a new StereoscopicGamepadCamera
  51864. * @param name defines camera name
  51865. * @param position defines initial position
  51866. * @param interaxialDistance defines distance between each color axis
  51867. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51868. * @param scene defines the hosting scene
  51869. */
  51870. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51871. /**
  51872. * Gets camera class name
  51873. * @returns StereoscopicGamepadCamera
  51874. */
  51875. getClassName(): string;
  51876. }
  51877. }
  51878. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51879. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51880. import { Scene } from "babylonjs/scene";
  51881. import { Vector3 } from "babylonjs/Maths/math.vector";
  51882. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51883. /**
  51884. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51885. * @see https://doc.babylonjs.com/features/cameras
  51886. */
  51887. export class StereoscopicUniversalCamera extends UniversalCamera {
  51888. /**
  51889. * Creates a new StereoscopicUniversalCamera
  51890. * @param name defines camera name
  51891. * @param position defines initial position
  51892. * @param interaxialDistance defines distance between each color axis
  51893. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51894. * @param scene defines the hosting scene
  51895. */
  51896. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51897. /**
  51898. * Gets camera class name
  51899. * @returns StereoscopicUniversalCamera
  51900. */
  51901. getClassName(): string;
  51902. }
  51903. }
  51904. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51905. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51906. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51907. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51908. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51909. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51910. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51911. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51912. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51913. }
  51914. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51915. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51916. import { Scene } from "babylonjs/scene";
  51917. import { Vector3 } from "babylonjs/Maths/math.vector";
  51918. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51919. /**
  51920. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51921. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51922. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51923. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51924. */
  51925. export class VirtualJoysticksCamera extends FreeCamera {
  51926. /**
  51927. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51928. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51929. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51930. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51931. * @param name Define the name of the camera in the scene
  51932. * @param position Define the start position of the camera in the scene
  51933. * @param scene Define the scene the camera belongs to
  51934. */
  51935. constructor(name: string, position: Vector3, scene: Scene);
  51936. /**
  51937. * Gets the current object class name.
  51938. * @return the class name
  51939. */
  51940. getClassName(): string;
  51941. }
  51942. }
  51943. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51944. import { Matrix } from "babylonjs/Maths/math.vector";
  51945. /**
  51946. * This represents all the required metrics to create a VR camera.
  51947. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51948. */
  51949. export class VRCameraMetrics {
  51950. /**
  51951. * Define the horizontal resolution off the screen.
  51952. */
  51953. hResolution: number;
  51954. /**
  51955. * Define the vertical resolution off the screen.
  51956. */
  51957. vResolution: number;
  51958. /**
  51959. * Define the horizontal screen size.
  51960. */
  51961. hScreenSize: number;
  51962. /**
  51963. * Define the vertical screen size.
  51964. */
  51965. vScreenSize: number;
  51966. /**
  51967. * Define the vertical screen center position.
  51968. */
  51969. vScreenCenter: number;
  51970. /**
  51971. * Define the distance of the eyes to the screen.
  51972. */
  51973. eyeToScreenDistance: number;
  51974. /**
  51975. * Define the distance between both lenses
  51976. */
  51977. lensSeparationDistance: number;
  51978. /**
  51979. * Define the distance between both viewer's eyes.
  51980. */
  51981. interpupillaryDistance: number;
  51982. /**
  51983. * Define the distortion factor of the VR postprocess.
  51984. * Please, touch with care.
  51985. */
  51986. distortionK: number[];
  51987. /**
  51988. * Define the chromatic aberration correction factors for the VR post process.
  51989. */
  51990. chromaAbCorrection: number[];
  51991. /**
  51992. * Define the scale factor of the post process.
  51993. * The smaller the better but the slower.
  51994. */
  51995. postProcessScaleFactor: number;
  51996. /**
  51997. * Define an offset for the lens center.
  51998. */
  51999. lensCenterOffset: number;
  52000. /**
  52001. * Define if the current vr camera should compensate the distortion of the lense or not.
  52002. */
  52003. compensateDistortion: boolean;
  52004. /**
  52005. * Defines if multiview should be enabled when rendering (Default: false)
  52006. */
  52007. multiviewEnabled: boolean;
  52008. /**
  52009. * Gets the rendering aspect ratio based on the provided resolutions.
  52010. */
  52011. get aspectRatio(): number;
  52012. /**
  52013. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  52014. */
  52015. get aspectRatioFov(): number;
  52016. /**
  52017. * @hidden
  52018. */
  52019. get leftHMatrix(): Matrix;
  52020. /**
  52021. * @hidden
  52022. */
  52023. get rightHMatrix(): Matrix;
  52024. /**
  52025. * @hidden
  52026. */
  52027. get leftPreViewMatrix(): Matrix;
  52028. /**
  52029. * @hidden
  52030. */
  52031. get rightPreViewMatrix(): Matrix;
  52032. /**
  52033. * Get the default VRMetrics based on the most generic setup.
  52034. * @returns the default vr metrics
  52035. */
  52036. static GetDefault(): VRCameraMetrics;
  52037. }
  52038. }
  52039. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  52040. /** @hidden */
  52041. export var vrDistortionCorrectionPixelShader: {
  52042. name: string;
  52043. shader: string;
  52044. };
  52045. }
  52046. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  52047. import { Camera } from "babylonjs/Cameras/camera";
  52048. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52049. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52050. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  52051. /**
  52052. * VRDistortionCorrectionPostProcess used for mobile VR
  52053. */
  52054. export class VRDistortionCorrectionPostProcess extends PostProcess {
  52055. private _isRightEye;
  52056. private _distortionFactors;
  52057. private _postProcessScaleFactor;
  52058. private _lensCenterOffset;
  52059. private _scaleIn;
  52060. private _scaleFactor;
  52061. private _lensCenter;
  52062. /**
  52063. * Gets a string identifying the name of the class
  52064. * @returns "VRDistortionCorrectionPostProcess" string
  52065. */
  52066. getClassName(): string;
  52067. /**
  52068. * Initializes the VRDistortionCorrectionPostProcess
  52069. * @param name The name of the effect.
  52070. * @param camera The camera to apply the render pass to.
  52071. * @param isRightEye If this is for the right eye distortion
  52072. * @param vrMetrics All the required metrics for the VR camera
  52073. */
  52074. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  52075. }
  52076. }
  52077. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  52078. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  52079. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  52080. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52081. import { Scene } from "babylonjs/scene";
  52082. import { Vector3 } from "babylonjs/Maths/math.vector";
  52083. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  52084. import "babylonjs/Cameras/RigModes/vrRigMode";
  52085. /**
  52086. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  52087. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52088. */
  52089. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  52090. /**
  52091. * Creates a new VRDeviceOrientationArcRotateCamera
  52092. * @param name defines camera name
  52093. * @param alpha defines the camera rotation along the logitudinal axis
  52094. * @param beta defines the camera rotation along the latitudinal axis
  52095. * @param radius defines the camera distance from its target
  52096. * @param target defines the camera target
  52097. * @param scene defines the scene the camera belongs to
  52098. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52099. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52100. */
  52101. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52102. /**
  52103. * Gets camera class name
  52104. * @returns VRDeviceOrientationArcRotateCamera
  52105. */
  52106. getClassName(): string;
  52107. }
  52108. }
  52109. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  52110. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  52111. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52112. import { Scene } from "babylonjs/scene";
  52113. import { Vector3 } from "babylonjs/Maths/math.vector";
  52114. import "babylonjs/Cameras/RigModes/vrRigMode";
  52115. /**
  52116. * Camera used to simulate VR rendering (based on FreeCamera)
  52117. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52118. */
  52119. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  52120. /**
  52121. * Creates a new VRDeviceOrientationFreeCamera
  52122. * @param name defines camera name
  52123. * @param position defines the start position of the camera
  52124. * @param scene defines the scene the camera belongs to
  52125. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52126. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52127. */
  52128. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52129. /**
  52130. * Gets camera class name
  52131. * @returns VRDeviceOrientationFreeCamera
  52132. */
  52133. getClassName(): string;
  52134. }
  52135. }
  52136. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  52137. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52138. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52139. import { Scene } from "babylonjs/scene";
  52140. import { Vector3 } from "babylonjs/Maths/math.vector";
  52141. import "babylonjs/Gamepads/gamepadSceneComponent";
  52142. /**
  52143. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  52144. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52145. */
  52146. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  52147. /**
  52148. * Creates a new VRDeviceOrientationGamepadCamera
  52149. * @param name defines camera name
  52150. * @param position defines the start position of the camera
  52151. * @param scene defines the scene the camera belongs to
  52152. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52153. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52154. */
  52155. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52156. /**
  52157. * Gets camera class name
  52158. * @returns VRDeviceOrientationGamepadCamera
  52159. */
  52160. getClassName(): string;
  52161. }
  52162. }
  52163. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  52164. import { Scene } from "babylonjs/scene";
  52165. import { Texture } from "babylonjs/Materials/Textures/texture";
  52166. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  52167. /**
  52168. * A class extending Texture allowing drawing on a texture
  52169. * @see https://doc.babylonjs.com/how_to/dynamictexture
  52170. */
  52171. export class DynamicTexture extends Texture {
  52172. private _generateMipMaps;
  52173. private _canvas;
  52174. private _context;
  52175. /**
  52176. * Creates a DynamicTexture
  52177. * @param name defines the name of the texture
  52178. * @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
  52179. * @param scene defines the scene where you want the texture
  52180. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  52181. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52182. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  52183. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  52184. */
  52185. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  52186. /**
  52187. * Get the current class name of the texture useful for serialization or dynamic coding.
  52188. * @returns "DynamicTexture"
  52189. */
  52190. getClassName(): string;
  52191. /**
  52192. * Gets the current state of canRescale
  52193. */
  52194. get canRescale(): boolean;
  52195. private _recreate;
  52196. /**
  52197. * Scales the texture
  52198. * @param ratio the scale factor to apply to both width and height
  52199. */
  52200. scale(ratio: number): void;
  52201. /**
  52202. * Resizes the texture
  52203. * @param width the new width
  52204. * @param height the new height
  52205. */
  52206. scaleTo(width: number, height: number): void;
  52207. /**
  52208. * Gets the context of the canvas used by the texture
  52209. * @returns the canvas context of the dynamic texture
  52210. */
  52211. getContext(): CanvasRenderingContext2D;
  52212. /**
  52213. * Clears the texture
  52214. */
  52215. clear(): void;
  52216. /**
  52217. * Updates the texture
  52218. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52219. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  52220. */
  52221. update(invertY?: boolean, premulAlpha?: boolean): void;
  52222. /**
  52223. * Draws text onto the texture
  52224. * @param text defines the text to be drawn
  52225. * @param x defines the placement of the text from the left
  52226. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  52227. * @param font defines the font to be used with font-style, font-size, font-name
  52228. * @param color defines the color used for the text
  52229. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  52230. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52231. * @param update defines whether texture is immediately update (default is true)
  52232. */
  52233. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  52234. /**
  52235. * Clones the texture
  52236. * @returns the clone of the texture.
  52237. */
  52238. clone(): DynamicTexture;
  52239. /**
  52240. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  52241. * @returns a serialized dynamic texture object
  52242. */
  52243. serialize(): any;
  52244. private _IsCanvasElement;
  52245. /** @hidden */
  52246. _rebuild(): void;
  52247. }
  52248. }
  52249. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  52250. import { Scene } from "babylonjs/scene";
  52251. import { Color3 } from "babylonjs/Maths/math.color";
  52252. import { Mesh } from "babylonjs/Meshes/mesh";
  52253. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52254. import { Nullable } from "babylonjs/types";
  52255. /**
  52256. * Class containing static functions to help procedurally build meshes
  52257. */
  52258. export class GroundBuilder {
  52259. /**
  52260. * Creates a ground mesh
  52261. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52262. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52264. * @param name defines the name of the mesh
  52265. * @param options defines the options used to create the mesh
  52266. * @param scene defines the hosting scene
  52267. * @returns the ground mesh
  52268. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52269. */
  52270. static CreateGround(name: string, options: {
  52271. width?: number;
  52272. height?: number;
  52273. subdivisions?: number;
  52274. subdivisionsX?: number;
  52275. subdivisionsY?: number;
  52276. updatable?: boolean;
  52277. }, scene: any): Mesh;
  52278. /**
  52279. * Creates a tiled ground mesh
  52280. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52281. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52282. * * 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
  52283. * * 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
  52284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52285. * @param name defines the name of the mesh
  52286. * @param options defines the options used to create the mesh
  52287. * @param scene defines the hosting scene
  52288. * @returns the tiled ground mesh
  52289. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52290. */
  52291. static CreateTiledGround(name: string, options: {
  52292. xmin: number;
  52293. zmin: number;
  52294. xmax: number;
  52295. zmax: number;
  52296. subdivisions?: {
  52297. w: number;
  52298. h: number;
  52299. };
  52300. precision?: {
  52301. w: number;
  52302. h: number;
  52303. };
  52304. updatable?: boolean;
  52305. }, scene?: Nullable<Scene>): Mesh;
  52306. /**
  52307. * Creates a ground mesh from a height map
  52308. * * The parameter `url` sets the URL of the height map image resource.
  52309. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52310. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52311. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52312. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52313. * * 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.
  52314. * * 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).
  52315. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52317. * @param name defines the name of the mesh
  52318. * @param url defines the url to the height map
  52319. * @param options defines the options used to create the mesh
  52320. * @param scene defines the hosting scene
  52321. * @returns the ground mesh
  52322. * @see https://doc.babylonjs.com/babylon101/height_map
  52323. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52324. */
  52325. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52326. width?: number;
  52327. height?: number;
  52328. subdivisions?: number;
  52329. minHeight?: number;
  52330. maxHeight?: number;
  52331. colorFilter?: Color3;
  52332. alphaFilter?: number;
  52333. updatable?: boolean;
  52334. onReady?: (mesh: GroundMesh) => void;
  52335. }, scene?: Nullable<Scene>): GroundMesh;
  52336. }
  52337. }
  52338. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  52339. import { Vector4 } from "babylonjs/Maths/math.vector";
  52340. import { Mesh } from "babylonjs/Meshes/mesh";
  52341. /**
  52342. * Class containing static functions to help procedurally build meshes
  52343. */
  52344. export class TorusBuilder {
  52345. /**
  52346. * Creates a torus mesh
  52347. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52348. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52349. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52353. * @param name defines the name of the mesh
  52354. * @param options defines the options used to create the mesh
  52355. * @param scene defines the hosting scene
  52356. * @returns the torus mesh
  52357. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52358. */
  52359. static CreateTorus(name: string, options: {
  52360. diameter?: number;
  52361. thickness?: number;
  52362. tessellation?: number;
  52363. updatable?: boolean;
  52364. sideOrientation?: number;
  52365. frontUVs?: Vector4;
  52366. backUVs?: Vector4;
  52367. }, scene: any): Mesh;
  52368. }
  52369. }
  52370. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  52371. import { Vector4 } from "babylonjs/Maths/math.vector";
  52372. import { Color4 } from "babylonjs/Maths/math.color";
  52373. import { Mesh } from "babylonjs/Meshes/mesh";
  52374. /**
  52375. * Class containing static functions to help procedurally build meshes
  52376. */
  52377. export class CylinderBuilder {
  52378. /**
  52379. * Creates a cylinder or a cone mesh
  52380. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52381. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52382. * * 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.
  52383. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52384. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52385. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52386. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52387. * * 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).
  52388. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52389. * * 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).
  52390. * * 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
  52391. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52392. * * 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
  52393. * * 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.
  52394. * * If `enclose` is false, a ring surface is one element.
  52395. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52396. * * 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
  52397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52400. * @param name defines the name of the mesh
  52401. * @param options defines the options used to create the mesh
  52402. * @param scene defines the hosting scene
  52403. * @returns the cylinder mesh
  52404. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52405. */
  52406. static CreateCylinder(name: string, options: {
  52407. height?: number;
  52408. diameterTop?: number;
  52409. diameterBottom?: number;
  52410. diameter?: number;
  52411. tessellation?: number;
  52412. subdivisions?: number;
  52413. arc?: number;
  52414. faceColors?: Color4[];
  52415. faceUV?: Vector4[];
  52416. updatable?: boolean;
  52417. hasRings?: boolean;
  52418. enclose?: boolean;
  52419. cap?: number;
  52420. sideOrientation?: number;
  52421. frontUVs?: Vector4;
  52422. backUVs?: Vector4;
  52423. }, scene: any): Mesh;
  52424. }
  52425. }
  52426. declare module "babylonjs/XR/webXRTypes" {
  52427. import { Nullable } from "babylonjs/types";
  52428. import { IDisposable } from "babylonjs/scene";
  52429. /**
  52430. * States of the webXR experience
  52431. */
  52432. export enum WebXRState {
  52433. /**
  52434. * Transitioning to being in XR mode
  52435. */
  52436. ENTERING_XR = 0,
  52437. /**
  52438. * Transitioning to non XR mode
  52439. */
  52440. EXITING_XR = 1,
  52441. /**
  52442. * In XR mode and presenting
  52443. */
  52444. IN_XR = 2,
  52445. /**
  52446. * Not entered XR mode
  52447. */
  52448. NOT_IN_XR = 3
  52449. }
  52450. /**
  52451. * The state of the XR camera's tracking
  52452. */
  52453. export enum WebXRTrackingState {
  52454. /**
  52455. * No transformation received, device is not being tracked
  52456. */
  52457. NOT_TRACKING = 0,
  52458. /**
  52459. * Tracking lost - using emulated position
  52460. */
  52461. TRACKING_LOST = 1,
  52462. /**
  52463. * Transformation tracking works normally
  52464. */
  52465. TRACKING = 2
  52466. }
  52467. /**
  52468. * Abstraction of the XR render target
  52469. */
  52470. export interface WebXRRenderTarget extends IDisposable {
  52471. /**
  52472. * xrpresent context of the canvas which can be used to display/mirror xr content
  52473. */
  52474. canvasContext: WebGLRenderingContext;
  52475. /**
  52476. * xr layer for the canvas
  52477. */
  52478. xrLayer: Nullable<XRWebGLLayer>;
  52479. /**
  52480. * Initializes the xr layer for the session
  52481. * @param xrSession xr session
  52482. * @returns a promise that will resolve once the XR Layer has been created
  52483. */
  52484. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52485. }
  52486. }
  52487. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  52488. import { Nullable } from "babylonjs/types";
  52489. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  52490. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52491. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52492. import { Observable } from "babylonjs/Misc/observable";
  52493. /**
  52494. * COnfiguration object for WebXR output canvas
  52495. */
  52496. export class WebXRManagedOutputCanvasOptions {
  52497. /**
  52498. * An optional canvas in case you wish to create it yourself and provide it here.
  52499. * If not provided, a new canvas will be created
  52500. */
  52501. canvasElement?: HTMLCanvasElement;
  52502. /**
  52503. * Options for this XR Layer output
  52504. */
  52505. canvasOptions?: XRWebGLLayerInit;
  52506. /**
  52507. * CSS styling for a newly created canvas (if not provided)
  52508. */
  52509. newCanvasCssStyle?: string;
  52510. /**
  52511. * Get the default values of the configuration object
  52512. * @param engine defines the engine to use (can be null)
  52513. * @returns default values of this configuration object
  52514. */
  52515. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  52516. }
  52517. /**
  52518. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  52519. */
  52520. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  52521. private _options;
  52522. private _canvas;
  52523. private _engine;
  52524. private _originalCanvasSize;
  52525. /**
  52526. * Rendering context of the canvas which can be used to display/mirror xr content
  52527. */
  52528. canvasContext: WebGLRenderingContext;
  52529. /**
  52530. * xr layer for the canvas
  52531. */
  52532. xrLayer: Nullable<XRWebGLLayer>;
  52533. /**
  52534. * Obseervers registered here will be triggered when the xr layer was initialized
  52535. */
  52536. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  52537. /**
  52538. * Initializes the canvas to be added/removed upon entering/exiting xr
  52539. * @param _xrSessionManager The XR Session manager
  52540. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  52541. */
  52542. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  52543. /**
  52544. * Disposes of the object
  52545. */
  52546. dispose(): void;
  52547. /**
  52548. * Initializes the xr layer for the session
  52549. * @param xrSession xr session
  52550. * @returns a promise that will resolve once the XR Layer has been created
  52551. */
  52552. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52553. private _addCanvas;
  52554. private _removeCanvas;
  52555. private _setCanvasSize;
  52556. private _setManagedOutputCanvas;
  52557. }
  52558. }
  52559. declare module "babylonjs/XR/webXRSessionManager" {
  52560. import { Observable } from "babylonjs/Misc/observable";
  52561. import { Nullable } from "babylonjs/types";
  52562. import { IDisposable, Scene } from "babylonjs/scene";
  52563. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52564. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52565. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  52566. /**
  52567. * Manages an XRSession to work with Babylon's engine
  52568. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  52569. */
  52570. export class WebXRSessionManager implements IDisposable {
  52571. /** The scene which the session should be created for */
  52572. scene: Scene;
  52573. private _referenceSpace;
  52574. private _rttProvider;
  52575. private _sessionEnded;
  52576. private _xrNavigator;
  52577. private baseLayer;
  52578. /**
  52579. * The base reference space from which the session started. good if you want to reset your
  52580. * reference space
  52581. */
  52582. baseReferenceSpace: XRReferenceSpace;
  52583. /**
  52584. * Current XR frame
  52585. */
  52586. currentFrame: Nullable<XRFrame>;
  52587. /** WebXR timestamp updated every frame */
  52588. currentTimestamp: number;
  52589. /**
  52590. * Used just in case of a failure to initialize an immersive session.
  52591. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  52592. */
  52593. defaultHeightCompensation: number;
  52594. /**
  52595. * Fires every time a new xrFrame arrives which can be used to update the camera
  52596. */
  52597. onXRFrameObservable: Observable<XRFrame>;
  52598. /**
  52599. * Fires when the reference space changed
  52600. */
  52601. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  52602. /**
  52603. * Fires when the xr session is ended either by the device or manually done
  52604. */
  52605. onXRSessionEnded: Observable<any>;
  52606. /**
  52607. * Fires when the xr session is ended either by the device or manually done
  52608. */
  52609. onXRSessionInit: Observable<XRSession>;
  52610. /**
  52611. * Underlying xr session
  52612. */
  52613. session: XRSession;
  52614. /**
  52615. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  52616. * or get the offset the player is currently at.
  52617. */
  52618. viewerReferenceSpace: XRReferenceSpace;
  52619. /**
  52620. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  52621. * @param scene The scene which the session should be created for
  52622. */
  52623. constructor(
  52624. /** The scene which the session should be created for */
  52625. scene: Scene);
  52626. /**
  52627. * The current reference space used in this session. This reference space can constantly change!
  52628. * It is mainly used to offset the camera's position.
  52629. */
  52630. get referenceSpace(): XRReferenceSpace;
  52631. /**
  52632. * Set a new reference space and triggers the observable
  52633. */
  52634. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  52635. /**
  52636. * Disposes of the session manager
  52637. */
  52638. dispose(): void;
  52639. /**
  52640. * Stops the xrSession and restores the render loop
  52641. * @returns Promise which resolves after it exits XR
  52642. */
  52643. exitXRAsync(): Promise<void>;
  52644. /**
  52645. * Gets the correct render target texture to be rendered this frame for this eye
  52646. * @param eye the eye for which to get the render target
  52647. * @returns the render target for the specified eye
  52648. */
  52649. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  52650. /**
  52651. * Creates a WebXRRenderTarget object for the XR session
  52652. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  52653. * @param options optional options to provide when creating a new render target
  52654. * @returns a WebXR render target to which the session can render
  52655. */
  52656. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  52657. /**
  52658. * Initializes the manager
  52659. * After initialization enterXR can be called to start an XR session
  52660. * @returns Promise which resolves after it is initialized
  52661. */
  52662. initializeAsync(): Promise<void>;
  52663. /**
  52664. * Initializes an xr session
  52665. * @param xrSessionMode mode to initialize
  52666. * @param xrSessionInit defines optional and required values to pass to the session builder
  52667. * @returns a promise which will resolve once the session has been initialized
  52668. */
  52669. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52670. /**
  52671. * Checks if a session would be supported for the creation options specified
  52672. * @param sessionMode session mode to check if supported eg. immersive-vr
  52673. * @returns A Promise that resolves to true if supported and false if not
  52674. */
  52675. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52676. /**
  52677. * Resets the reference space to the one started the session
  52678. */
  52679. resetReferenceSpace(): void;
  52680. /**
  52681. * Starts rendering to the xr layer
  52682. */
  52683. runXRRenderLoop(): void;
  52684. /**
  52685. * Sets the reference space on the xr session
  52686. * @param referenceSpaceType space to set
  52687. * @returns a promise that will resolve once the reference space has been set
  52688. */
  52689. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52690. /**
  52691. * Updates the render state of the session
  52692. * @param state state to set
  52693. * @returns a promise that resolves once the render state has been updated
  52694. */
  52695. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52696. /**
  52697. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52698. * @param sessionMode defines the session to test
  52699. * @returns a promise with boolean as final value
  52700. */
  52701. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52702. private _createRenderTargetTexture;
  52703. }
  52704. }
  52705. declare module "babylonjs/XR/webXRCamera" {
  52706. import { Vector3 } from "babylonjs/Maths/math.vector";
  52707. import { Scene } from "babylonjs/scene";
  52708. import { Camera } from "babylonjs/Cameras/camera";
  52709. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52710. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52711. import { Observable } from "babylonjs/Misc/observable";
  52712. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  52713. /**
  52714. * WebXR Camera which holds the views for the xrSession
  52715. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52716. */
  52717. export class WebXRCamera extends FreeCamera {
  52718. private _xrSessionManager;
  52719. private _firstFrame;
  52720. private _referenceQuaternion;
  52721. private _referencedPosition;
  52722. private _xrInvPositionCache;
  52723. private _xrInvQuaternionCache;
  52724. private _trackingState;
  52725. /**
  52726. * Observable raised before camera teleportation
  52727. */
  52728. onBeforeCameraTeleport: Observable<Vector3>;
  52729. /**
  52730. * Observable raised after camera teleportation
  52731. */
  52732. onAfterCameraTeleport: Observable<Vector3>;
  52733. /**
  52734. * Notifies when the camera's tracking state has changed.
  52735. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  52736. */
  52737. onTrackingStateChanged: Observable<WebXRTrackingState>;
  52738. /**
  52739. * Should position compensation execute on first frame.
  52740. * This is used when copying the position from a native (non XR) camera
  52741. */
  52742. compensateOnFirstFrame: boolean;
  52743. /**
  52744. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52745. * @param name the name of the camera
  52746. * @param scene the scene to add the camera to
  52747. * @param _xrSessionManager a constructed xr session manager
  52748. */
  52749. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52750. /**
  52751. * Get the current XR tracking state of the camera
  52752. */
  52753. get trackingState(): WebXRTrackingState;
  52754. private _setTrackingState;
  52755. /**
  52756. * Return the user's height, unrelated to the current ground.
  52757. * This will be the y position of this camera, when ground level is 0.
  52758. */
  52759. get realWorldHeight(): number;
  52760. /** @hidden */
  52761. _updateForDualEyeDebugging(): void;
  52762. /**
  52763. * Sets this camera's transformation based on a non-vr camera
  52764. * @param otherCamera the non-vr camera to copy the transformation from
  52765. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52766. */
  52767. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52768. /**
  52769. * Gets the current instance class name ("WebXRCamera").
  52770. * @returns the class name
  52771. */
  52772. getClassName(): string;
  52773. private _rotate180;
  52774. private _updateFromXRSession;
  52775. private _updateNumberOfRigCameras;
  52776. private _updateReferenceSpace;
  52777. private _updateReferenceSpaceOffset;
  52778. }
  52779. }
  52780. declare module "babylonjs/XR/webXRFeaturesManager" {
  52781. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52782. import { IDisposable } from "babylonjs/scene";
  52783. /**
  52784. * Defining the interface required for a (webxr) feature
  52785. */
  52786. export interface IWebXRFeature extends IDisposable {
  52787. /**
  52788. * Is this feature attached
  52789. */
  52790. attached: boolean;
  52791. /**
  52792. * Should auto-attach be disabled?
  52793. */
  52794. disableAutoAttach: boolean;
  52795. /**
  52796. * Attach the feature to the session
  52797. * Will usually be called by the features manager
  52798. *
  52799. * @param force should attachment be forced (even when already attached)
  52800. * @returns true if successful.
  52801. */
  52802. attach(force?: boolean): boolean;
  52803. /**
  52804. * Detach the feature from the session
  52805. * Will usually be called by the features manager
  52806. *
  52807. * @returns true if successful.
  52808. */
  52809. detach(): boolean;
  52810. /**
  52811. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52812. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52813. *
  52814. * @returns whether or not the feature is compatible in this environment
  52815. */
  52816. isCompatible(): boolean;
  52817. /**
  52818. * Was this feature disposed;
  52819. */
  52820. isDisposed: boolean;
  52821. /**
  52822. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52823. */
  52824. xrNativeFeatureName?: string;
  52825. /**
  52826. * A list of (Babylon WebXR) features this feature depends on
  52827. */
  52828. dependsOn?: string[];
  52829. }
  52830. /**
  52831. * A list of the currently available features without referencing them
  52832. */
  52833. export class WebXRFeatureName {
  52834. /**
  52835. * The name of the anchor system feature
  52836. */
  52837. static readonly ANCHOR_SYSTEM: string;
  52838. /**
  52839. * The name of the background remover feature
  52840. */
  52841. static readonly BACKGROUND_REMOVER: string;
  52842. /**
  52843. * The name of the hit test feature
  52844. */
  52845. static readonly HIT_TEST: string;
  52846. /**
  52847. * physics impostors for xr controllers feature
  52848. */
  52849. static readonly PHYSICS_CONTROLLERS: string;
  52850. /**
  52851. * The name of the plane detection feature
  52852. */
  52853. static readonly PLANE_DETECTION: string;
  52854. /**
  52855. * The name of the pointer selection feature
  52856. */
  52857. static readonly POINTER_SELECTION: string;
  52858. /**
  52859. * The name of the teleportation feature
  52860. */
  52861. static readonly TELEPORTATION: string;
  52862. /**
  52863. * The name of the feature points feature.
  52864. */
  52865. static readonly FEATURE_POINTS: string;
  52866. /**
  52867. * The name of the hand tracking feature.
  52868. */
  52869. static readonly HAND_TRACKING: string;
  52870. }
  52871. /**
  52872. * Defining the constructor of a feature. Used to register the modules.
  52873. */
  52874. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52875. /**
  52876. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52877. * It is mainly used in AR sessions.
  52878. *
  52879. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52880. */
  52881. export class WebXRFeaturesManager implements IDisposable {
  52882. private _xrSessionManager;
  52883. private static readonly _AvailableFeatures;
  52884. private _features;
  52885. /**
  52886. * constructs a new features manages.
  52887. *
  52888. * @param _xrSessionManager an instance of WebXRSessionManager
  52889. */
  52890. constructor(_xrSessionManager: WebXRSessionManager);
  52891. /**
  52892. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52893. * Mainly used internally.
  52894. *
  52895. * @param featureName the name of the feature to register
  52896. * @param constructorFunction the function used to construct the module
  52897. * @param version the (babylon) version of the module
  52898. * @param stable is that a stable version of this module
  52899. */
  52900. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52901. /**
  52902. * Returns a constructor of a specific feature.
  52903. *
  52904. * @param featureName the name of the feature to construct
  52905. * @param version the version of the feature to load
  52906. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52907. * @param options optional options provided to the module.
  52908. * @returns a function that, when called, will return a new instance of this feature
  52909. */
  52910. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52911. /**
  52912. * Can be used to return the list of features currently registered
  52913. *
  52914. * @returns an Array of available features
  52915. */
  52916. static GetAvailableFeatures(): string[];
  52917. /**
  52918. * Gets the versions available for a specific feature
  52919. * @param featureName the name of the feature
  52920. * @returns an array with the available versions
  52921. */
  52922. static GetAvailableVersions(featureName: string): string[];
  52923. /**
  52924. * Return the latest unstable version of this feature
  52925. * @param featureName the name of the feature to search
  52926. * @returns the version number. if not found will return -1
  52927. */
  52928. static GetLatestVersionOfFeature(featureName: string): number;
  52929. /**
  52930. * Return the latest stable version of this feature
  52931. * @param featureName the name of the feature to search
  52932. * @returns the version number. if not found will return -1
  52933. */
  52934. static GetStableVersionOfFeature(featureName: string): number;
  52935. /**
  52936. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52937. * Can be used during a session to start a feature
  52938. * @param featureName the name of feature to attach
  52939. */
  52940. attachFeature(featureName: string): void;
  52941. /**
  52942. * Can be used inside a session or when the session ends to detach a specific feature
  52943. * @param featureName the name of the feature to detach
  52944. */
  52945. detachFeature(featureName: string): void;
  52946. /**
  52947. * Used to disable an already-enabled feature
  52948. * The feature will be disposed and will be recreated once enabled.
  52949. * @param featureName the feature to disable
  52950. * @returns true if disable was successful
  52951. */
  52952. disableFeature(featureName: string | {
  52953. Name: string;
  52954. }): boolean;
  52955. /**
  52956. * dispose this features manager
  52957. */
  52958. dispose(): void;
  52959. /**
  52960. * 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.
  52961. * 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.
  52962. *
  52963. * @param featureName the name of the feature to load or the class of the feature
  52964. * @param version optional version to load. if not provided the latest version will be enabled
  52965. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52966. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52967. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52968. * @returns a new constructed feature or throws an error if feature not found.
  52969. */
  52970. enableFeature(featureName: string | {
  52971. Name: string;
  52972. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52973. /**
  52974. * get the implementation of an enabled feature.
  52975. * @param featureName the name of the feature to load
  52976. * @returns the feature class, if found
  52977. */
  52978. getEnabledFeature(featureName: string): IWebXRFeature;
  52979. /**
  52980. * Get the list of enabled features
  52981. * @returns an array of enabled features
  52982. */
  52983. getEnabledFeatures(): string[];
  52984. /**
  52985. * This function will exten the session creation configuration object with enabled features.
  52986. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52987. * according to the defined "required" variable, provided during enableFeature call
  52988. * @param xrSessionInit the xr Session init object to extend
  52989. *
  52990. * @returns an extended XRSessionInit object
  52991. */
  52992. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52993. }
  52994. }
  52995. declare module "babylonjs/XR/webXRExperienceHelper" {
  52996. import { Observable } from "babylonjs/Misc/observable";
  52997. import { IDisposable, Scene } from "babylonjs/scene";
  52998. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52999. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53000. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  53001. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  53002. /**
  53003. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  53004. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  53005. */
  53006. export class WebXRExperienceHelper implements IDisposable {
  53007. private scene;
  53008. private _nonVRCamera;
  53009. private _originalSceneAutoClear;
  53010. private _supported;
  53011. /**
  53012. * Camera used to render xr content
  53013. */
  53014. camera: WebXRCamera;
  53015. /** A features manager for this xr session */
  53016. featuresManager: WebXRFeaturesManager;
  53017. /**
  53018. * Observers registered here will be triggered after the camera's initial transformation is set
  53019. * This can be used to set a different ground level or an extra rotation.
  53020. *
  53021. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  53022. * to the position set after this observable is done executing.
  53023. */
  53024. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  53025. /**
  53026. * Fires when the state of the experience helper has changed
  53027. */
  53028. onStateChangedObservable: Observable<WebXRState>;
  53029. /** Session manager used to keep track of xr session */
  53030. sessionManager: WebXRSessionManager;
  53031. /**
  53032. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  53033. */
  53034. state: WebXRState;
  53035. /**
  53036. * Creates a WebXRExperienceHelper
  53037. * @param scene The scene the helper should be created in
  53038. */
  53039. private constructor();
  53040. /**
  53041. * Creates the experience helper
  53042. * @param scene the scene to attach the experience helper to
  53043. * @returns a promise for the experience helper
  53044. */
  53045. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  53046. /**
  53047. * Disposes of the experience helper
  53048. */
  53049. dispose(): void;
  53050. /**
  53051. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  53052. * @param sessionMode options for the XR session
  53053. * @param referenceSpaceType frame of reference of the XR session
  53054. * @param renderTarget the output canvas that will be used to enter XR mode
  53055. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  53056. * @returns promise that resolves after xr mode has entered
  53057. */
  53058. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  53059. /**
  53060. * Exits XR mode and returns the scene to its original state
  53061. * @returns promise that resolves after xr mode has exited
  53062. */
  53063. exitXRAsync(): Promise<void>;
  53064. private _nonXRToXRCamera;
  53065. private _setState;
  53066. }
  53067. }
  53068. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  53069. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53070. import { Observable } from "babylonjs/Misc/observable";
  53071. import { IDisposable } from "babylonjs/scene";
  53072. /**
  53073. * X-Y values for axes in WebXR
  53074. */
  53075. export interface IWebXRMotionControllerAxesValue {
  53076. /**
  53077. * The value of the x axis
  53078. */
  53079. x: number;
  53080. /**
  53081. * The value of the y-axis
  53082. */
  53083. y: number;
  53084. }
  53085. /**
  53086. * changed / previous values for the values of this component
  53087. */
  53088. export interface IWebXRMotionControllerComponentChangesValues<T> {
  53089. /**
  53090. * current (this frame) value
  53091. */
  53092. current: T;
  53093. /**
  53094. * previous (last change) value
  53095. */
  53096. previous: T;
  53097. }
  53098. /**
  53099. * Represents changes in the component between current frame and last values recorded
  53100. */
  53101. export interface IWebXRMotionControllerComponentChanges {
  53102. /**
  53103. * will be populated with previous and current values if axes changed
  53104. */
  53105. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  53106. /**
  53107. * will be populated with previous and current values if pressed changed
  53108. */
  53109. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53110. /**
  53111. * will be populated with previous and current values if touched changed
  53112. */
  53113. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53114. /**
  53115. * will be populated with previous and current values if value changed
  53116. */
  53117. value?: IWebXRMotionControllerComponentChangesValues<number>;
  53118. }
  53119. /**
  53120. * This class represents a single component (for example button or thumbstick) of a motion controller
  53121. */
  53122. export class WebXRControllerComponent implements IDisposable {
  53123. /**
  53124. * the id of this component
  53125. */
  53126. id: string;
  53127. /**
  53128. * the type of the component
  53129. */
  53130. type: MotionControllerComponentType;
  53131. private _buttonIndex;
  53132. private _axesIndices;
  53133. private _axes;
  53134. private _changes;
  53135. private _currentValue;
  53136. private _hasChanges;
  53137. private _pressed;
  53138. private _touched;
  53139. /**
  53140. * button component type
  53141. */
  53142. static BUTTON_TYPE: MotionControllerComponentType;
  53143. /**
  53144. * squeeze component type
  53145. */
  53146. static SQUEEZE_TYPE: MotionControllerComponentType;
  53147. /**
  53148. * Thumbstick component type
  53149. */
  53150. static THUMBSTICK_TYPE: MotionControllerComponentType;
  53151. /**
  53152. * Touchpad component type
  53153. */
  53154. static TOUCHPAD_TYPE: MotionControllerComponentType;
  53155. /**
  53156. * trigger component type
  53157. */
  53158. static TRIGGER_TYPE: MotionControllerComponentType;
  53159. /**
  53160. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  53161. * the axes data changes
  53162. */
  53163. onAxisValueChangedObservable: Observable<{
  53164. x: number;
  53165. y: number;
  53166. }>;
  53167. /**
  53168. * Observers registered here will be triggered when the state of a button changes
  53169. * State change is either pressed / touched / value
  53170. */
  53171. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  53172. /**
  53173. * Creates a new component for a motion controller.
  53174. * It is created by the motion controller itself
  53175. *
  53176. * @param id the id of this component
  53177. * @param type the type of the component
  53178. * @param _buttonIndex index in the buttons array of the gamepad
  53179. * @param _axesIndices indices of the values in the axes array of the gamepad
  53180. */
  53181. constructor(
  53182. /**
  53183. * the id of this component
  53184. */
  53185. id: string,
  53186. /**
  53187. * the type of the component
  53188. */
  53189. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  53190. /**
  53191. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  53192. */
  53193. get axes(): IWebXRMotionControllerAxesValue;
  53194. /**
  53195. * Get the changes. Elements will be populated only if they changed with their previous and current value
  53196. */
  53197. get changes(): IWebXRMotionControllerComponentChanges;
  53198. /**
  53199. * Return whether or not the component changed the last frame
  53200. */
  53201. get hasChanges(): boolean;
  53202. /**
  53203. * is the button currently pressed
  53204. */
  53205. get pressed(): boolean;
  53206. /**
  53207. * is the button currently touched
  53208. */
  53209. get touched(): boolean;
  53210. /**
  53211. * Get the current value of this component
  53212. */
  53213. get value(): number;
  53214. /**
  53215. * Dispose this component
  53216. */
  53217. dispose(): void;
  53218. /**
  53219. * Are there axes correlating to this component
  53220. * @return true is axes data is available
  53221. */
  53222. isAxes(): boolean;
  53223. /**
  53224. * Is this component a button (hence - pressable)
  53225. * @returns true if can be pressed
  53226. */
  53227. isButton(): boolean;
  53228. /**
  53229. * update this component using the gamepad object it is in. Called on every frame
  53230. * @param nativeController the native gamepad controller object
  53231. */
  53232. update(nativeController: IMinimalMotionControllerObject): void;
  53233. }
  53234. }
  53235. declare module "babylonjs/Loading/sceneLoader" {
  53236. import { Observable } from "babylonjs/Misc/observable";
  53237. import { Nullable } from "babylonjs/types";
  53238. import { Scene } from "babylonjs/scene";
  53239. import { Engine } from "babylonjs/Engines/engine";
  53240. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53241. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  53242. import { AssetContainer } from "babylonjs/assetContainer";
  53243. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53244. import { Skeleton } from "babylonjs/Bones/skeleton";
  53245. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  53246. import { WebRequest } from "babylonjs/Misc/webRequest";
  53247. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53248. import { Geometry } from "babylonjs/Meshes/geometry";
  53249. import { Light } from "babylonjs/Lights/light";
  53250. /**
  53251. * Type used for the success callback of ImportMesh
  53252. */
  53253. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  53254. /**
  53255. * Interface used for the result of ImportMeshAsync
  53256. */
  53257. export interface ISceneLoaderAsyncResult {
  53258. /**
  53259. * The array of loaded meshes
  53260. */
  53261. readonly meshes: AbstractMesh[];
  53262. /**
  53263. * The array of loaded particle systems
  53264. */
  53265. readonly particleSystems: IParticleSystem[];
  53266. /**
  53267. * The array of loaded skeletons
  53268. */
  53269. readonly skeletons: Skeleton[];
  53270. /**
  53271. * The array of loaded animation groups
  53272. */
  53273. readonly animationGroups: AnimationGroup[];
  53274. /**
  53275. * The array of loaded transform nodes
  53276. */
  53277. readonly transformNodes: TransformNode[];
  53278. /**
  53279. * The array of loaded geometries
  53280. */
  53281. readonly geometries: Geometry[];
  53282. /**
  53283. * The array of loaded lights
  53284. */
  53285. readonly lights: Light[];
  53286. }
  53287. /**
  53288. * Interface used to represent data loading progression
  53289. */
  53290. export interface ISceneLoaderProgressEvent {
  53291. /**
  53292. * Defines if data length to load can be evaluated
  53293. */
  53294. readonly lengthComputable: boolean;
  53295. /**
  53296. * Defines the loaded data length
  53297. */
  53298. readonly loaded: number;
  53299. /**
  53300. * Defines the data length to load
  53301. */
  53302. readonly total: number;
  53303. }
  53304. /**
  53305. * Interface used by SceneLoader plugins to define supported file extensions
  53306. */
  53307. export interface ISceneLoaderPluginExtensions {
  53308. /**
  53309. * Defines the list of supported extensions
  53310. */
  53311. [extension: string]: {
  53312. isBinary: boolean;
  53313. };
  53314. }
  53315. /**
  53316. * Interface used by SceneLoader plugin factory
  53317. */
  53318. export interface ISceneLoaderPluginFactory {
  53319. /**
  53320. * Defines the name of the factory
  53321. */
  53322. name: string;
  53323. /**
  53324. * Function called to create a new plugin
  53325. * @return the new plugin
  53326. */
  53327. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  53328. /**
  53329. * The callback that returns true if the data can be directly loaded.
  53330. * @param data string containing the file data
  53331. * @returns if the data can be loaded directly
  53332. */
  53333. canDirectLoad?(data: string): boolean;
  53334. }
  53335. /**
  53336. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  53337. */
  53338. export interface ISceneLoaderPluginBase {
  53339. /**
  53340. * The friendly name of this plugin.
  53341. */
  53342. name: string;
  53343. /**
  53344. * The file extensions supported by this plugin.
  53345. */
  53346. extensions: string | ISceneLoaderPluginExtensions;
  53347. /**
  53348. * The callback called when loading from a url.
  53349. * @param scene scene loading this url
  53350. * @param url url to load
  53351. * @param onSuccess callback called when the file successfully loads
  53352. * @param onProgress callback called while file is loading (if the server supports this mode)
  53353. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  53354. * @param onError callback called when the file fails to load
  53355. * @returns a file request object
  53356. */
  53357. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53358. /**
  53359. * The callback called when loading from a file object.
  53360. * @param scene scene loading this file
  53361. * @param file defines the file to load
  53362. * @param onSuccess defines the callback to call when data is loaded
  53363. * @param onProgress defines the callback to call during loading process
  53364. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  53365. * @param onError defines the callback to call when an error occurs
  53366. * @returns a file request object
  53367. */
  53368. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53369. /**
  53370. * The callback that returns true if the data can be directly loaded.
  53371. * @param data string containing the file data
  53372. * @returns if the data can be loaded directly
  53373. */
  53374. canDirectLoad?(data: string): boolean;
  53375. /**
  53376. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  53377. * @param scene scene loading this data
  53378. * @param data string containing the data
  53379. * @returns data to pass to the plugin
  53380. */
  53381. directLoad?(scene: Scene, data: string): any;
  53382. /**
  53383. * The callback that allows custom handling of the root url based on the response url.
  53384. * @param rootUrl the original root url
  53385. * @param responseURL the response url if available
  53386. * @returns the new root url
  53387. */
  53388. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  53389. }
  53390. /**
  53391. * Interface used to define a SceneLoader plugin
  53392. */
  53393. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  53394. /**
  53395. * Import meshes into a scene.
  53396. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53397. * @param scene The scene to import into
  53398. * @param data The data to import
  53399. * @param rootUrl The root url for scene and resources
  53400. * @param meshes The meshes array to import into
  53401. * @param particleSystems The particle systems array to import into
  53402. * @param skeletons The skeletons array to import into
  53403. * @param onError The callback when import fails
  53404. * @returns True if successful or false otherwise
  53405. */
  53406. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  53407. /**
  53408. * Load into a scene.
  53409. * @param scene The scene to load into
  53410. * @param data The data to import
  53411. * @param rootUrl The root url for scene and resources
  53412. * @param onError The callback when import fails
  53413. * @returns True if successful or false otherwise
  53414. */
  53415. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  53416. /**
  53417. * Load into an asset container.
  53418. * @param scene The scene to load into
  53419. * @param data The data to import
  53420. * @param rootUrl The root url for scene and resources
  53421. * @param onError The callback when import fails
  53422. * @returns The loaded asset container
  53423. */
  53424. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  53425. }
  53426. /**
  53427. * Interface used to define an async SceneLoader plugin
  53428. */
  53429. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  53430. /**
  53431. * Import meshes into a scene.
  53432. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53433. * @param scene The scene to import into
  53434. * @param data The data to import
  53435. * @param rootUrl The root url for scene and resources
  53436. * @param onProgress The callback when the load progresses
  53437. * @param fileName Defines the name of the file to load
  53438. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  53439. */
  53440. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  53441. /**
  53442. * Load into a scene.
  53443. * @param scene The scene to load into
  53444. * @param data The data to import
  53445. * @param rootUrl The root url for scene and resources
  53446. * @param onProgress The callback when the load progresses
  53447. * @param fileName Defines the name of the file to load
  53448. * @returns Nothing
  53449. */
  53450. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  53451. /**
  53452. * Load into an asset container.
  53453. * @param scene The scene to load into
  53454. * @param data The data to import
  53455. * @param rootUrl The root url for scene and resources
  53456. * @param onProgress The callback when the load progresses
  53457. * @param fileName Defines the name of the file to load
  53458. * @returns The loaded asset container
  53459. */
  53460. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  53461. }
  53462. /**
  53463. * Mode that determines how to handle old animation groups before loading new ones.
  53464. */
  53465. export enum SceneLoaderAnimationGroupLoadingMode {
  53466. /**
  53467. * Reset all old animations to initial state then dispose them.
  53468. */
  53469. Clean = 0,
  53470. /**
  53471. * Stop all old animations.
  53472. */
  53473. Stop = 1,
  53474. /**
  53475. * Restart old animations from first frame.
  53476. */
  53477. Sync = 2,
  53478. /**
  53479. * Old animations remains untouched.
  53480. */
  53481. NoSync = 3
  53482. }
  53483. /**
  53484. * Defines a plugin registered by the SceneLoader
  53485. */
  53486. interface IRegisteredPlugin {
  53487. /**
  53488. * Defines the plugin to use
  53489. */
  53490. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53491. /**
  53492. * Defines if the plugin supports binary data
  53493. */
  53494. isBinary: boolean;
  53495. }
  53496. /**
  53497. * Class used to load scene from various file formats using registered plugins
  53498. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  53499. */
  53500. export class SceneLoader {
  53501. /**
  53502. * No logging while loading
  53503. */
  53504. static readonly NO_LOGGING: number;
  53505. /**
  53506. * Minimal logging while loading
  53507. */
  53508. static readonly MINIMAL_LOGGING: number;
  53509. /**
  53510. * Summary logging while loading
  53511. */
  53512. static readonly SUMMARY_LOGGING: number;
  53513. /**
  53514. * Detailled logging while loading
  53515. */
  53516. static readonly DETAILED_LOGGING: number;
  53517. /**
  53518. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  53519. */
  53520. static get ForceFullSceneLoadingForIncremental(): boolean;
  53521. static set ForceFullSceneLoadingForIncremental(value: boolean);
  53522. /**
  53523. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  53524. */
  53525. static get ShowLoadingScreen(): boolean;
  53526. static set ShowLoadingScreen(value: boolean);
  53527. /**
  53528. * Defines the current logging level (while loading the scene)
  53529. * @ignorenaming
  53530. */
  53531. static get loggingLevel(): number;
  53532. static set loggingLevel(value: number);
  53533. /**
  53534. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  53535. */
  53536. static get CleanBoneMatrixWeights(): boolean;
  53537. static set CleanBoneMatrixWeights(value: boolean);
  53538. /**
  53539. * Event raised when a plugin is used to load a scene
  53540. */
  53541. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  53542. private static _registeredPlugins;
  53543. private static _showingLoadingScreen;
  53544. /**
  53545. * Gets the default plugin (used to load Babylon files)
  53546. * @returns the .babylon plugin
  53547. */
  53548. static GetDefaultPlugin(): IRegisteredPlugin;
  53549. private static _GetPluginForExtension;
  53550. private static _GetPluginForDirectLoad;
  53551. private static _GetPluginForFilename;
  53552. private static _GetDirectLoad;
  53553. private static _LoadData;
  53554. private static _GetFileInfo;
  53555. /**
  53556. * Gets a plugin that can load the given extension
  53557. * @param extension defines the extension to load
  53558. * @returns a plugin or null if none works
  53559. */
  53560. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53561. /**
  53562. * Gets a boolean indicating that the given extension can be loaded
  53563. * @param extension defines the extension to load
  53564. * @returns true if the extension is supported
  53565. */
  53566. static IsPluginForExtensionAvailable(extension: string): boolean;
  53567. /**
  53568. * Adds a new plugin to the list of registered plugins
  53569. * @param plugin defines the plugin to add
  53570. */
  53571. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  53572. /**
  53573. * Import meshes into a scene
  53574. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53575. * @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)
  53576. * @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)
  53577. * @param scene the instance of BABYLON.Scene to append to
  53578. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  53579. * @param onProgress a callback with a progress event for each file being loaded
  53580. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53581. * @param pluginExtension the extension used to determine the plugin
  53582. * @returns The loaded plugin
  53583. */
  53584. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  53585. /**
  53586. * Import meshes into a scene
  53587. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53588. * @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)
  53589. * @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)
  53590. * @param scene the instance of BABYLON.Scene to append to
  53591. * @param onProgress a callback with a progress event for each file being loaded
  53592. * @param pluginExtension the extension used to determine the plugin
  53593. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  53594. */
  53595. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  53596. /**
  53597. * Load a scene
  53598. * @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)
  53599. * @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)
  53600. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53601. * @param onSuccess a callback with the scene when import succeeds
  53602. * @param onProgress a callback with a progress event for each file being loaded
  53603. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53604. * @param pluginExtension the extension used to determine the plugin
  53605. * @returns The loaded plugin
  53606. */
  53607. 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>;
  53608. /**
  53609. * Load a scene
  53610. * @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)
  53611. * @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)
  53612. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53613. * @param onProgress a callback with a progress event for each file being loaded
  53614. * @param pluginExtension the extension used to determine the plugin
  53615. * @returns The loaded scene
  53616. */
  53617. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53618. /**
  53619. * Append a scene
  53620. * @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)
  53621. * @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)
  53622. * @param scene is the instance of BABYLON.Scene to append to
  53623. * @param onSuccess a callback with the scene when import succeeds
  53624. * @param onProgress a callback with a progress event for each file being loaded
  53625. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53626. * @param pluginExtension the extension used to determine the plugin
  53627. * @returns The loaded plugin
  53628. */
  53629. 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>;
  53630. /**
  53631. * Append a scene
  53632. * @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)
  53633. * @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)
  53634. * @param scene is the instance of BABYLON.Scene to append to
  53635. * @param onProgress a callback with a progress event for each file being loaded
  53636. * @param pluginExtension the extension used to determine the plugin
  53637. * @returns The given scene
  53638. */
  53639. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53640. /**
  53641. * Load a scene into an asset container
  53642. * @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)
  53643. * @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)
  53644. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53645. * @param onSuccess a callback with the scene when import succeeds
  53646. * @param onProgress a callback with a progress event for each file being loaded
  53647. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53648. * @param pluginExtension the extension used to determine the plugin
  53649. * @returns The loaded plugin
  53650. */
  53651. 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>;
  53652. /**
  53653. * Load a scene into an asset container
  53654. * @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)
  53655. * @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)
  53656. * @param scene is the instance of Scene to append to
  53657. * @param onProgress a callback with a progress event for each file being loaded
  53658. * @param pluginExtension the extension used to determine the plugin
  53659. * @returns The loaded asset container
  53660. */
  53661. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  53662. /**
  53663. * Import animations from a file into a scene
  53664. * @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)
  53665. * @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)
  53666. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53667. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53668. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53669. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53670. * @param onSuccess a callback with the scene when import succeeds
  53671. * @param onProgress a callback with a progress event for each file being loaded
  53672. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53673. * @param pluginExtension the extension used to determine the plugin
  53674. */
  53675. 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;
  53676. /**
  53677. * Import animations from a file into a scene
  53678. * @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)
  53679. * @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)
  53680. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53681. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53682. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53683. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53684. * @param onSuccess a callback with the scene when import succeeds
  53685. * @param onProgress a callback with a progress event for each file being loaded
  53686. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53687. * @param pluginExtension the extension used to determine the plugin
  53688. * @returns the updated scene with imported animations
  53689. */
  53690. 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>;
  53691. }
  53692. }
  53693. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  53694. import { IDisposable, Scene } from "babylonjs/scene";
  53695. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  53696. import { Observable } from "babylonjs/Misc/observable";
  53697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53698. import { Nullable } from "babylonjs/types";
  53699. /**
  53700. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  53701. */
  53702. export type MotionControllerHandedness = "none" | "left" | "right";
  53703. /**
  53704. * The type of components available in motion controllers.
  53705. * This is not the name of the component.
  53706. */
  53707. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53708. /**
  53709. * The state of a controller component
  53710. */
  53711. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53712. /**
  53713. * The schema of motion controller layout.
  53714. * No object will be initialized using this interface
  53715. * This is used just to define the profile.
  53716. */
  53717. export interface IMotionControllerLayout {
  53718. /**
  53719. * Path to load the assets. Usually relative to the base path
  53720. */
  53721. assetPath: string;
  53722. /**
  53723. * Available components (unsorted)
  53724. */
  53725. components: {
  53726. /**
  53727. * A map of component Ids
  53728. */
  53729. [componentId: string]: {
  53730. /**
  53731. * The type of input the component outputs
  53732. */
  53733. type: MotionControllerComponentType;
  53734. /**
  53735. * The indices of this component in the gamepad object
  53736. */
  53737. gamepadIndices: {
  53738. /**
  53739. * Index of button
  53740. */
  53741. button?: number;
  53742. /**
  53743. * If available, index of x-axis
  53744. */
  53745. xAxis?: number;
  53746. /**
  53747. * If available, index of y-axis
  53748. */
  53749. yAxis?: number;
  53750. };
  53751. /**
  53752. * The mesh's root node name
  53753. */
  53754. rootNodeName: string;
  53755. /**
  53756. * Animation definitions for this model
  53757. */
  53758. visualResponses: {
  53759. [stateKey: string]: {
  53760. /**
  53761. * What property will be animated
  53762. */
  53763. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53764. /**
  53765. * What states influence this visual response
  53766. */
  53767. states: MotionControllerComponentStateType[];
  53768. /**
  53769. * Type of animation - movement or visibility
  53770. */
  53771. valueNodeProperty: "transform" | "visibility";
  53772. /**
  53773. * Base node name to move. Its position will be calculated according to the min and max nodes
  53774. */
  53775. valueNodeName?: string;
  53776. /**
  53777. * Minimum movement node
  53778. */
  53779. minNodeName?: string;
  53780. /**
  53781. * Max movement node
  53782. */
  53783. maxNodeName?: string;
  53784. };
  53785. };
  53786. /**
  53787. * If touch enabled, what is the name of node to display user feedback
  53788. */
  53789. touchPointNodeName?: string;
  53790. };
  53791. };
  53792. /**
  53793. * Is it xr standard mapping or not
  53794. */
  53795. gamepadMapping: "" | "xr-standard";
  53796. /**
  53797. * Base root node of this entire model
  53798. */
  53799. rootNodeName: string;
  53800. /**
  53801. * Defines the main button component id
  53802. */
  53803. selectComponentId: string;
  53804. }
  53805. /**
  53806. * A definition for the layout map in the input profile
  53807. */
  53808. export interface IMotionControllerLayoutMap {
  53809. /**
  53810. * Layouts with handedness type as a key
  53811. */
  53812. [handedness: string]: IMotionControllerLayout;
  53813. }
  53814. /**
  53815. * The XR Input profile schema
  53816. * Profiles can be found here:
  53817. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53818. */
  53819. export interface IMotionControllerProfile {
  53820. /**
  53821. * fallback profiles for this profileId
  53822. */
  53823. fallbackProfileIds: string[];
  53824. /**
  53825. * The layout map, with handedness as key
  53826. */
  53827. layouts: IMotionControllerLayoutMap;
  53828. /**
  53829. * The id of this profile
  53830. * correlates to the profile(s) in the xrInput.profiles array
  53831. */
  53832. profileId: string;
  53833. }
  53834. /**
  53835. * A helper-interface for the 3 meshes needed for controller button animation
  53836. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53837. */
  53838. export interface IMotionControllerButtonMeshMap {
  53839. /**
  53840. * the mesh that defines the pressed value mesh position.
  53841. * This is used to find the max-position of this button
  53842. */
  53843. pressedMesh: AbstractMesh;
  53844. /**
  53845. * the mesh that defines the unpressed value mesh position.
  53846. * This is used to find the min (or initial) position of this button
  53847. */
  53848. unpressedMesh: AbstractMesh;
  53849. /**
  53850. * The mesh that will be changed when value changes
  53851. */
  53852. valueMesh: AbstractMesh;
  53853. }
  53854. /**
  53855. * A helper-interface for the 3 meshes needed for controller axis animation.
  53856. * This will be expanded when touchpad animations are fully supported
  53857. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53858. */
  53859. export interface IMotionControllerMeshMap {
  53860. /**
  53861. * the mesh that defines the maximum value mesh position.
  53862. */
  53863. maxMesh?: AbstractMesh;
  53864. /**
  53865. * the mesh that defines the minimum value mesh position.
  53866. */
  53867. minMesh?: AbstractMesh;
  53868. /**
  53869. * The mesh that will be changed when axis value changes
  53870. */
  53871. valueMesh?: AbstractMesh;
  53872. }
  53873. /**
  53874. * The elements needed for change-detection of the gamepad objects in motion controllers
  53875. */
  53876. export interface IMinimalMotionControllerObject {
  53877. /**
  53878. * Available axes of this controller
  53879. */
  53880. axes: number[];
  53881. /**
  53882. * An array of available buttons
  53883. */
  53884. buttons: Array<{
  53885. /**
  53886. * Value of the button/trigger
  53887. */
  53888. value: number;
  53889. /**
  53890. * If the button/trigger is currently touched
  53891. */
  53892. touched: boolean;
  53893. /**
  53894. * If the button/trigger is currently pressed
  53895. */
  53896. pressed: boolean;
  53897. }>;
  53898. /**
  53899. * EXPERIMENTAL haptic support.
  53900. */
  53901. hapticActuators?: Array<{
  53902. pulse: (value: number, duration: number) => Promise<boolean>;
  53903. }>;
  53904. }
  53905. /**
  53906. * An Abstract Motion controller
  53907. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53908. * Each component has an observable to check for changes in value and state
  53909. */
  53910. export abstract class WebXRAbstractMotionController implements IDisposable {
  53911. protected scene: Scene;
  53912. protected layout: IMotionControllerLayout;
  53913. /**
  53914. * The gamepad object correlating to this controller
  53915. */
  53916. gamepadObject: IMinimalMotionControllerObject;
  53917. /**
  53918. * handedness (left/right/none) of this controller
  53919. */
  53920. handedness: MotionControllerHandedness;
  53921. private _initComponent;
  53922. private _modelReady;
  53923. /**
  53924. * A map of components (WebXRControllerComponent) in this motion controller
  53925. * Components have a ComponentType and can also have both button and axis definitions
  53926. */
  53927. readonly components: {
  53928. [id: string]: WebXRControllerComponent;
  53929. };
  53930. /**
  53931. * Disable the model's animation. Can be set at any time.
  53932. */
  53933. disableAnimation: boolean;
  53934. /**
  53935. * Observers registered here will be triggered when the model of this controller is done loading
  53936. */
  53937. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53938. /**
  53939. * The profile id of this motion controller
  53940. */
  53941. abstract profileId: string;
  53942. /**
  53943. * The root mesh of the model. It is null if the model was not yet initialized
  53944. */
  53945. rootMesh: Nullable<AbstractMesh>;
  53946. /**
  53947. * constructs a new abstract motion controller
  53948. * @param scene the scene to which the model of the controller will be added
  53949. * @param layout The profile layout to load
  53950. * @param gamepadObject The gamepad object correlating to this controller
  53951. * @param handedness handedness (left/right/none) of this controller
  53952. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53953. */
  53954. constructor(scene: Scene, layout: IMotionControllerLayout,
  53955. /**
  53956. * The gamepad object correlating to this controller
  53957. */
  53958. gamepadObject: IMinimalMotionControllerObject,
  53959. /**
  53960. * handedness (left/right/none) of this controller
  53961. */
  53962. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53963. /**
  53964. * Dispose this controller, the model mesh and all its components
  53965. */
  53966. dispose(): void;
  53967. /**
  53968. * Returns all components of specific type
  53969. * @param type the type to search for
  53970. * @return an array of components with this type
  53971. */
  53972. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53973. /**
  53974. * get a component based an its component id as defined in layout.components
  53975. * @param id the id of the component
  53976. * @returns the component correlates to the id or undefined if not found
  53977. */
  53978. getComponent(id: string): WebXRControllerComponent;
  53979. /**
  53980. * Get the list of components available in this motion controller
  53981. * @returns an array of strings correlating to available components
  53982. */
  53983. getComponentIds(): string[];
  53984. /**
  53985. * Get the first component of specific type
  53986. * @param type type of component to find
  53987. * @return a controller component or null if not found
  53988. */
  53989. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53990. /**
  53991. * Get the main (Select) component of this controller as defined in the layout
  53992. * @returns the main component of this controller
  53993. */
  53994. getMainComponent(): WebXRControllerComponent;
  53995. /**
  53996. * Loads the model correlating to this controller
  53997. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53998. * @returns A promise fulfilled with the result of the model loading
  53999. */
  54000. loadModel(): Promise<boolean>;
  54001. /**
  54002. * Update this model using the current XRFrame
  54003. * @param xrFrame the current xr frame to use and update the model
  54004. */
  54005. updateFromXRFrame(xrFrame: XRFrame): void;
  54006. /**
  54007. * Backwards compatibility due to a deeply-integrated typo
  54008. */
  54009. get handness(): XREye;
  54010. /**
  54011. * Pulse (vibrate) this controller
  54012. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  54013. * Consecutive calls to this function will cancel the last pulse call
  54014. *
  54015. * @param value the strength of the pulse in 0.0...1.0 range
  54016. * @param duration Duration of the pulse in milliseconds
  54017. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  54018. * @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
  54019. */
  54020. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  54021. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54022. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54023. /**
  54024. * Moves the axis on the controller mesh based on its current state
  54025. * @param axis the index of the axis
  54026. * @param axisValue the value of the axis which determines the meshes new position
  54027. * @hidden
  54028. */
  54029. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  54030. /**
  54031. * Update the model itself with the current frame data
  54032. * @param xrFrame the frame to use for updating the model mesh
  54033. */
  54034. protected updateModel(xrFrame: XRFrame): void;
  54035. /**
  54036. * Get the filename and path for this controller's model
  54037. * @returns a map of filename and path
  54038. */
  54039. protected abstract _getFilenameAndPath(): {
  54040. filename: string;
  54041. path: string;
  54042. };
  54043. /**
  54044. * This function is called before the mesh is loaded. It checks for loading constraints.
  54045. * For example, this function can check if the GLB loader is available
  54046. * If this function returns false, the generic controller will be loaded instead
  54047. * @returns Is the client ready to load the mesh
  54048. */
  54049. protected abstract _getModelLoadingConstraints(): boolean;
  54050. /**
  54051. * This function will be called after the model was successfully loaded and can be used
  54052. * for mesh transformations before it is available for the user
  54053. * @param meshes the loaded meshes
  54054. */
  54055. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  54056. /**
  54057. * Set the root mesh for this controller. Important for the WebXR controller class
  54058. * @param meshes the loaded meshes
  54059. */
  54060. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  54061. /**
  54062. * A function executed each frame that updates the mesh (if needed)
  54063. * @param xrFrame the current xrFrame
  54064. */
  54065. protected abstract _updateModel(xrFrame: XRFrame): void;
  54066. private _getGenericFilenameAndPath;
  54067. private _getGenericParentMesh;
  54068. }
  54069. }
  54070. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  54071. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54073. import { Scene } from "babylonjs/scene";
  54074. /**
  54075. * A generic trigger-only motion controller for WebXR
  54076. */
  54077. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  54078. /**
  54079. * Static version of the profile id of this controller
  54080. */
  54081. static ProfileId: string;
  54082. profileId: string;
  54083. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  54084. protected _getFilenameAndPath(): {
  54085. filename: string;
  54086. path: string;
  54087. };
  54088. protected _getModelLoadingConstraints(): boolean;
  54089. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  54090. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54091. protected _updateModel(): void;
  54092. }
  54093. }
  54094. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  54095. import { Vector4 } from "babylonjs/Maths/math.vector";
  54096. import { Mesh } from "babylonjs/Meshes/mesh";
  54097. import { Scene } from "babylonjs/scene";
  54098. import { Nullable } from "babylonjs/types";
  54099. /**
  54100. * Class containing static functions to help procedurally build meshes
  54101. */
  54102. export class SphereBuilder {
  54103. /**
  54104. * Creates a sphere mesh
  54105. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54106. * * 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`)
  54107. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54108. * * 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
  54109. * * 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)
  54110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54113. * @param name defines the name of the mesh
  54114. * @param options defines the options used to create the mesh
  54115. * @param scene defines the hosting scene
  54116. * @returns the sphere mesh
  54117. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54118. */
  54119. static CreateSphere(name: string, options: {
  54120. segments?: number;
  54121. diameter?: number;
  54122. diameterX?: number;
  54123. diameterY?: number;
  54124. diameterZ?: number;
  54125. arc?: number;
  54126. slice?: number;
  54127. sideOrientation?: number;
  54128. frontUVs?: Vector4;
  54129. backUVs?: Vector4;
  54130. updatable?: boolean;
  54131. }, scene?: Nullable<Scene>): Mesh;
  54132. }
  54133. }
  54134. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  54135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54136. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54137. import { Scene } from "babylonjs/scene";
  54138. /**
  54139. * A profiled motion controller has its profile loaded from an online repository.
  54140. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  54141. */
  54142. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  54143. private _repositoryUrl;
  54144. private _buttonMeshMapping;
  54145. private _touchDots;
  54146. /**
  54147. * The profile ID of this controller. Will be populated when the controller initializes.
  54148. */
  54149. profileId: string;
  54150. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  54151. dispose(): void;
  54152. protected _getFilenameAndPath(): {
  54153. filename: string;
  54154. path: string;
  54155. };
  54156. protected _getModelLoadingConstraints(): boolean;
  54157. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  54158. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54159. protected _updateModel(_xrFrame: XRFrame): void;
  54160. }
  54161. }
  54162. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  54163. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54164. import { Scene } from "babylonjs/scene";
  54165. /**
  54166. * A construction function type to create a new controller based on an xrInput object
  54167. */
  54168. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  54169. /**
  54170. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  54171. *
  54172. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  54173. * it should be replaced with auto-loaded controllers.
  54174. *
  54175. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  54176. */
  54177. export class WebXRMotionControllerManager {
  54178. private static _AvailableControllers;
  54179. private static _Fallbacks;
  54180. private static _ProfileLoadingPromises;
  54181. private static _ProfilesList;
  54182. /**
  54183. * The base URL of the online controller repository. Can be changed at any time.
  54184. */
  54185. static BaseRepositoryUrl: string;
  54186. /**
  54187. * Which repository gets priority - local or online
  54188. */
  54189. static PrioritizeOnlineRepository: boolean;
  54190. /**
  54191. * Use the online repository, or use only locally-defined controllers
  54192. */
  54193. static UseOnlineRepository: boolean;
  54194. /**
  54195. * Clear the cache used for profile loading and reload when requested again
  54196. */
  54197. static ClearProfilesCache(): void;
  54198. /**
  54199. * Register the default fallbacks.
  54200. * This function is called automatically when this file is imported.
  54201. */
  54202. static DefaultFallbacks(): void;
  54203. /**
  54204. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  54205. * @param profileId the profile to which a fallback needs to be found
  54206. * @return an array with corresponding fallback profiles
  54207. */
  54208. static FindFallbackWithProfileId(profileId: string): string[];
  54209. /**
  54210. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  54211. * The order of search:
  54212. *
  54213. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  54214. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  54215. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  54216. * 4) return the generic trigger controller if none were found
  54217. *
  54218. * @param xrInput the xrInput to which a new controller is initialized
  54219. * @param scene the scene to which the model will be added
  54220. * @param forceProfile force a certain profile for this controller
  54221. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  54222. */
  54223. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  54224. /**
  54225. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  54226. *
  54227. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  54228. *
  54229. * @param type the profile type to register
  54230. * @param constructFunction the function to be called when loading this profile
  54231. */
  54232. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  54233. /**
  54234. * Register a fallback to a specific profile.
  54235. * @param profileId the profileId that will receive the fallbacks
  54236. * @param fallbacks A list of fallback profiles
  54237. */
  54238. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  54239. /**
  54240. * Will update the list of profiles available in the repository
  54241. * @return a promise that resolves to a map of profiles available online
  54242. */
  54243. static UpdateProfilesList(): Promise<{
  54244. [profile: string]: string;
  54245. }>;
  54246. private static _LoadProfileFromRepository;
  54247. private static _LoadProfilesFromAvailableControllers;
  54248. }
  54249. }
  54250. declare module "babylonjs/XR/webXRInputSource" {
  54251. import { Observable } from "babylonjs/Misc/observable";
  54252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54253. import { Ray } from "babylonjs/Culling/ray";
  54254. import { Scene } from "babylonjs/scene";
  54255. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54256. /**
  54257. * Configuration options for the WebXR controller creation
  54258. */
  54259. export interface IWebXRControllerOptions {
  54260. /**
  54261. * Should the controller mesh be animated when a user interacts with it
  54262. * The pressed buttons / thumbstick and touchpad animations will be disabled
  54263. */
  54264. disableMotionControllerAnimation?: boolean;
  54265. /**
  54266. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  54267. */
  54268. doNotLoadControllerMesh?: boolean;
  54269. /**
  54270. * Force a specific controller type for this controller.
  54271. * This can be used when creating your own profile or when testing different controllers
  54272. */
  54273. forceControllerProfile?: string;
  54274. /**
  54275. * Defines a rendering group ID for meshes that will be loaded.
  54276. * This is for the default controllers only.
  54277. */
  54278. renderingGroupId?: number;
  54279. }
  54280. /**
  54281. * Represents an XR controller
  54282. */
  54283. export class WebXRInputSource {
  54284. private _scene;
  54285. /** The underlying input source for the controller */
  54286. inputSource: XRInputSource;
  54287. private _options;
  54288. private _tmpVector;
  54289. private _uniqueId;
  54290. private _disposed;
  54291. /**
  54292. * 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
  54293. */
  54294. grip?: AbstractMesh;
  54295. /**
  54296. * If available, this is the gamepad object related to this controller.
  54297. * Using this object it is possible to get click events and trackpad changes of the
  54298. * webxr controller that is currently being used.
  54299. */
  54300. motionController?: WebXRAbstractMotionController;
  54301. /**
  54302. * Event that fires when the controller is removed/disposed.
  54303. * The object provided as event data is this controller, after associated assets were disposed.
  54304. * uniqueId is still available.
  54305. */
  54306. onDisposeObservable: Observable<WebXRInputSource>;
  54307. /**
  54308. * Will be triggered when the mesh associated with the motion controller is done loading.
  54309. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  54310. * A shortened version of controller -> motion controller -> on mesh loaded.
  54311. */
  54312. onMeshLoadedObservable: Observable<AbstractMesh>;
  54313. /**
  54314. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  54315. */
  54316. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  54317. /**
  54318. * Pointer which can be used to select objects or attach a visible laser to
  54319. */
  54320. pointer: AbstractMesh;
  54321. /**
  54322. * Creates the input source object
  54323. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  54324. * @param _scene the scene which the controller should be associated to
  54325. * @param inputSource the underlying input source for the controller
  54326. * @param _options options for this controller creation
  54327. */
  54328. constructor(_scene: Scene,
  54329. /** The underlying input source for the controller */
  54330. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  54331. /**
  54332. * Get this controllers unique id
  54333. */
  54334. get uniqueId(): string;
  54335. /**
  54336. * Disposes of the object
  54337. */
  54338. dispose(): void;
  54339. /**
  54340. * Gets a world space ray coming from the pointer or grip
  54341. * @param result the resulting ray
  54342. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  54343. */
  54344. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  54345. /**
  54346. * Updates the controller pose based on the given XRFrame
  54347. * @param xrFrame xr frame to update the pose with
  54348. * @param referenceSpace reference space to use
  54349. */
  54350. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  54351. }
  54352. }
  54353. declare module "babylonjs/XR/webXRInput" {
  54354. import { Observable } from "babylonjs/Misc/observable";
  54355. import { IDisposable } from "babylonjs/scene";
  54356. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  54357. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54358. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54359. /**
  54360. * The schema for initialization options of the XR Input class
  54361. */
  54362. export interface IWebXRInputOptions {
  54363. /**
  54364. * If set to true no model will be automatically loaded
  54365. */
  54366. doNotLoadControllerMeshes?: boolean;
  54367. /**
  54368. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  54369. * If not found, the xr input profile data will be used.
  54370. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  54371. */
  54372. forceInputProfile?: string;
  54373. /**
  54374. * Do not send a request to the controller repository to load the profile.
  54375. *
  54376. * Instead, use the controllers available in babylon itself.
  54377. */
  54378. disableOnlineControllerRepository?: boolean;
  54379. /**
  54380. * A custom URL for the controllers repository
  54381. */
  54382. customControllersRepositoryURL?: string;
  54383. /**
  54384. * Should the controller model's components not move according to the user input
  54385. */
  54386. disableControllerAnimation?: boolean;
  54387. /**
  54388. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  54389. */
  54390. controllerOptions?: IWebXRControllerOptions;
  54391. }
  54392. /**
  54393. * XR input used to track XR inputs such as controllers/rays
  54394. */
  54395. export class WebXRInput implements IDisposable {
  54396. /**
  54397. * the xr session manager for this session
  54398. */
  54399. xrSessionManager: WebXRSessionManager;
  54400. /**
  54401. * the WebXR camera for this session. Mainly used for teleportation
  54402. */
  54403. xrCamera: WebXRCamera;
  54404. private readonly options;
  54405. /**
  54406. * XR controllers being tracked
  54407. */
  54408. controllers: Array<WebXRInputSource>;
  54409. private _frameObserver;
  54410. private _sessionEndedObserver;
  54411. private _sessionInitObserver;
  54412. /**
  54413. * Event when a controller has been connected/added
  54414. */
  54415. onControllerAddedObservable: Observable<WebXRInputSource>;
  54416. /**
  54417. * Event when a controller has been removed/disconnected
  54418. */
  54419. onControllerRemovedObservable: Observable<WebXRInputSource>;
  54420. /**
  54421. * Initializes the WebXRInput
  54422. * @param xrSessionManager the xr session manager for this session
  54423. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  54424. * @param options = initialization options for this xr input
  54425. */
  54426. constructor(
  54427. /**
  54428. * the xr session manager for this session
  54429. */
  54430. xrSessionManager: WebXRSessionManager,
  54431. /**
  54432. * the WebXR camera for this session. Mainly used for teleportation
  54433. */
  54434. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  54435. private _onInputSourcesChange;
  54436. private _addAndRemoveControllers;
  54437. /**
  54438. * Disposes of the object
  54439. */
  54440. dispose(): void;
  54441. }
  54442. }
  54443. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  54444. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54445. import { Observable, EventState } from "babylonjs/Misc/observable";
  54446. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54447. /**
  54448. * This is the base class for all WebXR features.
  54449. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  54450. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  54451. */
  54452. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  54453. protected _xrSessionManager: WebXRSessionManager;
  54454. private _attached;
  54455. private _removeOnDetach;
  54456. /**
  54457. * Is this feature disposed?
  54458. */
  54459. isDisposed: boolean;
  54460. /**
  54461. * Should auto-attach be disabled?
  54462. */
  54463. disableAutoAttach: boolean;
  54464. /**
  54465. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  54466. */
  54467. xrNativeFeatureName: string;
  54468. /**
  54469. * Construct a new (abstract) WebXR feature
  54470. * @param _xrSessionManager the xr session manager for this feature
  54471. */
  54472. constructor(_xrSessionManager: WebXRSessionManager);
  54473. /**
  54474. * Is this feature attached
  54475. */
  54476. get attached(): boolean;
  54477. /**
  54478. * attach this feature
  54479. *
  54480. * @param force should attachment be forced (even when already attached)
  54481. * @returns true if successful, false is failed or already attached
  54482. */
  54483. attach(force?: boolean): boolean;
  54484. /**
  54485. * detach this feature.
  54486. *
  54487. * @returns true if successful, false if failed or already detached
  54488. */
  54489. detach(): boolean;
  54490. /**
  54491. * Dispose this feature and all of the resources attached
  54492. */
  54493. dispose(): void;
  54494. /**
  54495. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54496. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54497. *
  54498. * @returns whether or not the feature is compatible in this environment
  54499. */
  54500. isCompatible(): boolean;
  54501. /**
  54502. * This is used to register callbacks that will automatically be removed when detach is called.
  54503. * @param observable the observable to which the observer will be attached
  54504. * @param callback the callback to register
  54505. */
  54506. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  54507. /**
  54508. * Code in this function will be executed on each xrFrame received from the browser.
  54509. * This function will not execute after the feature is detached.
  54510. * @param _xrFrame the current frame
  54511. */
  54512. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  54513. }
  54514. }
  54515. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  54516. import { IDisposable, Scene } from "babylonjs/scene";
  54517. import { Nullable } from "babylonjs/types";
  54518. import { Observable } from "babylonjs/Misc/observable";
  54519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54520. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  54521. import { Camera } from "babylonjs/Cameras/camera";
  54522. /**
  54523. * Renders a layer on top of an existing scene
  54524. */
  54525. export class UtilityLayerRenderer implements IDisposable {
  54526. /** the original scene that will be rendered on top of */
  54527. originalScene: Scene;
  54528. private _pointerCaptures;
  54529. private _lastPointerEvents;
  54530. private static _DefaultUtilityLayer;
  54531. private static _DefaultKeepDepthUtilityLayer;
  54532. private _sharedGizmoLight;
  54533. private _renderCamera;
  54534. /**
  54535. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  54536. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  54537. * @returns the camera that is used when rendering the utility layer
  54538. */
  54539. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  54540. /**
  54541. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  54542. * @param cam the camera that should be used when rendering the utility layer
  54543. */
  54544. setRenderCamera(cam: Nullable<Camera>): void;
  54545. /**
  54546. * @hidden
  54547. * Light which used by gizmos to get light shading
  54548. */
  54549. _getSharedGizmoLight(): HemisphericLight;
  54550. /**
  54551. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  54552. */
  54553. pickUtilitySceneFirst: boolean;
  54554. /**
  54555. * 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)
  54556. */
  54557. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  54558. /**
  54559. * 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)
  54560. */
  54561. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  54562. /**
  54563. * The scene that is rendered on top of the original scene
  54564. */
  54565. utilityLayerScene: Scene;
  54566. /**
  54567. * If the utility layer should automatically be rendered on top of existing scene
  54568. */
  54569. shouldRender: boolean;
  54570. /**
  54571. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  54572. */
  54573. onlyCheckPointerDownEvents: boolean;
  54574. /**
  54575. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  54576. */
  54577. processAllEvents: boolean;
  54578. /**
  54579. * Observable raised when the pointer move from the utility layer scene to the main scene
  54580. */
  54581. onPointerOutObservable: Observable<number>;
  54582. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  54583. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  54584. private _afterRenderObserver;
  54585. private _sceneDisposeObserver;
  54586. private _originalPointerObserver;
  54587. /**
  54588. * Instantiates a UtilityLayerRenderer
  54589. * @param originalScene the original scene that will be rendered on top of
  54590. * @param handleEvents boolean indicating if the utility layer should handle events
  54591. */
  54592. constructor(
  54593. /** the original scene that will be rendered on top of */
  54594. originalScene: Scene, handleEvents?: boolean);
  54595. private _notifyObservers;
  54596. /**
  54597. * Renders the utility layers scene on top of the original scene
  54598. */
  54599. render(): void;
  54600. /**
  54601. * Disposes of the renderer
  54602. */
  54603. dispose(): void;
  54604. private _updateCamera;
  54605. }
  54606. }
  54607. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  54608. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54610. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54611. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  54612. import { Scene } from "babylonjs/scene";
  54613. import { Nullable } from "babylonjs/types";
  54614. import { Color3 } from "babylonjs/Maths/math.color";
  54615. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54616. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54617. /**
  54618. * Options interface for the pointer selection module
  54619. */
  54620. export interface IWebXRControllerPointerSelectionOptions {
  54621. /**
  54622. * if provided, this scene will be used to render meshes.
  54623. */
  54624. customUtilityLayerScene?: Scene;
  54625. /**
  54626. * 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)
  54627. * If not disabled, the last picked point will be used to execute a pointer up event
  54628. * If disabled, pointer up event will be triggered right after the pointer down event.
  54629. * Used in screen and gaze target ray mode only
  54630. */
  54631. disablePointerUpOnTouchOut: boolean;
  54632. /**
  54633. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  54634. */
  54635. forceGazeMode: boolean;
  54636. /**
  54637. * 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
  54638. * to start a new countdown to the pointer down event.
  54639. * Defaults to 1.
  54640. */
  54641. gazeModePointerMovedFactor?: number;
  54642. /**
  54643. * Different button type to use instead of the main component
  54644. */
  54645. overrideButtonId?: string;
  54646. /**
  54647. * use this rendering group id for the meshes (optional)
  54648. */
  54649. renderingGroupId?: number;
  54650. /**
  54651. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  54652. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  54653. * 3000 means 3 seconds between pointing at something and selecting it
  54654. */
  54655. timeToSelect?: number;
  54656. /**
  54657. * Should meshes created here be added to a utility layer or the main scene
  54658. */
  54659. useUtilityLayer?: boolean;
  54660. /**
  54661. * Optional WebXR camera to be used for gaze selection
  54662. */
  54663. gazeCamera?: WebXRCamera;
  54664. /**
  54665. * the xr input to use with this pointer selection
  54666. */
  54667. xrInput: WebXRInput;
  54668. /**
  54669. * Should the scene pointerX and pointerY update be disabled
  54670. * This is required for fullscreen AR GUI, but might slow down other experiences.
  54671. * Disable in VR, if not needed.
  54672. * The first rig camera (left eye) will be used to calculate the projection
  54673. */
  54674. disableScenePointerVectorUpdate: boolean;
  54675. /**
  54676. * Enable pointer selection on all controllers instead of switching between them
  54677. */
  54678. enablePointerSelectionOnAllControllers?: boolean;
  54679. /**
  54680. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  54681. * If switch is enabled, it will still allow the user to switch between the different controllers
  54682. */
  54683. preferredHandedness?: XRHandedness;
  54684. /**
  54685. * Disable switching the pointer selection from one controller to the other.
  54686. * 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
  54687. */
  54688. disableSwitchOnClick?: boolean;
  54689. /**
  54690. * The maximum distance of the pointer selection feature. Defaults to 100.
  54691. */
  54692. maxPointerDistance?: number;
  54693. }
  54694. /**
  54695. * A module that will enable pointer selection for motion controllers of XR Input Sources
  54696. */
  54697. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  54698. private readonly _options;
  54699. private static _idCounter;
  54700. private _attachController;
  54701. private _controllers;
  54702. private _scene;
  54703. private _tmpVectorForPickCompare;
  54704. private _attachedController;
  54705. /**
  54706. * The module's name
  54707. */
  54708. static readonly Name: string;
  54709. /**
  54710. * The (Babylon) version of this module.
  54711. * This is an integer representing the implementation version.
  54712. * This number does not correspond to the WebXR specs version
  54713. */
  54714. static readonly Version: number;
  54715. /**
  54716. * Disable lighting on the laser pointer (so it will always be visible)
  54717. */
  54718. disablePointerLighting: boolean;
  54719. /**
  54720. * Disable lighting on the selection mesh (so it will always be visible)
  54721. */
  54722. disableSelectionMeshLighting: boolean;
  54723. /**
  54724. * Should the laser pointer be displayed
  54725. */
  54726. displayLaserPointer: boolean;
  54727. /**
  54728. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  54729. */
  54730. displaySelectionMesh: boolean;
  54731. /**
  54732. * This color will be set to the laser pointer when selection is triggered
  54733. */
  54734. laserPointerPickedColor: Color3;
  54735. /**
  54736. * Default color of the laser pointer
  54737. */
  54738. laserPointerDefaultColor: Color3;
  54739. /**
  54740. * default color of the selection ring
  54741. */
  54742. selectionMeshDefaultColor: Color3;
  54743. /**
  54744. * This color will be applied to the selection ring when selection is triggered
  54745. */
  54746. selectionMeshPickedColor: Color3;
  54747. /**
  54748. * Optional filter to be used for ray selection. This predicate shares behavior with
  54749. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54750. */
  54751. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54752. /**
  54753. * constructs a new background remover module
  54754. * @param _xrSessionManager the session manager for this module
  54755. * @param _options read-only options to be used in this module
  54756. */
  54757. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54758. /**
  54759. * attach this feature
  54760. * Will usually be called by the features manager
  54761. *
  54762. * @returns true if successful.
  54763. */
  54764. attach(): boolean;
  54765. /**
  54766. * detach this feature.
  54767. * Will usually be called by the features manager
  54768. *
  54769. * @returns true if successful.
  54770. */
  54771. detach(): boolean;
  54772. /**
  54773. * Will get the mesh under a specific pointer.
  54774. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54775. * @param controllerId the controllerId to check
  54776. * @returns The mesh under pointer or null if no mesh is under the pointer
  54777. */
  54778. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54779. /**
  54780. * Get the xr controller that correlates to the pointer id in the pointer event
  54781. *
  54782. * @param id the pointer id to search for
  54783. * @returns the controller that correlates to this id or null if not found
  54784. */
  54785. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54786. private _identityMatrix;
  54787. private _screenCoordinatesRef;
  54788. private _viewportRef;
  54789. protected _onXRFrame(_xrFrame: XRFrame): void;
  54790. private _attachGazeMode;
  54791. private _attachScreenRayMode;
  54792. private _attachTrackedPointerRayMode;
  54793. private _convertNormalToDirectionOfRay;
  54794. private _detachController;
  54795. private _generateNewMeshPair;
  54796. private _pickingMoved;
  54797. private _updatePointerDistance;
  54798. /** @hidden */
  54799. get lasterPointerDefaultColor(): Color3;
  54800. }
  54801. }
  54802. declare module "babylonjs/XR/webXREnterExitUI" {
  54803. import { Nullable } from "babylonjs/types";
  54804. import { Observable } from "babylonjs/Misc/observable";
  54805. import { IDisposable, Scene } from "babylonjs/scene";
  54806. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54807. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54808. /**
  54809. * Button which can be used to enter a different mode of XR
  54810. */
  54811. export class WebXREnterExitUIButton {
  54812. /** button element */
  54813. element: HTMLElement;
  54814. /** XR initialization options for the button */
  54815. sessionMode: XRSessionMode;
  54816. /** Reference space type */
  54817. referenceSpaceType: XRReferenceSpaceType;
  54818. /**
  54819. * Creates a WebXREnterExitUIButton
  54820. * @param element button element
  54821. * @param sessionMode XR initialization session mode
  54822. * @param referenceSpaceType the type of reference space to be used
  54823. */
  54824. constructor(
  54825. /** button element */
  54826. element: HTMLElement,
  54827. /** XR initialization options for the button */
  54828. sessionMode: XRSessionMode,
  54829. /** Reference space type */
  54830. referenceSpaceType: XRReferenceSpaceType);
  54831. /**
  54832. * Extendable function which can be used to update the button's visuals when the state changes
  54833. * @param activeButton the current active button in the UI
  54834. */
  54835. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54836. }
  54837. /**
  54838. * Options to create the webXR UI
  54839. */
  54840. export class WebXREnterExitUIOptions {
  54841. /**
  54842. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54843. */
  54844. customButtons?: Array<WebXREnterExitUIButton>;
  54845. /**
  54846. * A reference space type to use when creating the default button.
  54847. * Default is local-floor
  54848. */
  54849. referenceSpaceType?: XRReferenceSpaceType;
  54850. /**
  54851. * Context to enter xr with
  54852. */
  54853. renderTarget?: Nullable<WebXRRenderTarget>;
  54854. /**
  54855. * A session mode to use when creating the default button.
  54856. * Default is immersive-vr
  54857. */
  54858. sessionMode?: XRSessionMode;
  54859. /**
  54860. * A list of optional features to init the session with
  54861. */
  54862. optionalFeatures?: string[];
  54863. /**
  54864. * A list of optional features to init the session with
  54865. */
  54866. requiredFeatures?: string[];
  54867. /**
  54868. * If defined, this function will be executed if the UI encounters an error when entering XR
  54869. */
  54870. onError?: (error: any) => void;
  54871. }
  54872. /**
  54873. * UI to allow the user to enter/exit XR mode
  54874. */
  54875. export class WebXREnterExitUI implements IDisposable {
  54876. private scene;
  54877. /** version of the options passed to this UI */
  54878. options: WebXREnterExitUIOptions;
  54879. private _activeButton;
  54880. private _buttons;
  54881. /**
  54882. * The HTML Div Element to which buttons are added.
  54883. */
  54884. readonly overlay: HTMLDivElement;
  54885. /**
  54886. * Fired every time the active button is changed.
  54887. *
  54888. * When xr is entered via a button that launches xr that button will be the callback parameter
  54889. *
  54890. * When exiting xr the callback parameter will be null)
  54891. */
  54892. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54893. /**
  54894. *
  54895. * @param scene babylon scene object to use
  54896. * @param options (read-only) version of the options passed to this UI
  54897. */
  54898. private constructor();
  54899. /**
  54900. * Creates UI to allow the user to enter/exit XR mode
  54901. * @param scene the scene to add the ui to
  54902. * @param helper the xr experience helper to enter/exit xr with
  54903. * @param options options to configure the UI
  54904. * @returns the created ui
  54905. */
  54906. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54907. /**
  54908. * Disposes of the XR UI component
  54909. */
  54910. dispose(): void;
  54911. private _updateButtons;
  54912. }
  54913. }
  54914. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54915. import { Vector3 } from "babylonjs/Maths/math.vector";
  54916. import { Color4 } from "babylonjs/Maths/math.color";
  54917. import { Nullable } from "babylonjs/types";
  54918. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54919. import { Scene } from "babylonjs/scene";
  54920. /**
  54921. * Class containing static functions to help procedurally build meshes
  54922. */
  54923. export class LinesBuilder {
  54924. /**
  54925. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54926. * * 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
  54927. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54928. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54929. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54930. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54931. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54932. * * 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
  54933. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54935. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54936. * @param name defines the name of the new line system
  54937. * @param options defines the options used to create the line system
  54938. * @param scene defines the hosting scene
  54939. * @returns a new line system mesh
  54940. */
  54941. static CreateLineSystem(name: string, options: {
  54942. lines: Vector3[][];
  54943. updatable?: boolean;
  54944. instance?: Nullable<LinesMesh>;
  54945. colors?: Nullable<Color4[][]>;
  54946. useVertexAlpha?: boolean;
  54947. }, scene: Nullable<Scene>): LinesMesh;
  54948. /**
  54949. * Creates a line mesh
  54950. * 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
  54951. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54952. * * The parameter `points` is an array successive Vector3
  54953. * * 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
  54954. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54955. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54956. * * When updating an instance, remember that only point positions can change, not the number of points
  54957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54958. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54959. * @param name defines the name of the new line system
  54960. * @param options defines the options used to create the line system
  54961. * @param scene defines the hosting scene
  54962. * @returns a new line mesh
  54963. */
  54964. static CreateLines(name: string, options: {
  54965. points: Vector3[];
  54966. updatable?: boolean;
  54967. instance?: Nullable<LinesMesh>;
  54968. colors?: Color4[];
  54969. useVertexAlpha?: boolean;
  54970. }, scene?: Nullable<Scene>): LinesMesh;
  54971. /**
  54972. * Creates a dashed line mesh
  54973. * * 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
  54974. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54975. * * The parameter `points` is an array successive Vector3
  54976. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54977. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54978. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54979. * * 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
  54980. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54981. * * When updating an instance, remember that only point positions can change, not the number of points
  54982. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54983. * @param name defines the name of the mesh
  54984. * @param options defines the options used to create the mesh
  54985. * @param scene defines the hosting scene
  54986. * @returns the dashed line mesh
  54987. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54988. */
  54989. static CreateDashedLines(name: string, options: {
  54990. points: Vector3[];
  54991. dashSize?: number;
  54992. gapSize?: number;
  54993. dashNb?: number;
  54994. updatable?: boolean;
  54995. instance?: LinesMesh;
  54996. useVertexAlpha?: boolean;
  54997. }, scene?: Nullable<Scene>): LinesMesh;
  54998. }
  54999. }
  55000. declare module "babylonjs/Misc/timer" {
  55001. import { Observable, Observer } from "babylonjs/Misc/observable";
  55002. import { Nullable } from "babylonjs/types";
  55003. import { IDisposable } from "babylonjs/scene";
  55004. /**
  55005. * Construction options for a timer
  55006. */
  55007. export interface ITimerOptions<T> {
  55008. /**
  55009. * Time-to-end
  55010. */
  55011. timeout: number;
  55012. /**
  55013. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  55014. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  55015. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  55016. */
  55017. contextObservable: Observable<T>;
  55018. /**
  55019. * Optional parameters when adding an observer to the observable
  55020. */
  55021. observableParameters?: {
  55022. mask?: number;
  55023. insertFirst?: boolean;
  55024. scope?: any;
  55025. };
  55026. /**
  55027. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  55028. */
  55029. breakCondition?: (data?: ITimerData<T>) => boolean;
  55030. /**
  55031. * Will be triggered when the time condition has met
  55032. */
  55033. onEnded?: (data: ITimerData<any>) => void;
  55034. /**
  55035. * Will be triggered when the break condition has met (prematurely ended)
  55036. */
  55037. onAborted?: (data: ITimerData<any>) => void;
  55038. /**
  55039. * Optional function to execute on each tick (or count)
  55040. */
  55041. onTick?: (data: ITimerData<any>) => void;
  55042. }
  55043. /**
  55044. * An interface defining the data sent by the timer
  55045. */
  55046. export interface ITimerData<T> {
  55047. /**
  55048. * When did it start
  55049. */
  55050. startTime: number;
  55051. /**
  55052. * Time now
  55053. */
  55054. currentTime: number;
  55055. /**
  55056. * Time passed since started
  55057. */
  55058. deltaTime: number;
  55059. /**
  55060. * How much is completed, in [0.0...1.0].
  55061. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  55062. */
  55063. completeRate: number;
  55064. /**
  55065. * What the registered observable sent in the last count
  55066. */
  55067. payload: T;
  55068. }
  55069. /**
  55070. * The current state of the timer
  55071. */
  55072. export enum TimerState {
  55073. /**
  55074. * Timer initialized, not yet started
  55075. */
  55076. INIT = 0,
  55077. /**
  55078. * Timer started and counting
  55079. */
  55080. STARTED = 1,
  55081. /**
  55082. * Timer ended (whether aborted or time reached)
  55083. */
  55084. ENDED = 2
  55085. }
  55086. /**
  55087. * A simple version of the timer. Will take options and start the timer immediately after calling it
  55088. *
  55089. * @param options options with which to initialize this timer
  55090. */
  55091. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  55092. /**
  55093. * An advanced implementation of a timer class
  55094. */
  55095. export class AdvancedTimer<T = any> implements IDisposable {
  55096. /**
  55097. * Will notify each time the timer calculates the remaining time
  55098. */
  55099. onEachCountObservable: Observable<ITimerData<T>>;
  55100. /**
  55101. * Will trigger when the timer was aborted due to the break condition
  55102. */
  55103. onTimerAbortedObservable: Observable<ITimerData<T>>;
  55104. /**
  55105. * Will trigger when the timer ended successfully
  55106. */
  55107. onTimerEndedObservable: Observable<ITimerData<T>>;
  55108. /**
  55109. * Will trigger when the timer state has changed
  55110. */
  55111. onStateChangedObservable: Observable<TimerState>;
  55112. private _observer;
  55113. private _contextObservable;
  55114. private _observableParameters;
  55115. private _startTime;
  55116. private _timer;
  55117. private _state;
  55118. private _breakCondition;
  55119. private _timeToEnd;
  55120. private _breakOnNextTick;
  55121. /**
  55122. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  55123. * @param options construction options for this advanced timer
  55124. */
  55125. constructor(options: ITimerOptions<T>);
  55126. /**
  55127. * set a breaking condition for this timer. Default is to never break during count
  55128. * @param predicate the new break condition. Returns true to break, false otherwise
  55129. */
  55130. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  55131. /**
  55132. * Reset ALL associated observables in this advanced timer
  55133. */
  55134. clearObservables(): void;
  55135. /**
  55136. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  55137. *
  55138. * @param timeToEnd how much time to measure until timer ended
  55139. */
  55140. start(timeToEnd?: number): void;
  55141. /**
  55142. * Will force a stop on the next tick.
  55143. */
  55144. stop(): void;
  55145. /**
  55146. * Dispose this timer, clearing all resources
  55147. */
  55148. dispose(): void;
  55149. private _setState;
  55150. private _tick;
  55151. private _stop;
  55152. }
  55153. }
  55154. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  55155. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  55156. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55157. import { Nullable } from "babylonjs/types";
  55158. import { WebXRInput } from "babylonjs/XR/webXRInput";
  55159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55160. import { Vector3 } from "babylonjs/Maths/math.vector";
  55161. import { Material } from "babylonjs/Materials/material";
  55162. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  55163. import { Scene } from "babylonjs/scene";
  55164. /**
  55165. * The options container for the teleportation module
  55166. */
  55167. export interface IWebXRTeleportationOptions {
  55168. /**
  55169. * if provided, this scene will be used to render meshes.
  55170. */
  55171. customUtilityLayerScene?: Scene;
  55172. /**
  55173. * Values to configure the default target mesh
  55174. */
  55175. defaultTargetMeshOptions?: {
  55176. /**
  55177. * Fill color of the teleportation area
  55178. */
  55179. teleportationFillColor?: string;
  55180. /**
  55181. * Border color for the teleportation area
  55182. */
  55183. teleportationBorderColor?: string;
  55184. /**
  55185. * Disable the mesh's animation sequence
  55186. */
  55187. disableAnimation?: boolean;
  55188. /**
  55189. * Disable lighting on the material or the ring and arrow
  55190. */
  55191. disableLighting?: boolean;
  55192. /**
  55193. * Override the default material of the torus and arrow
  55194. */
  55195. torusArrowMaterial?: Material;
  55196. };
  55197. /**
  55198. * A list of meshes to use as floor meshes.
  55199. * Meshes can be added and removed after initializing the feature using the
  55200. * addFloorMesh and removeFloorMesh functions
  55201. * If empty, rotation will still work
  55202. */
  55203. floorMeshes?: AbstractMesh[];
  55204. /**
  55205. * use this rendering group id for the meshes (optional)
  55206. */
  55207. renderingGroupId?: number;
  55208. /**
  55209. * Should teleportation move only to snap points
  55210. */
  55211. snapPointsOnly?: boolean;
  55212. /**
  55213. * An array of points to which the teleportation will snap to.
  55214. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  55215. */
  55216. snapPositions?: Vector3[];
  55217. /**
  55218. * How close should the teleportation ray be in order to snap to position.
  55219. * Default to 0.8 units (meters)
  55220. */
  55221. snapToPositionRadius?: number;
  55222. /**
  55223. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  55224. * If you want to support rotation, make sure your mesh has a direction indicator.
  55225. *
  55226. * When left untouched, the default mesh will be initialized.
  55227. */
  55228. teleportationTargetMesh?: AbstractMesh;
  55229. /**
  55230. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  55231. */
  55232. timeToTeleport?: number;
  55233. /**
  55234. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  55235. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  55236. */
  55237. useMainComponentOnly?: boolean;
  55238. /**
  55239. * Should meshes created here be added to a utility layer or the main scene
  55240. */
  55241. useUtilityLayer?: boolean;
  55242. /**
  55243. * Babylon XR Input class for controller
  55244. */
  55245. xrInput: WebXRInput;
  55246. /**
  55247. * Meshes that the teleportation ray cannot go through
  55248. */
  55249. pickBlockerMeshes?: AbstractMesh[];
  55250. /**
  55251. * Should teleport work only on a specific hand?
  55252. */
  55253. forceHandedness?: XRHandedness;
  55254. /**
  55255. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  55256. */
  55257. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  55258. }
  55259. /**
  55260. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  55261. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  55262. * the input of the attached controllers.
  55263. */
  55264. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  55265. private _options;
  55266. private _controllers;
  55267. private _currentTeleportationControllerId;
  55268. private _floorMeshes;
  55269. private _quadraticBezierCurve;
  55270. private _selectionFeature;
  55271. private _snapToPositions;
  55272. private _snappedToPoint;
  55273. private _teleportationRingMaterial?;
  55274. private _tmpRay;
  55275. private _tmpVector;
  55276. private _tmpQuaternion;
  55277. /**
  55278. * The module's name
  55279. */
  55280. static readonly Name: string;
  55281. /**
  55282. * The (Babylon) version of this module.
  55283. * This is an integer representing the implementation version.
  55284. * This number does not correspond to the webxr specs version
  55285. */
  55286. static readonly Version: number;
  55287. /**
  55288. * Is movement backwards enabled
  55289. */
  55290. backwardsMovementEnabled: boolean;
  55291. /**
  55292. * Distance to travel when moving backwards
  55293. */
  55294. backwardsTeleportationDistance: number;
  55295. /**
  55296. * The distance from the user to the inspection point in the direction of the controller
  55297. * A higher number will allow the user to move further
  55298. * defaults to 5 (meters, in xr units)
  55299. */
  55300. parabolicCheckRadius: number;
  55301. /**
  55302. * Should the module support parabolic ray on top of direct ray
  55303. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  55304. * Very helpful when moving between floors / different heights
  55305. */
  55306. parabolicRayEnabled: boolean;
  55307. /**
  55308. * The second type of ray - straight line.
  55309. * Should it be enabled or should the parabolic line be the only one.
  55310. */
  55311. straightRayEnabled: boolean;
  55312. /**
  55313. * How much rotation should be applied when rotating right and left
  55314. */
  55315. rotationAngle: number;
  55316. private _rotationEnabled;
  55317. /**
  55318. * Is rotation enabled when moving forward?
  55319. * Disabling this feature will prevent the user from deciding the direction when teleporting
  55320. */
  55321. get rotationEnabled(): boolean;
  55322. /**
  55323. * Sets wether rotation is enabled or not
  55324. * @param enabled is rotation enabled when teleportation is shown
  55325. */
  55326. set rotationEnabled(enabled: boolean);
  55327. /**
  55328. * Exposes the currently set teleportation target mesh.
  55329. */
  55330. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  55331. /**
  55332. * constructs a new anchor system
  55333. * @param _xrSessionManager an instance of WebXRSessionManager
  55334. * @param _options configuration object for this feature
  55335. */
  55336. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  55337. /**
  55338. * Get the snapPointsOnly flag
  55339. */
  55340. get snapPointsOnly(): boolean;
  55341. /**
  55342. * Sets the snapPointsOnly flag
  55343. * @param snapToPoints should teleportation be exclusively to snap points
  55344. */
  55345. set snapPointsOnly(snapToPoints: boolean);
  55346. /**
  55347. * Add a new mesh to the floor meshes array
  55348. * @param mesh the mesh to use as floor mesh
  55349. */
  55350. addFloorMesh(mesh: AbstractMesh): void;
  55351. /**
  55352. * Add a new snap-to point to fix teleportation to this position
  55353. * @param newSnapPoint The new Snap-To point
  55354. */
  55355. addSnapPoint(newSnapPoint: Vector3): void;
  55356. attach(): boolean;
  55357. detach(): boolean;
  55358. dispose(): void;
  55359. /**
  55360. * Remove a mesh from the floor meshes array
  55361. * @param mesh the mesh to remove
  55362. */
  55363. removeFloorMesh(mesh: AbstractMesh): void;
  55364. /**
  55365. * Remove a mesh from the floor meshes array using its name
  55366. * @param name the mesh name to remove
  55367. */
  55368. removeFloorMeshByName(name: string): void;
  55369. /**
  55370. * 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
  55371. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  55372. * @returns was the point found and removed or not
  55373. */
  55374. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  55375. /**
  55376. * This function sets a selection feature that will be disabled when
  55377. * the forward ray is shown and will be reattached when hidden.
  55378. * This is used to remove the selection rays when moving.
  55379. * @param selectionFeature the feature to disable when forward movement is enabled
  55380. */
  55381. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  55382. protected _onXRFrame(_xrFrame: XRFrame): void;
  55383. private _attachController;
  55384. private _createDefaultTargetMesh;
  55385. private _detachController;
  55386. private _findClosestSnapPointWithRadius;
  55387. private _setTargetMeshPosition;
  55388. private _setTargetMeshVisibility;
  55389. private _showParabolicPath;
  55390. private _teleportForward;
  55391. }
  55392. }
  55393. declare module "babylonjs/XR/webXRDefaultExperience" {
  55394. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  55395. import { Scene } from "babylonjs/scene";
  55396. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  55397. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  55398. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55399. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  55400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55401. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  55402. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  55403. /**
  55404. * Options for the default xr helper
  55405. */
  55406. export class WebXRDefaultExperienceOptions {
  55407. /**
  55408. * Enable or disable default UI to enter XR
  55409. */
  55410. disableDefaultUI?: boolean;
  55411. /**
  55412. * Should teleportation not initialize. defaults to false.
  55413. */
  55414. disableTeleportation?: boolean;
  55415. /**
  55416. * Floor meshes that will be used for teleport
  55417. */
  55418. floorMeshes?: Array<AbstractMesh>;
  55419. /**
  55420. * If set to true, the first frame will not be used to reset position
  55421. * The first frame is mainly used when copying transformation from the old camera
  55422. * Mainly used in AR
  55423. */
  55424. ignoreNativeCameraTransformation?: boolean;
  55425. /**
  55426. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  55427. */
  55428. inputOptions?: IWebXRInputOptions;
  55429. /**
  55430. * optional configuration for the output canvas
  55431. */
  55432. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  55433. /**
  55434. * optional UI options. This can be used among other to change session mode and reference space type
  55435. */
  55436. uiOptions?: WebXREnterExitUIOptions;
  55437. /**
  55438. * When loading teleportation and pointer select, use stable versions instead of latest.
  55439. */
  55440. useStablePlugins?: boolean;
  55441. /**
  55442. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  55443. */
  55444. renderingGroupId?: number;
  55445. /**
  55446. * A list of optional features to init the session with
  55447. * If set to true, all features we support will be added
  55448. */
  55449. optionalFeatures?: boolean | string[];
  55450. }
  55451. /**
  55452. * Default experience which provides a similar setup to the previous webVRExperience
  55453. */
  55454. export class WebXRDefaultExperience {
  55455. /**
  55456. * Base experience
  55457. */
  55458. baseExperience: WebXRExperienceHelper;
  55459. /**
  55460. * Enables ui for entering/exiting xr
  55461. */
  55462. enterExitUI: WebXREnterExitUI;
  55463. /**
  55464. * Input experience extension
  55465. */
  55466. input: WebXRInput;
  55467. /**
  55468. * Enables laser pointer and selection
  55469. */
  55470. pointerSelection: WebXRControllerPointerSelection;
  55471. /**
  55472. * Default target xr should render to
  55473. */
  55474. renderTarget: WebXRRenderTarget;
  55475. /**
  55476. * Enables teleportation
  55477. */
  55478. teleportation: WebXRMotionControllerTeleportation;
  55479. private constructor();
  55480. /**
  55481. * Creates the default xr experience
  55482. * @param scene scene
  55483. * @param options options for basic configuration
  55484. * @returns resulting WebXRDefaultExperience
  55485. */
  55486. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55487. /**
  55488. * DIsposes of the experience helper
  55489. */
  55490. dispose(): void;
  55491. }
  55492. }
  55493. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  55494. import { Observable } from "babylonjs/Misc/observable";
  55495. import { Nullable } from "babylonjs/types";
  55496. import { Camera } from "babylonjs/Cameras/camera";
  55497. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  55498. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55499. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  55500. import { Scene } from "babylonjs/scene";
  55501. import { Vector3 } from "babylonjs/Maths/math.vector";
  55502. import { Color3 } from "babylonjs/Maths/math.color";
  55503. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55505. import { Mesh } from "babylonjs/Meshes/mesh";
  55506. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  55507. import { EasingFunction } from "babylonjs/Animations/easing";
  55508. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55509. import "babylonjs/Meshes/Builders/groundBuilder";
  55510. import "babylonjs/Meshes/Builders/torusBuilder";
  55511. import "babylonjs/Meshes/Builders/cylinderBuilder";
  55512. import "babylonjs/Gamepads/gamepadSceneComponent";
  55513. import "babylonjs/Animations/animatable";
  55514. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  55515. /**
  55516. * Options to modify the vr teleportation behavior.
  55517. */
  55518. export interface VRTeleportationOptions {
  55519. /**
  55520. * The name of the mesh which should be used as the teleportation floor. (default: null)
  55521. */
  55522. floorMeshName?: string;
  55523. /**
  55524. * A list of meshes to be used as the teleportation floor. (default: empty)
  55525. */
  55526. floorMeshes?: Mesh[];
  55527. /**
  55528. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  55529. */
  55530. teleportationMode?: number;
  55531. /**
  55532. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  55533. */
  55534. teleportationTime?: number;
  55535. /**
  55536. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  55537. */
  55538. teleportationSpeed?: number;
  55539. /**
  55540. * The easing function used in the animation or null for Linear. (default CircleEase)
  55541. */
  55542. easingFunction?: EasingFunction;
  55543. }
  55544. /**
  55545. * Options to modify the vr experience helper's behavior.
  55546. */
  55547. export interface VRExperienceHelperOptions extends WebVROptions {
  55548. /**
  55549. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  55550. */
  55551. createDeviceOrientationCamera?: boolean;
  55552. /**
  55553. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  55554. */
  55555. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  55556. /**
  55557. * Uses the main button on the controller to toggle the laser casted. (default: true)
  55558. */
  55559. laserToggle?: boolean;
  55560. /**
  55561. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  55562. */
  55563. floorMeshes?: Mesh[];
  55564. /**
  55565. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  55566. */
  55567. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  55568. /**
  55569. * Defines if WebXR should be used instead of WebVR (if available)
  55570. */
  55571. useXR?: boolean;
  55572. }
  55573. /**
  55574. * Event containing information after VR has been entered
  55575. */
  55576. export class OnAfterEnteringVRObservableEvent {
  55577. /**
  55578. * If entering vr was successful
  55579. */
  55580. success: boolean;
  55581. }
  55582. /**
  55583. * Helps to quickly add VR support to an existing scene.
  55584. * See https://doc.babylonjs.com/how_to/webvr_helper
  55585. */
  55586. export class VRExperienceHelper {
  55587. /** Options to modify the vr experience helper's behavior. */
  55588. webVROptions: VRExperienceHelperOptions;
  55589. private _scene;
  55590. private _position;
  55591. private _btnVR;
  55592. private _btnVRDisplayed;
  55593. private _webVRsupported;
  55594. private _webVRready;
  55595. private _webVRrequesting;
  55596. private _webVRpresenting;
  55597. private _hasEnteredVR;
  55598. private _fullscreenVRpresenting;
  55599. private _inputElement;
  55600. private _webVRCamera;
  55601. private _vrDeviceOrientationCamera;
  55602. private _deviceOrientationCamera;
  55603. private _existingCamera;
  55604. private _onKeyDown;
  55605. private _onVrDisplayPresentChange;
  55606. private _onVRDisplayChanged;
  55607. private _onVRRequestPresentStart;
  55608. private _onVRRequestPresentComplete;
  55609. /**
  55610. * 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)
  55611. */
  55612. enableGazeEvenWhenNoPointerLock: boolean;
  55613. /**
  55614. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  55615. */
  55616. exitVROnDoubleTap: boolean;
  55617. /**
  55618. * Observable raised right before entering VR.
  55619. */
  55620. onEnteringVRObservable: Observable<VRExperienceHelper>;
  55621. /**
  55622. * Observable raised when entering VR has completed.
  55623. */
  55624. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  55625. /**
  55626. * Observable raised when exiting VR.
  55627. */
  55628. onExitingVRObservable: Observable<VRExperienceHelper>;
  55629. /**
  55630. * Observable raised when controller mesh is loaded.
  55631. */
  55632. onControllerMeshLoadedObservable: Observable<WebVRController>;
  55633. /** Return this.onEnteringVRObservable
  55634. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  55635. */
  55636. get onEnteringVR(): Observable<VRExperienceHelper>;
  55637. /** Return this.onExitingVRObservable
  55638. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  55639. */
  55640. get onExitingVR(): Observable<VRExperienceHelper>;
  55641. /** Return this.onControllerMeshLoadedObservable
  55642. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  55643. */
  55644. get onControllerMeshLoaded(): Observable<WebVRController>;
  55645. private _rayLength;
  55646. private _useCustomVRButton;
  55647. private _teleportationRequested;
  55648. private _teleportActive;
  55649. private _floorMeshName;
  55650. private _floorMeshesCollection;
  55651. private _teleportationMode;
  55652. private _teleportationTime;
  55653. private _teleportationSpeed;
  55654. private _teleportationEasing;
  55655. private _rotationAllowed;
  55656. private _teleportBackwardsVector;
  55657. private _teleportationTarget;
  55658. private _isDefaultTeleportationTarget;
  55659. private _postProcessMove;
  55660. private _teleportationFillColor;
  55661. private _teleportationBorderColor;
  55662. private _rotationAngle;
  55663. private _haloCenter;
  55664. private _cameraGazer;
  55665. private _padSensibilityUp;
  55666. private _padSensibilityDown;
  55667. private _leftController;
  55668. private _rightController;
  55669. private _gazeColor;
  55670. private _laserColor;
  55671. private _pickedLaserColor;
  55672. private _pickedGazeColor;
  55673. /**
  55674. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  55675. */
  55676. onNewMeshSelected: Observable<AbstractMesh>;
  55677. /**
  55678. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  55679. * This observable will provide the mesh and the controller used to select the mesh
  55680. */
  55681. onMeshSelectedWithController: Observable<{
  55682. mesh: AbstractMesh;
  55683. controller: WebVRController;
  55684. }>;
  55685. /**
  55686. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  55687. */
  55688. onNewMeshPicked: Observable<PickingInfo>;
  55689. private _circleEase;
  55690. /**
  55691. * Observable raised before camera teleportation
  55692. */
  55693. onBeforeCameraTeleport: Observable<Vector3>;
  55694. /**
  55695. * Observable raised after camera teleportation
  55696. */
  55697. onAfterCameraTeleport: Observable<Vector3>;
  55698. /**
  55699. * Observable raised when current selected mesh gets unselected
  55700. */
  55701. onSelectedMeshUnselected: Observable<AbstractMesh>;
  55702. private _raySelectionPredicate;
  55703. /**
  55704. * To be optionaly changed by user to define custom ray selection
  55705. */
  55706. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55707. /**
  55708. * To be optionaly changed by user to define custom selection logic (after ray selection)
  55709. */
  55710. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55711. /**
  55712. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  55713. */
  55714. teleportationEnabled: boolean;
  55715. private _defaultHeight;
  55716. private _teleportationInitialized;
  55717. private _interactionsEnabled;
  55718. private _interactionsRequested;
  55719. private _displayGaze;
  55720. private _displayLaserPointer;
  55721. /**
  55722. * The mesh used to display where the user is going to teleport.
  55723. */
  55724. get teleportationTarget(): Mesh;
  55725. /**
  55726. * Sets the mesh to be used to display where the user is going to teleport.
  55727. */
  55728. set teleportationTarget(value: Mesh);
  55729. /**
  55730. * 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
  55731. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  55732. * See https://doc.babylonjs.com/resources/baking_transformations
  55733. */
  55734. get gazeTrackerMesh(): Mesh;
  55735. set gazeTrackerMesh(value: Mesh);
  55736. /**
  55737. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  55738. */
  55739. updateGazeTrackerScale: boolean;
  55740. /**
  55741. * If the gaze trackers color should be updated when selecting meshes
  55742. */
  55743. updateGazeTrackerColor: boolean;
  55744. /**
  55745. * If the controller laser color should be updated when selecting meshes
  55746. */
  55747. updateControllerLaserColor: boolean;
  55748. /**
  55749. * The gaze tracking mesh corresponding to the left controller
  55750. */
  55751. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  55752. /**
  55753. * The gaze tracking mesh corresponding to the right controller
  55754. */
  55755. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  55756. /**
  55757. * If the ray of the gaze should be displayed.
  55758. */
  55759. get displayGaze(): boolean;
  55760. /**
  55761. * Sets if the ray of the gaze should be displayed.
  55762. */
  55763. set displayGaze(value: boolean);
  55764. /**
  55765. * If the ray of the LaserPointer should be displayed.
  55766. */
  55767. get displayLaserPointer(): boolean;
  55768. /**
  55769. * Sets if the ray of the LaserPointer should be displayed.
  55770. */
  55771. set displayLaserPointer(value: boolean);
  55772. /**
  55773. * The deviceOrientationCamera used as the camera when not in VR.
  55774. */
  55775. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55776. /**
  55777. * Based on the current WebVR support, returns the current VR camera used.
  55778. */
  55779. get currentVRCamera(): Nullable<Camera>;
  55780. /**
  55781. * The webVRCamera which is used when in VR.
  55782. */
  55783. get webVRCamera(): WebVRFreeCamera;
  55784. /**
  55785. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55786. */
  55787. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55788. /**
  55789. * The html button that is used to trigger entering into VR.
  55790. */
  55791. get vrButton(): Nullable<HTMLButtonElement>;
  55792. private get _teleportationRequestInitiated();
  55793. /**
  55794. * Defines whether or not Pointer lock should be requested when switching to
  55795. * full screen.
  55796. */
  55797. requestPointerLockOnFullScreen: boolean;
  55798. /**
  55799. * If asking to force XR, this will be populated with the default xr experience
  55800. */
  55801. xr: WebXRDefaultExperience;
  55802. /**
  55803. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55804. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55805. */
  55806. xrTestDone: boolean;
  55807. /**
  55808. * Instantiates a VRExperienceHelper.
  55809. * Helps to quickly add VR support to an existing scene.
  55810. * @param scene The scene the VRExperienceHelper belongs to.
  55811. * @param webVROptions Options to modify the vr experience helper's behavior.
  55812. */
  55813. constructor(scene: Scene,
  55814. /** Options to modify the vr experience helper's behavior. */
  55815. webVROptions?: VRExperienceHelperOptions);
  55816. private completeVRInit;
  55817. private _onDefaultMeshLoaded;
  55818. private _onResize;
  55819. private _onFullscreenChange;
  55820. /**
  55821. * Gets a value indicating if we are currently in VR mode.
  55822. */
  55823. get isInVRMode(): boolean;
  55824. private onVrDisplayPresentChange;
  55825. private onVRDisplayChanged;
  55826. private moveButtonToBottomRight;
  55827. private displayVRButton;
  55828. private updateButtonVisibility;
  55829. private _cachedAngularSensibility;
  55830. /**
  55831. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55832. * Otherwise, will use the fullscreen API.
  55833. */
  55834. enterVR(): void;
  55835. /**
  55836. * Attempt to exit VR, or fullscreen.
  55837. */
  55838. exitVR(): void;
  55839. /**
  55840. * The position of the vr experience helper.
  55841. */
  55842. get position(): Vector3;
  55843. /**
  55844. * Sets the position of the vr experience helper.
  55845. */
  55846. set position(value: Vector3);
  55847. /**
  55848. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55849. */
  55850. enableInteractions(): void;
  55851. private get _noControllerIsActive();
  55852. private beforeRender;
  55853. private _isTeleportationFloor;
  55854. /**
  55855. * Adds a floor mesh to be used for teleportation.
  55856. * @param floorMesh the mesh to be used for teleportation.
  55857. */
  55858. addFloorMesh(floorMesh: Mesh): void;
  55859. /**
  55860. * Removes a floor mesh from being used for teleportation.
  55861. * @param floorMesh the mesh to be removed.
  55862. */
  55863. removeFloorMesh(floorMesh: Mesh): void;
  55864. /**
  55865. * Enables interactions and teleportation using the VR controllers and gaze.
  55866. * @param vrTeleportationOptions options to modify teleportation behavior.
  55867. */
  55868. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55869. private _onNewGamepadConnected;
  55870. private _tryEnableInteractionOnController;
  55871. private _onNewGamepadDisconnected;
  55872. private _enableInteractionOnController;
  55873. private _checkTeleportWithRay;
  55874. private _checkRotate;
  55875. private _checkTeleportBackwards;
  55876. private _enableTeleportationOnController;
  55877. private _createTeleportationCircles;
  55878. private _displayTeleportationTarget;
  55879. private _hideTeleportationTarget;
  55880. private _rotateCamera;
  55881. private _moveTeleportationSelectorTo;
  55882. private _workingVector;
  55883. private _workingQuaternion;
  55884. private _workingMatrix;
  55885. /**
  55886. * Time Constant Teleportation Mode
  55887. */
  55888. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55889. /**
  55890. * Speed Constant Teleportation Mode
  55891. */
  55892. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55893. /**
  55894. * Teleports the users feet to the desired location
  55895. * @param location The location where the user's feet should be placed
  55896. */
  55897. teleportCamera(location: Vector3): void;
  55898. private _convertNormalToDirectionOfRay;
  55899. private _castRayAndSelectObject;
  55900. private _notifySelectedMeshUnselected;
  55901. /**
  55902. * Permanently set new colors for the laser pointer
  55903. * @param color the new laser color
  55904. * @param pickedColor the new laser color when picked mesh detected
  55905. */
  55906. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55907. /**
  55908. * Set lighting enabled / disabled on the laser pointer of both controllers
  55909. * @param enabled should the lighting be enabled on the laser pointer
  55910. */
  55911. setLaserLightingState(enabled?: boolean): void;
  55912. /**
  55913. * Permanently set new colors for the gaze pointer
  55914. * @param color the new gaze color
  55915. * @param pickedColor the new gaze color when picked mesh detected
  55916. */
  55917. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55918. /**
  55919. * Sets the color of the laser ray from the vr controllers.
  55920. * @param color new color for the ray.
  55921. */
  55922. changeLaserColor(color: Color3): void;
  55923. /**
  55924. * Sets the color of the ray from the vr headsets gaze.
  55925. * @param color new color for the ray.
  55926. */
  55927. changeGazeColor(color: Color3): void;
  55928. /**
  55929. * Exits VR and disposes of the vr experience helper
  55930. */
  55931. dispose(): void;
  55932. /**
  55933. * Gets the name of the VRExperienceHelper class
  55934. * @returns "VRExperienceHelper"
  55935. */
  55936. getClassName(): string;
  55937. }
  55938. }
  55939. declare module "babylonjs/Cameras/VR/index" {
  55940. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55941. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55942. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55943. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55944. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55945. export * from "babylonjs/Cameras/VR/webVRCamera";
  55946. }
  55947. declare module "babylonjs/Cameras/RigModes/index" {
  55948. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55949. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55950. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55951. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55952. }
  55953. declare module "babylonjs/Cameras/index" {
  55954. export * from "babylonjs/Cameras/Inputs/index";
  55955. export * from "babylonjs/Cameras/cameraInputsManager";
  55956. export * from "babylonjs/Cameras/camera";
  55957. export * from "babylonjs/Cameras/targetCamera";
  55958. export * from "babylonjs/Cameras/freeCamera";
  55959. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55960. export * from "babylonjs/Cameras/touchCamera";
  55961. export * from "babylonjs/Cameras/arcRotateCamera";
  55962. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55963. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55964. export * from "babylonjs/Cameras/flyCamera";
  55965. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55966. export * from "babylonjs/Cameras/followCamera";
  55967. export * from "babylonjs/Cameras/followCameraInputsManager";
  55968. export * from "babylonjs/Cameras/gamepadCamera";
  55969. export * from "babylonjs/Cameras/Stereoscopic/index";
  55970. export * from "babylonjs/Cameras/universalCamera";
  55971. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55972. export * from "babylonjs/Cameras/VR/index";
  55973. export * from "babylonjs/Cameras/RigModes/index";
  55974. }
  55975. declare module "babylonjs/Collisions/index" {
  55976. export * from "babylonjs/Collisions/collider";
  55977. export * from "babylonjs/Collisions/collisionCoordinator";
  55978. export * from "babylonjs/Collisions/pickingInfo";
  55979. export * from "babylonjs/Collisions/intersectionInfo";
  55980. export * from "babylonjs/Collisions/meshCollisionData";
  55981. }
  55982. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55983. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55984. import { Vector3 } from "babylonjs/Maths/math.vector";
  55985. import { Ray } from "babylonjs/Culling/ray";
  55986. import { Plane } from "babylonjs/Maths/math.plane";
  55987. /**
  55988. * Contains an array of blocks representing the octree
  55989. */
  55990. export interface IOctreeContainer<T> {
  55991. /**
  55992. * Blocks within the octree
  55993. */
  55994. blocks: Array<OctreeBlock<T>>;
  55995. }
  55996. /**
  55997. * Class used to store a cell in an octree
  55998. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55999. */
  56000. export class OctreeBlock<T> {
  56001. /**
  56002. * Gets the content of the current block
  56003. */
  56004. entries: T[];
  56005. /**
  56006. * Gets the list of block children
  56007. */
  56008. blocks: Array<OctreeBlock<T>>;
  56009. private _depth;
  56010. private _maxDepth;
  56011. private _capacity;
  56012. private _minPoint;
  56013. private _maxPoint;
  56014. private _boundingVectors;
  56015. private _creationFunc;
  56016. /**
  56017. * Creates a new block
  56018. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  56019. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  56020. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56021. * @param depth defines the current depth of this block in the octree
  56022. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  56023. * @param creationFunc defines a callback to call when an element is added to the block
  56024. */
  56025. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  56026. /**
  56027. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56028. */
  56029. get capacity(): number;
  56030. /**
  56031. * Gets the minimum vector (in world space) of the block's bounding box
  56032. */
  56033. get minPoint(): Vector3;
  56034. /**
  56035. * Gets the maximum vector (in world space) of the block's bounding box
  56036. */
  56037. get maxPoint(): Vector3;
  56038. /**
  56039. * Add a new element to this block
  56040. * @param entry defines the element to add
  56041. */
  56042. addEntry(entry: T): void;
  56043. /**
  56044. * Remove an element from this block
  56045. * @param entry defines the element to remove
  56046. */
  56047. removeEntry(entry: T): void;
  56048. /**
  56049. * Add an array of elements to this block
  56050. * @param entries defines the array of elements to add
  56051. */
  56052. addEntries(entries: T[]): void;
  56053. /**
  56054. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  56055. * @param frustumPlanes defines the frustum planes to test
  56056. * @param selection defines the array to store current content if selection is positive
  56057. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56058. */
  56059. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56060. /**
  56061. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  56062. * @param sphereCenter defines the bounding sphere center
  56063. * @param sphereRadius defines the bounding sphere radius
  56064. * @param selection defines the array to store current content if selection is positive
  56065. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56066. */
  56067. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56068. /**
  56069. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  56070. * @param ray defines the ray to test with
  56071. * @param selection defines the array to store current content if selection is positive
  56072. */
  56073. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  56074. /**
  56075. * Subdivide the content into child blocks (this block will then be empty)
  56076. */
  56077. createInnerBlocks(): void;
  56078. /**
  56079. * @hidden
  56080. */
  56081. 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;
  56082. }
  56083. }
  56084. declare module "babylonjs/Culling/Octrees/octree" {
  56085. import { SmartArray } from "babylonjs/Misc/smartArray";
  56086. import { Vector3 } from "babylonjs/Maths/math.vector";
  56087. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56089. import { Ray } from "babylonjs/Culling/ray";
  56090. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  56091. import { Plane } from "babylonjs/Maths/math.plane";
  56092. /**
  56093. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  56094. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56095. */
  56096. export class Octree<T> {
  56097. /** 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.) */
  56098. maxDepth: number;
  56099. /**
  56100. * Blocks within the octree containing objects
  56101. */
  56102. blocks: Array<OctreeBlock<T>>;
  56103. /**
  56104. * Content stored in the octree
  56105. */
  56106. dynamicContent: T[];
  56107. private _maxBlockCapacity;
  56108. private _selectionContent;
  56109. private _creationFunc;
  56110. /**
  56111. * Creates a octree
  56112. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56113. * @param creationFunc function to be used to instatiate the octree
  56114. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  56115. * @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.)
  56116. */
  56117. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  56118. /** 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.) */
  56119. maxDepth?: number);
  56120. /**
  56121. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  56122. * @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);
  56123. * @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);
  56124. * @param entries meshes to be added to the octree blocks
  56125. */
  56126. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  56127. /**
  56128. * Adds a mesh to the octree
  56129. * @param entry Mesh to add to the octree
  56130. */
  56131. addMesh(entry: T): void;
  56132. /**
  56133. * Remove an element from the octree
  56134. * @param entry defines the element to remove
  56135. */
  56136. removeMesh(entry: T): void;
  56137. /**
  56138. * Selects an array of meshes within the frustum
  56139. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  56140. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  56141. * @returns array of meshes within the frustum
  56142. */
  56143. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  56144. /**
  56145. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  56146. * @param sphereCenter defines the bounding sphere center
  56147. * @param sphereRadius defines the bounding sphere radius
  56148. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56149. * @returns an array of objects that intersect the sphere
  56150. */
  56151. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  56152. /**
  56153. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  56154. * @param ray defines the ray to test with
  56155. * @returns array of intersected objects
  56156. */
  56157. intersectsRay(ray: Ray): SmartArray<T>;
  56158. /**
  56159. * Adds a mesh into the octree block if it intersects the block
  56160. */
  56161. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  56162. /**
  56163. * Adds a submesh into the octree block if it intersects the block
  56164. */
  56165. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  56166. }
  56167. }
  56168. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  56169. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  56170. import { Scene } from "babylonjs/scene";
  56171. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56173. import { Ray } from "babylonjs/Culling/ray";
  56174. import { Octree } from "babylonjs/Culling/Octrees/octree";
  56175. import { Collider } from "babylonjs/Collisions/collider";
  56176. module "babylonjs/scene" {
  56177. interface Scene {
  56178. /**
  56179. * @hidden
  56180. * Backing Filed
  56181. */
  56182. _selectionOctree: Octree<AbstractMesh>;
  56183. /**
  56184. * Gets the octree used to boost mesh selection (picking)
  56185. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56186. */
  56187. selectionOctree: Octree<AbstractMesh>;
  56188. /**
  56189. * Creates or updates the octree used to boost selection (picking)
  56190. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56191. * @param maxCapacity defines the maximum capacity per leaf
  56192. * @param maxDepth defines the maximum depth of the octree
  56193. * @returns an octree of AbstractMesh
  56194. */
  56195. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  56196. }
  56197. }
  56198. module "babylonjs/Meshes/abstractMesh" {
  56199. interface AbstractMesh {
  56200. /**
  56201. * @hidden
  56202. * Backing Field
  56203. */
  56204. _submeshesOctree: Octree<SubMesh>;
  56205. /**
  56206. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  56207. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  56208. * @param maxCapacity defines the maximum size of each block (64 by default)
  56209. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  56210. * @returns the new octree
  56211. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  56212. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56213. */
  56214. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  56215. }
  56216. }
  56217. /**
  56218. * Defines the octree scene component responsible to manage any octrees
  56219. * in a given scene.
  56220. */
  56221. export class OctreeSceneComponent {
  56222. /**
  56223. * The component name help to identify the component in the list of scene components.
  56224. */
  56225. readonly name: string;
  56226. /**
  56227. * The scene the component belongs to.
  56228. */
  56229. scene: Scene;
  56230. /**
  56231. * Indicates if the meshes have been checked to make sure they are isEnabled()
  56232. */
  56233. readonly checksIsEnabled: boolean;
  56234. /**
  56235. * Creates a new instance of the component for the given scene
  56236. * @param scene Defines the scene to register the component in
  56237. */
  56238. constructor(scene: Scene);
  56239. /**
  56240. * Registers the component in a given scene
  56241. */
  56242. register(): void;
  56243. /**
  56244. * Return the list of active meshes
  56245. * @returns the list of active meshes
  56246. */
  56247. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  56248. /**
  56249. * Return the list of active sub meshes
  56250. * @param mesh The mesh to get the candidates sub meshes from
  56251. * @returns the list of active sub meshes
  56252. */
  56253. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  56254. private _tempRay;
  56255. /**
  56256. * Return the list of sub meshes intersecting with a given local ray
  56257. * @param mesh defines the mesh to find the submesh for
  56258. * @param localRay defines the ray in local space
  56259. * @returns the list of intersecting sub meshes
  56260. */
  56261. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  56262. /**
  56263. * Return the list of sub meshes colliding with a collider
  56264. * @param mesh defines the mesh to find the submesh for
  56265. * @param collider defines the collider to evaluate the collision against
  56266. * @returns the list of colliding sub meshes
  56267. */
  56268. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  56269. /**
  56270. * Rebuilds the elements related to this component in case of
  56271. * context lost for instance.
  56272. */
  56273. rebuild(): void;
  56274. /**
  56275. * Disposes the component and the associated ressources.
  56276. */
  56277. dispose(): void;
  56278. }
  56279. }
  56280. declare module "babylonjs/Culling/Octrees/index" {
  56281. export * from "babylonjs/Culling/Octrees/octree";
  56282. export * from "babylonjs/Culling/Octrees/octreeBlock";
  56283. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  56284. }
  56285. declare module "babylonjs/Culling/index" {
  56286. export * from "babylonjs/Culling/boundingBox";
  56287. export * from "babylonjs/Culling/boundingInfo";
  56288. export * from "babylonjs/Culling/boundingSphere";
  56289. export * from "babylonjs/Culling/Octrees/index";
  56290. export * from "babylonjs/Culling/ray";
  56291. }
  56292. declare module "babylonjs/Gizmos/gizmo" {
  56293. import { Observer } from "babylonjs/Misc/observable";
  56294. import { Nullable } from "babylonjs/types";
  56295. import { IDisposable } from "babylonjs/scene";
  56296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56297. import { Mesh } from "babylonjs/Meshes/mesh";
  56298. import { Node } from "babylonjs/node";
  56299. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56300. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56301. import { PointerInfo } from "babylonjs/Events/pointerEvents";
  56302. /**
  56303. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  56304. */
  56305. export interface GizmoAxisCache {
  56306. /** Mesh used to runder the Gizmo */
  56307. gizmoMeshes: Mesh[];
  56308. /** Mesh used to detect user interaction with Gizmo */
  56309. colliderMeshes: Mesh[];
  56310. /** Material used to inicate color of gizmo mesh */
  56311. material: StandardMaterial;
  56312. /** Material used to inicate hover state of the Gizmo */
  56313. hoverMaterial: StandardMaterial;
  56314. /** Material used to inicate disabled state of the Gizmo */
  56315. disableMaterial: StandardMaterial;
  56316. /** Used to indicate Active state of the Gizmo */
  56317. active: boolean;
  56318. }
  56319. /**
  56320. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  56321. */
  56322. export class Gizmo implements IDisposable {
  56323. /** The utility layer the gizmo will be added to */
  56324. gizmoLayer: UtilityLayerRenderer;
  56325. /**
  56326. * The root mesh of the gizmo
  56327. */
  56328. _rootMesh: Mesh;
  56329. private _attachedMesh;
  56330. private _attachedNode;
  56331. /**
  56332. * Ratio for the scale of the gizmo (Default: 1)
  56333. */
  56334. protected _scaleRatio: number;
  56335. /**
  56336. * boolean updated by pointermove when a gizmo mesh is hovered
  56337. */
  56338. protected _isHovered: boolean;
  56339. /**
  56340. * Ratio for the scale of the gizmo (Default: 1)
  56341. */
  56342. set scaleRatio(value: number);
  56343. get scaleRatio(): number;
  56344. /**
  56345. * True when the mouse pointer is hovered a gizmo mesh
  56346. */
  56347. get isHovered(): boolean;
  56348. /**
  56349. * If a custom mesh has been set (Default: false)
  56350. */
  56351. protected _customMeshSet: boolean;
  56352. /**
  56353. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  56354. * * When set, interactions will be enabled
  56355. */
  56356. get attachedMesh(): Nullable<AbstractMesh>;
  56357. set attachedMesh(value: Nullable<AbstractMesh>);
  56358. /**
  56359. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  56360. * * When set, interactions will be enabled
  56361. */
  56362. get attachedNode(): Nullable<Node>;
  56363. set attachedNode(value: Nullable<Node>);
  56364. /**
  56365. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56366. * @param mesh The mesh to replace the default mesh of the gizmo
  56367. */
  56368. setCustomMesh(mesh: Mesh): void;
  56369. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  56370. /**
  56371. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  56372. */
  56373. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56374. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56375. /**
  56376. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  56377. */
  56378. updateGizmoPositionToMatchAttachedMesh: boolean;
  56379. /**
  56380. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  56381. */
  56382. updateScale: boolean;
  56383. protected _interactionsEnabled: boolean;
  56384. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56385. private _beforeRenderObserver;
  56386. private _tempQuaternion;
  56387. private _tempVector;
  56388. private _tempVector2;
  56389. private _tempMatrix1;
  56390. private _tempMatrix2;
  56391. private _rightHandtoLeftHandMatrix;
  56392. /**
  56393. * Creates a gizmo
  56394. * @param gizmoLayer The utility layer the gizmo will be added to
  56395. */
  56396. constructor(
  56397. /** The utility layer the gizmo will be added to */
  56398. gizmoLayer?: UtilityLayerRenderer);
  56399. /**
  56400. * Updates the gizmo to match the attached mesh's position/rotation
  56401. */
  56402. protected _update(): void;
  56403. /**
  56404. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  56405. * @param value Node, TransformNode or mesh
  56406. */
  56407. protected _matrixChanged(): void;
  56408. /**
  56409. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  56410. * @param gizmoLayer The utility layer the gizmo will be added to
  56411. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  56412. * @returns {Observer<PointerInfo>} pointerObserver
  56413. */
  56414. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  56415. /**
  56416. * Disposes of the gizmo
  56417. */
  56418. dispose(): void;
  56419. }
  56420. }
  56421. declare module "babylonjs/Gizmos/planeDragGizmo" {
  56422. import { Observable } from "babylonjs/Misc/observable";
  56423. import { Nullable } from "babylonjs/types";
  56424. import { Vector3 } from "babylonjs/Maths/math.vector";
  56425. import { Color3 } from "babylonjs/Maths/math.color";
  56426. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56427. import { Node } from "babylonjs/node";
  56428. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56429. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56430. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56431. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56432. import { Scene } from "babylonjs/scene";
  56433. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56434. /**
  56435. * Single plane drag gizmo
  56436. */
  56437. export class PlaneDragGizmo extends Gizmo {
  56438. /**
  56439. * Drag behavior responsible for the gizmos dragging interactions
  56440. */
  56441. dragBehavior: PointerDragBehavior;
  56442. private _pointerObserver;
  56443. /**
  56444. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56445. */
  56446. snapDistance: number;
  56447. /**
  56448. * Event that fires each time the gizmo snaps to a new location.
  56449. * * snapDistance is the the change in distance
  56450. */
  56451. onSnapObservable: Observable<{
  56452. snapDistance: number;
  56453. }>;
  56454. private _gizmoMesh;
  56455. private _coloredMaterial;
  56456. private _hoverMaterial;
  56457. private _disableMaterial;
  56458. private _isEnabled;
  56459. private _parent;
  56460. private _dragging;
  56461. /** @hidden */
  56462. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  56463. /**
  56464. * Creates a PlaneDragGizmo
  56465. * @param gizmoLayer The utility layer the gizmo will be added to
  56466. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  56467. * @param color The color of the gizmo
  56468. */
  56469. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  56470. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56471. /**
  56472. * If the gizmo is enabled
  56473. */
  56474. set isEnabled(value: boolean);
  56475. get isEnabled(): boolean;
  56476. /**
  56477. * Disposes of the gizmo
  56478. */
  56479. dispose(): void;
  56480. }
  56481. }
  56482. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56483. import { Observable } from "babylonjs/Misc/observable";
  56484. import { Nullable } from "babylonjs/types";
  56485. import { Vector3 } from "babylonjs/Maths/math.vector";
  56486. import { Color3 } from "babylonjs/Maths/math.color";
  56487. import "babylonjs/Meshes/Builders/linesBuilder";
  56488. import { Node } from "babylonjs/node";
  56489. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56490. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56491. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56492. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56493. /**
  56494. * Single plane rotation gizmo
  56495. */
  56496. export class PlaneRotationGizmo extends Gizmo {
  56497. /**
  56498. * Drag behavior responsible for the gizmos dragging interactions
  56499. */
  56500. dragBehavior: PointerDragBehavior;
  56501. private _pointerObserver;
  56502. /**
  56503. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56504. */
  56505. snapDistance: number;
  56506. /**
  56507. * Event that fires each time the gizmo snaps to a new location.
  56508. * * snapDistance is the the change in distance
  56509. */
  56510. onSnapObservable: Observable<{
  56511. snapDistance: number;
  56512. }>;
  56513. private _isEnabled;
  56514. private _parent;
  56515. private _coloredMaterial;
  56516. private _hoverMaterial;
  56517. private _disableMaterial;
  56518. private _gizmoMesh;
  56519. private _rotationCircle;
  56520. private _dragging;
  56521. private static _CircleConstants;
  56522. /**
  56523. * Creates a PlaneRotationGizmo
  56524. * @param gizmoLayer The utility layer the gizmo will be added to
  56525. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56526. * @param color The color of the gizmo
  56527. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56528. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56529. * @param thickness display gizmo axis thickness
  56530. */
  56531. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56532. /** Create Geometry for Gizmo */
  56533. private _createGizmoMesh;
  56534. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56535. private setupRotationCircle;
  56536. private updateRotationPath;
  56537. private updateRotationCircle;
  56538. /**
  56539. * If the gizmo is enabled
  56540. */
  56541. set isEnabled(value: boolean);
  56542. get isEnabled(): boolean;
  56543. /**
  56544. * Disposes of the gizmo
  56545. */
  56546. dispose(): void;
  56547. }
  56548. }
  56549. declare module "babylonjs/Gizmos/rotationGizmo" {
  56550. import { Observable } from "babylonjs/Misc/observable";
  56551. import { Nullable } from "babylonjs/types";
  56552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56553. import { Mesh } from "babylonjs/Meshes/mesh";
  56554. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  56555. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56556. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56557. import { Node } from "babylonjs/node";
  56558. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  56559. /**
  56560. * Gizmo that enables rotating a mesh along 3 axis
  56561. */
  56562. export class RotationGizmo extends Gizmo {
  56563. /**
  56564. * Internal gizmo used for interactions on the x axis
  56565. */
  56566. xGizmo: PlaneRotationGizmo;
  56567. /**
  56568. * Internal gizmo used for interactions on the y axis
  56569. */
  56570. yGizmo: PlaneRotationGizmo;
  56571. /**
  56572. * Internal gizmo used for interactions on the z axis
  56573. */
  56574. zGizmo: PlaneRotationGizmo;
  56575. /** Fires an event when any of it's sub gizmos are dragged */
  56576. onDragStartObservable: Observable<unknown>;
  56577. /** Fires an event when any of it's sub gizmos are released from dragging */
  56578. onDragEndObservable: Observable<unknown>;
  56579. private _meshAttached;
  56580. private _nodeAttached;
  56581. private _observables;
  56582. /** Node Caching for quick lookup */
  56583. private _gizmoAxisCache;
  56584. get attachedMesh(): Nullable<AbstractMesh>;
  56585. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56586. get attachedNode(): Nullable<Node>;
  56587. set attachedNode(node: Nullable<Node>);
  56588. protected _checkBillboardTransform(): void;
  56589. /**
  56590. * True when the mouse pointer is hovering a gizmo mesh
  56591. */
  56592. get isHovered(): boolean;
  56593. /**
  56594. * Creates a RotationGizmo
  56595. * @param gizmoLayer The utility layer the gizmo will be added to
  56596. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56597. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56598. * @param thickness display gizmo axis thickness
  56599. */
  56600. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  56601. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56602. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56603. /**
  56604. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56605. */
  56606. set snapDistance(value: number);
  56607. get snapDistance(): number;
  56608. /**
  56609. * Ratio for the scale of the gizmo (Default: 1)
  56610. */
  56611. set scaleRatio(value: number);
  56612. get scaleRatio(): number;
  56613. /**
  56614. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  56615. * @param mesh Axis gizmo mesh
  56616. * @param cache Gizmo axis definition used for reactive gizmo UI
  56617. */
  56618. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  56619. /**
  56620. * Disposes of the gizmo
  56621. */
  56622. dispose(): void;
  56623. /**
  56624. * CustomMeshes are not supported by this gizmo
  56625. * @param mesh The mesh to replace the default mesh of the gizmo
  56626. */
  56627. setCustomMesh(mesh: Mesh): void;
  56628. }
  56629. }
  56630. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  56631. import { Scene } from "babylonjs/scene";
  56632. import { Vector4 } from "babylonjs/Maths/math.vector";
  56633. import { Color4 } from "babylonjs/Maths/math.color";
  56634. import { Mesh } from "babylonjs/Meshes/mesh";
  56635. import { Nullable } from "babylonjs/types";
  56636. /**
  56637. * Class containing static functions to help procedurally build meshes
  56638. */
  56639. export class PolyhedronBuilder {
  56640. /**
  56641. * Creates a polyhedron mesh
  56642. * * 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
  56643. * * The parameter `size` (positive float, default 1) sets the polygon size
  56644. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56645. * * 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`
  56646. * * 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
  56647. * * 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)`)
  56648. * * 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
  56649. * * 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
  56650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56653. * @param name defines the name of the mesh
  56654. * @param options defines the options used to create the mesh
  56655. * @param scene defines the hosting scene
  56656. * @returns the polyhedron mesh
  56657. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56658. */
  56659. static CreatePolyhedron(name: string, options: {
  56660. type?: number;
  56661. size?: number;
  56662. sizeX?: number;
  56663. sizeY?: number;
  56664. sizeZ?: number;
  56665. custom?: any;
  56666. faceUV?: Vector4[];
  56667. faceColors?: Color4[];
  56668. flat?: boolean;
  56669. updatable?: boolean;
  56670. sideOrientation?: number;
  56671. frontUVs?: Vector4;
  56672. backUVs?: Vector4;
  56673. }, scene?: Nullable<Scene>): Mesh;
  56674. }
  56675. }
  56676. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56677. import { Nullable } from "babylonjs/types";
  56678. import { Scene } from "babylonjs/scene";
  56679. import { Vector4 } from "babylonjs/Maths/math.vector";
  56680. import { Color4 } from "babylonjs/Maths/math.color";
  56681. import { Mesh } from "babylonjs/Meshes/mesh";
  56682. /**
  56683. * Class containing static functions to help procedurally build meshes
  56684. */
  56685. export class BoxBuilder {
  56686. /**
  56687. * Creates a box mesh
  56688. * * The parameter `size` sets the size (float) of each box side (default 1)
  56689. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56690. * * 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)
  56691. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56692. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56693. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56695. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56696. * @param name defines the name of the mesh
  56697. * @param options defines the options used to create the mesh
  56698. * @param scene defines the hosting scene
  56699. * @returns the box mesh
  56700. */
  56701. static CreateBox(name: string, options: {
  56702. size?: number;
  56703. width?: number;
  56704. height?: number;
  56705. depth?: number;
  56706. faceUV?: Vector4[];
  56707. faceColors?: Color4[];
  56708. sideOrientation?: number;
  56709. frontUVs?: Vector4;
  56710. backUVs?: Vector4;
  56711. wrap?: boolean;
  56712. topBaseAt?: number;
  56713. bottomBaseAt?: number;
  56714. updatable?: boolean;
  56715. }, scene?: Nullable<Scene>): Mesh;
  56716. }
  56717. }
  56718. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  56719. import { Observable } from "babylonjs/Misc/observable";
  56720. import { Nullable } from "babylonjs/types";
  56721. import { Vector3 } from "babylonjs/Maths/math.vector";
  56722. import { Node } from "babylonjs/node";
  56723. import { Mesh } from "babylonjs/Meshes/mesh";
  56724. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56725. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56726. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56727. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56728. import { Color3 } from "babylonjs/Maths/math.color";
  56729. /**
  56730. * Single axis scale gizmo
  56731. */
  56732. export class AxisScaleGizmo extends Gizmo {
  56733. /**
  56734. * Drag behavior responsible for the gizmos dragging interactions
  56735. */
  56736. dragBehavior: PointerDragBehavior;
  56737. private _pointerObserver;
  56738. /**
  56739. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56740. */
  56741. snapDistance: number;
  56742. /**
  56743. * Event that fires each time the gizmo snaps to a new location.
  56744. * * snapDistance is the the change in distance
  56745. */
  56746. onSnapObservable: Observable<{
  56747. snapDistance: number;
  56748. }>;
  56749. /**
  56750. * If the scaling operation should be done on all axis (default: false)
  56751. */
  56752. uniformScaling: boolean;
  56753. /**
  56754. * Custom sensitivity value for the drag strength
  56755. */
  56756. sensitivity: number;
  56757. private _isEnabled;
  56758. private _parent;
  56759. private _gizmoMesh;
  56760. private _coloredMaterial;
  56761. private _hoverMaterial;
  56762. private _disableMaterial;
  56763. private _dragging;
  56764. private _tmpVector;
  56765. private _tmpMatrix;
  56766. private _tmpMatrix2;
  56767. /**
  56768. * Creates an AxisScaleGizmo
  56769. * @param gizmoLayer The utility layer the gizmo will be added to
  56770. * @param dragAxis The axis which the gizmo will be able to scale on
  56771. * @param color The color of the gizmo
  56772. * @param thickness display gizmo axis thickness
  56773. */
  56774. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56775. /** Create Geometry for Gizmo */
  56776. private _createGizmoMesh;
  56777. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56778. /**
  56779. * If the gizmo is enabled
  56780. */
  56781. set isEnabled(value: boolean);
  56782. get isEnabled(): boolean;
  56783. /**
  56784. * Disposes of the gizmo
  56785. */
  56786. dispose(): void;
  56787. /**
  56788. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56789. * @param mesh The mesh to replace the default mesh of the gizmo
  56790. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56791. */
  56792. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56793. }
  56794. }
  56795. declare module "babylonjs/Gizmos/scaleGizmo" {
  56796. import { Observable } from "babylonjs/Misc/observable";
  56797. import { Nullable } from "babylonjs/types";
  56798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56799. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  56800. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  56801. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56802. import { Mesh } from "babylonjs/Meshes/mesh";
  56803. import { Node } from "babylonjs/node";
  56804. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  56805. /**
  56806. * Gizmo that enables scaling a mesh along 3 axis
  56807. */
  56808. export class ScaleGizmo extends Gizmo {
  56809. /**
  56810. * Internal gizmo used for interactions on the x axis
  56811. */
  56812. xGizmo: AxisScaleGizmo;
  56813. /**
  56814. * Internal gizmo used for interactions on the y axis
  56815. */
  56816. yGizmo: AxisScaleGizmo;
  56817. /**
  56818. * Internal gizmo used for interactions on the z axis
  56819. */
  56820. zGizmo: AxisScaleGizmo;
  56821. /**
  56822. * Internal gizmo used to scale all axis equally
  56823. */
  56824. uniformScaleGizmo: AxisScaleGizmo;
  56825. private _meshAttached;
  56826. private _nodeAttached;
  56827. private _snapDistance;
  56828. private _uniformScalingMesh;
  56829. private _octahedron;
  56830. private _sensitivity;
  56831. private _coloredMaterial;
  56832. private _hoverMaterial;
  56833. private _disableMaterial;
  56834. private _observables;
  56835. /** Node Caching for quick lookup */
  56836. private _gizmoAxisCache;
  56837. /** Fires an event when any of it's sub gizmos are dragged */
  56838. onDragStartObservable: Observable<unknown>;
  56839. /** Fires an event when any of it's sub gizmos are released from dragging */
  56840. onDragEndObservable: Observable<unknown>;
  56841. get attachedMesh(): Nullable<AbstractMesh>;
  56842. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56843. get attachedNode(): Nullable<Node>;
  56844. set attachedNode(node: Nullable<Node>);
  56845. /**
  56846. * True when the mouse pointer is hovering a gizmo mesh
  56847. */
  56848. get isHovered(): boolean;
  56849. /**
  56850. * Creates a ScaleGizmo
  56851. * @param gizmoLayer The utility layer the gizmo will be added to
  56852. * @param thickness display gizmo axis thickness
  56853. */
  56854. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  56855. /** Create Geometry for Gizmo */
  56856. private _createUniformScaleMesh;
  56857. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56858. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56859. /**
  56860. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56861. */
  56862. set snapDistance(value: number);
  56863. get snapDistance(): number;
  56864. /**
  56865. * Ratio for the scale of the gizmo (Default: 1)
  56866. */
  56867. set scaleRatio(value: number);
  56868. get scaleRatio(): number;
  56869. /**
  56870. * Sensitivity factor for dragging (Default: 1)
  56871. */
  56872. set sensitivity(value: number);
  56873. get sensitivity(): number;
  56874. /**
  56875. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  56876. * @param mesh Axis gizmo mesh
  56877. * @param cache Gizmo axis definition used for reactive gizmo UI
  56878. */
  56879. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  56880. /**
  56881. * Disposes of the gizmo
  56882. */
  56883. dispose(): void;
  56884. }
  56885. }
  56886. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56887. import { Observable } from "babylonjs/Misc/observable";
  56888. import { Nullable } from "babylonjs/types";
  56889. import { Vector3 } from "babylonjs/Maths/math.vector";
  56890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56891. import { Mesh } from "babylonjs/Meshes/mesh";
  56892. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56893. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56894. import { Color3 } from "babylonjs/Maths/math.color";
  56895. import "babylonjs/Meshes/Builders/boxBuilder";
  56896. /**
  56897. * Bounding box gizmo
  56898. */
  56899. export class BoundingBoxGizmo extends Gizmo {
  56900. private _lineBoundingBox;
  56901. private _rotateSpheresParent;
  56902. private _scaleBoxesParent;
  56903. private _boundingDimensions;
  56904. private _renderObserver;
  56905. private _pointerObserver;
  56906. private _scaleDragSpeed;
  56907. private _tmpQuaternion;
  56908. private _tmpVector;
  56909. private _tmpRotationMatrix;
  56910. /**
  56911. * 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)
  56912. */
  56913. ignoreChildren: boolean;
  56914. /**
  56915. * 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)
  56916. */
  56917. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56918. /**
  56919. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56920. */
  56921. rotationSphereSize: number;
  56922. /**
  56923. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56924. */
  56925. scaleBoxSize: number;
  56926. /**
  56927. * 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)
  56928. */
  56929. fixedDragMeshScreenSize: boolean;
  56930. /**
  56931. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56932. */
  56933. fixedDragMeshScreenSizeDistanceFactor: number;
  56934. /**
  56935. * Fired when a rotation sphere or scale box is dragged
  56936. */
  56937. onDragStartObservable: Observable<{}>;
  56938. /**
  56939. * Fired when a scale box is dragged
  56940. */
  56941. onScaleBoxDragObservable: Observable<{}>;
  56942. /**
  56943. * Fired when a scale box drag is ended
  56944. */
  56945. onScaleBoxDragEndObservable: Observable<{}>;
  56946. /**
  56947. * Fired when a rotation sphere is dragged
  56948. */
  56949. onRotationSphereDragObservable: Observable<{}>;
  56950. /**
  56951. * Fired when a rotation sphere drag is ended
  56952. */
  56953. onRotationSphereDragEndObservable: Observable<{}>;
  56954. /**
  56955. * 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)
  56956. */
  56957. scalePivot: Nullable<Vector3>;
  56958. /**
  56959. * Mesh used as a pivot to rotate the attached node
  56960. */
  56961. private _anchorMesh;
  56962. private _existingMeshScale;
  56963. private _dragMesh;
  56964. private pointerDragBehavior;
  56965. private coloredMaterial;
  56966. private hoverColoredMaterial;
  56967. /**
  56968. * Sets the color of the bounding box gizmo
  56969. * @param color the color to set
  56970. */
  56971. setColor(color: Color3): void;
  56972. /**
  56973. * Creates an BoundingBoxGizmo
  56974. * @param gizmoLayer The utility layer the gizmo will be added to
  56975. * @param color The color of the gizmo
  56976. */
  56977. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56978. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56979. private _selectNode;
  56980. /**
  56981. * Updates the bounding box information for the Gizmo
  56982. */
  56983. updateBoundingBox(): void;
  56984. private _updateRotationSpheres;
  56985. private _updateScaleBoxes;
  56986. /**
  56987. * Enables rotation on the specified axis and disables rotation on the others
  56988. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56989. */
  56990. setEnabledRotationAxis(axis: string): void;
  56991. /**
  56992. * Enables/disables scaling
  56993. * @param enable if scaling should be enabled
  56994. * @param homogeneousScaling defines if scaling should only be homogeneous
  56995. */
  56996. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56997. private _updateDummy;
  56998. /**
  56999. * Enables a pointer drag behavior on the bounding box of the gizmo
  57000. */
  57001. enableDragBehavior(): void;
  57002. /**
  57003. * Disposes of the gizmo
  57004. */
  57005. dispose(): void;
  57006. /**
  57007. * 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)
  57008. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57009. * @returns the bounding box mesh with the passed in mesh as a child
  57010. */
  57011. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57012. /**
  57013. * CustomMeshes are not supported by this gizmo
  57014. * @param mesh The mesh to replace the default mesh of the gizmo
  57015. */
  57016. setCustomMesh(mesh: Mesh): void;
  57017. }
  57018. }
  57019. declare module "babylonjs/Gizmos/gizmoManager" {
  57020. import { Observable } from "babylonjs/Misc/observable";
  57021. import { Nullable } from "babylonjs/types";
  57022. import { Scene, IDisposable } from "babylonjs/scene";
  57023. import { Node } from "babylonjs/node";
  57024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57025. import { Mesh } from "babylonjs/Meshes/mesh";
  57026. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57027. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  57028. import { GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  57029. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  57030. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  57031. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  57032. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  57033. /**
  57034. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57035. */
  57036. export class GizmoManager implements IDisposable {
  57037. private scene;
  57038. /**
  57039. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57040. */
  57041. gizmos: {
  57042. positionGizmo: Nullable<PositionGizmo>;
  57043. rotationGizmo: Nullable<RotationGizmo>;
  57044. scaleGizmo: Nullable<ScaleGizmo>;
  57045. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57046. };
  57047. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57048. clearGizmoOnEmptyPointerEvent: boolean;
  57049. /** Fires an event when the manager is attached to a mesh */
  57050. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57051. /** Fires an event when the manager is attached to a node */
  57052. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57053. private _gizmosEnabled;
  57054. private _pointerObservers;
  57055. private _attachedMesh;
  57056. private _attachedNode;
  57057. private _boundingBoxColor;
  57058. private _defaultUtilityLayer;
  57059. private _defaultKeepDepthUtilityLayer;
  57060. private _thickness;
  57061. /** Node Caching for quick lookup */
  57062. private _gizmoAxisCache;
  57063. /**
  57064. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57065. */
  57066. boundingBoxDragBehavior: SixDofDragBehavior;
  57067. /**
  57068. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57069. */
  57070. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57071. /**
  57072. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57073. */
  57074. attachableNodes: Nullable<Array<Node>>;
  57075. /**
  57076. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57077. */
  57078. usePointerToAttachGizmos: boolean;
  57079. /**
  57080. * Utility layer that the bounding box gizmo belongs to
  57081. */
  57082. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57083. /**
  57084. * Utility layer that all gizmos besides bounding box belong to
  57085. */
  57086. get utilityLayer(): UtilityLayerRenderer;
  57087. /**
  57088. * True when the mouse pointer is hovering a gizmo mesh
  57089. */
  57090. get isHovered(): boolean;
  57091. /**
  57092. * Instatiates a gizmo manager
  57093. * @param scene the scene to overlay the gizmos on top of
  57094. * @param thickness display gizmo axis thickness
  57095. * @param utilityLayer the layer where gizmos are rendered
  57096. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  57097. */
  57098. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  57099. /**
  57100. * Subscribes to pointer down events, for attaching and detaching mesh
  57101. * @param scene The sceme layer the observer will be added to
  57102. */
  57103. private _attachToMeshPointerObserver;
  57104. /**
  57105. * Attaches a set of gizmos to the specified mesh
  57106. * @param mesh The mesh the gizmo's should be attached to
  57107. */
  57108. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57109. /**
  57110. * Attaches a set of gizmos to the specified node
  57111. * @param node The node the gizmo's should be attached to
  57112. */
  57113. attachToNode(node: Nullable<Node>): void;
  57114. /**
  57115. * If the position gizmo is enabled
  57116. */
  57117. set positionGizmoEnabled(value: boolean);
  57118. get positionGizmoEnabled(): boolean;
  57119. /**
  57120. * If the rotation gizmo is enabled
  57121. */
  57122. set rotationGizmoEnabled(value: boolean);
  57123. get rotationGizmoEnabled(): boolean;
  57124. /**
  57125. * If the scale gizmo is enabled
  57126. */
  57127. set scaleGizmoEnabled(value: boolean);
  57128. get scaleGizmoEnabled(): boolean;
  57129. /**
  57130. * If the boundingBox gizmo is enabled
  57131. */
  57132. set boundingBoxGizmoEnabled(value: boolean);
  57133. get boundingBoxGizmoEnabled(): boolean;
  57134. /**
  57135. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57136. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57137. */
  57138. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  57139. /**
  57140. * Disposes of the gizmo manager
  57141. */
  57142. dispose(): void;
  57143. }
  57144. }
  57145. declare module "babylonjs/Gizmos/positionGizmo" {
  57146. import { Observable } from "babylonjs/Misc/observable";
  57147. import { Nullable } from "babylonjs/types";
  57148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57149. import { Node } from "babylonjs/node";
  57150. import { Mesh } from "babylonjs/Meshes/mesh";
  57151. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  57152. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  57153. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  57154. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57155. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  57156. /**
  57157. * Gizmo that enables dragging a mesh along 3 axis
  57158. */
  57159. export class PositionGizmo extends Gizmo {
  57160. /**
  57161. * Internal gizmo used for interactions on the x axis
  57162. */
  57163. xGizmo: AxisDragGizmo;
  57164. /**
  57165. * Internal gizmo used for interactions on the y axis
  57166. */
  57167. yGizmo: AxisDragGizmo;
  57168. /**
  57169. * Internal gizmo used for interactions on the z axis
  57170. */
  57171. zGizmo: AxisDragGizmo;
  57172. /**
  57173. * Internal gizmo used for interactions on the yz plane
  57174. */
  57175. xPlaneGizmo: PlaneDragGizmo;
  57176. /**
  57177. * Internal gizmo used for interactions on the xz plane
  57178. */
  57179. yPlaneGizmo: PlaneDragGizmo;
  57180. /**
  57181. * Internal gizmo used for interactions on the xy plane
  57182. */
  57183. zPlaneGizmo: PlaneDragGizmo;
  57184. /**
  57185. * private variables
  57186. */
  57187. private _meshAttached;
  57188. private _nodeAttached;
  57189. private _snapDistance;
  57190. private _observables;
  57191. /** Node Caching for quick lookup */
  57192. private _gizmoAxisCache;
  57193. /** Fires an event when any of it's sub gizmos are dragged */
  57194. onDragStartObservable: Observable<unknown>;
  57195. /** Fires an event when any of it's sub gizmos are released from dragging */
  57196. onDragEndObservable: Observable<unknown>;
  57197. /**
  57198. * If set to true, planar drag is enabled
  57199. */
  57200. private _planarGizmoEnabled;
  57201. get attachedMesh(): Nullable<AbstractMesh>;
  57202. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57203. get attachedNode(): Nullable<Node>;
  57204. set attachedNode(node: Nullable<Node>);
  57205. /**
  57206. * True when the mouse pointer is hovering a gizmo mesh
  57207. */
  57208. get isHovered(): boolean;
  57209. /**
  57210. * Creates a PositionGizmo
  57211. * @param gizmoLayer The utility layer the gizmo will be added to
  57212. @param thickness display gizmo axis thickness
  57213. */
  57214. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57215. /**
  57216. * If the planar drag gizmo is enabled
  57217. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  57218. */
  57219. set planarGizmoEnabled(value: boolean);
  57220. get planarGizmoEnabled(): boolean;
  57221. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57222. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57223. /**
  57224. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57225. */
  57226. set snapDistance(value: number);
  57227. get snapDistance(): number;
  57228. /**
  57229. * Ratio for the scale of the gizmo (Default: 1)
  57230. */
  57231. set scaleRatio(value: number);
  57232. get scaleRatio(): number;
  57233. /**
  57234. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57235. * @param mesh Axis gizmo mesh
  57236. * @param cache Gizmo axis definition used for reactive gizmo UI
  57237. */
  57238. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57239. /**
  57240. * Disposes of the gizmo
  57241. */
  57242. dispose(): void;
  57243. /**
  57244. * CustomMeshes are not supported by this gizmo
  57245. * @param mesh The mesh to replace the default mesh of the gizmo
  57246. */
  57247. setCustomMesh(mesh: Mesh): void;
  57248. }
  57249. }
  57250. declare module "babylonjs/Gizmos/axisDragGizmo" {
  57251. import { Observable } from "babylonjs/Misc/observable";
  57252. import { Nullable } from "babylonjs/types";
  57253. import { Vector3 } from "babylonjs/Maths/math.vector";
  57254. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57255. import { Node } from "babylonjs/node";
  57256. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  57257. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  57258. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57259. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  57260. import { Scene } from "babylonjs/scene";
  57261. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  57262. import { Color3 } from "babylonjs/Maths/math.color";
  57263. /**
  57264. * Single axis drag gizmo
  57265. */
  57266. export class AxisDragGizmo extends Gizmo {
  57267. /**
  57268. * Drag behavior responsible for the gizmos dragging interactions
  57269. */
  57270. dragBehavior: PointerDragBehavior;
  57271. private _pointerObserver;
  57272. /**
  57273. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57274. */
  57275. snapDistance: number;
  57276. /**
  57277. * Event that fires each time the gizmo snaps to a new location.
  57278. * * snapDistance is the the change in distance
  57279. */
  57280. onSnapObservable: Observable<{
  57281. snapDistance: number;
  57282. }>;
  57283. private _isEnabled;
  57284. private _parent;
  57285. private _gizmoMesh;
  57286. private _coloredMaterial;
  57287. private _hoverMaterial;
  57288. private _disableMaterial;
  57289. private _dragging;
  57290. /** @hidden */
  57291. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  57292. /** @hidden */
  57293. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  57294. /**
  57295. * Creates an AxisDragGizmo
  57296. * @param gizmoLayer The utility layer the gizmo will be added to
  57297. * @param dragAxis The axis which the gizmo will be able to drag on
  57298. * @param color The color of the gizmo
  57299. * @param thickness display gizmo axis thickness
  57300. */
  57301. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  57302. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57303. /**
  57304. * If the gizmo is enabled
  57305. */
  57306. set isEnabled(value: boolean);
  57307. get isEnabled(): boolean;
  57308. /**
  57309. * Disposes of the gizmo
  57310. */
  57311. dispose(): void;
  57312. }
  57313. }
  57314. declare module "babylonjs/Debug/axesViewer" {
  57315. import { Vector3 } from "babylonjs/Maths/math.vector";
  57316. import { Nullable } from "babylonjs/types";
  57317. import { Scene } from "babylonjs/scene";
  57318. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57319. /**
  57320. * The Axes viewer will show 3 axes in a specific point in space
  57321. */
  57322. export class AxesViewer {
  57323. private _xAxis;
  57324. private _yAxis;
  57325. private _zAxis;
  57326. private _scaleLinesFactor;
  57327. private _instanced;
  57328. /**
  57329. * Gets the hosting scene
  57330. */
  57331. scene: Nullable<Scene>;
  57332. /**
  57333. * Gets or sets a number used to scale line length
  57334. */
  57335. scaleLines: number;
  57336. /** Gets the node hierarchy used to render x-axis */
  57337. get xAxis(): TransformNode;
  57338. /** Gets the node hierarchy used to render y-axis */
  57339. get yAxis(): TransformNode;
  57340. /** Gets the node hierarchy used to render z-axis */
  57341. get zAxis(): TransformNode;
  57342. /**
  57343. * Creates a new AxesViewer
  57344. * @param scene defines the hosting scene
  57345. * @param scaleLines defines a number used to scale line length (1 by default)
  57346. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  57347. * @param xAxis defines the node hierarchy used to render the x-axis
  57348. * @param yAxis defines the node hierarchy used to render the y-axis
  57349. * @param zAxis defines the node hierarchy used to render the z-axis
  57350. */
  57351. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  57352. /**
  57353. * Force the viewer to update
  57354. * @param position defines the position of the viewer
  57355. * @param xaxis defines the x axis of the viewer
  57356. * @param yaxis defines the y axis of the viewer
  57357. * @param zaxis defines the z axis of the viewer
  57358. */
  57359. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  57360. /**
  57361. * Creates an instance of this axes viewer.
  57362. * @returns a new axes viewer with instanced meshes
  57363. */
  57364. createInstance(): AxesViewer;
  57365. /** Releases resources */
  57366. dispose(): void;
  57367. private static _SetRenderingGroupId;
  57368. }
  57369. }
  57370. declare module "babylonjs/Debug/boneAxesViewer" {
  57371. import { Nullable } from "babylonjs/types";
  57372. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  57373. import { Vector3 } from "babylonjs/Maths/math.vector";
  57374. import { Mesh } from "babylonjs/Meshes/mesh";
  57375. import { Bone } from "babylonjs/Bones/bone";
  57376. import { Scene } from "babylonjs/scene";
  57377. /**
  57378. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  57379. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  57380. */
  57381. export class BoneAxesViewer extends AxesViewer {
  57382. /**
  57383. * Gets or sets the target mesh where to display the axes viewer
  57384. */
  57385. mesh: Nullable<Mesh>;
  57386. /**
  57387. * Gets or sets the target bone where to display the axes viewer
  57388. */
  57389. bone: Nullable<Bone>;
  57390. /** Gets current position */
  57391. pos: Vector3;
  57392. /** Gets direction of X axis */
  57393. xaxis: Vector3;
  57394. /** Gets direction of Y axis */
  57395. yaxis: Vector3;
  57396. /** Gets direction of Z axis */
  57397. zaxis: Vector3;
  57398. /**
  57399. * Creates a new BoneAxesViewer
  57400. * @param scene defines the hosting scene
  57401. * @param bone defines the target bone
  57402. * @param mesh defines the target mesh
  57403. * @param scaleLines defines a scaling factor for line length (1 by default)
  57404. */
  57405. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  57406. /**
  57407. * Force the viewer to update
  57408. */
  57409. update(): void;
  57410. /** Releases resources */
  57411. dispose(): void;
  57412. }
  57413. }
  57414. declare module "babylonjs/Debug/debugLayer" {
  57415. import { Scene } from "babylonjs/scene";
  57416. /**
  57417. * Interface used to define scene explorer extensibility option
  57418. */
  57419. export interface IExplorerExtensibilityOption {
  57420. /**
  57421. * Define the option label
  57422. */
  57423. label: string;
  57424. /**
  57425. * Defines the action to execute on click
  57426. */
  57427. action: (entity: any) => void;
  57428. }
  57429. /**
  57430. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  57431. */
  57432. export interface IExplorerExtensibilityGroup {
  57433. /**
  57434. * Defines a predicate to test if a given type mut be extended
  57435. */
  57436. predicate: (entity: any) => boolean;
  57437. /**
  57438. * Gets the list of options added to a type
  57439. */
  57440. entries: IExplorerExtensibilityOption[];
  57441. }
  57442. /**
  57443. * Interface used to define the options to use to create the Inspector
  57444. */
  57445. export interface IInspectorOptions {
  57446. /**
  57447. * Display in overlay mode (default: false)
  57448. */
  57449. overlay?: boolean;
  57450. /**
  57451. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  57452. */
  57453. globalRoot?: HTMLElement;
  57454. /**
  57455. * Display the Scene explorer
  57456. */
  57457. showExplorer?: boolean;
  57458. /**
  57459. * Display the property inspector
  57460. */
  57461. showInspector?: boolean;
  57462. /**
  57463. * Display in embed mode (both panes on the right)
  57464. */
  57465. embedMode?: boolean;
  57466. /**
  57467. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  57468. */
  57469. handleResize?: boolean;
  57470. /**
  57471. * Allow the panes to popup (default: true)
  57472. */
  57473. enablePopup?: boolean;
  57474. /**
  57475. * Allow the panes to be closed by users (default: true)
  57476. */
  57477. enableClose?: boolean;
  57478. /**
  57479. * Optional list of extensibility entries
  57480. */
  57481. explorerExtensibility?: IExplorerExtensibilityGroup[];
  57482. /**
  57483. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  57484. */
  57485. inspectorURL?: string;
  57486. /**
  57487. * Optional initial tab (default to DebugLayerTab.Properties)
  57488. */
  57489. initialTab?: DebugLayerTab;
  57490. }
  57491. module "babylonjs/scene" {
  57492. interface Scene {
  57493. /**
  57494. * @hidden
  57495. * Backing field
  57496. */
  57497. _debugLayer: DebugLayer;
  57498. /**
  57499. * Gets the debug layer (aka Inspector) associated with the scene
  57500. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57501. */
  57502. debugLayer: DebugLayer;
  57503. }
  57504. }
  57505. /**
  57506. * Enum of inspector action tab
  57507. */
  57508. export enum DebugLayerTab {
  57509. /**
  57510. * Properties tag (default)
  57511. */
  57512. Properties = 0,
  57513. /**
  57514. * Debug tab
  57515. */
  57516. Debug = 1,
  57517. /**
  57518. * Statistics tab
  57519. */
  57520. Statistics = 2,
  57521. /**
  57522. * Tools tab
  57523. */
  57524. Tools = 3,
  57525. /**
  57526. * Settings tab
  57527. */
  57528. Settings = 4
  57529. }
  57530. /**
  57531. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57532. * what is happening in your scene
  57533. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57534. */
  57535. export class DebugLayer {
  57536. /**
  57537. * Define the url to get the inspector script from.
  57538. * By default it uses the babylonjs CDN.
  57539. * @ignoreNaming
  57540. */
  57541. static InspectorURL: string;
  57542. private _scene;
  57543. private BJSINSPECTOR;
  57544. private _onPropertyChangedObservable?;
  57545. /**
  57546. * Observable triggered when a property is changed through the inspector.
  57547. */
  57548. get onPropertyChangedObservable(): any;
  57549. /**
  57550. * Instantiates a new debug layer.
  57551. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57552. * what is happening in your scene
  57553. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57554. * @param scene Defines the scene to inspect
  57555. */
  57556. constructor(scene: Scene);
  57557. /** Creates the inspector window. */
  57558. private _createInspector;
  57559. /**
  57560. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  57561. * @param entity defines the entity to select
  57562. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  57563. */
  57564. select(entity: any, lineContainerTitles?: string | string[]): void;
  57565. /** Get the inspector from bundle or global */
  57566. private _getGlobalInspector;
  57567. /**
  57568. * Get if the inspector is visible or not.
  57569. * @returns true if visible otherwise, false
  57570. */
  57571. isVisible(): boolean;
  57572. /**
  57573. * Hide the inspector and close its window.
  57574. */
  57575. hide(): void;
  57576. /**
  57577. * Update the scene in the inspector
  57578. */
  57579. setAsActiveScene(): void;
  57580. /**
  57581. * Launch the debugLayer.
  57582. * @param config Define the configuration of the inspector
  57583. * @return a promise fulfilled when the debug layer is visible
  57584. */
  57585. show(config?: IInspectorOptions): Promise<DebugLayer>;
  57586. }
  57587. }
  57588. declare module "babylonjs/Debug/physicsViewer" {
  57589. import { Nullable } from "babylonjs/types";
  57590. import { Scene } from "babylonjs/scene";
  57591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57592. import { Mesh } from "babylonjs/Meshes/mesh";
  57593. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57594. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57595. /**
  57596. * Used to show the physics impostor around the specific mesh
  57597. */
  57598. export class PhysicsViewer {
  57599. /** @hidden */
  57600. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  57601. /** @hidden */
  57602. protected _meshes: Array<Nullable<AbstractMesh>>;
  57603. /** @hidden */
  57604. protected _scene: Nullable<Scene>;
  57605. /** @hidden */
  57606. protected _numMeshes: number;
  57607. /** @hidden */
  57608. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  57609. private _renderFunction;
  57610. private _utilityLayer;
  57611. private _debugBoxMesh;
  57612. private _debugSphereMesh;
  57613. private _debugCylinderMesh;
  57614. private _debugMaterial;
  57615. private _debugMeshMeshes;
  57616. /**
  57617. * Creates a new PhysicsViewer
  57618. * @param scene defines the hosting scene
  57619. */
  57620. constructor(scene: Scene);
  57621. /** @hidden */
  57622. protected _updateDebugMeshes(): void;
  57623. /**
  57624. * Renders a specified physic impostor
  57625. * @param impostor defines the impostor to render
  57626. * @param targetMesh defines the mesh represented by the impostor
  57627. * @returns the new debug mesh used to render the impostor
  57628. */
  57629. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  57630. /**
  57631. * Hides a specified physic impostor
  57632. * @param impostor defines the impostor to hide
  57633. */
  57634. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  57635. private _getDebugMaterial;
  57636. private _getDebugBoxMesh;
  57637. private _getDebugSphereMesh;
  57638. private _getDebugCylinderMesh;
  57639. private _getDebugMeshMesh;
  57640. private _getDebugMesh;
  57641. /** Releases all resources */
  57642. dispose(): void;
  57643. }
  57644. }
  57645. declare module "babylonjs/Debug/rayHelper" {
  57646. import { Nullable } from "babylonjs/types";
  57647. import { Ray } from "babylonjs/Culling/ray";
  57648. import { Vector3 } from "babylonjs/Maths/math.vector";
  57649. import { Color3 } from "babylonjs/Maths/math.color";
  57650. import { Scene } from "babylonjs/scene";
  57651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57652. import "babylonjs/Meshes/Builders/linesBuilder";
  57653. /**
  57654. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  57655. * in order to better appreciate the issue one might have.
  57656. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  57657. */
  57658. export class RayHelper {
  57659. /**
  57660. * Defines the ray we are currently tryin to visualize.
  57661. */
  57662. ray: Nullable<Ray>;
  57663. private _renderPoints;
  57664. private _renderLine;
  57665. private _renderFunction;
  57666. private _scene;
  57667. private _onAfterRenderObserver;
  57668. private _onAfterStepObserver;
  57669. private _attachedToMesh;
  57670. private _meshSpaceDirection;
  57671. private _meshSpaceOrigin;
  57672. /**
  57673. * Helper function to create a colored helper in a scene in one line.
  57674. * @param ray Defines the ray we are currently tryin to visualize
  57675. * @param scene Defines the scene the ray is used in
  57676. * @param color Defines the color we want to see the ray in
  57677. * @returns The newly created ray helper.
  57678. */
  57679. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  57680. /**
  57681. * Instantiate a new ray helper.
  57682. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  57683. * in order to better appreciate the issue one might have.
  57684. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  57685. * @param ray Defines the ray we are currently tryin to visualize
  57686. */
  57687. constructor(ray: Ray);
  57688. /**
  57689. * Shows the ray we are willing to debug.
  57690. * @param scene Defines the scene the ray needs to be rendered in
  57691. * @param color Defines the color the ray needs to be rendered in
  57692. */
  57693. show(scene: Scene, color?: Color3): void;
  57694. /**
  57695. * Hides the ray we are debugging.
  57696. */
  57697. hide(): void;
  57698. private _render;
  57699. /**
  57700. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  57701. * @param mesh Defines the mesh we want the helper attached to
  57702. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  57703. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  57704. * @param length Defines the length of the ray
  57705. */
  57706. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  57707. /**
  57708. * Detach the ray helper from the mesh it has previously been attached to.
  57709. */
  57710. detachFromMesh(): void;
  57711. private _updateToMesh;
  57712. /**
  57713. * Dispose the helper and release its associated resources.
  57714. */
  57715. dispose(): void;
  57716. }
  57717. }
  57718. declare module "babylonjs/Debug/ISkeletonViewer" {
  57719. import { Skeleton } from "babylonjs/Bones/skeleton";
  57720. import { Color3 } from "babylonjs/Maths/math.color";
  57721. /**
  57722. * Defines the options associated with the creation of a SkeletonViewer.
  57723. */
  57724. export interface ISkeletonViewerOptions {
  57725. /** Should the system pause animations before building the Viewer? */
  57726. pauseAnimations: boolean;
  57727. /** Should the system return the skeleton to rest before building? */
  57728. returnToRest: boolean;
  57729. /** public Display Mode of the Viewer */
  57730. displayMode: number;
  57731. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  57732. displayOptions: ISkeletonViewerDisplayOptions;
  57733. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  57734. computeBonesUsingShaders: boolean;
  57735. /** Flag ignore non weighted bones */
  57736. useAllBones: boolean;
  57737. }
  57738. /**
  57739. * Defines how to display the various bone meshes for the viewer.
  57740. */
  57741. export interface ISkeletonViewerDisplayOptions {
  57742. /** How far down to start tapering the bone spurs */
  57743. midStep?: number;
  57744. /** How big is the midStep? */
  57745. midStepFactor?: number;
  57746. /** Base for the Sphere Size */
  57747. sphereBaseSize?: number;
  57748. /** The ratio of the sphere to the longest bone in units */
  57749. sphereScaleUnit?: number;
  57750. /** Ratio for the Sphere Size */
  57751. sphereFactor?: number;
  57752. /** Whether a spur should attach its far end to the child bone position */
  57753. spurFollowsChild?: boolean;
  57754. /** Whether to show local axes or not */
  57755. showLocalAxes?: boolean;
  57756. /** Length of each local axis */
  57757. localAxesSize?: number;
  57758. }
  57759. /**
  57760. * Defines the constructor options for the BoneWeight Shader.
  57761. */
  57762. export interface IBoneWeightShaderOptions {
  57763. /** Skeleton to Map */
  57764. skeleton: Skeleton;
  57765. /** Colors for Uninfluenced bones */
  57766. colorBase?: Color3;
  57767. /** Colors for 0.0-0.25 Weight bones */
  57768. colorZero?: Color3;
  57769. /** Color for 0.25-0.5 Weight Influence */
  57770. colorQuarter?: Color3;
  57771. /** Color for 0.5-0.75 Weight Influence */
  57772. colorHalf?: Color3;
  57773. /** Color for 0.75-1 Weight Influence */
  57774. colorFull?: Color3;
  57775. /** Color for Zero Weight Influence */
  57776. targetBoneIndex?: number;
  57777. }
  57778. /**
  57779. * Simple structure of the gradient steps for the Color Map.
  57780. */
  57781. export interface ISkeletonMapShaderColorMapKnot {
  57782. /** Color of the Knot */
  57783. color: Color3;
  57784. /** Location of the Knot */
  57785. location: number;
  57786. }
  57787. /**
  57788. * Defines the constructor options for the SkeletonMap Shader.
  57789. */
  57790. export interface ISkeletonMapShaderOptions {
  57791. /** Skeleton to Map */
  57792. skeleton: Skeleton;
  57793. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  57794. colorMap?: ISkeletonMapShaderColorMapKnot[];
  57795. }
  57796. }
  57797. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57798. import { Nullable } from "babylonjs/types";
  57799. import { Scene } from "babylonjs/scene";
  57800. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57801. import { Color4 } from "babylonjs/Maths/math.color";
  57802. import { Mesh } from "babylonjs/Meshes/mesh";
  57803. /**
  57804. * Class containing static functions to help procedurally build meshes
  57805. */
  57806. export class RibbonBuilder {
  57807. /**
  57808. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57809. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57810. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57811. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57812. * * 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
  57813. * * 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
  57814. * * 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
  57815. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57816. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57817. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57818. * * 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
  57819. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57820. * * 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
  57821. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57823. * @param name defines the name of the mesh
  57824. * @param options defines the options used to create the mesh
  57825. * @param scene defines the hosting scene
  57826. * @returns the ribbon mesh
  57827. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57828. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57829. */
  57830. static CreateRibbon(name: string, options: {
  57831. pathArray: Vector3[][];
  57832. closeArray?: boolean;
  57833. closePath?: boolean;
  57834. offset?: number;
  57835. updatable?: boolean;
  57836. sideOrientation?: number;
  57837. frontUVs?: Vector4;
  57838. backUVs?: Vector4;
  57839. instance?: Mesh;
  57840. invertUV?: boolean;
  57841. uvs?: Vector2[];
  57842. colors?: Color4[];
  57843. }, scene?: Nullable<Scene>): Mesh;
  57844. }
  57845. }
  57846. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57847. import { Nullable } from "babylonjs/types";
  57848. import { Scene } from "babylonjs/scene";
  57849. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57850. import { Mesh } from "babylonjs/Meshes/mesh";
  57851. /**
  57852. * Class containing static functions to help procedurally build meshes
  57853. */
  57854. export class ShapeBuilder {
  57855. /**
  57856. * 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.
  57857. * * 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.
  57858. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57859. * * 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.
  57860. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57861. * * 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
  57862. * * 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
  57863. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57865. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57866. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57868. * @param name defines the name of the mesh
  57869. * @param options defines the options used to create the mesh
  57870. * @param scene defines the hosting scene
  57871. * @returns the extruded shape mesh
  57872. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57873. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57874. */
  57875. static ExtrudeShape(name: string, options: {
  57876. shape: Vector3[];
  57877. path: Vector3[];
  57878. scale?: number;
  57879. rotation?: number;
  57880. cap?: number;
  57881. updatable?: boolean;
  57882. sideOrientation?: number;
  57883. frontUVs?: Vector4;
  57884. backUVs?: Vector4;
  57885. instance?: Mesh;
  57886. invertUV?: boolean;
  57887. }, scene?: Nullable<Scene>): Mesh;
  57888. /**
  57889. * Creates an custom extruded shape mesh.
  57890. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57891. * * 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.
  57892. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57893. * * 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
  57894. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57895. * * 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
  57896. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57897. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57898. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57899. * * 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
  57900. * * 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
  57901. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57903. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57904. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57906. * @param name defines the name of the mesh
  57907. * @param options defines the options used to create the mesh
  57908. * @param scene defines the hosting scene
  57909. * @returns the custom extruded shape mesh
  57910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57911. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57912. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57913. */
  57914. static ExtrudeShapeCustom(name: string, options: {
  57915. shape: Vector3[];
  57916. path: Vector3[];
  57917. scaleFunction?: any;
  57918. rotationFunction?: any;
  57919. ribbonCloseArray?: boolean;
  57920. ribbonClosePath?: boolean;
  57921. cap?: number;
  57922. updatable?: boolean;
  57923. sideOrientation?: number;
  57924. frontUVs?: Vector4;
  57925. backUVs?: Vector4;
  57926. instance?: Mesh;
  57927. invertUV?: boolean;
  57928. }, scene?: Nullable<Scene>): Mesh;
  57929. private static _ExtrudeShapeGeneric;
  57930. }
  57931. }
  57932. declare module "babylonjs/Debug/skeletonViewer" {
  57933. import { Color3 } from "babylonjs/Maths/math.color";
  57934. import { Scene } from "babylonjs/scene";
  57935. import { Nullable } from "babylonjs/types";
  57936. import { Skeleton } from "babylonjs/Bones/skeleton";
  57937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57938. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57939. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57940. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  57941. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  57942. /**
  57943. * Class used to render a debug view of a given skeleton
  57944. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  57945. */
  57946. export class SkeletonViewer {
  57947. /** defines the skeleton to render */
  57948. skeleton: Skeleton;
  57949. /** defines the mesh attached to the skeleton */
  57950. mesh: AbstractMesh;
  57951. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  57952. autoUpdateBonesMatrices: boolean;
  57953. /** defines the rendering group id to use with the viewer */
  57954. renderingGroupId: number;
  57955. /** is the options for the viewer */
  57956. options: Partial<ISkeletonViewerOptions>;
  57957. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  57958. static readonly DISPLAY_LINES: number;
  57959. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  57960. static readonly DISPLAY_SPHERES: number;
  57961. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  57962. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  57963. /** public static method to create a BoneWeight Shader
  57964. * @param options The constructor options
  57965. * @param scene The scene that the shader is scoped to
  57966. * @returns The created ShaderMaterial
  57967. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  57968. */
  57969. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  57970. /** public static method to create a BoneWeight Shader
  57971. * @param options The constructor options
  57972. * @param scene The scene that the shader is scoped to
  57973. * @returns The created ShaderMaterial
  57974. */
  57975. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  57976. /** private static method to create a BoneWeight Shader
  57977. * @param size The size of the buffer to create (usually the bone count)
  57978. * @param colorMap The gradient data to generate
  57979. * @param scene The scene that the shader is scoped to
  57980. * @returns an Array of floats from the color gradient values
  57981. */
  57982. private static _CreateBoneMapColorBuffer;
  57983. /** If SkeletonViewer scene scope. */
  57984. private _scene;
  57985. /** Gets or sets the color used to render the skeleton */
  57986. color: Color3;
  57987. /** Array of the points of the skeleton fo the line view. */
  57988. private _debugLines;
  57989. /** The SkeletonViewers Mesh. */
  57990. private _debugMesh;
  57991. /** The local axes Meshes. */
  57992. private _localAxes;
  57993. /** If SkeletonViewer is enabled. */
  57994. private _isEnabled;
  57995. /** If SkeletonViewer is ready. */
  57996. private _ready;
  57997. /** SkeletonViewer render observable. */
  57998. private _obs;
  57999. /** The Utility Layer to render the gizmos in. */
  58000. private _utilityLayer;
  58001. private _boneIndices;
  58002. /** Gets the Scene. */
  58003. get scene(): Scene;
  58004. /** Gets the utilityLayer. */
  58005. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58006. /** Checks Ready Status. */
  58007. get isReady(): Boolean;
  58008. /** Sets Ready Status. */
  58009. set ready(value: boolean);
  58010. /** Gets the debugMesh */
  58011. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58012. /** Sets the debugMesh */
  58013. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58014. /** Gets the displayMode */
  58015. get displayMode(): number;
  58016. /** Sets the displayMode */
  58017. set displayMode(value: number);
  58018. /**
  58019. * Creates a new SkeletonViewer
  58020. * @param skeleton defines the skeleton to render
  58021. * @param mesh defines the mesh attached to the skeleton
  58022. * @param scene defines the hosting scene
  58023. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58024. * @param renderingGroupId defines the rendering group id to use with the viewer
  58025. * @param options All of the extra constructor options for the SkeletonViewer
  58026. */
  58027. constructor(
  58028. /** defines the skeleton to render */
  58029. skeleton: Skeleton,
  58030. /** defines the mesh attached to the skeleton */
  58031. mesh: AbstractMesh,
  58032. /** The Scene scope*/
  58033. scene: Scene,
  58034. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58035. autoUpdateBonesMatrices?: boolean,
  58036. /** defines the rendering group id to use with the viewer */
  58037. renderingGroupId?: number,
  58038. /** is the options for the viewer */
  58039. options?: Partial<ISkeletonViewerOptions>);
  58040. /** The Dynamic bindings for the update functions */
  58041. private _bindObs;
  58042. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  58043. update(): void;
  58044. /** Gets or sets a boolean indicating if the viewer is enabled */
  58045. set isEnabled(value: boolean);
  58046. get isEnabled(): boolean;
  58047. private _getBonePosition;
  58048. private _getLinesForBonesWithLength;
  58049. private _getLinesForBonesNoLength;
  58050. /** function to revert the mesh and scene back to the initial state. */
  58051. private _revert;
  58052. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58053. private _getAbsoluteBindPoseToRef;
  58054. /** function to build and bind sphere joint points and spur bone representations. */
  58055. private _buildSpheresAndSpurs;
  58056. private _buildLocalAxes;
  58057. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58058. private _displayLinesUpdate;
  58059. /** Changes the displayMode of the skeleton viewer
  58060. * @param mode The displayMode numerical value
  58061. */
  58062. changeDisplayMode(mode: number): void;
  58063. /** Sets a display option of the skeleton viewer
  58064. *
  58065. * | Option | Type | Default | Description |
  58066. * | ---------------- | ------- | ------- | ----------- |
  58067. * | 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`. |
  58068. * | 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`. |
  58069. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58070. * | 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`. |
  58071. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58072. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58073. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58074. *
  58075. * @param option String of the option name
  58076. * @param value The numerical option value
  58077. */
  58078. changeDisplayOptions(option: string, value: number): void;
  58079. /** Release associated resources */
  58080. dispose(): void;
  58081. }
  58082. }
  58083. declare module "babylonjs/Debug/index" {
  58084. export * from "babylonjs/Debug/axesViewer";
  58085. export * from "babylonjs/Debug/boneAxesViewer";
  58086. export * from "babylonjs/Debug/debugLayer";
  58087. export * from "babylonjs/Debug/physicsViewer";
  58088. export * from "babylonjs/Debug/rayHelper";
  58089. export * from "babylonjs/Debug/skeletonViewer";
  58090. export * from "babylonjs/Debug/ISkeletonViewer";
  58091. }
  58092. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  58093. /**
  58094. * Enum for Device Types
  58095. */
  58096. export enum DeviceType {
  58097. /** Generic */
  58098. Generic = 0,
  58099. /** Keyboard */
  58100. Keyboard = 1,
  58101. /** Mouse */
  58102. Mouse = 2,
  58103. /** Touch Pointers */
  58104. Touch = 3,
  58105. /** PS4 Dual Shock */
  58106. DualShock = 4,
  58107. /** Xbox */
  58108. Xbox = 5,
  58109. /** Switch Controller */
  58110. Switch = 6
  58111. }
  58112. /**
  58113. * Enum for All Pointers (Touch/Mouse)
  58114. */
  58115. export enum PointerInput {
  58116. /** Horizontal Axis */
  58117. Horizontal = 0,
  58118. /** Vertical Axis */
  58119. Vertical = 1,
  58120. /** Left Click or Touch */
  58121. LeftClick = 2,
  58122. /** Middle Click */
  58123. MiddleClick = 3,
  58124. /** Right Click */
  58125. RightClick = 4,
  58126. /** Browser Back */
  58127. BrowserBack = 5,
  58128. /** Browser Forward */
  58129. BrowserForward = 6
  58130. }
  58131. /**
  58132. * Enum for Dual Shock Gamepad
  58133. */
  58134. export enum DualShockInput {
  58135. /** Cross */
  58136. Cross = 0,
  58137. /** Circle */
  58138. Circle = 1,
  58139. /** Square */
  58140. Square = 2,
  58141. /** Triangle */
  58142. Triangle = 3,
  58143. /** L1 */
  58144. L1 = 4,
  58145. /** R1 */
  58146. R1 = 5,
  58147. /** L2 */
  58148. L2 = 6,
  58149. /** R2 */
  58150. R2 = 7,
  58151. /** Share */
  58152. Share = 8,
  58153. /** Options */
  58154. Options = 9,
  58155. /** L3 */
  58156. L3 = 10,
  58157. /** R3 */
  58158. R3 = 11,
  58159. /** DPadUp */
  58160. DPadUp = 12,
  58161. /** DPadDown */
  58162. DPadDown = 13,
  58163. /** DPadLeft */
  58164. DPadLeft = 14,
  58165. /** DRight */
  58166. DPadRight = 15,
  58167. /** Home */
  58168. Home = 16,
  58169. /** TouchPad */
  58170. TouchPad = 17,
  58171. /** LStickXAxis */
  58172. LStickXAxis = 18,
  58173. /** LStickYAxis */
  58174. LStickYAxis = 19,
  58175. /** RStickXAxis */
  58176. RStickXAxis = 20,
  58177. /** RStickYAxis */
  58178. RStickYAxis = 21
  58179. }
  58180. /**
  58181. * Enum for Xbox Gamepad
  58182. */
  58183. export enum XboxInput {
  58184. /** A */
  58185. A = 0,
  58186. /** B */
  58187. B = 1,
  58188. /** X */
  58189. X = 2,
  58190. /** Y */
  58191. Y = 3,
  58192. /** LB */
  58193. LB = 4,
  58194. /** RB */
  58195. RB = 5,
  58196. /** LT */
  58197. LT = 6,
  58198. /** RT */
  58199. RT = 7,
  58200. /** Back */
  58201. Back = 8,
  58202. /** Start */
  58203. Start = 9,
  58204. /** LS */
  58205. LS = 10,
  58206. /** RS */
  58207. RS = 11,
  58208. /** DPadUp */
  58209. DPadUp = 12,
  58210. /** DPadDown */
  58211. DPadDown = 13,
  58212. /** DPadLeft */
  58213. DPadLeft = 14,
  58214. /** DRight */
  58215. DPadRight = 15,
  58216. /** Home */
  58217. Home = 16,
  58218. /** LStickXAxis */
  58219. LStickXAxis = 17,
  58220. /** LStickYAxis */
  58221. LStickYAxis = 18,
  58222. /** RStickXAxis */
  58223. RStickXAxis = 19,
  58224. /** RStickYAxis */
  58225. RStickYAxis = 20
  58226. }
  58227. /**
  58228. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  58229. */
  58230. export enum SwitchInput {
  58231. /** B */
  58232. B = 0,
  58233. /** A */
  58234. A = 1,
  58235. /** Y */
  58236. Y = 2,
  58237. /** X */
  58238. X = 3,
  58239. /** L */
  58240. L = 4,
  58241. /** R */
  58242. R = 5,
  58243. /** ZL */
  58244. ZL = 6,
  58245. /** ZR */
  58246. ZR = 7,
  58247. /** Minus */
  58248. Minus = 8,
  58249. /** Plus */
  58250. Plus = 9,
  58251. /** LS */
  58252. LS = 10,
  58253. /** RS */
  58254. RS = 11,
  58255. /** DPadUp */
  58256. DPadUp = 12,
  58257. /** DPadDown */
  58258. DPadDown = 13,
  58259. /** DPadLeft */
  58260. DPadLeft = 14,
  58261. /** DRight */
  58262. DPadRight = 15,
  58263. /** Home */
  58264. Home = 16,
  58265. /** Capture */
  58266. Capture = 17,
  58267. /** LStickXAxis */
  58268. LStickXAxis = 18,
  58269. /** LStickYAxis */
  58270. LStickYAxis = 19,
  58271. /** RStickXAxis */
  58272. RStickXAxis = 20,
  58273. /** RStickYAxis */
  58274. RStickYAxis = 21
  58275. }
  58276. }
  58277. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  58278. import { Engine } from "babylonjs/Engines/engine";
  58279. import { IDisposable } from "babylonjs/scene";
  58280. import { Nullable } from "babylonjs/types";
  58281. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58282. /**
  58283. * This class will take all inputs from Keyboard, Pointer, and
  58284. * any Gamepads and provide a polling system that all devices
  58285. * will use. This class assumes that there will only be one
  58286. * pointer device and one keyboard.
  58287. */
  58288. export class DeviceInputSystem implements IDisposable {
  58289. /**
  58290. * Returns onDeviceConnected callback property
  58291. * @returns Callback with function to execute when a device is connected
  58292. */
  58293. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  58294. /**
  58295. * Sets callback function when a device is connected and executes against all connected devices
  58296. * @param callback Function to execute when a device is connected
  58297. */
  58298. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  58299. /**
  58300. * Callback to be triggered when a device is disconnected
  58301. */
  58302. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  58303. /**
  58304. * Callback to be triggered when event driven input is updated
  58305. */
  58306. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  58307. private _inputs;
  58308. private _gamepads;
  58309. private _keyboardActive;
  58310. private _pointerActive;
  58311. private _elementToAttachTo;
  58312. private _keyboardDownEvent;
  58313. private _keyboardUpEvent;
  58314. private _pointerMoveEvent;
  58315. private _pointerDownEvent;
  58316. private _pointerUpEvent;
  58317. private _gamepadConnectedEvent;
  58318. private _gamepadDisconnectedEvent;
  58319. private _onDeviceConnected;
  58320. private static _MAX_KEYCODES;
  58321. private static _MAX_POINTER_INPUTS;
  58322. private constructor();
  58323. /**
  58324. * Creates a new DeviceInputSystem instance
  58325. * @param engine Engine to pull input element from
  58326. * @returns The new instance
  58327. */
  58328. static Create(engine: Engine): DeviceInputSystem;
  58329. /**
  58330. * Checks for current device input value, given an id and input index
  58331. * @param deviceName Id of connected device
  58332. * @param inputIndex Index of device input
  58333. * @returns Current value of input
  58334. */
  58335. /**
  58336. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  58337. * @param deviceType Enum specifiying device type
  58338. * @param deviceSlot "Slot" or index that device is referenced in
  58339. * @param inputIndex Id of input to be checked
  58340. * @returns Current value of input
  58341. */
  58342. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  58343. /**
  58344. * Dispose of all the eventlisteners
  58345. */
  58346. dispose(): void;
  58347. /**
  58348. * Checks for existing connections to devices and register them, if necessary
  58349. * Currently handles gamepads and mouse
  58350. */
  58351. private _checkForConnectedDevices;
  58352. /**
  58353. * Add a gamepad to the DeviceInputSystem
  58354. * @param gamepad A single DOM Gamepad object
  58355. */
  58356. private _addGamePad;
  58357. /**
  58358. * Add pointer device to DeviceInputSystem
  58359. * @param deviceType Type of Pointer to add
  58360. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  58361. * @param currentX Current X at point of adding
  58362. * @param currentY Current Y at point of adding
  58363. */
  58364. private _addPointerDevice;
  58365. /**
  58366. * Add device and inputs to device array
  58367. * @param deviceType Enum specifiying device type
  58368. * @param deviceSlot "Slot" or index that device is referenced in
  58369. * @param numberOfInputs Number of input entries to create for given device
  58370. */
  58371. private _registerDevice;
  58372. /**
  58373. * Given a specific device name, remove that device from the device map
  58374. * @param deviceType Enum specifiying device type
  58375. * @param deviceSlot "Slot" or index that device is referenced in
  58376. */
  58377. private _unregisterDevice;
  58378. /**
  58379. * Handle all actions that come from keyboard interaction
  58380. */
  58381. private _handleKeyActions;
  58382. /**
  58383. * Handle all actions that come from pointer interaction
  58384. */
  58385. private _handlePointerActions;
  58386. /**
  58387. * Handle all actions that come from gamepad interaction
  58388. */
  58389. private _handleGamepadActions;
  58390. /**
  58391. * Update all non-event based devices with each frame
  58392. * @param deviceType Enum specifiying device type
  58393. * @param deviceSlot "Slot" or index that device is referenced in
  58394. * @param inputIndex Id of input to be checked
  58395. */
  58396. private _updateDevice;
  58397. /**
  58398. * Gets DeviceType from the device name
  58399. * @param deviceName Name of Device from DeviceInputSystem
  58400. * @returns DeviceType enum value
  58401. */
  58402. private _getGamepadDeviceType;
  58403. }
  58404. }
  58405. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  58406. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58407. /**
  58408. * Type to handle enforcement of inputs
  58409. */
  58410. 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;
  58411. }
  58412. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  58413. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  58414. import { Engine } from "babylonjs/Engines/engine";
  58415. import { IDisposable } from "babylonjs/scene";
  58416. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58417. import { Nullable } from "babylonjs/types";
  58418. import { Observable } from "babylonjs/Misc/observable";
  58419. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  58420. /**
  58421. * Class that handles all input for a specific device
  58422. */
  58423. export class DeviceSource<T extends DeviceType> {
  58424. /** Type of device */
  58425. readonly deviceType: DeviceType;
  58426. /** "Slot" or index that device is referenced in */
  58427. readonly deviceSlot: number;
  58428. /**
  58429. * Observable to handle device input changes per device
  58430. */
  58431. readonly onInputChangedObservable: Observable<{
  58432. inputIndex: DeviceInput<T>;
  58433. previousState: Nullable<number>;
  58434. currentState: Nullable<number>;
  58435. }>;
  58436. private readonly _deviceInputSystem;
  58437. /**
  58438. * Default Constructor
  58439. * @param deviceInputSystem Reference to DeviceInputSystem
  58440. * @param deviceType Type of device
  58441. * @param deviceSlot "Slot" or index that device is referenced in
  58442. */
  58443. constructor(deviceInputSystem: DeviceInputSystem,
  58444. /** Type of device */
  58445. deviceType: DeviceType,
  58446. /** "Slot" or index that device is referenced in */
  58447. deviceSlot?: number);
  58448. /**
  58449. * Get input for specific input
  58450. * @param inputIndex index of specific input on device
  58451. * @returns Input value from DeviceInputSystem
  58452. */
  58453. getInput(inputIndex: DeviceInput<T>): number;
  58454. }
  58455. /**
  58456. * Class to keep track of devices
  58457. */
  58458. export class DeviceSourceManager implements IDisposable {
  58459. /**
  58460. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  58461. */
  58462. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  58463. /**
  58464. * Observable to be triggered when after a device is disconnected
  58465. */
  58466. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  58467. private readonly _devices;
  58468. private readonly _firstDevice;
  58469. private readonly _deviceInputSystem;
  58470. /**
  58471. * Default Constructor
  58472. * @param engine engine to pull input element from
  58473. */
  58474. constructor(engine: Engine);
  58475. /**
  58476. * Gets a DeviceSource, given a type and slot
  58477. * @param deviceType Enum specifying device type
  58478. * @param deviceSlot "Slot" or index that device is referenced in
  58479. * @returns DeviceSource object
  58480. */
  58481. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  58482. /**
  58483. * Gets an array of DeviceSource objects for a given device type
  58484. * @param deviceType Enum specifying device type
  58485. * @returns Array of DeviceSource objects
  58486. */
  58487. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  58488. /**
  58489. * Returns a read-only list of all available devices
  58490. * @returns Read-only array with active devices
  58491. */
  58492. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  58493. /**
  58494. * Dispose of DeviceInputSystem and other parts
  58495. */
  58496. dispose(): void;
  58497. /**
  58498. * Function to add device name to device list
  58499. * @param deviceType Enum specifying device type
  58500. * @param deviceSlot "Slot" or index that device is referenced in
  58501. */
  58502. private _addDevice;
  58503. /**
  58504. * Function to remove device name to device list
  58505. * @param deviceType Enum specifying device type
  58506. * @param deviceSlot "Slot" or index that device is referenced in
  58507. */
  58508. private _removeDevice;
  58509. /**
  58510. * Updates array storing first connected device of each type
  58511. * @param type Type of Device
  58512. */
  58513. private _updateFirstDevices;
  58514. }
  58515. }
  58516. declare module "babylonjs/DeviceInput/index" {
  58517. export * from "babylonjs/DeviceInput/deviceInputSystem";
  58518. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58519. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  58520. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  58521. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  58522. }
  58523. declare module "babylonjs/Engines/nullEngine" {
  58524. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  58525. import { Engine } from "babylonjs/Engines/engine";
  58526. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58527. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58528. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58529. import { Effect } from "babylonjs/Materials/effect";
  58530. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58531. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58532. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  58533. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58534. /**
  58535. * Options to create the null engine
  58536. */
  58537. export class NullEngineOptions {
  58538. /**
  58539. * Render width (Default: 512)
  58540. */
  58541. renderWidth: number;
  58542. /**
  58543. * Render height (Default: 256)
  58544. */
  58545. renderHeight: number;
  58546. /**
  58547. * Texture size (Default: 512)
  58548. */
  58549. textureSize: number;
  58550. /**
  58551. * If delta time between frames should be constant
  58552. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58553. */
  58554. deterministicLockstep: boolean;
  58555. /**
  58556. * Maximum about of steps between frames (Default: 4)
  58557. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58558. */
  58559. lockstepMaxSteps: number;
  58560. /**
  58561. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  58562. */
  58563. useHighPrecisionMatrix?: boolean;
  58564. }
  58565. /**
  58566. * The null engine class provides support for headless version of babylon.js.
  58567. * This can be used in server side scenario or for testing purposes
  58568. */
  58569. export class NullEngine extends Engine {
  58570. private _options;
  58571. /**
  58572. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  58573. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58574. * @returns true if engine is in deterministic lock step mode
  58575. */
  58576. isDeterministicLockStep(): boolean;
  58577. /**
  58578. * Gets the max steps when engine is running in deterministic lock step
  58579. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58580. * @returns the max steps
  58581. */
  58582. getLockstepMaxSteps(): number;
  58583. /**
  58584. * Gets the current hardware scaling level.
  58585. * By default the hardware scaling level is computed from the window device ratio.
  58586. * 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.
  58587. * @returns a number indicating the current hardware scaling level
  58588. */
  58589. getHardwareScalingLevel(): number;
  58590. constructor(options?: NullEngineOptions);
  58591. /**
  58592. * Creates a vertex buffer
  58593. * @param vertices the data for the vertex buffer
  58594. * @returns the new WebGL static buffer
  58595. */
  58596. createVertexBuffer(vertices: FloatArray): DataBuffer;
  58597. /**
  58598. * Creates a new index buffer
  58599. * @param indices defines the content of the index buffer
  58600. * @param updatable defines if the index buffer must be updatable
  58601. * @returns a new webGL buffer
  58602. */
  58603. createIndexBuffer(indices: IndicesArray): DataBuffer;
  58604. /**
  58605. * Clear the current render buffer or the current render target (if any is set up)
  58606. * @param color defines the color to use
  58607. * @param backBuffer defines if the back buffer must be cleared
  58608. * @param depth defines if the depth buffer must be cleared
  58609. * @param stencil defines if the stencil buffer must be cleared
  58610. */
  58611. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58612. /**
  58613. * Gets the current render width
  58614. * @param useScreen defines if screen size must be used (or the current render target if any)
  58615. * @returns a number defining the current render width
  58616. */
  58617. getRenderWidth(useScreen?: boolean): number;
  58618. /**
  58619. * Gets the current render height
  58620. * @param useScreen defines if screen size must be used (or the current render target if any)
  58621. * @returns a number defining the current render height
  58622. */
  58623. getRenderHeight(useScreen?: boolean): number;
  58624. /**
  58625. * Set the WebGL's viewport
  58626. * @param viewport defines the viewport element to be used
  58627. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  58628. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  58629. */
  58630. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  58631. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  58632. /**
  58633. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  58634. * @param pipelineContext defines the pipeline context to use
  58635. * @param uniformsNames defines the list of uniform names
  58636. * @returns an array of webGL uniform locations
  58637. */
  58638. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  58639. /**
  58640. * Gets the lsit of active attributes for a given webGL program
  58641. * @param pipelineContext defines the pipeline context to use
  58642. * @param attributesNames defines the list of attribute names to get
  58643. * @returns an array of indices indicating the offset of each attribute
  58644. */
  58645. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58646. /**
  58647. * Binds an effect to the webGL context
  58648. * @param effect defines the effect to bind
  58649. */
  58650. bindSamplers(effect: Effect): void;
  58651. /**
  58652. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  58653. * @param effect defines the effect to activate
  58654. */
  58655. enableEffect(effect: Effect): void;
  58656. /**
  58657. * Set various states to the webGL context
  58658. * @param culling defines backface culling state
  58659. * @param zOffset defines the value to apply to zOffset (0 by default)
  58660. * @param force defines if states must be applied even if cache is up to date
  58661. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  58662. */
  58663. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58664. /**
  58665. * Set the value of an uniform to an array of int32
  58666. * @param uniform defines the webGL uniform location where to store the value
  58667. * @param array defines the array of int32 to store
  58668. * @returns true if value was set
  58669. */
  58670. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58671. /**
  58672. * Set the value of an uniform to an array of int32 (stored as vec2)
  58673. * @param uniform defines the webGL uniform location where to store the value
  58674. * @param array defines the array of int32 to store
  58675. * @returns true if value was set
  58676. */
  58677. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58678. /**
  58679. * Set the value of an uniform to an array of int32 (stored as vec3)
  58680. * @param uniform defines the webGL uniform location where to store the value
  58681. * @param array defines the array of int32 to store
  58682. * @returns true if value was set
  58683. */
  58684. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58685. /**
  58686. * Set the value of an uniform to an array of int32 (stored as vec4)
  58687. * @param uniform defines the webGL uniform location where to store the value
  58688. * @param array defines the array of int32 to store
  58689. * @returns true if value was set
  58690. */
  58691. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58692. /**
  58693. * Set the value of an uniform to an array of float32
  58694. * @param uniform defines the webGL uniform location where to store the value
  58695. * @param array defines the array of float32 to store
  58696. * @returns true if value was set
  58697. */
  58698. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58699. /**
  58700. * Set the value of an uniform to an array of float32 (stored as vec2)
  58701. * @param uniform defines the webGL uniform location where to store the value
  58702. * @param array defines the array of float32 to store
  58703. * @returns true if value was set
  58704. */
  58705. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58706. /**
  58707. * Set the value of an uniform to an array of float32 (stored as vec3)
  58708. * @param uniform defines the webGL uniform location where to store the value
  58709. * @param array defines the array of float32 to store
  58710. * @returns true if value was set
  58711. */
  58712. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58713. /**
  58714. * Set the value of an uniform to an array of float32 (stored as vec4)
  58715. * @param uniform defines the webGL uniform location where to store the value
  58716. * @param array defines the array of float32 to store
  58717. * @returns true if value was set
  58718. */
  58719. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58720. /**
  58721. * Set the value of an uniform to an array of number
  58722. * @param uniform defines the webGL uniform location where to store the value
  58723. * @param array defines the array of number to store
  58724. * @returns true if value was set
  58725. */
  58726. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58727. /**
  58728. * Set the value of an uniform to an array of number (stored as vec2)
  58729. * @param uniform defines the webGL uniform location where to store the value
  58730. * @param array defines the array of number to store
  58731. * @returns true if value was set
  58732. */
  58733. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58734. /**
  58735. * Set the value of an uniform to an array of number (stored as vec3)
  58736. * @param uniform defines the webGL uniform location where to store the value
  58737. * @param array defines the array of number to store
  58738. * @returns true if value was set
  58739. */
  58740. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58741. /**
  58742. * Set the value of an uniform to an array of number (stored as vec4)
  58743. * @param uniform defines the webGL uniform location where to store the value
  58744. * @param array defines the array of number to store
  58745. * @returns true if value was set
  58746. */
  58747. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58748. /**
  58749. * Set the value of an uniform to an array of float32 (stored as matrices)
  58750. * @param uniform defines the webGL uniform location where to store the value
  58751. * @param matrices defines the array of float32 to store
  58752. * @returns true if value was set
  58753. */
  58754. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58755. /**
  58756. * Set the value of an uniform to a matrix (3x3)
  58757. * @param uniform defines the webGL uniform location where to store the value
  58758. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  58759. * @returns true if value was set
  58760. */
  58761. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58762. /**
  58763. * Set the value of an uniform to a matrix (2x2)
  58764. * @param uniform defines the webGL uniform location where to store the value
  58765. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  58766. * @returns true if value was set
  58767. */
  58768. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58769. /**
  58770. * Set the value of an uniform to a number (float)
  58771. * @param uniform defines the webGL uniform location where to store the value
  58772. * @param value defines the float number to store
  58773. * @returns true if value was set
  58774. */
  58775. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58776. /**
  58777. * Set the value of an uniform to a vec2
  58778. * @param uniform defines the webGL uniform location where to store the value
  58779. * @param x defines the 1st component of the value
  58780. * @param y defines the 2nd component of the value
  58781. * @returns true if value was set
  58782. */
  58783. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58784. /**
  58785. * Set the value of an uniform to a vec3
  58786. * @param uniform defines the webGL uniform location where to store the value
  58787. * @param x defines the 1st component of the value
  58788. * @param y defines the 2nd component of the value
  58789. * @param z defines the 3rd component of the value
  58790. * @returns true if value was set
  58791. */
  58792. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58793. /**
  58794. * Set the value of an uniform to a boolean
  58795. * @param uniform defines the webGL uniform location where to store the value
  58796. * @param bool defines the boolean to store
  58797. * @returns true if value was set
  58798. */
  58799. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  58800. /**
  58801. * Set the value of an uniform to a vec4
  58802. * @param uniform defines the webGL uniform location where to store the value
  58803. * @param x defines the 1st component of the value
  58804. * @param y defines the 2nd component of the value
  58805. * @param z defines the 3rd component of the value
  58806. * @param w defines the 4th component of the value
  58807. * @returns true if value was set
  58808. */
  58809. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58810. /**
  58811. * Sets the current alpha mode
  58812. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  58813. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58814. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58815. */
  58816. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58817. /**
  58818. * Bind webGl buffers directly to the webGL context
  58819. * @param vertexBuffers defines the vertex buffer to bind
  58820. * @param indexBuffer defines the index buffer to bind
  58821. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  58822. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  58823. * @param effect defines the effect associated with the vertex buffer
  58824. */
  58825. bindBuffers(vertexBuffers: {
  58826. [key: string]: VertexBuffer;
  58827. }, indexBuffer: DataBuffer, effect: Effect): void;
  58828. /**
  58829. * Force the entire cache to be cleared
  58830. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  58831. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  58832. */
  58833. wipeCaches(bruteForce?: boolean): void;
  58834. /**
  58835. * Send a draw order
  58836. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  58837. * @param indexStart defines the starting index
  58838. * @param indexCount defines the number of index to draw
  58839. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58840. */
  58841. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  58842. /**
  58843. * Draw a list of indexed primitives
  58844. * @param fillMode defines the primitive to use
  58845. * @param indexStart defines the starting index
  58846. * @param indexCount defines the number of index to draw
  58847. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58848. */
  58849. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58850. /**
  58851. * Draw a list of unindexed primitives
  58852. * @param fillMode defines the primitive to use
  58853. * @param verticesStart defines the index of first vertex to draw
  58854. * @param verticesCount defines the count of vertices to draw
  58855. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58856. */
  58857. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58858. /** @hidden */
  58859. _createTexture(): WebGLTexture;
  58860. /** @hidden */
  58861. _releaseTexture(texture: InternalTexture): void;
  58862. /**
  58863. * Usually called from Texture.ts.
  58864. * Passed information to create a WebGLTexture
  58865. * @param urlArg defines a value which contains one of the following:
  58866. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58867. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58868. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58869. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58870. * @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)
  58871. * @param scene needed for loading to the correct scene
  58872. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58873. * @param onLoad optional callback to be called upon successful completion
  58874. * @param onError optional callback to be called upon failure
  58875. * @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
  58876. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58877. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58878. * @param forcedExtension defines the extension to use to pick the right loader
  58879. * @param mimeType defines an optional mime type
  58880. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58881. */
  58882. 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;
  58883. /**
  58884. * Creates a new render target texture
  58885. * @param size defines the size of the texture
  58886. * @param options defines the options used to create the texture
  58887. * @returns a new render target texture stored in an InternalTexture
  58888. */
  58889. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  58890. /**
  58891. * Update the sampling mode of a given texture
  58892. * @param samplingMode defines the required sampling mode
  58893. * @param texture defines the texture to update
  58894. */
  58895. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58896. /**
  58897. * Binds the frame buffer to the specified texture.
  58898. * @param texture The texture to render to or null for the default canvas
  58899. * @param faceIndex The face of the texture to render to in case of cube texture
  58900. * @param requiredWidth The width of the target to render to
  58901. * @param requiredHeight The height of the target to render to
  58902. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  58903. * @param lodLevel defines le lod level to bind to the frame buffer
  58904. */
  58905. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58906. /**
  58907. * Unbind the current render target texture from the webGL context
  58908. * @param texture defines the render target texture to unbind
  58909. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  58910. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  58911. */
  58912. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58913. /**
  58914. * Creates a dynamic vertex buffer
  58915. * @param vertices the data for the dynamic vertex buffer
  58916. * @returns the new WebGL dynamic buffer
  58917. */
  58918. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  58919. /**
  58920. * Update the content of a dynamic texture
  58921. * @param texture defines the texture to update
  58922. * @param canvas defines the canvas containing the source
  58923. * @param invertY defines if data must be stored with Y axis inverted
  58924. * @param premulAlpha defines if alpha is stored as premultiplied
  58925. * @param format defines the format of the data
  58926. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58927. */
  58928. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58929. /**
  58930. * Gets a boolean indicating if all created effects are ready
  58931. * @returns true if all effects are ready
  58932. */
  58933. areAllEffectsReady(): boolean;
  58934. /**
  58935. * @hidden
  58936. * Get the current error code of the webGL context
  58937. * @returns the error code
  58938. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  58939. */
  58940. getError(): number;
  58941. /** @hidden */
  58942. _getUnpackAlignement(): number;
  58943. /** @hidden */
  58944. _unpackFlipY(value: boolean): void;
  58945. /**
  58946. * Update a dynamic index buffer
  58947. * @param indexBuffer defines the target index buffer
  58948. * @param indices defines the data to update
  58949. * @param offset defines the offset in the target index buffer where update should start
  58950. */
  58951. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  58952. /**
  58953. * Updates a dynamic vertex buffer.
  58954. * @param vertexBuffer the vertex buffer to update
  58955. * @param vertices the data used to update the vertex buffer
  58956. * @param byteOffset the byte offset of the data (optional)
  58957. * @param byteLength the byte length of the data (optional)
  58958. */
  58959. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  58960. /** @hidden */
  58961. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  58962. /** @hidden */
  58963. _bindTexture(channel: number, texture: InternalTexture): void;
  58964. protected _deleteBuffer(buffer: WebGLBuffer): void;
  58965. /**
  58966. * 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
  58967. */
  58968. releaseEffects(): void;
  58969. displayLoadingUI(): void;
  58970. hideLoadingUI(): void;
  58971. /** @hidden */
  58972. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58973. /** @hidden */
  58974. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58975. /** @hidden */
  58976. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58977. /** @hidden */
  58978. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58979. }
  58980. }
  58981. declare module "babylonjs/Instrumentation/timeToken" {
  58982. import { Nullable } from "babylonjs/types";
  58983. /**
  58984. * @hidden
  58985. **/
  58986. export class _TimeToken {
  58987. _startTimeQuery: Nullable<WebGLQuery>;
  58988. _endTimeQuery: Nullable<WebGLQuery>;
  58989. _timeElapsedQuery: Nullable<WebGLQuery>;
  58990. _timeElapsedQueryEnded: boolean;
  58991. }
  58992. }
  58993. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  58994. import { Nullable, int } from "babylonjs/types";
  58995. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  58996. /** @hidden */
  58997. export class _OcclusionDataStorage {
  58998. /** @hidden */
  58999. occlusionInternalRetryCounter: number;
  59000. /** @hidden */
  59001. isOcclusionQueryInProgress: boolean;
  59002. /** @hidden */
  59003. isOccluded: boolean;
  59004. /** @hidden */
  59005. occlusionRetryCount: number;
  59006. /** @hidden */
  59007. occlusionType: number;
  59008. /** @hidden */
  59009. occlusionQueryAlgorithmType: number;
  59010. }
  59011. module "babylonjs/Engines/engine" {
  59012. interface Engine {
  59013. /**
  59014. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59015. * @return the new query
  59016. */
  59017. createQuery(): WebGLQuery;
  59018. /**
  59019. * Delete and release a webGL query
  59020. * @param query defines the query to delete
  59021. * @return the current engine
  59022. */
  59023. deleteQuery(query: WebGLQuery): Engine;
  59024. /**
  59025. * Check if a given query has resolved and got its value
  59026. * @param query defines the query to check
  59027. * @returns true if the query got its value
  59028. */
  59029. isQueryResultAvailable(query: WebGLQuery): boolean;
  59030. /**
  59031. * Gets the value of a given query
  59032. * @param query defines the query to check
  59033. * @returns the value of the query
  59034. */
  59035. getQueryResult(query: WebGLQuery): number;
  59036. /**
  59037. * Initiates an occlusion query
  59038. * @param algorithmType defines the algorithm to use
  59039. * @param query defines the query to use
  59040. * @returns the current engine
  59041. * @see https://doc.babylonjs.com/features/occlusionquery
  59042. */
  59043. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59044. /**
  59045. * Ends an occlusion query
  59046. * @see https://doc.babylonjs.com/features/occlusionquery
  59047. * @param algorithmType defines the algorithm to use
  59048. * @returns the current engine
  59049. */
  59050. endOcclusionQuery(algorithmType: number): Engine;
  59051. /**
  59052. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59053. * Please note that only one query can be issued at a time
  59054. * @returns a time token used to track the time span
  59055. */
  59056. startTimeQuery(): Nullable<_TimeToken>;
  59057. /**
  59058. * Ends a time query
  59059. * @param token defines the token used to measure the time span
  59060. * @returns the time spent (in ns)
  59061. */
  59062. endTimeQuery(token: _TimeToken): int;
  59063. /** @hidden */
  59064. _currentNonTimestampToken: Nullable<_TimeToken>;
  59065. /** @hidden */
  59066. _createTimeQuery(): WebGLQuery;
  59067. /** @hidden */
  59068. _deleteTimeQuery(query: WebGLQuery): void;
  59069. /** @hidden */
  59070. _getGlAlgorithmType(algorithmType: number): number;
  59071. /** @hidden */
  59072. _getTimeQueryResult(query: WebGLQuery): any;
  59073. /** @hidden */
  59074. _getTimeQueryAvailability(query: WebGLQuery): any;
  59075. }
  59076. }
  59077. module "babylonjs/Meshes/abstractMesh" {
  59078. interface AbstractMesh {
  59079. /**
  59080. * Backing filed
  59081. * @hidden
  59082. */
  59083. __occlusionDataStorage: _OcclusionDataStorage;
  59084. /**
  59085. * Access property
  59086. * @hidden
  59087. */
  59088. _occlusionDataStorage: _OcclusionDataStorage;
  59089. /**
  59090. * 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.
  59091. * The default value is -1 which means don't break the query and wait till the result
  59092. * @see https://doc.babylonjs.com/features/occlusionquery
  59093. */
  59094. occlusionRetryCount: number;
  59095. /**
  59096. * 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:
  59097. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  59098. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59099. * * 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.
  59100. * @see https://doc.babylonjs.com/features/occlusionquery
  59101. */
  59102. occlusionType: number;
  59103. /**
  59104. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59105. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59106. * * 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.
  59107. * @see https://doc.babylonjs.com/features/occlusionquery
  59108. */
  59109. occlusionQueryAlgorithmType: number;
  59110. /**
  59111. * 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
  59112. * @see https://doc.babylonjs.com/features/occlusionquery
  59113. */
  59114. isOccluded: boolean;
  59115. /**
  59116. * Flag to check the progress status of the query
  59117. * @see https://doc.babylonjs.com/features/occlusionquery
  59118. */
  59119. isOcclusionQueryInProgress: boolean;
  59120. }
  59121. }
  59122. }
  59123. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  59124. import { Nullable } from "babylonjs/types";
  59125. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  59126. /** @hidden */
  59127. export var _forceTransformFeedbackToBundle: boolean;
  59128. module "babylonjs/Engines/engine" {
  59129. interface Engine {
  59130. /**
  59131. * Creates a webGL transform feedback object
  59132. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59133. * @returns the webGL transform feedback object
  59134. */
  59135. createTransformFeedback(): WebGLTransformFeedback;
  59136. /**
  59137. * Delete a webGL transform feedback object
  59138. * @param value defines the webGL transform feedback object to delete
  59139. */
  59140. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59141. /**
  59142. * Bind a webGL transform feedback object to the webgl context
  59143. * @param value defines the webGL transform feedback object to bind
  59144. */
  59145. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59146. /**
  59147. * Begins a transform feedback operation
  59148. * @param usePoints defines if points or triangles must be used
  59149. */
  59150. beginTransformFeedback(usePoints: boolean): void;
  59151. /**
  59152. * Ends a transform feedback operation
  59153. */
  59154. endTransformFeedback(): void;
  59155. /**
  59156. * Specify the varyings to use with transform feedback
  59157. * @param program defines the associated webGL program
  59158. * @param value defines the list of strings representing the varying names
  59159. */
  59160. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59161. /**
  59162. * Bind a webGL buffer for a transform feedback operation
  59163. * @param value defines the webGL buffer to bind
  59164. */
  59165. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59166. }
  59167. }
  59168. }
  59169. declare module "babylonjs/Engines/Extensions/engine.views" {
  59170. import { Camera } from "babylonjs/Cameras/camera";
  59171. import { Nullable } from "babylonjs/types";
  59172. /**
  59173. * Class used to define an additional view for the engine
  59174. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59175. */
  59176. export class EngineView {
  59177. /** Defines the canvas where to render the view */
  59178. target: HTMLCanvasElement;
  59179. /** Defines an optional camera used to render the view (will use active camera else) */
  59180. camera?: Camera;
  59181. }
  59182. module "babylonjs/Engines/engine" {
  59183. interface Engine {
  59184. /**
  59185. * Gets or sets the HTML element to use for attaching events
  59186. */
  59187. inputElement: Nullable<HTMLElement>;
  59188. /**
  59189. * Gets the current engine view
  59190. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59191. */
  59192. activeView: Nullable<EngineView>;
  59193. /** Gets or sets the list of views */
  59194. views: EngineView[];
  59195. /**
  59196. * Register a new child canvas
  59197. * @param canvas defines the canvas to register
  59198. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  59199. * @returns the associated view
  59200. */
  59201. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  59202. /**
  59203. * Remove a registered child canvas
  59204. * @param canvas defines the canvas to remove
  59205. * @returns the current engine
  59206. */
  59207. unRegisterView(canvas: HTMLCanvasElement): Engine;
  59208. }
  59209. }
  59210. }
  59211. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  59212. import { Nullable } from "babylonjs/types";
  59213. module "babylonjs/Engines/engine" {
  59214. interface Engine {
  59215. /** @hidden */
  59216. _excludedCompressedTextures: string[];
  59217. /** @hidden */
  59218. _textureFormatInUse: string;
  59219. /**
  59220. * Gets the list of texture formats supported
  59221. */
  59222. readonly texturesSupported: Array<string>;
  59223. /**
  59224. * Gets the texture format in use
  59225. */
  59226. readonly textureFormatInUse: Nullable<string>;
  59227. /**
  59228. * Set the compressed texture extensions or file names to skip.
  59229. *
  59230. * @param skippedFiles defines the list of those texture files you want to skip
  59231. * Example: [".dds", ".env", "myfile.png"]
  59232. */
  59233. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  59234. /**
  59235. * Set the compressed texture format to use, based on the formats you have, and the formats
  59236. * supported by the hardware / browser.
  59237. *
  59238. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  59239. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  59240. * to API arguments needed to compressed textures. This puts the burden on the container
  59241. * generator to house the arcane code for determining these for current & future formats.
  59242. *
  59243. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59244. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59245. *
  59246. * Note: The result of this call is not taken into account when a texture is base64.
  59247. *
  59248. * @param formatsAvailable defines the list of those format families you have created
  59249. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  59250. *
  59251. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  59252. * @returns The extension selected.
  59253. */
  59254. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  59255. }
  59256. }
  59257. }
  59258. declare module "babylonjs/Engines/Extensions/index" {
  59259. export * from "babylonjs/Engines/Extensions/engine.alpha";
  59260. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  59261. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  59262. export * from "babylonjs/Engines/Extensions/engine.multiview";
  59263. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  59264. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59265. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  59266. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  59267. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  59268. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  59269. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  59270. export * from "babylonjs/Engines/Extensions/engine.webVR";
  59271. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  59272. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  59273. export * from "babylonjs/Engines/Extensions/engine.views";
  59274. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  59275. import "babylonjs/Engines/Extensions/engine.textureSelector";
  59276. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  59277. }
  59278. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  59279. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59280. /** @hidden */
  59281. export var rgbdEncodePixelShader: {
  59282. name: string;
  59283. shader: string;
  59284. };
  59285. }
  59286. declare module "babylonjs/Misc/environmentTextureTools" {
  59287. import { Nullable } from "babylonjs/types";
  59288. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59289. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59290. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59291. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  59292. import "babylonjs/Engines/Extensions/engine.readTexture";
  59293. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59294. import "babylonjs/Shaders/rgbdEncode.fragment";
  59295. import "babylonjs/Shaders/rgbdDecode.fragment";
  59296. /**
  59297. * Raw texture data and descriptor sufficient for WebGL texture upload
  59298. */
  59299. export interface EnvironmentTextureInfo {
  59300. /**
  59301. * Version of the environment map
  59302. */
  59303. version: number;
  59304. /**
  59305. * Width of image
  59306. */
  59307. width: number;
  59308. /**
  59309. * Irradiance information stored in the file.
  59310. */
  59311. irradiance: any;
  59312. /**
  59313. * Specular information stored in the file.
  59314. */
  59315. specular: any;
  59316. }
  59317. /**
  59318. * Defines One Image in the file. It requires only the position in the file
  59319. * as well as the length.
  59320. */
  59321. interface BufferImageData {
  59322. /**
  59323. * Length of the image data.
  59324. */
  59325. length: number;
  59326. /**
  59327. * Position of the data from the null terminator delimiting the end of the JSON.
  59328. */
  59329. position: number;
  59330. }
  59331. /**
  59332. * Defines the specular data enclosed in the file.
  59333. * This corresponds to the version 1 of the data.
  59334. */
  59335. export interface EnvironmentTextureSpecularInfoV1 {
  59336. /**
  59337. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  59338. */
  59339. specularDataPosition?: number;
  59340. /**
  59341. * This contains all the images data needed to reconstruct the cubemap.
  59342. */
  59343. mipmaps: Array<BufferImageData>;
  59344. /**
  59345. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  59346. */
  59347. lodGenerationScale: number;
  59348. }
  59349. /**
  59350. * Sets of helpers addressing the serialization and deserialization of environment texture
  59351. * stored in a BabylonJS env file.
  59352. * Those files are usually stored as .env files.
  59353. */
  59354. export class EnvironmentTextureTools {
  59355. /**
  59356. * Magic number identifying the env file.
  59357. */
  59358. private static _MagicBytes;
  59359. /**
  59360. * Gets the environment info from an env file.
  59361. * @param data The array buffer containing the .env bytes.
  59362. * @returns the environment file info (the json header) if successfully parsed.
  59363. */
  59364. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  59365. /**
  59366. * Creates an environment texture from a loaded cube texture.
  59367. * @param texture defines the cube texture to convert in env file
  59368. * @return a promise containing the environment data if succesfull.
  59369. */
  59370. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  59371. /**
  59372. * Creates a JSON representation of the spherical data.
  59373. * @param texture defines the texture containing the polynomials
  59374. * @return the JSON representation of the spherical info
  59375. */
  59376. private static _CreateEnvTextureIrradiance;
  59377. /**
  59378. * Creates the ArrayBufferViews used for initializing environment texture image data.
  59379. * @param data the image data
  59380. * @param info parameters that determine what views will be created for accessing the underlying buffer
  59381. * @return the views described by info providing access to the underlying buffer
  59382. */
  59383. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  59384. /**
  59385. * Uploads the texture info contained in the env file to the GPU.
  59386. * @param texture defines the internal texture to upload to
  59387. * @param data defines the data to load
  59388. * @param info defines the texture info retrieved through the GetEnvInfo method
  59389. * @returns a promise
  59390. */
  59391. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  59392. private static _OnImageReadyAsync;
  59393. /**
  59394. * Uploads the levels of image data to the GPU.
  59395. * @param texture defines the internal texture to upload to
  59396. * @param imageData defines the array buffer views of image data [mipmap][face]
  59397. * @returns a promise
  59398. */
  59399. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  59400. /**
  59401. * Uploads spherical polynomials information to the texture.
  59402. * @param texture defines the texture we are trying to upload the information to
  59403. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  59404. */
  59405. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  59406. /** @hidden */
  59407. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59408. }
  59409. }
  59410. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  59411. /**
  59412. * Class used to inline functions in shader code
  59413. */
  59414. export class ShaderCodeInliner {
  59415. private static readonly _RegexpFindFunctionNameAndType;
  59416. private _sourceCode;
  59417. private _functionDescr;
  59418. private _numMaxIterations;
  59419. /** Gets or sets the token used to mark the functions to inline */
  59420. inlineToken: string;
  59421. /** Gets or sets the debug mode */
  59422. debug: boolean;
  59423. /** Gets the code after the inlining process */
  59424. get code(): string;
  59425. /**
  59426. * Initializes the inliner
  59427. * @param sourceCode shader code source to inline
  59428. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  59429. */
  59430. constructor(sourceCode: string, numMaxIterations?: number);
  59431. /**
  59432. * Start the processing of the shader code
  59433. */
  59434. processCode(): void;
  59435. private _collectFunctions;
  59436. private _processInlining;
  59437. private _extractBetweenMarkers;
  59438. private _skipWhitespaces;
  59439. private _removeComments;
  59440. private _replaceFunctionCallsByCode;
  59441. private _findBackward;
  59442. private _escapeRegExp;
  59443. private _replaceNames;
  59444. }
  59445. }
  59446. declare module "babylonjs/Engines/nativeEngine" {
  59447. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  59448. import { Engine } from "babylonjs/Engines/engine";
  59449. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  59450. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59451. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59452. import { Effect } from "babylonjs/Materials/effect";
  59453. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  59454. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  59455. import { IColor4Like } from "babylonjs/Maths/math.like";
  59456. import { Scene } from "babylonjs/scene";
  59457. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  59458. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  59459. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  59460. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  59461. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  59462. /**
  59463. * Container for accessors for natively-stored mesh data buffers.
  59464. */
  59465. class NativeDataBuffer extends DataBuffer {
  59466. /**
  59467. * Accessor value used to identify/retrieve a natively-stored index buffer.
  59468. */
  59469. nativeIndexBuffer?: any;
  59470. /**
  59471. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  59472. */
  59473. nativeVertexBuffer?: any;
  59474. }
  59475. /** @hidden */
  59476. class NativeTexture extends InternalTexture {
  59477. getInternalTexture(): InternalTexture;
  59478. getViewCount(): number;
  59479. }
  59480. /** @hidden */
  59481. export class NativeEngine extends Engine {
  59482. private readonly _native;
  59483. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  59484. private readonly INVALID_HANDLE;
  59485. private _boundBuffersVertexArray;
  59486. private _currentDepthTest;
  59487. getHardwareScalingLevel(): number;
  59488. constructor();
  59489. dispose(): void;
  59490. /**
  59491. * Can be used to override the current requestAnimationFrame requester.
  59492. * @hidden
  59493. */
  59494. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  59495. /**
  59496. * Override default engine behavior.
  59497. * @param color
  59498. * @param backBuffer
  59499. * @param depth
  59500. * @param stencil
  59501. */
  59502. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  59503. /**
  59504. * Gets host document
  59505. * @returns the host document object
  59506. */
  59507. getHostDocument(): Nullable<Document>;
  59508. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59509. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  59510. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  59511. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  59512. [key: string]: VertexBuffer;
  59513. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59514. bindBuffers(vertexBuffers: {
  59515. [key: string]: VertexBuffer;
  59516. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59517. recordVertexArrayObject(vertexBuffers: {
  59518. [key: string]: VertexBuffer;
  59519. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  59520. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59521. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59522. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59523. /**
  59524. * Draw a list of indexed primitives
  59525. * @param fillMode defines the primitive to use
  59526. * @param indexStart defines the starting index
  59527. * @param indexCount defines the number of index to draw
  59528. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59529. */
  59530. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59531. /**
  59532. * Draw a list of unindexed primitives
  59533. * @param fillMode defines the primitive to use
  59534. * @param verticesStart defines the index of first vertex to draw
  59535. * @param verticesCount defines the count of vertices to draw
  59536. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59537. */
  59538. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59539. createPipelineContext(): IPipelineContext;
  59540. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  59541. /** @hidden */
  59542. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  59543. /** @hidden */
  59544. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  59545. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59546. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59547. protected _setProgram(program: WebGLProgram): void;
  59548. _releaseEffect(effect: Effect): void;
  59549. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  59550. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  59551. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  59552. bindSamplers(effect: Effect): void;
  59553. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  59554. getRenderWidth(useScreen?: boolean): number;
  59555. getRenderHeight(useScreen?: boolean): number;
  59556. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  59557. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59558. /**
  59559. * Set the z offset to apply to current rendering
  59560. * @param value defines the offset to apply
  59561. */
  59562. setZOffset(value: number): void;
  59563. /**
  59564. * Gets the current value of the zOffset
  59565. * @returns the current zOffset state
  59566. */
  59567. getZOffset(): number;
  59568. /**
  59569. * Enable or disable depth buffering
  59570. * @param enable defines the state to set
  59571. */
  59572. setDepthBuffer(enable: boolean): void;
  59573. /**
  59574. * Gets a boolean indicating if depth writing is enabled
  59575. * @returns the current depth writing state
  59576. */
  59577. getDepthWrite(): boolean;
  59578. setDepthFunctionToGreater(): void;
  59579. setDepthFunctionToGreaterOrEqual(): void;
  59580. setDepthFunctionToLess(): void;
  59581. setDepthFunctionToLessOrEqual(): void;
  59582. /**
  59583. * Enable or disable depth writing
  59584. * @param enable defines the state to set
  59585. */
  59586. setDepthWrite(enable: boolean): void;
  59587. /**
  59588. * Enable or disable color writing
  59589. * @param enable defines the state to set
  59590. */
  59591. setColorWrite(enable: boolean): void;
  59592. /**
  59593. * Gets a boolean indicating if color writing is enabled
  59594. * @returns the current color writing state
  59595. */
  59596. getColorWrite(): boolean;
  59597. /**
  59598. * Sets alpha constants used by some alpha blending modes
  59599. * @param r defines the red component
  59600. * @param g defines the green component
  59601. * @param b defines the blue component
  59602. * @param a defines the alpha component
  59603. */
  59604. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  59605. /**
  59606. * Sets the current alpha mode
  59607. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  59608. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59609. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59610. */
  59611. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59612. /**
  59613. * Gets the current alpha mode
  59614. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59615. * @returns the current alpha mode
  59616. */
  59617. getAlphaMode(): number;
  59618. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  59619. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59620. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59621. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59622. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59623. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59624. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59625. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59626. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59627. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59628. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59629. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59630. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59631. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59632. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59633. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59634. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59635. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59636. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59637. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59638. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  59639. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  59640. wipeCaches(bruteForce?: boolean): void;
  59641. _createTexture(): WebGLTexture;
  59642. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  59643. /**
  59644. * Update the content of a dynamic texture
  59645. * @param texture defines the texture to update
  59646. * @param canvas defines the canvas containing the source
  59647. * @param invertY defines if data must be stored with Y axis inverted
  59648. * @param premulAlpha defines if alpha is stored as premultiplied
  59649. * @param format defines the format of the data
  59650. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59651. */
  59652. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59653. /**
  59654. * Usually called from Texture.ts.
  59655. * Passed information to create a WebGLTexture
  59656. * @param url defines a value which contains one of the following:
  59657. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59658. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59659. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59660. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59661. * @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)
  59662. * @param scene needed for loading to the correct scene
  59663. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59664. * @param onLoad optional callback to be called upon successful completion
  59665. * @param onError optional callback to be called upon failure
  59666. * @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
  59667. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59668. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59669. * @param forcedExtension defines the extension to use to pick the right loader
  59670. * @param mimeType defines an optional mime type
  59671. * @param loaderOptions options to be passed to the loader
  59672. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59673. */
  59674. 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;
  59675. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  59676. _releaseFramebufferObjects(texture: InternalTexture): void;
  59677. /**
  59678. * Creates a cube texture
  59679. * @param rootUrl defines the url where the files to load is located
  59680. * @param scene defines the current scene
  59681. * @param files defines the list of files to load (1 per face)
  59682. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  59683. * @param onLoad defines an optional callback raised when the texture is loaded
  59684. * @param onError defines an optional callback raised if there is an issue to load the texture
  59685. * @param format defines the format of the data
  59686. * @param forcedExtension defines the extension to use to pick the right loader
  59687. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  59688. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59689. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59690. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  59691. * @returns the cube texture as an InternalTexture
  59692. */
  59693. 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;
  59694. createRenderTargetTexture(size: number | {
  59695. width: number;
  59696. height: number;
  59697. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  59698. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59699. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59700. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59701. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  59702. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  59703. /**
  59704. * Updates a dynamic vertex buffer.
  59705. * @param vertexBuffer the vertex buffer to update
  59706. * @param data the data used to update the vertex buffer
  59707. * @param byteOffset the byte offset of the data (optional)
  59708. * @param byteLength the byte length of the data (optional)
  59709. */
  59710. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  59711. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  59712. private _updateAnisotropicLevel;
  59713. private _getAddressMode;
  59714. /** @hidden */
  59715. _bindTexture(channel: number, texture: InternalTexture): void;
  59716. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  59717. releaseEffects(): void;
  59718. /** @hidden */
  59719. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59720. /** @hidden */
  59721. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59722. /** @hidden */
  59723. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59724. /** @hidden */
  59725. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59726. private _getNativeSamplingMode;
  59727. private _getNativeTextureFormat;
  59728. private _getNativeAlphaMode;
  59729. private _getNativeAttribType;
  59730. }
  59731. }
  59732. declare module "babylonjs/Engines/index" {
  59733. export * from "babylonjs/Engines/constants";
  59734. export * from "babylonjs/Engines/engineCapabilities";
  59735. export * from "babylonjs/Engines/instancingAttributeInfo";
  59736. export * from "babylonjs/Engines/thinEngine";
  59737. export * from "babylonjs/Engines/engine";
  59738. export * from "babylonjs/Engines/engineStore";
  59739. export * from "babylonjs/Engines/nullEngine";
  59740. export * from "babylonjs/Engines/Extensions/index";
  59741. export * from "babylonjs/Engines/IPipelineContext";
  59742. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  59743. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  59744. export * from "babylonjs/Engines/nativeEngine";
  59745. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  59746. export * from "babylonjs/Engines/performanceConfigurator";
  59747. }
  59748. declare module "babylonjs/Events/clipboardEvents" {
  59749. /**
  59750. * Gather the list of clipboard event types as constants.
  59751. */
  59752. export class ClipboardEventTypes {
  59753. /**
  59754. * The clipboard event is fired when a copy command is active (pressed).
  59755. */
  59756. static readonly COPY: number;
  59757. /**
  59758. * The clipboard event is fired when a cut command is active (pressed).
  59759. */
  59760. static readonly CUT: number;
  59761. /**
  59762. * The clipboard event is fired when a paste command is active (pressed).
  59763. */
  59764. static readonly PASTE: number;
  59765. }
  59766. /**
  59767. * This class is used to store clipboard related info for the onClipboardObservable event.
  59768. */
  59769. export class ClipboardInfo {
  59770. /**
  59771. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59772. */
  59773. type: number;
  59774. /**
  59775. * Defines the related dom event
  59776. */
  59777. event: ClipboardEvent;
  59778. /**
  59779. *Creates an instance of ClipboardInfo.
  59780. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  59781. * @param event Defines the related dom event
  59782. */
  59783. constructor(
  59784. /**
  59785. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59786. */
  59787. type: number,
  59788. /**
  59789. * Defines the related dom event
  59790. */
  59791. event: ClipboardEvent);
  59792. /**
  59793. * Get the clipboard event's type from the keycode.
  59794. * @param keyCode Defines the keyCode for the current keyboard event.
  59795. * @return {number}
  59796. */
  59797. static GetTypeFromCharacter(keyCode: number): number;
  59798. }
  59799. }
  59800. declare module "babylonjs/Events/index" {
  59801. export * from "babylonjs/Events/keyboardEvents";
  59802. export * from "babylonjs/Events/pointerEvents";
  59803. export * from "babylonjs/Events/clipboardEvents";
  59804. }
  59805. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  59806. import { Scene } from "babylonjs/scene";
  59807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59808. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59809. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59810. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59811. /**
  59812. * Google Daydream controller
  59813. */
  59814. export class DaydreamController extends WebVRController {
  59815. /**
  59816. * Base Url for the controller model.
  59817. */
  59818. static MODEL_BASE_URL: string;
  59819. /**
  59820. * File name for the controller model.
  59821. */
  59822. static MODEL_FILENAME: string;
  59823. /**
  59824. * Gamepad Id prefix used to identify Daydream Controller.
  59825. */
  59826. static readonly GAMEPAD_ID_PREFIX: string;
  59827. /**
  59828. * Creates a new DaydreamController from a gamepad
  59829. * @param vrGamepad the gamepad that the controller should be created from
  59830. */
  59831. constructor(vrGamepad: any);
  59832. /**
  59833. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59834. * @param scene scene in which to add meshes
  59835. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59836. */
  59837. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59838. /**
  59839. * Called once for each button that changed state since the last frame
  59840. * @param buttonIdx Which button index changed
  59841. * @param state New state of the button
  59842. * @param changes Which properties on the state changed since last frame
  59843. */
  59844. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59845. }
  59846. }
  59847. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  59848. import { Scene } from "babylonjs/scene";
  59849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59850. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59851. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59852. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59853. /**
  59854. * Gear VR Controller
  59855. */
  59856. export class GearVRController extends WebVRController {
  59857. /**
  59858. * Base Url for the controller model.
  59859. */
  59860. static MODEL_BASE_URL: string;
  59861. /**
  59862. * File name for the controller model.
  59863. */
  59864. static MODEL_FILENAME: string;
  59865. /**
  59866. * Gamepad Id prefix used to identify this controller.
  59867. */
  59868. static readonly GAMEPAD_ID_PREFIX: string;
  59869. private readonly _buttonIndexToObservableNameMap;
  59870. /**
  59871. * Creates a new GearVRController from a gamepad
  59872. * @param vrGamepad the gamepad that the controller should be created from
  59873. */
  59874. constructor(vrGamepad: any);
  59875. /**
  59876. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59877. * @param scene scene in which to add meshes
  59878. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59879. */
  59880. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59881. /**
  59882. * Called once for each button that changed state since the last frame
  59883. * @param buttonIdx Which button index changed
  59884. * @param state New state of the button
  59885. * @param changes Which properties on the state changed since last frame
  59886. */
  59887. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59888. }
  59889. }
  59890. declare module "babylonjs/Gamepads/Controllers/genericController" {
  59891. import { Scene } from "babylonjs/scene";
  59892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59893. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59894. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59895. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59896. /**
  59897. * Generic Controller
  59898. */
  59899. export class GenericController extends WebVRController {
  59900. /**
  59901. * Base Url for the controller model.
  59902. */
  59903. static readonly MODEL_BASE_URL: string;
  59904. /**
  59905. * File name for the controller model.
  59906. */
  59907. static readonly MODEL_FILENAME: string;
  59908. /**
  59909. * Creates a new GenericController from a gamepad
  59910. * @param vrGamepad the gamepad that the controller should be created from
  59911. */
  59912. constructor(vrGamepad: any);
  59913. /**
  59914. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59915. * @param scene scene in which to add meshes
  59916. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59917. */
  59918. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59919. /**
  59920. * Called once for each button that changed state since the last frame
  59921. * @param buttonIdx Which button index changed
  59922. * @param state New state of the button
  59923. * @param changes Which properties on the state changed since last frame
  59924. */
  59925. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59926. }
  59927. }
  59928. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  59929. import { Observable } from "babylonjs/Misc/observable";
  59930. import { Scene } from "babylonjs/scene";
  59931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59932. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59933. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59934. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59935. /**
  59936. * Oculus Touch Controller
  59937. */
  59938. export class OculusTouchController extends WebVRController {
  59939. /**
  59940. * Base Url for the controller model.
  59941. */
  59942. static MODEL_BASE_URL: string;
  59943. /**
  59944. * File name for the left controller model.
  59945. */
  59946. static MODEL_LEFT_FILENAME: string;
  59947. /**
  59948. * File name for the right controller model.
  59949. */
  59950. static MODEL_RIGHT_FILENAME: string;
  59951. /**
  59952. * Base Url for the Quest controller model.
  59953. */
  59954. static QUEST_MODEL_BASE_URL: string;
  59955. /**
  59956. * @hidden
  59957. * If the controllers are running on a device that needs the updated Quest controller models
  59958. */
  59959. static _IsQuest: boolean;
  59960. /**
  59961. * Fired when the secondary trigger on this controller is modified
  59962. */
  59963. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  59964. /**
  59965. * Fired when the thumb rest on this controller is modified
  59966. */
  59967. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  59968. /**
  59969. * Creates a new OculusTouchController from a gamepad
  59970. * @param vrGamepad the gamepad that the controller should be created from
  59971. */
  59972. constructor(vrGamepad: any);
  59973. /**
  59974. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59975. * @param scene scene in which to add meshes
  59976. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59977. */
  59978. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59979. /**
  59980. * Fired when the A button on this controller is modified
  59981. */
  59982. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59983. /**
  59984. * Fired when the B button on this controller is modified
  59985. */
  59986. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59987. /**
  59988. * Fired when the X button on this controller is modified
  59989. */
  59990. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59991. /**
  59992. * Fired when the Y button on this controller is modified
  59993. */
  59994. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59995. /**
  59996. * Called once for each button that changed state since the last frame
  59997. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  59998. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  59999. * 2) secondary trigger (same)
  60000. * 3) A (right) X (left), touch, pressed = value
  60001. * 4) B / Y
  60002. * 5) thumb rest
  60003. * @param buttonIdx Which button index changed
  60004. * @param state New state of the button
  60005. * @param changes Which properties on the state changed since last frame
  60006. */
  60007. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60008. }
  60009. }
  60010. declare module "babylonjs/Gamepads/Controllers/viveController" {
  60011. import { Scene } from "babylonjs/scene";
  60012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60013. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  60014. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  60015. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  60016. import { Observable } from "babylonjs/Misc/observable";
  60017. /**
  60018. * Vive Controller
  60019. */
  60020. export class ViveController extends WebVRController {
  60021. /**
  60022. * Base Url for the controller model.
  60023. */
  60024. static MODEL_BASE_URL: string;
  60025. /**
  60026. * File name for the controller model.
  60027. */
  60028. static MODEL_FILENAME: string;
  60029. /**
  60030. * Creates a new ViveController from a gamepad
  60031. * @param vrGamepad the gamepad that the controller should be created from
  60032. */
  60033. constructor(vrGamepad: any);
  60034. /**
  60035. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60036. * @param scene scene in which to add meshes
  60037. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60038. */
  60039. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60040. /**
  60041. * Fired when the left button on this controller is modified
  60042. */
  60043. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60044. /**
  60045. * Fired when the right button on this controller is modified
  60046. */
  60047. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60048. /**
  60049. * Fired when the menu button on this controller is modified
  60050. */
  60051. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60052. /**
  60053. * Called once for each button that changed state since the last frame
  60054. * Vive mapping:
  60055. * 0: touchpad
  60056. * 1: trigger
  60057. * 2: left AND right buttons
  60058. * 3: menu button
  60059. * @param buttonIdx Which button index changed
  60060. * @param state New state of the button
  60061. * @param changes Which properties on the state changed since last frame
  60062. */
  60063. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60064. }
  60065. }
  60066. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  60067. import { Observable } from "babylonjs/Misc/observable";
  60068. import { Scene } from "babylonjs/scene";
  60069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60070. import { Ray } from "babylonjs/Culling/ray";
  60071. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  60072. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  60073. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  60074. /**
  60075. * Defines the WindowsMotionController object that the state of the windows motion controller
  60076. */
  60077. export class WindowsMotionController extends WebVRController {
  60078. /**
  60079. * The base url used to load the left and right controller models
  60080. */
  60081. static MODEL_BASE_URL: string;
  60082. /**
  60083. * The name of the left controller model file
  60084. */
  60085. static MODEL_LEFT_FILENAME: string;
  60086. /**
  60087. * The name of the right controller model file
  60088. */
  60089. static MODEL_RIGHT_FILENAME: string;
  60090. /**
  60091. * The controller name prefix for this controller type
  60092. */
  60093. static readonly GAMEPAD_ID_PREFIX: string;
  60094. /**
  60095. * The controller id pattern for this controller type
  60096. */
  60097. private static readonly GAMEPAD_ID_PATTERN;
  60098. private _loadedMeshInfo;
  60099. protected readonly _mapping: {
  60100. buttons: string[];
  60101. buttonMeshNames: {
  60102. trigger: string;
  60103. menu: string;
  60104. grip: string;
  60105. thumbstick: string;
  60106. trackpad: string;
  60107. };
  60108. buttonObservableNames: {
  60109. trigger: string;
  60110. menu: string;
  60111. grip: string;
  60112. thumbstick: string;
  60113. trackpad: string;
  60114. };
  60115. axisMeshNames: string[];
  60116. pointingPoseMeshName: string;
  60117. };
  60118. /**
  60119. * Fired when the trackpad on this controller is clicked
  60120. */
  60121. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60122. /**
  60123. * Fired when the trackpad on this controller is modified
  60124. */
  60125. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60126. /**
  60127. * The current x and y values of this controller's trackpad
  60128. */
  60129. trackpad: StickValues;
  60130. /**
  60131. * Creates a new WindowsMotionController from a gamepad
  60132. * @param vrGamepad the gamepad that the controller should be created from
  60133. */
  60134. constructor(vrGamepad: any);
  60135. /**
  60136. * Fired when the trigger on this controller is modified
  60137. */
  60138. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60139. /**
  60140. * Fired when the menu button on this controller is modified
  60141. */
  60142. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60143. /**
  60144. * Fired when the grip button on this controller is modified
  60145. */
  60146. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60147. /**
  60148. * Fired when the thumbstick button on this controller is modified
  60149. */
  60150. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60151. /**
  60152. * Fired when the touchpad button on this controller is modified
  60153. */
  60154. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60155. /**
  60156. * Fired when the touchpad values on this controller are modified
  60157. */
  60158. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60159. protected _updateTrackpad(): void;
  60160. /**
  60161. * Called once per frame by the engine.
  60162. */
  60163. update(): void;
  60164. /**
  60165. * Called once for each button that changed state since the last frame
  60166. * @param buttonIdx Which button index changed
  60167. * @param state New state of the button
  60168. * @param changes Which properties on the state changed since last frame
  60169. */
  60170. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60171. /**
  60172. * Moves the buttons on the controller mesh based on their current state
  60173. * @param buttonName the name of the button to move
  60174. * @param buttonValue the value of the button which determines the buttons new position
  60175. */
  60176. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60177. /**
  60178. * Moves the axis on the controller mesh based on its current state
  60179. * @param axis the index of the axis
  60180. * @param axisValue the value of the axis which determines the meshes new position
  60181. * @hidden
  60182. */
  60183. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60184. /**
  60185. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60186. * @param scene scene in which to add meshes
  60187. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60188. */
  60189. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60190. /**
  60191. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60192. * can be transformed by button presses and axes values, based on this._mapping.
  60193. *
  60194. * @param scene scene in which the meshes exist
  60195. * @param meshes list of meshes that make up the controller model to process
  60196. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60197. */
  60198. private processModel;
  60199. private createMeshInfo;
  60200. /**
  60201. * Gets the ray of the controller in the direction the controller is pointing
  60202. * @param length the length the resulting ray should be
  60203. * @returns a ray in the direction the controller is pointing
  60204. */
  60205. getForwardRay(length?: number): Ray;
  60206. /**
  60207. * Disposes of the controller
  60208. */
  60209. dispose(): void;
  60210. }
  60211. /**
  60212. * This class represents a new windows motion controller in XR.
  60213. */
  60214. export class XRWindowsMotionController extends WindowsMotionController {
  60215. /**
  60216. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60217. */
  60218. protected readonly _mapping: {
  60219. buttons: string[];
  60220. buttonMeshNames: {
  60221. trigger: string;
  60222. menu: string;
  60223. grip: string;
  60224. thumbstick: string;
  60225. trackpad: string;
  60226. };
  60227. buttonObservableNames: {
  60228. trigger: string;
  60229. menu: string;
  60230. grip: string;
  60231. thumbstick: string;
  60232. trackpad: string;
  60233. };
  60234. axisMeshNames: string[];
  60235. pointingPoseMeshName: string;
  60236. };
  60237. /**
  60238. * Construct a new XR-Based windows motion controller
  60239. *
  60240. * @param gamepadInfo the gamepad object from the browser
  60241. */
  60242. constructor(gamepadInfo: any);
  60243. /**
  60244. * holds the thumbstick values (X,Y)
  60245. */
  60246. thumbstickValues: StickValues;
  60247. /**
  60248. * Fired when the thumbstick on this controller is clicked
  60249. */
  60250. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60251. /**
  60252. * Fired when the thumbstick on this controller is modified
  60253. */
  60254. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60255. /**
  60256. * Fired when the touchpad button on this controller is modified
  60257. */
  60258. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60259. /**
  60260. * Fired when the touchpad values on this controller are modified
  60261. */
  60262. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60263. /**
  60264. * Fired when the thumbstick button on this controller is modified
  60265. * here to prevent breaking changes
  60266. */
  60267. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60268. /**
  60269. * updating the thumbstick(!) and not the trackpad.
  60270. * This is named this way due to the difference between WebVR and XR and to avoid
  60271. * changing the parent class.
  60272. */
  60273. protected _updateTrackpad(): void;
  60274. /**
  60275. * Disposes the class with joy
  60276. */
  60277. dispose(): void;
  60278. }
  60279. }
  60280. declare module "babylonjs/Gamepads/Controllers/index" {
  60281. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  60282. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  60283. export * from "babylonjs/Gamepads/Controllers/genericController";
  60284. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  60285. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  60286. export * from "babylonjs/Gamepads/Controllers/viveController";
  60287. export * from "babylonjs/Gamepads/Controllers/webVRController";
  60288. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  60289. }
  60290. declare module "babylonjs/Gamepads/index" {
  60291. export * from "babylonjs/Gamepads/Controllers/index";
  60292. export * from "babylonjs/Gamepads/gamepad";
  60293. export * from "babylonjs/Gamepads/gamepadManager";
  60294. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  60295. export * from "babylonjs/Gamepads/xboxGamepad";
  60296. export * from "babylonjs/Gamepads/dualShockGamepad";
  60297. }
  60298. declare module "babylonjs/Lights/directionalLight" {
  60299. import { Camera } from "babylonjs/Cameras/camera";
  60300. import { Scene } from "babylonjs/scene";
  60301. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60303. import { Light } from "babylonjs/Lights/light";
  60304. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60305. import { Effect } from "babylonjs/Materials/effect";
  60306. /**
  60307. * A directional light is defined by a direction (what a surprise!).
  60308. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60309. * 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.
  60310. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60311. */
  60312. export class DirectionalLight extends ShadowLight {
  60313. private _shadowFrustumSize;
  60314. /**
  60315. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60316. */
  60317. get shadowFrustumSize(): number;
  60318. /**
  60319. * Specifies a fix frustum size for the shadow generation.
  60320. */
  60321. set shadowFrustumSize(value: number);
  60322. private _shadowOrthoScale;
  60323. /**
  60324. * Gets the shadow projection scale against the optimal computed one.
  60325. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60326. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60327. */
  60328. get shadowOrthoScale(): number;
  60329. /**
  60330. * Sets the shadow projection scale against the optimal computed one.
  60331. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60332. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60333. */
  60334. set shadowOrthoScale(value: number);
  60335. /**
  60336. * Automatically compute the projection matrix to best fit (including all the casters)
  60337. * on each frame.
  60338. */
  60339. autoUpdateExtends: boolean;
  60340. /**
  60341. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  60342. * on each frame. autoUpdateExtends must be set to true for this to work
  60343. */
  60344. autoCalcShadowZBounds: boolean;
  60345. private _orthoLeft;
  60346. private _orthoRight;
  60347. private _orthoTop;
  60348. private _orthoBottom;
  60349. /**
  60350. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  60351. * The directional light is emitted from everywhere in the given direction.
  60352. * It can cast shadows.
  60353. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60354. * @param name The friendly name of the light
  60355. * @param direction The direction of the light
  60356. * @param scene The scene the light belongs to
  60357. */
  60358. constructor(name: string, direction: Vector3, scene: Scene);
  60359. /**
  60360. * Returns the string "DirectionalLight".
  60361. * @return The class name
  60362. */
  60363. getClassName(): string;
  60364. /**
  60365. * Returns the integer 1.
  60366. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60367. */
  60368. getTypeID(): number;
  60369. /**
  60370. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  60371. * Returns the DirectionalLight Shadow projection matrix.
  60372. */
  60373. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60374. /**
  60375. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  60376. * Returns the DirectionalLight Shadow projection matrix.
  60377. */
  60378. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  60379. /**
  60380. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  60381. * Returns the DirectionalLight Shadow projection matrix.
  60382. */
  60383. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60384. protected _buildUniformLayout(): void;
  60385. /**
  60386. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  60387. * @param effect The effect to update
  60388. * @param lightIndex The index of the light in the effect to update
  60389. * @returns The directional light
  60390. */
  60391. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  60392. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  60393. /**
  60394. * Gets the minZ used for shadow according to both the scene and the light.
  60395. *
  60396. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60397. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60398. * @param activeCamera The camera we are returning the min for
  60399. * @returns the depth min z
  60400. */
  60401. getDepthMinZ(activeCamera: Camera): number;
  60402. /**
  60403. * Gets the maxZ used for shadow according to both the scene and the light.
  60404. *
  60405. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60406. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60407. * @param activeCamera The camera we are returning the max for
  60408. * @returns the depth max z
  60409. */
  60410. getDepthMaxZ(activeCamera: Camera): number;
  60411. /**
  60412. * Prepares the list of defines specific to the light type.
  60413. * @param defines the list of defines
  60414. * @param lightIndex defines the index of the light for the effect
  60415. */
  60416. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60417. }
  60418. }
  60419. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  60420. import { Mesh } from "babylonjs/Meshes/mesh";
  60421. /**
  60422. * Class containing static functions to help procedurally build meshes
  60423. */
  60424. export class HemisphereBuilder {
  60425. /**
  60426. * Creates a hemisphere mesh
  60427. * @param name defines the name of the mesh
  60428. * @param options defines the options used to create the mesh
  60429. * @param scene defines the hosting scene
  60430. * @returns the hemisphere mesh
  60431. */
  60432. static CreateHemisphere(name: string, options: {
  60433. segments?: number;
  60434. diameter?: number;
  60435. sideOrientation?: number;
  60436. }, scene: any): Mesh;
  60437. }
  60438. }
  60439. declare module "babylonjs/Lights/spotLight" {
  60440. import { Nullable } from "babylonjs/types";
  60441. import { Scene } from "babylonjs/scene";
  60442. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60444. import { Effect } from "babylonjs/Materials/effect";
  60445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60446. import { Light } from "babylonjs/Lights/light";
  60447. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60448. /**
  60449. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60450. * These values define a cone of light starting from the position, emitting toward the direction.
  60451. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60452. * and the exponent defines the speed of the decay of the light with distance (reach).
  60453. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60454. */
  60455. export class SpotLight extends ShadowLight {
  60456. private _angle;
  60457. private _innerAngle;
  60458. private _cosHalfAngle;
  60459. private _lightAngleScale;
  60460. private _lightAngleOffset;
  60461. /**
  60462. * Gets the cone angle of the spot light in Radians.
  60463. */
  60464. get angle(): number;
  60465. /**
  60466. * Sets the cone angle of the spot light in Radians.
  60467. */
  60468. set angle(value: number);
  60469. /**
  60470. * Only used in gltf falloff mode, this defines the angle where
  60471. * the directional falloff will start before cutting at angle which could be seen
  60472. * as outer angle.
  60473. */
  60474. get innerAngle(): number;
  60475. /**
  60476. * Only used in gltf falloff mode, this defines the angle where
  60477. * the directional falloff will start before cutting at angle which could be seen
  60478. * as outer angle.
  60479. */
  60480. set innerAngle(value: number);
  60481. private _shadowAngleScale;
  60482. /**
  60483. * Allows scaling the angle of the light for shadow generation only.
  60484. */
  60485. get shadowAngleScale(): number;
  60486. /**
  60487. * Allows scaling the angle of the light for shadow generation only.
  60488. */
  60489. set shadowAngleScale(value: number);
  60490. /**
  60491. * The light decay speed with the distance from the emission spot.
  60492. */
  60493. exponent: number;
  60494. private _projectionTextureMatrix;
  60495. /**
  60496. * Allows reading the projecton texture
  60497. */
  60498. get projectionTextureMatrix(): Matrix;
  60499. protected _projectionTextureLightNear: number;
  60500. /**
  60501. * Gets the near clip of the Spotlight for texture projection.
  60502. */
  60503. get projectionTextureLightNear(): number;
  60504. /**
  60505. * Sets the near clip of the Spotlight for texture projection.
  60506. */
  60507. set projectionTextureLightNear(value: number);
  60508. protected _projectionTextureLightFar: number;
  60509. /**
  60510. * Gets the far clip of the Spotlight for texture projection.
  60511. */
  60512. get projectionTextureLightFar(): number;
  60513. /**
  60514. * Sets the far clip of the Spotlight for texture projection.
  60515. */
  60516. set projectionTextureLightFar(value: number);
  60517. protected _projectionTextureUpDirection: Vector3;
  60518. /**
  60519. * Gets the Up vector of the Spotlight for texture projection.
  60520. */
  60521. get projectionTextureUpDirection(): Vector3;
  60522. /**
  60523. * Sets the Up vector of the Spotlight for texture projection.
  60524. */
  60525. set projectionTextureUpDirection(value: Vector3);
  60526. private _projectionTexture;
  60527. /**
  60528. * Gets the projection texture of the light.
  60529. */
  60530. get projectionTexture(): Nullable<BaseTexture>;
  60531. /**
  60532. * Sets the projection texture of the light.
  60533. */
  60534. set projectionTexture(value: Nullable<BaseTexture>);
  60535. private static _IsProceduralTexture;
  60536. private static _IsTexture;
  60537. private _projectionTextureViewLightDirty;
  60538. private _projectionTextureProjectionLightDirty;
  60539. private _projectionTextureDirty;
  60540. private _projectionTextureViewTargetVector;
  60541. private _projectionTextureViewLightMatrix;
  60542. private _projectionTextureProjectionLightMatrix;
  60543. private _projectionTextureScalingMatrix;
  60544. /**
  60545. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60546. * It can cast shadows.
  60547. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60548. * @param name The light friendly name
  60549. * @param position The position of the spot light in the scene
  60550. * @param direction The direction of the light in the scene
  60551. * @param angle The cone angle of the light in Radians
  60552. * @param exponent The light decay speed with the distance from the emission spot
  60553. * @param scene The scene the lights belongs to
  60554. */
  60555. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60556. /**
  60557. * Returns the string "SpotLight".
  60558. * @returns the class name
  60559. */
  60560. getClassName(): string;
  60561. /**
  60562. * Returns the integer 2.
  60563. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60564. */
  60565. getTypeID(): number;
  60566. /**
  60567. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60568. */
  60569. protected _setDirection(value: Vector3): void;
  60570. /**
  60571. * Overrides the position setter to recompute the projection texture view light Matrix.
  60572. */
  60573. protected _setPosition(value: Vector3): void;
  60574. /**
  60575. * 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.
  60576. * Returns the SpotLight.
  60577. */
  60578. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60579. protected _computeProjectionTextureViewLightMatrix(): void;
  60580. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60581. /**
  60582. * Main function for light texture projection matrix computing.
  60583. */
  60584. protected _computeProjectionTextureMatrix(): void;
  60585. protected _buildUniformLayout(): void;
  60586. private _computeAngleValues;
  60587. /**
  60588. * Sets the passed Effect "effect" with the Light textures.
  60589. * @param effect The effect to update
  60590. * @param lightIndex The index of the light in the effect to update
  60591. * @returns The light
  60592. */
  60593. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60594. /**
  60595. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60596. * @param effect The effect to update
  60597. * @param lightIndex The index of the light in the effect to update
  60598. * @returns The spot light
  60599. */
  60600. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60601. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60602. /**
  60603. * Disposes the light and the associated resources.
  60604. */
  60605. dispose(): void;
  60606. /**
  60607. * Prepares the list of defines specific to the light type.
  60608. * @param defines the list of defines
  60609. * @param lightIndex defines the index of the light for the effect
  60610. */
  60611. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60612. }
  60613. }
  60614. declare module "babylonjs/Gizmos/lightGizmo" {
  60615. import { Nullable } from "babylonjs/types";
  60616. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60617. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60618. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60619. import { Light } from "babylonjs/Lights/light";
  60620. import { Observable } from "babylonjs/Misc/observable";
  60621. /**
  60622. * Gizmo that enables viewing a light
  60623. */
  60624. export class LightGizmo extends Gizmo {
  60625. private _lightMesh;
  60626. private _material;
  60627. private _cachedPosition;
  60628. private _cachedForward;
  60629. private _attachedMeshParent;
  60630. private _pointerObserver;
  60631. /**
  60632. * Event that fires each time the gizmo is clicked
  60633. */
  60634. onClickedObservable: Observable<Light>;
  60635. /**
  60636. * Creates a LightGizmo
  60637. * @param gizmoLayer The utility layer the gizmo will be added to
  60638. */
  60639. constructor(gizmoLayer?: UtilityLayerRenderer);
  60640. private _light;
  60641. /**
  60642. * The light that the gizmo is attached to
  60643. */
  60644. set light(light: Nullable<Light>);
  60645. get light(): Nullable<Light>;
  60646. /**
  60647. * Gets the material used to render the light gizmo
  60648. */
  60649. get material(): StandardMaterial;
  60650. /**
  60651. * @hidden
  60652. * Updates the gizmo to match the attached mesh's position/rotation
  60653. */
  60654. protected _update(): void;
  60655. private static _Scale;
  60656. /**
  60657. * Creates the lines for a light mesh
  60658. */
  60659. private static _CreateLightLines;
  60660. /**
  60661. * Disposes of the light gizmo
  60662. */
  60663. dispose(): void;
  60664. private static _CreateHemisphericLightMesh;
  60665. private static _CreatePointLightMesh;
  60666. private static _CreateSpotLightMesh;
  60667. private static _CreateDirectionalLightMesh;
  60668. }
  60669. }
  60670. declare module "babylonjs/Gizmos/cameraGizmo" {
  60671. import { Nullable } from "babylonjs/types";
  60672. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60673. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60674. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60675. import { Camera } from "babylonjs/Cameras/camera";
  60676. import { Observable } from "babylonjs/Misc/observable";
  60677. /**
  60678. * Gizmo that enables viewing a camera
  60679. */
  60680. export class CameraGizmo extends Gizmo {
  60681. private _cameraMesh;
  60682. private _cameraLinesMesh;
  60683. private _material;
  60684. private _pointerObserver;
  60685. /**
  60686. * Event that fires each time the gizmo is clicked
  60687. */
  60688. onClickedObservable: Observable<Camera>;
  60689. /**
  60690. * Creates a CameraGizmo
  60691. * @param gizmoLayer The utility layer the gizmo will be added to
  60692. */
  60693. constructor(gizmoLayer?: UtilityLayerRenderer);
  60694. private _camera;
  60695. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  60696. get displayFrustum(): boolean;
  60697. set displayFrustum(value: boolean);
  60698. /**
  60699. * The camera that the gizmo is attached to
  60700. */
  60701. set camera(camera: Nullable<Camera>);
  60702. get camera(): Nullable<Camera>;
  60703. /**
  60704. * Gets the material used to render the camera gizmo
  60705. */
  60706. get material(): StandardMaterial;
  60707. /**
  60708. * @hidden
  60709. * Updates the gizmo to match the attached mesh's position/rotation
  60710. */
  60711. protected _update(): void;
  60712. private static _Scale;
  60713. private _invProjection;
  60714. /**
  60715. * Disposes of the camera gizmo
  60716. */
  60717. dispose(): void;
  60718. private static _CreateCameraMesh;
  60719. private static _CreateCameraFrustum;
  60720. }
  60721. }
  60722. declare module "babylonjs/Gizmos/index" {
  60723. export * from "babylonjs/Gizmos/axisDragGizmo";
  60724. export * from "babylonjs/Gizmos/axisScaleGizmo";
  60725. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  60726. export * from "babylonjs/Gizmos/gizmo";
  60727. export * from "babylonjs/Gizmos/gizmoManager";
  60728. export * from "babylonjs/Gizmos/planeRotationGizmo";
  60729. export * from "babylonjs/Gizmos/positionGizmo";
  60730. export * from "babylonjs/Gizmos/rotationGizmo";
  60731. export * from "babylonjs/Gizmos/scaleGizmo";
  60732. export * from "babylonjs/Gizmos/lightGizmo";
  60733. export * from "babylonjs/Gizmos/cameraGizmo";
  60734. export * from "babylonjs/Gizmos/planeDragGizmo";
  60735. }
  60736. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  60737. /** @hidden */
  60738. export var backgroundFragmentDeclaration: {
  60739. name: string;
  60740. shader: string;
  60741. };
  60742. }
  60743. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  60744. /** @hidden */
  60745. export var backgroundUboDeclaration: {
  60746. name: string;
  60747. shader: string;
  60748. };
  60749. }
  60750. declare module "babylonjs/Shaders/background.fragment" {
  60751. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  60752. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60753. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60754. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60755. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60756. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60757. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60758. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  60759. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  60760. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60761. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  60762. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  60763. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60764. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60765. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  60766. /** @hidden */
  60767. export var backgroundPixelShader: {
  60768. name: string;
  60769. shader: string;
  60770. };
  60771. }
  60772. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  60773. /** @hidden */
  60774. export var backgroundVertexDeclaration: {
  60775. name: string;
  60776. shader: string;
  60777. };
  60778. }
  60779. declare module "babylonjs/Shaders/background.vertex" {
  60780. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  60781. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60782. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60783. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60784. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60785. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  60786. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  60787. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60788. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60789. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60790. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60791. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60792. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  60793. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60794. /** @hidden */
  60795. export var backgroundVertexShader: {
  60796. name: string;
  60797. shader: string;
  60798. };
  60799. }
  60800. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  60801. import { Nullable, int, float } from "babylonjs/types";
  60802. import { Scene } from "babylonjs/scene";
  60803. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60804. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60806. import { Mesh } from "babylonjs/Meshes/mesh";
  60807. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60808. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  60809. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  60810. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60811. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  60812. import { Color3 } from "babylonjs/Maths/math.color";
  60813. import "babylonjs/Shaders/background.fragment";
  60814. import "babylonjs/Shaders/background.vertex";
  60815. /**
  60816. * Background material used to create an efficient environement around your scene.
  60817. */
  60818. export class BackgroundMaterial extends PushMaterial {
  60819. /**
  60820. * Standard reflectance value at parallel view angle.
  60821. */
  60822. static StandardReflectance0: number;
  60823. /**
  60824. * Standard reflectance value at grazing angle.
  60825. */
  60826. static StandardReflectance90: number;
  60827. protected _primaryColor: Color3;
  60828. /**
  60829. * Key light Color (multiply against the environement texture)
  60830. */
  60831. primaryColor: Color3;
  60832. protected __perceptualColor: Nullable<Color3>;
  60833. /**
  60834. * Experimental Internal Use Only.
  60835. *
  60836. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60837. * This acts as a helper to set the primary color to a more "human friendly" value.
  60838. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60839. * output color as close as possible from the chosen value.
  60840. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60841. * part of lighting setup.)
  60842. */
  60843. get _perceptualColor(): Nullable<Color3>;
  60844. set _perceptualColor(value: Nullable<Color3>);
  60845. protected _primaryColorShadowLevel: float;
  60846. /**
  60847. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60848. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60849. */
  60850. get primaryColorShadowLevel(): float;
  60851. set primaryColorShadowLevel(value: float);
  60852. protected _primaryColorHighlightLevel: float;
  60853. /**
  60854. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60855. * The primary color is used at the level chosen to define what the white area would look.
  60856. */
  60857. get primaryColorHighlightLevel(): float;
  60858. set primaryColorHighlightLevel(value: float);
  60859. protected _reflectionTexture: Nullable<BaseTexture>;
  60860. /**
  60861. * Reflection Texture used in the material.
  60862. * Should be author in a specific way for the best result (refer to the documentation).
  60863. */
  60864. reflectionTexture: Nullable<BaseTexture>;
  60865. protected _reflectionBlur: float;
  60866. /**
  60867. * Reflection Texture level of blur.
  60868. *
  60869. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60870. * texture twice.
  60871. */
  60872. reflectionBlur: float;
  60873. protected _diffuseTexture: Nullable<BaseTexture>;
  60874. /**
  60875. * Diffuse Texture used in the material.
  60876. * Should be author in a specific way for the best result (refer to the documentation).
  60877. */
  60878. diffuseTexture: Nullable<BaseTexture>;
  60879. protected _shadowLights: Nullable<IShadowLight[]>;
  60880. /**
  60881. * Specify the list of lights casting shadow on the material.
  60882. * All scene shadow lights will be included if null.
  60883. */
  60884. shadowLights: Nullable<IShadowLight[]>;
  60885. protected _shadowLevel: float;
  60886. /**
  60887. * Helps adjusting the shadow to a softer level if required.
  60888. * 0 means black shadows and 1 means no shadows.
  60889. */
  60890. shadowLevel: float;
  60891. protected _sceneCenter: Vector3;
  60892. /**
  60893. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60894. * It is usually zero but might be interesting to modify according to your setup.
  60895. */
  60896. sceneCenter: Vector3;
  60897. protected _opacityFresnel: boolean;
  60898. /**
  60899. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60900. * This helps ensuring a nice transition when the camera goes under the ground.
  60901. */
  60902. opacityFresnel: boolean;
  60903. protected _reflectionFresnel: boolean;
  60904. /**
  60905. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60906. * This helps adding a mirror texture on the ground.
  60907. */
  60908. reflectionFresnel: boolean;
  60909. protected _reflectionFalloffDistance: number;
  60910. /**
  60911. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60912. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60913. */
  60914. reflectionFalloffDistance: number;
  60915. protected _reflectionAmount: number;
  60916. /**
  60917. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60918. */
  60919. reflectionAmount: number;
  60920. protected _reflectionReflectance0: number;
  60921. /**
  60922. * This specifies the weight of the reflection at grazing angle.
  60923. */
  60924. reflectionReflectance0: number;
  60925. protected _reflectionReflectance90: number;
  60926. /**
  60927. * This specifies the weight of the reflection at a perpendicular point of view.
  60928. */
  60929. reflectionReflectance90: number;
  60930. /**
  60931. * Sets the reflection reflectance fresnel values according to the default standard
  60932. * empirically know to work well :-)
  60933. */
  60934. set reflectionStandardFresnelWeight(value: number);
  60935. protected _useRGBColor: boolean;
  60936. /**
  60937. * Helps to directly use the maps channels instead of their level.
  60938. */
  60939. useRGBColor: boolean;
  60940. protected _enableNoise: boolean;
  60941. /**
  60942. * This helps reducing the banding effect that could occur on the background.
  60943. */
  60944. enableNoise: boolean;
  60945. /**
  60946. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60947. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60948. * Recommended to be keep at 1.0 except for special cases.
  60949. */
  60950. get fovMultiplier(): number;
  60951. set fovMultiplier(value: number);
  60952. private _fovMultiplier;
  60953. /**
  60954. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60955. */
  60956. useEquirectangularFOV: boolean;
  60957. private _maxSimultaneousLights;
  60958. /**
  60959. * Number of Simultaneous lights allowed on the material.
  60960. */
  60961. maxSimultaneousLights: int;
  60962. private _shadowOnly;
  60963. /**
  60964. * Make the material only render shadows
  60965. */
  60966. shadowOnly: boolean;
  60967. /**
  60968. * Default configuration related to image processing available in the Background Material.
  60969. */
  60970. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60971. /**
  60972. * Keep track of the image processing observer to allow dispose and replace.
  60973. */
  60974. private _imageProcessingObserver;
  60975. /**
  60976. * Attaches a new image processing configuration to the PBR Material.
  60977. * @param configuration (if null the scene configuration will be use)
  60978. */
  60979. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60980. /**
  60981. * Gets the image processing configuration used either in this material.
  60982. */
  60983. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60984. /**
  60985. * Sets the Default image processing configuration used either in the this material.
  60986. *
  60987. * If sets to null, the scene one is in use.
  60988. */
  60989. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60990. /**
  60991. * Gets wether the color curves effect is enabled.
  60992. */
  60993. get cameraColorCurvesEnabled(): boolean;
  60994. /**
  60995. * Sets wether the color curves effect is enabled.
  60996. */
  60997. set cameraColorCurvesEnabled(value: boolean);
  60998. /**
  60999. * Gets wether the color grading effect is enabled.
  61000. */
  61001. get cameraColorGradingEnabled(): boolean;
  61002. /**
  61003. * Gets wether the color grading effect is enabled.
  61004. */
  61005. set cameraColorGradingEnabled(value: boolean);
  61006. /**
  61007. * Gets wether tonemapping is enabled or not.
  61008. */
  61009. get cameraToneMappingEnabled(): boolean;
  61010. /**
  61011. * Sets wether tonemapping is enabled or not
  61012. */
  61013. set cameraToneMappingEnabled(value: boolean);
  61014. /**
  61015. * The camera exposure used on this material.
  61016. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61017. * This corresponds to a photographic exposure.
  61018. */
  61019. get cameraExposure(): float;
  61020. /**
  61021. * The camera exposure used on this material.
  61022. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61023. * This corresponds to a photographic exposure.
  61024. */
  61025. set cameraExposure(value: float);
  61026. /**
  61027. * Gets The camera contrast used on this material.
  61028. */
  61029. get cameraContrast(): float;
  61030. /**
  61031. * Sets The camera contrast used on this material.
  61032. */
  61033. set cameraContrast(value: float);
  61034. /**
  61035. * Gets the Color Grading 2D Lookup Texture.
  61036. */
  61037. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61038. /**
  61039. * Sets the Color Grading 2D Lookup Texture.
  61040. */
  61041. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61042. /**
  61043. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61044. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61045. * 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;
  61046. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61047. */
  61048. get cameraColorCurves(): Nullable<ColorCurves>;
  61049. /**
  61050. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61051. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61052. * 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;
  61053. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61054. */
  61055. set cameraColorCurves(value: Nullable<ColorCurves>);
  61056. /**
  61057. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61058. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61059. */
  61060. switchToBGR: boolean;
  61061. private _renderTargets;
  61062. private _reflectionControls;
  61063. private _white;
  61064. private _primaryShadowColor;
  61065. private _primaryHighlightColor;
  61066. /**
  61067. * Instantiates a Background Material in the given scene
  61068. * @param name The friendly name of the material
  61069. * @param scene The scene to add the material to
  61070. */
  61071. constructor(name: string, scene: Scene);
  61072. /**
  61073. * Gets a boolean indicating that current material needs to register RTT
  61074. */
  61075. get hasRenderTargetTextures(): boolean;
  61076. /**
  61077. * The entire material has been created in order to prevent overdraw.
  61078. * @returns false
  61079. */
  61080. needAlphaTesting(): boolean;
  61081. /**
  61082. * The entire material has been created in order to prevent overdraw.
  61083. * @returns true if blending is enable
  61084. */
  61085. needAlphaBlending(): boolean;
  61086. /**
  61087. * Checks wether the material is ready to be rendered for a given mesh.
  61088. * @param mesh The mesh to render
  61089. * @param subMesh The submesh to check against
  61090. * @param useInstances Specify wether or not the material is used with instances
  61091. * @returns true if all the dependencies are ready (Textures, Effects...)
  61092. */
  61093. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61094. /**
  61095. * Compute the primary color according to the chosen perceptual color.
  61096. */
  61097. private _computePrimaryColorFromPerceptualColor;
  61098. /**
  61099. * Compute the highlights and shadow colors according to their chosen levels.
  61100. */
  61101. private _computePrimaryColors;
  61102. /**
  61103. * Build the uniform buffer used in the material.
  61104. */
  61105. buildUniformLayout(): void;
  61106. /**
  61107. * Unbind the material.
  61108. */
  61109. unbind(): void;
  61110. /**
  61111. * Bind only the world matrix to the material.
  61112. * @param world The world matrix to bind.
  61113. */
  61114. bindOnlyWorldMatrix(world: Matrix): void;
  61115. /**
  61116. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61117. * @param world The world matrix to bind.
  61118. * @param subMesh The submesh to bind for.
  61119. */
  61120. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61121. /**
  61122. * Checks to see if a texture is used in the material.
  61123. * @param texture - Base texture to use.
  61124. * @returns - Boolean specifying if a texture is used in the material.
  61125. */
  61126. hasTexture(texture: BaseTexture): boolean;
  61127. /**
  61128. * Dispose the material.
  61129. * @param forceDisposeEffect Force disposal of the associated effect.
  61130. * @param forceDisposeTextures Force disposal of the associated textures.
  61131. */
  61132. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61133. /**
  61134. * Clones the material.
  61135. * @param name The cloned name.
  61136. * @returns The cloned material.
  61137. */
  61138. clone(name: string): BackgroundMaterial;
  61139. /**
  61140. * Serializes the current material to its JSON representation.
  61141. * @returns The JSON representation.
  61142. */
  61143. serialize(): any;
  61144. /**
  61145. * Gets the class name of the material
  61146. * @returns "BackgroundMaterial"
  61147. */
  61148. getClassName(): string;
  61149. /**
  61150. * Parse a JSON input to create back a background material.
  61151. * @param source The JSON data to parse
  61152. * @param scene The scene to create the parsed material in
  61153. * @param rootUrl The root url of the assets the material depends upon
  61154. * @returns the instantiated BackgroundMaterial.
  61155. */
  61156. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61157. }
  61158. }
  61159. declare module "babylonjs/Helpers/environmentHelper" {
  61160. import { Observable } from "babylonjs/Misc/observable";
  61161. import { Nullable } from "babylonjs/types";
  61162. import { Scene } from "babylonjs/scene";
  61163. import { Vector3 } from "babylonjs/Maths/math.vector";
  61164. import { Color3 } from "babylonjs/Maths/math.color";
  61165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61166. import { Mesh } from "babylonjs/Meshes/mesh";
  61167. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61168. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  61169. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  61170. import "babylonjs/Meshes/Builders/planeBuilder";
  61171. import "babylonjs/Meshes/Builders/boxBuilder";
  61172. /**
  61173. * Represents the different options available during the creation of
  61174. * a Environment helper.
  61175. *
  61176. * This can control the default ground, skybox and image processing setup of your scene.
  61177. */
  61178. export interface IEnvironmentHelperOptions {
  61179. /**
  61180. * Specifies whether or not to create a ground.
  61181. * True by default.
  61182. */
  61183. createGround: boolean;
  61184. /**
  61185. * Specifies the ground size.
  61186. * 15 by default.
  61187. */
  61188. groundSize: number;
  61189. /**
  61190. * The texture used on the ground for the main color.
  61191. * Comes from the BabylonJS CDN by default.
  61192. *
  61193. * Remarks: Can be either a texture or a url.
  61194. */
  61195. groundTexture: string | BaseTexture;
  61196. /**
  61197. * The color mixed in the ground texture by default.
  61198. * BabylonJS clearColor by default.
  61199. */
  61200. groundColor: Color3;
  61201. /**
  61202. * Specifies the ground opacity.
  61203. * 1 by default.
  61204. */
  61205. groundOpacity: number;
  61206. /**
  61207. * Enables the ground to receive shadows.
  61208. * True by default.
  61209. */
  61210. enableGroundShadow: boolean;
  61211. /**
  61212. * Helps preventing the shadow to be fully black on the ground.
  61213. * 0.5 by default.
  61214. */
  61215. groundShadowLevel: number;
  61216. /**
  61217. * Creates a mirror texture attach to the ground.
  61218. * false by default.
  61219. */
  61220. enableGroundMirror: boolean;
  61221. /**
  61222. * Specifies the ground mirror size ratio.
  61223. * 0.3 by default as the default kernel is 64.
  61224. */
  61225. groundMirrorSizeRatio: number;
  61226. /**
  61227. * Specifies the ground mirror blur kernel size.
  61228. * 64 by default.
  61229. */
  61230. groundMirrorBlurKernel: number;
  61231. /**
  61232. * Specifies the ground mirror visibility amount.
  61233. * 1 by default
  61234. */
  61235. groundMirrorAmount: number;
  61236. /**
  61237. * Specifies the ground mirror reflectance weight.
  61238. * This uses the standard weight of the background material to setup the fresnel effect
  61239. * of the mirror.
  61240. * 1 by default.
  61241. */
  61242. groundMirrorFresnelWeight: number;
  61243. /**
  61244. * Specifies the ground mirror Falloff distance.
  61245. * This can helps reducing the size of the reflection.
  61246. * 0 by Default.
  61247. */
  61248. groundMirrorFallOffDistance: number;
  61249. /**
  61250. * Specifies the ground mirror texture type.
  61251. * Unsigned Int by Default.
  61252. */
  61253. groundMirrorTextureType: number;
  61254. /**
  61255. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61256. * the shown objects.
  61257. */
  61258. groundYBias: number;
  61259. /**
  61260. * Specifies whether or not to create a skybox.
  61261. * True by default.
  61262. */
  61263. createSkybox: boolean;
  61264. /**
  61265. * Specifies the skybox size.
  61266. * 20 by default.
  61267. */
  61268. skyboxSize: number;
  61269. /**
  61270. * The texture used on the skybox for the main color.
  61271. * Comes from the BabylonJS CDN by default.
  61272. *
  61273. * Remarks: Can be either a texture or a url.
  61274. */
  61275. skyboxTexture: string | BaseTexture;
  61276. /**
  61277. * The color mixed in the skybox texture by default.
  61278. * BabylonJS clearColor by default.
  61279. */
  61280. skyboxColor: Color3;
  61281. /**
  61282. * The background rotation around the Y axis of the scene.
  61283. * This helps aligning the key lights of your scene with the background.
  61284. * 0 by default.
  61285. */
  61286. backgroundYRotation: number;
  61287. /**
  61288. * Compute automatically the size of the elements to best fit with the scene.
  61289. */
  61290. sizeAuto: boolean;
  61291. /**
  61292. * Default position of the rootMesh if autoSize is not true.
  61293. */
  61294. rootPosition: Vector3;
  61295. /**
  61296. * Sets up the image processing in the scene.
  61297. * true by default.
  61298. */
  61299. setupImageProcessing: boolean;
  61300. /**
  61301. * The texture used as your environment texture in the scene.
  61302. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61303. *
  61304. * Remarks: Can be either a texture or a url.
  61305. */
  61306. environmentTexture: string | BaseTexture;
  61307. /**
  61308. * The value of the exposure to apply to the scene.
  61309. * 0.6 by default if setupImageProcessing is true.
  61310. */
  61311. cameraExposure: number;
  61312. /**
  61313. * The value of the contrast to apply to the scene.
  61314. * 1.6 by default if setupImageProcessing is true.
  61315. */
  61316. cameraContrast: number;
  61317. /**
  61318. * Specifies whether or not tonemapping should be enabled in the scene.
  61319. * true by default if setupImageProcessing is true.
  61320. */
  61321. toneMappingEnabled: boolean;
  61322. }
  61323. /**
  61324. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  61325. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61326. * It also helps with the default setup of your imageProcessing configuration.
  61327. */
  61328. export class EnvironmentHelper {
  61329. /**
  61330. * Default ground texture URL.
  61331. */
  61332. private static _groundTextureCDNUrl;
  61333. /**
  61334. * Default skybox texture URL.
  61335. */
  61336. private static _skyboxTextureCDNUrl;
  61337. /**
  61338. * Default environment texture URL.
  61339. */
  61340. private static _environmentTextureCDNUrl;
  61341. /**
  61342. * Creates the default options for the helper.
  61343. */
  61344. private static _getDefaultOptions;
  61345. private _rootMesh;
  61346. /**
  61347. * Gets the root mesh created by the helper.
  61348. */
  61349. get rootMesh(): Mesh;
  61350. private _skybox;
  61351. /**
  61352. * Gets the skybox created by the helper.
  61353. */
  61354. get skybox(): Nullable<Mesh>;
  61355. private _skyboxTexture;
  61356. /**
  61357. * Gets the skybox texture created by the helper.
  61358. */
  61359. get skyboxTexture(): Nullable<BaseTexture>;
  61360. private _skyboxMaterial;
  61361. /**
  61362. * Gets the skybox material created by the helper.
  61363. */
  61364. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61365. private _ground;
  61366. /**
  61367. * Gets the ground mesh created by the helper.
  61368. */
  61369. get ground(): Nullable<Mesh>;
  61370. private _groundTexture;
  61371. /**
  61372. * Gets the ground texture created by the helper.
  61373. */
  61374. get groundTexture(): Nullable<BaseTexture>;
  61375. private _groundMirror;
  61376. /**
  61377. * Gets the ground mirror created by the helper.
  61378. */
  61379. get groundMirror(): Nullable<MirrorTexture>;
  61380. /**
  61381. * Gets the ground mirror render list to helps pushing the meshes
  61382. * you wish in the ground reflection.
  61383. */
  61384. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61385. private _groundMaterial;
  61386. /**
  61387. * Gets the ground material created by the helper.
  61388. */
  61389. get groundMaterial(): Nullable<BackgroundMaterial>;
  61390. /**
  61391. * Stores the creation options.
  61392. */
  61393. private readonly _scene;
  61394. private _options;
  61395. /**
  61396. * This observable will be notified with any error during the creation of the environment,
  61397. * mainly texture creation errors.
  61398. */
  61399. onErrorObservable: Observable<{
  61400. message?: string;
  61401. exception?: any;
  61402. }>;
  61403. /**
  61404. * constructor
  61405. * @param options Defines the options we want to customize the helper
  61406. * @param scene The scene to add the material to
  61407. */
  61408. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61409. /**
  61410. * Updates the background according to the new options
  61411. * @param options
  61412. */
  61413. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61414. /**
  61415. * Sets the primary color of all the available elements.
  61416. * @param color the main color to affect to the ground and the background
  61417. */
  61418. setMainColor(color: Color3): void;
  61419. /**
  61420. * Setup the image processing according to the specified options.
  61421. */
  61422. private _setupImageProcessing;
  61423. /**
  61424. * Setup the environment texture according to the specified options.
  61425. */
  61426. private _setupEnvironmentTexture;
  61427. /**
  61428. * Setup the background according to the specified options.
  61429. */
  61430. private _setupBackground;
  61431. /**
  61432. * Get the scene sizes according to the setup.
  61433. */
  61434. private _getSceneSize;
  61435. /**
  61436. * Setup the ground according to the specified options.
  61437. */
  61438. private _setupGround;
  61439. /**
  61440. * Setup the ground material according to the specified options.
  61441. */
  61442. private _setupGroundMaterial;
  61443. /**
  61444. * Setup the ground diffuse texture according to the specified options.
  61445. */
  61446. private _setupGroundDiffuseTexture;
  61447. /**
  61448. * Setup the ground mirror texture according to the specified options.
  61449. */
  61450. private _setupGroundMirrorTexture;
  61451. /**
  61452. * Setup the ground to receive the mirror texture.
  61453. */
  61454. private _setupMirrorInGroundMaterial;
  61455. /**
  61456. * Setup the skybox according to the specified options.
  61457. */
  61458. private _setupSkybox;
  61459. /**
  61460. * Setup the skybox material according to the specified options.
  61461. */
  61462. private _setupSkyboxMaterial;
  61463. /**
  61464. * Setup the skybox reflection texture according to the specified options.
  61465. */
  61466. private _setupSkyboxReflectionTexture;
  61467. private _errorHandler;
  61468. /**
  61469. * Dispose all the elements created by the Helper.
  61470. */
  61471. dispose(): void;
  61472. }
  61473. }
  61474. declare module "babylonjs/Helpers/textureDome" {
  61475. import { Scene } from "babylonjs/scene";
  61476. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61477. import { Mesh } from "babylonjs/Meshes/mesh";
  61478. import { Texture } from "babylonjs/Materials/Textures/texture";
  61479. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  61480. import "babylonjs/Meshes/Builders/sphereBuilder";
  61481. import { Nullable } from "babylonjs/types";
  61482. import { Observable } from "babylonjs/Misc/observable";
  61483. /**
  61484. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61485. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61486. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61487. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61488. */
  61489. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61490. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61491. /**
  61492. * Define the source as a Monoscopic panoramic 360/180.
  61493. */
  61494. static readonly MODE_MONOSCOPIC: number;
  61495. /**
  61496. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61497. */
  61498. static readonly MODE_TOPBOTTOM: number;
  61499. /**
  61500. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61501. */
  61502. static readonly MODE_SIDEBYSIDE: number;
  61503. private _halfDome;
  61504. private _crossEye;
  61505. protected _useDirectMapping: boolean;
  61506. /**
  61507. * The texture being displayed on the sphere
  61508. */
  61509. protected _texture: T;
  61510. /**
  61511. * Gets the texture being displayed on the sphere
  61512. */
  61513. get texture(): T;
  61514. /**
  61515. * Sets the texture being displayed on the sphere
  61516. */
  61517. set texture(newTexture: T);
  61518. /**
  61519. * The skybox material
  61520. */
  61521. protected _material: BackgroundMaterial;
  61522. /**
  61523. * The surface used for the dome
  61524. */
  61525. protected _mesh: Mesh;
  61526. /**
  61527. * Gets the mesh used for the dome.
  61528. */
  61529. get mesh(): Mesh;
  61530. /**
  61531. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61532. */
  61533. private _halfDomeMask;
  61534. /**
  61535. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61536. * Also see the options.resolution property.
  61537. */
  61538. get fovMultiplier(): number;
  61539. set fovMultiplier(value: number);
  61540. protected _textureMode: number;
  61541. /**
  61542. * Gets or set the current texture mode for the texture. It can be:
  61543. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61544. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61545. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61546. */
  61547. get textureMode(): number;
  61548. /**
  61549. * Sets the current texture mode for the texture. It can be:
  61550. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61551. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61552. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61553. */
  61554. set textureMode(value: number);
  61555. /**
  61556. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61557. */
  61558. get halfDome(): boolean;
  61559. /**
  61560. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61561. */
  61562. set halfDome(enabled: boolean);
  61563. /**
  61564. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61565. */
  61566. set crossEye(enabled: boolean);
  61567. /**
  61568. * Is it a cross-eye texture?
  61569. */
  61570. get crossEye(): boolean;
  61571. /**
  61572. * The background material of this dome.
  61573. */
  61574. get material(): BackgroundMaterial;
  61575. /**
  61576. * Oberserver used in Stereoscopic VR Mode.
  61577. */
  61578. private _onBeforeCameraRenderObserver;
  61579. /**
  61580. * Observable raised when an error occured while loading the 360 image
  61581. */
  61582. onLoadErrorObservable: Observable<string>;
  61583. /**
  61584. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61585. * @param name Element's name, child elements will append suffixes for their own names.
  61586. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61587. * @param options An object containing optional or exposed sub element properties
  61588. */
  61589. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61590. resolution?: number;
  61591. clickToPlay?: boolean;
  61592. autoPlay?: boolean;
  61593. loop?: boolean;
  61594. size?: number;
  61595. poster?: string;
  61596. faceForward?: boolean;
  61597. useDirectMapping?: boolean;
  61598. halfDomeMode?: boolean;
  61599. crossEyeMode?: boolean;
  61600. generateMipMaps?: boolean;
  61601. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61602. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61603. protected _changeTextureMode(value: number): void;
  61604. /**
  61605. * Releases resources associated with this node.
  61606. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61607. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61608. */
  61609. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61610. }
  61611. }
  61612. declare module "babylonjs/Helpers/photoDome" {
  61613. import { Scene } from "babylonjs/scene";
  61614. import { Texture } from "babylonjs/Materials/Textures/texture";
  61615. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61616. /**
  61617. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61618. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61619. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61620. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61621. */
  61622. export class PhotoDome extends TextureDome<Texture> {
  61623. /**
  61624. * Define the image as a Monoscopic panoramic 360 image.
  61625. */
  61626. static readonly MODE_MONOSCOPIC: number;
  61627. /**
  61628. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61629. */
  61630. static readonly MODE_TOPBOTTOM: number;
  61631. /**
  61632. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61633. */
  61634. static readonly MODE_SIDEBYSIDE: number;
  61635. /**
  61636. * Gets or sets the texture being displayed on the sphere
  61637. */
  61638. get photoTexture(): Texture;
  61639. /**
  61640. * sets the texture being displayed on the sphere
  61641. */
  61642. set photoTexture(value: Texture);
  61643. /**
  61644. * Gets the current video mode for the video. It can be:
  61645. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61646. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61647. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61648. */
  61649. get imageMode(): number;
  61650. /**
  61651. * Sets the current video mode for the video. It can be:
  61652. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61653. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61654. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61655. */
  61656. set imageMode(value: number);
  61657. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61658. }
  61659. }
  61660. declare module "babylonjs/Misc/dds" {
  61661. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  61662. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61663. import { Nullable } from "babylonjs/types";
  61664. import { Scene } from "babylonjs/scene";
  61665. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  61666. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61667. /**
  61668. * Direct draw surface info
  61669. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61670. */
  61671. export interface DDSInfo {
  61672. /**
  61673. * Width of the texture
  61674. */
  61675. width: number;
  61676. /**
  61677. * Width of the texture
  61678. */
  61679. height: number;
  61680. /**
  61681. * Number of Mipmaps for the texture
  61682. * @see https://en.wikipedia.org/wiki/Mipmap
  61683. */
  61684. mipmapCount: number;
  61685. /**
  61686. * If the textures format is a known fourCC format
  61687. * @see https://www.fourcc.org/
  61688. */
  61689. isFourCC: boolean;
  61690. /**
  61691. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61692. */
  61693. isRGB: boolean;
  61694. /**
  61695. * If the texture is a lumincance format
  61696. */
  61697. isLuminance: boolean;
  61698. /**
  61699. * If this is a cube texture
  61700. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61701. */
  61702. isCube: boolean;
  61703. /**
  61704. * If the texture is a compressed format eg. FOURCC_DXT1
  61705. */
  61706. isCompressed: boolean;
  61707. /**
  61708. * The dxgiFormat of the texture
  61709. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61710. */
  61711. dxgiFormat: number;
  61712. /**
  61713. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61714. */
  61715. textureType: number;
  61716. /**
  61717. * Sphericle polynomial created for the dds texture
  61718. */
  61719. sphericalPolynomial?: SphericalPolynomial;
  61720. }
  61721. /**
  61722. * Class used to provide DDS decompression tools
  61723. */
  61724. export class DDSTools {
  61725. /**
  61726. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61727. */
  61728. static StoreLODInAlphaChannel: boolean;
  61729. /**
  61730. * Gets DDS information from an array buffer
  61731. * @param data defines the array buffer view to read data from
  61732. * @returns the DDS information
  61733. */
  61734. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  61735. private static _FloatView;
  61736. private static _Int32View;
  61737. private static _ToHalfFloat;
  61738. private static _FromHalfFloat;
  61739. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  61740. private static _GetHalfFloatRGBAArrayBuffer;
  61741. private static _GetFloatRGBAArrayBuffer;
  61742. private static _GetFloatAsUIntRGBAArrayBuffer;
  61743. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  61744. private static _GetRGBAArrayBuffer;
  61745. private static _ExtractLongWordOrder;
  61746. private static _GetRGBArrayBuffer;
  61747. private static _GetLuminanceArrayBuffer;
  61748. /**
  61749. * Uploads DDS Levels to a Babylon Texture
  61750. * @hidden
  61751. */
  61752. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  61753. }
  61754. module "babylonjs/Engines/thinEngine" {
  61755. interface ThinEngine {
  61756. /**
  61757. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  61758. * @param rootUrl defines the url where the file to load is located
  61759. * @param scene defines the current scene
  61760. * @param lodScale defines scale to apply to the mip map selection
  61761. * @param lodOffset defines offset to apply to the mip map selection
  61762. * @param onLoad defines an optional callback raised when the texture is loaded
  61763. * @param onError defines an optional callback raised if there is an issue to load the texture
  61764. * @param format defines the format of the data
  61765. * @param forcedExtension defines the extension to use to pick the right loader
  61766. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  61767. * @returns the cube texture as an InternalTexture
  61768. */
  61769. 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;
  61770. }
  61771. }
  61772. }
  61773. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  61774. import { Nullable } from "babylonjs/types";
  61775. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61776. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61777. /**
  61778. * Implementation of the DDS Texture Loader.
  61779. * @hidden
  61780. */
  61781. export class _DDSTextureLoader implements IInternalTextureLoader {
  61782. /**
  61783. * Defines wether the loader supports cascade loading the different faces.
  61784. */
  61785. readonly supportCascades: boolean;
  61786. /**
  61787. * This returns if the loader support the current file information.
  61788. * @param extension defines the file extension of the file being loaded
  61789. * @returns true if the loader can load the specified file
  61790. */
  61791. canLoad(extension: string): boolean;
  61792. /**
  61793. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61794. * @param data contains the texture data
  61795. * @param texture defines the BabylonJS internal texture
  61796. * @param createPolynomials will be true if polynomials have been requested
  61797. * @param onLoad defines the callback to trigger once the texture is ready
  61798. * @param onError defines the callback to trigger in case of error
  61799. */
  61800. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61801. /**
  61802. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61803. * @param data contains the texture data
  61804. * @param texture defines the BabylonJS internal texture
  61805. * @param callback defines the method to call once ready to upload
  61806. */
  61807. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61808. }
  61809. }
  61810. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  61811. import { Nullable } from "babylonjs/types";
  61812. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61813. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61814. /**
  61815. * Implementation of the ENV Texture Loader.
  61816. * @hidden
  61817. */
  61818. export class _ENVTextureLoader implements IInternalTextureLoader {
  61819. /**
  61820. * Defines wether the loader supports cascade loading the different faces.
  61821. */
  61822. readonly supportCascades: boolean;
  61823. /**
  61824. * This returns if the loader support the current file information.
  61825. * @param extension defines the file extension of the file being loaded
  61826. * @returns true if the loader can load the specified file
  61827. */
  61828. canLoad(extension: string): boolean;
  61829. /**
  61830. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61831. * @param data contains the texture data
  61832. * @param texture defines the BabylonJS internal texture
  61833. * @param createPolynomials will be true if polynomials have been requested
  61834. * @param onLoad defines the callback to trigger once the texture is ready
  61835. * @param onError defines the callback to trigger in case of error
  61836. */
  61837. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61838. /**
  61839. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61840. * @param data contains the texture data
  61841. * @param texture defines the BabylonJS internal texture
  61842. * @param callback defines the method to call once ready to upload
  61843. */
  61844. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61845. }
  61846. }
  61847. declare module "babylonjs/Misc/khronosTextureContainer" {
  61848. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61849. /**
  61850. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61851. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61852. */
  61853. export class KhronosTextureContainer {
  61854. /** contents of the KTX container file */
  61855. data: ArrayBufferView;
  61856. private static HEADER_LEN;
  61857. private static COMPRESSED_2D;
  61858. private static COMPRESSED_3D;
  61859. private static TEX_2D;
  61860. private static TEX_3D;
  61861. /**
  61862. * Gets the openGL type
  61863. */
  61864. glType: number;
  61865. /**
  61866. * Gets the openGL type size
  61867. */
  61868. glTypeSize: number;
  61869. /**
  61870. * Gets the openGL format
  61871. */
  61872. glFormat: number;
  61873. /**
  61874. * Gets the openGL internal format
  61875. */
  61876. glInternalFormat: number;
  61877. /**
  61878. * Gets the base internal format
  61879. */
  61880. glBaseInternalFormat: number;
  61881. /**
  61882. * Gets image width in pixel
  61883. */
  61884. pixelWidth: number;
  61885. /**
  61886. * Gets image height in pixel
  61887. */
  61888. pixelHeight: number;
  61889. /**
  61890. * Gets image depth in pixels
  61891. */
  61892. pixelDepth: number;
  61893. /**
  61894. * Gets the number of array elements
  61895. */
  61896. numberOfArrayElements: number;
  61897. /**
  61898. * Gets the number of faces
  61899. */
  61900. numberOfFaces: number;
  61901. /**
  61902. * Gets the number of mipmap levels
  61903. */
  61904. numberOfMipmapLevels: number;
  61905. /**
  61906. * Gets the bytes of key value data
  61907. */
  61908. bytesOfKeyValueData: number;
  61909. /**
  61910. * Gets the load type
  61911. */
  61912. loadType: number;
  61913. /**
  61914. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61915. */
  61916. isInvalid: boolean;
  61917. /**
  61918. * Creates a new KhronosTextureContainer
  61919. * @param data contents of the KTX container file
  61920. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61921. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61922. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61923. */
  61924. constructor(
  61925. /** contents of the KTX container file */
  61926. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61927. /**
  61928. * Uploads KTX content to a Babylon Texture.
  61929. * It is assumed that the texture has already been created & is currently bound
  61930. * @hidden
  61931. */
  61932. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61933. private _upload2DCompressedLevels;
  61934. /**
  61935. * Checks if the given data starts with a KTX file identifier.
  61936. * @param data the data to check
  61937. * @returns true if the data is a KTX file or false otherwise
  61938. */
  61939. static IsValid(data: ArrayBufferView): boolean;
  61940. }
  61941. }
  61942. declare module "babylonjs/Misc/workerPool" {
  61943. import { IDisposable } from "babylonjs/scene";
  61944. /**
  61945. * Helper class to push actions to a pool of workers.
  61946. */
  61947. export class WorkerPool implements IDisposable {
  61948. private _workerInfos;
  61949. private _pendingActions;
  61950. /**
  61951. * Constructor
  61952. * @param workers Array of workers to use for actions
  61953. */
  61954. constructor(workers: Array<Worker>);
  61955. /**
  61956. * Terminates all workers and clears any pending actions.
  61957. */
  61958. dispose(): void;
  61959. /**
  61960. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61961. * pended until a worker has completed its action.
  61962. * @param action The action to perform. Call onComplete when the action is complete.
  61963. */
  61964. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61965. private _execute;
  61966. }
  61967. }
  61968. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61969. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61970. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61971. /**
  61972. * Class for loading KTX2 files
  61973. */
  61974. export class KhronosTextureContainer2 {
  61975. private static _WorkerPoolPromise?;
  61976. private static _Initialized;
  61977. private static _Ktx2Decoder;
  61978. /**
  61979. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61980. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61981. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61982. * Urls you can change:
  61983. * URLConfig.jsDecoderModule
  61984. * URLConfig.wasmUASTCToASTC
  61985. * URLConfig.wasmUASTCToBC7
  61986. * URLConfig.wasmUASTCToRGBA_UNORM
  61987. * URLConfig.wasmUASTCToRGBA_SRGB
  61988. * URLConfig.jsMSCTranscoder
  61989. * URLConfig.wasmMSCTranscoder
  61990. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61991. */
  61992. static URLConfig: {
  61993. jsDecoderModule: string;
  61994. wasmUASTCToASTC: null;
  61995. wasmUASTCToBC7: null;
  61996. wasmUASTCToRGBA_UNORM: null;
  61997. wasmUASTCToRGBA_SRGB: null;
  61998. jsMSCTranscoder: null;
  61999. wasmMSCTranscoder: null;
  62000. };
  62001. /**
  62002. * Default number of workers used to handle data decoding
  62003. */
  62004. static DefaultNumWorkers: number;
  62005. private static GetDefaultNumWorkers;
  62006. private _engine;
  62007. private static _CreateWorkerPool;
  62008. /**
  62009. * Constructor
  62010. * @param engine The engine to use
  62011. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62012. */
  62013. constructor(engine: ThinEngine, numWorkers?: number);
  62014. /** @hidden */
  62015. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62016. /**
  62017. * Stop all async operations and release resources.
  62018. */
  62019. dispose(): void;
  62020. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62021. /**
  62022. * Checks if the given data starts with a KTX2 file identifier.
  62023. * @param data the data to check
  62024. * @returns true if the data is a KTX2 file or false otherwise
  62025. */
  62026. static IsValid(data: ArrayBufferView): boolean;
  62027. }
  62028. }
  62029. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  62030. import { Nullable } from "babylonjs/types";
  62031. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62032. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62033. /**
  62034. * Implementation of the KTX Texture Loader.
  62035. * @hidden
  62036. */
  62037. export class _KTXTextureLoader implements IInternalTextureLoader {
  62038. /**
  62039. * Defines wether the loader supports cascade loading the different faces.
  62040. */
  62041. readonly supportCascades: boolean;
  62042. /**
  62043. * This returns if the loader support the current file information.
  62044. * @param extension defines the file extension of the file being loaded
  62045. * @param mimeType defines the optional mime type of the file being loaded
  62046. * @returns true if the loader can load the specified file
  62047. */
  62048. canLoad(extension: string, mimeType?: string): boolean;
  62049. /**
  62050. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62051. * @param data contains the texture data
  62052. * @param texture defines the BabylonJS internal texture
  62053. * @param createPolynomials will be true if polynomials have been requested
  62054. * @param onLoad defines the callback to trigger once the texture is ready
  62055. * @param onError defines the callback to trigger in case of error
  62056. */
  62057. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62058. /**
  62059. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62060. * @param data contains the texture data
  62061. * @param texture defines the BabylonJS internal texture
  62062. * @param callback defines the method to call once ready to upload
  62063. */
  62064. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62065. }
  62066. }
  62067. declare module "babylonjs/Helpers/sceneHelpers" {
  62068. import { Nullable } from "babylonjs/types";
  62069. import { Mesh } from "babylonjs/Meshes/mesh";
  62070. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62071. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  62072. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  62073. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  62074. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  62075. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  62076. import "babylonjs/Meshes/Builders/boxBuilder";
  62077. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  62078. /** @hidden */
  62079. export var _forceSceneHelpersToBundle: boolean;
  62080. module "babylonjs/scene" {
  62081. interface Scene {
  62082. /**
  62083. * Creates a default light for the scene.
  62084. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62085. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62086. */
  62087. createDefaultLight(replace?: boolean): void;
  62088. /**
  62089. * Creates a default camera for the scene.
  62090. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62091. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62092. * @param replace has default false, when true replaces the active camera in the scene
  62093. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62094. */
  62095. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62096. /**
  62097. * Creates a default camera and a default light.
  62098. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62099. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62100. * @param replace has the default false, when true replaces the active camera/light in the scene
  62101. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62102. */
  62103. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62104. /**
  62105. * Creates a new sky box
  62106. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62107. * @param environmentTexture defines the texture to use as environment texture
  62108. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62109. * @param scale defines the overall scale of the skybox
  62110. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62111. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62112. * @returns a new mesh holding the sky box
  62113. */
  62114. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62115. /**
  62116. * Creates a new environment
  62117. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62118. * @param options defines the options you can use to configure the environment
  62119. * @returns the new EnvironmentHelper
  62120. */
  62121. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62122. /**
  62123. * Creates a new VREXperienceHelper
  62124. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62125. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62126. * @returns a new VREXperienceHelper
  62127. */
  62128. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62129. /**
  62130. * Creates a new WebXRDefaultExperience
  62131. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62132. * @param options experience options
  62133. * @returns a promise for a new WebXRDefaultExperience
  62134. */
  62135. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62136. }
  62137. }
  62138. }
  62139. declare module "babylonjs/Helpers/videoDome" {
  62140. import { Scene } from "babylonjs/scene";
  62141. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  62142. import { TextureDome } from "babylonjs/Helpers/textureDome";
  62143. /**
  62144. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62145. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62146. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62147. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62148. */
  62149. export class VideoDome extends TextureDome<VideoTexture> {
  62150. /**
  62151. * Define the video source as a Monoscopic panoramic 360 video.
  62152. */
  62153. static readonly MODE_MONOSCOPIC: number;
  62154. /**
  62155. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62156. */
  62157. static readonly MODE_TOPBOTTOM: number;
  62158. /**
  62159. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62160. */
  62161. static readonly MODE_SIDEBYSIDE: number;
  62162. /**
  62163. * Get the video texture associated with this video dome
  62164. */
  62165. get videoTexture(): VideoTexture;
  62166. /**
  62167. * Get the video mode of this dome
  62168. */
  62169. get videoMode(): number;
  62170. /**
  62171. * Set the video mode of this dome.
  62172. * @see textureMode
  62173. */
  62174. set videoMode(value: number);
  62175. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62176. }
  62177. }
  62178. declare module "babylonjs/Helpers/index" {
  62179. export * from "babylonjs/Helpers/environmentHelper";
  62180. export * from "babylonjs/Helpers/photoDome";
  62181. export * from "babylonjs/Helpers/sceneHelpers";
  62182. export * from "babylonjs/Helpers/videoDome";
  62183. }
  62184. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  62185. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  62186. import { IDisposable } from "babylonjs/scene";
  62187. import { Engine } from "babylonjs/Engines/engine";
  62188. /**
  62189. * This class can be used to get instrumentation data from a Babylon engine
  62190. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62191. */
  62192. export class EngineInstrumentation implements IDisposable {
  62193. /**
  62194. * Define the instrumented engine.
  62195. */
  62196. engine: Engine;
  62197. private _captureGPUFrameTime;
  62198. private _gpuFrameTimeToken;
  62199. private _gpuFrameTime;
  62200. private _captureShaderCompilationTime;
  62201. private _shaderCompilationTime;
  62202. private _onBeginFrameObserver;
  62203. private _onEndFrameObserver;
  62204. private _onBeforeShaderCompilationObserver;
  62205. private _onAfterShaderCompilationObserver;
  62206. /**
  62207. * Gets the perf counter used for GPU frame time
  62208. */
  62209. get gpuFrameTimeCounter(): PerfCounter;
  62210. /**
  62211. * Gets the GPU frame time capture status
  62212. */
  62213. get captureGPUFrameTime(): boolean;
  62214. /**
  62215. * Enable or disable the GPU frame time capture
  62216. */
  62217. set captureGPUFrameTime(value: boolean);
  62218. /**
  62219. * Gets the perf counter used for shader compilation time
  62220. */
  62221. get shaderCompilationTimeCounter(): PerfCounter;
  62222. /**
  62223. * Gets the shader compilation time capture status
  62224. */
  62225. get captureShaderCompilationTime(): boolean;
  62226. /**
  62227. * Enable or disable the shader compilation time capture
  62228. */
  62229. set captureShaderCompilationTime(value: boolean);
  62230. /**
  62231. * Instantiates a new engine instrumentation.
  62232. * This class can be used to get instrumentation data from a Babylon engine
  62233. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62234. * @param engine Defines the engine to instrument
  62235. */
  62236. constructor(
  62237. /**
  62238. * Define the instrumented engine.
  62239. */
  62240. engine: Engine);
  62241. /**
  62242. * Dispose and release associated resources.
  62243. */
  62244. dispose(): void;
  62245. }
  62246. }
  62247. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  62248. import { Scene, IDisposable } from "babylonjs/scene";
  62249. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  62250. /**
  62251. * This class can be used to get instrumentation data from a Babylon engine
  62252. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62253. */
  62254. export class SceneInstrumentation implements IDisposable {
  62255. /**
  62256. * Defines the scene to instrument
  62257. */
  62258. scene: Scene;
  62259. private _captureActiveMeshesEvaluationTime;
  62260. private _activeMeshesEvaluationTime;
  62261. private _captureRenderTargetsRenderTime;
  62262. private _renderTargetsRenderTime;
  62263. private _captureFrameTime;
  62264. private _frameTime;
  62265. private _captureRenderTime;
  62266. private _renderTime;
  62267. private _captureInterFrameTime;
  62268. private _interFrameTime;
  62269. private _captureParticlesRenderTime;
  62270. private _particlesRenderTime;
  62271. private _captureSpritesRenderTime;
  62272. private _spritesRenderTime;
  62273. private _capturePhysicsTime;
  62274. private _physicsTime;
  62275. private _captureAnimationsTime;
  62276. private _animationsTime;
  62277. private _captureCameraRenderTime;
  62278. private _cameraRenderTime;
  62279. private _onBeforeActiveMeshesEvaluationObserver;
  62280. private _onAfterActiveMeshesEvaluationObserver;
  62281. private _onBeforeRenderTargetsRenderObserver;
  62282. private _onAfterRenderTargetsRenderObserver;
  62283. private _onAfterRenderObserver;
  62284. private _onBeforeDrawPhaseObserver;
  62285. private _onAfterDrawPhaseObserver;
  62286. private _onBeforeAnimationsObserver;
  62287. private _onBeforeParticlesRenderingObserver;
  62288. private _onAfterParticlesRenderingObserver;
  62289. private _onBeforeSpritesRenderingObserver;
  62290. private _onAfterSpritesRenderingObserver;
  62291. private _onBeforePhysicsObserver;
  62292. private _onAfterPhysicsObserver;
  62293. private _onAfterAnimationsObserver;
  62294. private _onBeforeCameraRenderObserver;
  62295. private _onAfterCameraRenderObserver;
  62296. /**
  62297. * Gets the perf counter used for active meshes evaluation time
  62298. */
  62299. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62300. /**
  62301. * Gets the active meshes evaluation time capture status
  62302. */
  62303. get captureActiveMeshesEvaluationTime(): boolean;
  62304. /**
  62305. * Enable or disable the active meshes evaluation time capture
  62306. */
  62307. set captureActiveMeshesEvaluationTime(value: boolean);
  62308. /**
  62309. * Gets the perf counter used for render targets render time
  62310. */
  62311. get renderTargetsRenderTimeCounter(): PerfCounter;
  62312. /**
  62313. * Gets the render targets render time capture status
  62314. */
  62315. get captureRenderTargetsRenderTime(): boolean;
  62316. /**
  62317. * Enable or disable the render targets render time capture
  62318. */
  62319. set captureRenderTargetsRenderTime(value: boolean);
  62320. /**
  62321. * Gets the perf counter used for particles render time
  62322. */
  62323. get particlesRenderTimeCounter(): PerfCounter;
  62324. /**
  62325. * Gets the particles render time capture status
  62326. */
  62327. get captureParticlesRenderTime(): boolean;
  62328. /**
  62329. * Enable or disable the particles render time capture
  62330. */
  62331. set captureParticlesRenderTime(value: boolean);
  62332. /**
  62333. * Gets the perf counter used for sprites render time
  62334. */
  62335. get spritesRenderTimeCounter(): PerfCounter;
  62336. /**
  62337. * Gets the sprites render time capture status
  62338. */
  62339. get captureSpritesRenderTime(): boolean;
  62340. /**
  62341. * Enable or disable the sprites render time capture
  62342. */
  62343. set captureSpritesRenderTime(value: boolean);
  62344. /**
  62345. * Gets the perf counter used for physics time
  62346. */
  62347. get physicsTimeCounter(): PerfCounter;
  62348. /**
  62349. * Gets the physics time capture status
  62350. */
  62351. get capturePhysicsTime(): boolean;
  62352. /**
  62353. * Enable or disable the physics time capture
  62354. */
  62355. set capturePhysicsTime(value: boolean);
  62356. /**
  62357. * Gets the perf counter used for animations time
  62358. */
  62359. get animationsTimeCounter(): PerfCounter;
  62360. /**
  62361. * Gets the animations time capture status
  62362. */
  62363. get captureAnimationsTime(): boolean;
  62364. /**
  62365. * Enable or disable the animations time capture
  62366. */
  62367. set captureAnimationsTime(value: boolean);
  62368. /**
  62369. * Gets the perf counter used for frame time capture
  62370. */
  62371. get frameTimeCounter(): PerfCounter;
  62372. /**
  62373. * Gets the frame time capture status
  62374. */
  62375. get captureFrameTime(): boolean;
  62376. /**
  62377. * Enable or disable the frame time capture
  62378. */
  62379. set captureFrameTime(value: boolean);
  62380. /**
  62381. * Gets the perf counter used for inter-frames time capture
  62382. */
  62383. get interFrameTimeCounter(): PerfCounter;
  62384. /**
  62385. * Gets the inter-frames time capture status
  62386. */
  62387. get captureInterFrameTime(): boolean;
  62388. /**
  62389. * Enable or disable the inter-frames time capture
  62390. */
  62391. set captureInterFrameTime(value: boolean);
  62392. /**
  62393. * Gets the perf counter used for render time capture
  62394. */
  62395. get renderTimeCounter(): PerfCounter;
  62396. /**
  62397. * Gets the render time capture status
  62398. */
  62399. get captureRenderTime(): boolean;
  62400. /**
  62401. * Enable or disable the render time capture
  62402. */
  62403. set captureRenderTime(value: boolean);
  62404. /**
  62405. * Gets the perf counter used for camera render time capture
  62406. */
  62407. get cameraRenderTimeCounter(): PerfCounter;
  62408. /**
  62409. * Gets the camera render time capture status
  62410. */
  62411. get captureCameraRenderTime(): boolean;
  62412. /**
  62413. * Enable or disable the camera render time capture
  62414. */
  62415. set captureCameraRenderTime(value: boolean);
  62416. /**
  62417. * Gets the perf counter used for draw calls
  62418. */
  62419. get drawCallsCounter(): PerfCounter;
  62420. /**
  62421. * Instantiates a new scene instrumentation.
  62422. * This class can be used to get instrumentation data from a Babylon engine
  62423. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62424. * @param scene Defines the scene to instrument
  62425. */
  62426. constructor(
  62427. /**
  62428. * Defines the scene to instrument
  62429. */
  62430. scene: Scene);
  62431. /**
  62432. * Dispose and release associated resources.
  62433. */
  62434. dispose(): void;
  62435. }
  62436. }
  62437. declare module "babylonjs/Instrumentation/index" {
  62438. export * from "babylonjs/Instrumentation/engineInstrumentation";
  62439. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  62440. export * from "babylonjs/Instrumentation/timeToken";
  62441. }
  62442. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  62443. /** @hidden */
  62444. export var glowMapGenerationPixelShader: {
  62445. name: string;
  62446. shader: string;
  62447. };
  62448. }
  62449. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  62450. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62451. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62452. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62453. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62454. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62455. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62456. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62457. /** @hidden */
  62458. export var glowMapGenerationVertexShader: {
  62459. name: string;
  62460. shader: string;
  62461. };
  62462. }
  62463. declare module "babylonjs/Layers/effectLayer" {
  62464. import { Observable } from "babylonjs/Misc/observable";
  62465. import { Nullable } from "babylonjs/types";
  62466. import { Camera } from "babylonjs/Cameras/camera";
  62467. import { Scene } from "babylonjs/scene";
  62468. import { ISize } from "babylonjs/Maths/math.size";
  62469. import { Color4 } from "babylonjs/Maths/math.color";
  62470. import { Engine } from "babylonjs/Engines/engine";
  62471. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62473. import { Mesh } from "babylonjs/Meshes/mesh";
  62474. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62475. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62476. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62477. import { Effect } from "babylonjs/Materials/effect";
  62478. import { Material } from "babylonjs/Materials/material";
  62479. import "babylonjs/Shaders/glowMapGeneration.fragment";
  62480. import "babylonjs/Shaders/glowMapGeneration.vertex";
  62481. /**
  62482. * Effect layer options. This helps customizing the behaviour
  62483. * of the effect layer.
  62484. */
  62485. export interface IEffectLayerOptions {
  62486. /**
  62487. * Multiplication factor apply to the canvas size to compute the render target size
  62488. * used to generated the objects (the smaller the faster).
  62489. */
  62490. mainTextureRatio: number;
  62491. /**
  62492. * Enforces a fixed size texture to ensure effect stability across devices.
  62493. */
  62494. mainTextureFixedSize?: number;
  62495. /**
  62496. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62497. */
  62498. alphaBlendingMode: number;
  62499. /**
  62500. * The camera attached to the layer.
  62501. */
  62502. camera: Nullable<Camera>;
  62503. /**
  62504. * The rendering group to draw the layer in.
  62505. */
  62506. renderingGroupId: number;
  62507. }
  62508. /**
  62509. * The effect layer Helps adding post process effect blended with the main pass.
  62510. *
  62511. * This can be for instance use to generate glow or higlight effects on the scene.
  62512. *
  62513. * The effect layer class can not be used directly and is intented to inherited from to be
  62514. * customized per effects.
  62515. */
  62516. export abstract class EffectLayer {
  62517. private _vertexBuffers;
  62518. private _indexBuffer;
  62519. private _cachedDefines;
  62520. private _effectLayerMapGenerationEffect;
  62521. private _effectLayerOptions;
  62522. private _mergeEffect;
  62523. protected _scene: Scene;
  62524. protected _engine: Engine;
  62525. protected _maxSize: number;
  62526. protected _mainTextureDesiredSize: ISize;
  62527. protected _mainTexture: RenderTargetTexture;
  62528. protected _shouldRender: boolean;
  62529. protected _postProcesses: PostProcess[];
  62530. protected _textures: BaseTexture[];
  62531. protected _emissiveTextureAndColor: {
  62532. texture: Nullable<BaseTexture>;
  62533. color: Color4;
  62534. };
  62535. /**
  62536. * The name of the layer
  62537. */
  62538. name: string;
  62539. /**
  62540. * The clear color of the texture used to generate the glow map.
  62541. */
  62542. neutralColor: Color4;
  62543. /**
  62544. * Specifies whether the highlight layer is enabled or not.
  62545. */
  62546. isEnabled: boolean;
  62547. /**
  62548. * Gets the camera attached to the layer.
  62549. */
  62550. get camera(): Nullable<Camera>;
  62551. /**
  62552. * Gets the rendering group id the layer should render in.
  62553. */
  62554. get renderingGroupId(): number;
  62555. set renderingGroupId(renderingGroupId: number);
  62556. /**
  62557. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62558. */
  62559. disableBoundingBoxesFromEffectLayer: boolean;
  62560. /**
  62561. * An event triggered when the effect layer has been disposed.
  62562. */
  62563. onDisposeObservable: Observable<EffectLayer>;
  62564. /**
  62565. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62566. */
  62567. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62568. /**
  62569. * An event triggered when the generated texture is being merged in the scene.
  62570. */
  62571. onBeforeComposeObservable: Observable<EffectLayer>;
  62572. /**
  62573. * An event triggered when the mesh is rendered into the effect render target.
  62574. */
  62575. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62576. /**
  62577. * An event triggered after the mesh has been rendered into the effect render target.
  62578. */
  62579. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62580. /**
  62581. * An event triggered when the generated texture has been merged in the scene.
  62582. */
  62583. onAfterComposeObservable: Observable<EffectLayer>;
  62584. /**
  62585. * An event triggered when the efffect layer changes its size.
  62586. */
  62587. onSizeChangedObservable: Observable<EffectLayer>;
  62588. /** @hidden */
  62589. static _SceneComponentInitialization: (scene: Scene) => void;
  62590. /**
  62591. * Instantiates a new effect Layer and references it in the scene.
  62592. * @param name The name of the layer
  62593. * @param scene The scene to use the layer in
  62594. */
  62595. constructor(
  62596. /** The Friendly of the effect in the scene */
  62597. name: string, scene: Scene);
  62598. /**
  62599. * Get the effect name of the layer.
  62600. * @return The effect name
  62601. */
  62602. abstract getEffectName(): string;
  62603. /**
  62604. * Checks for the readiness of the element composing the layer.
  62605. * @param subMesh the mesh to check for
  62606. * @param useInstances specify whether or not to use instances to render the mesh
  62607. * @return true if ready otherwise, false
  62608. */
  62609. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62610. /**
  62611. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62612. * @returns true if the effect requires stencil during the main canvas render pass.
  62613. */
  62614. abstract needStencil(): boolean;
  62615. /**
  62616. * Create the merge effect. This is the shader use to blit the information back
  62617. * to the main canvas at the end of the scene rendering.
  62618. * @returns The effect containing the shader used to merge the effect on the main canvas
  62619. */
  62620. protected abstract _createMergeEffect(): Effect;
  62621. /**
  62622. * Creates the render target textures and post processes used in the effect layer.
  62623. */
  62624. protected abstract _createTextureAndPostProcesses(): void;
  62625. /**
  62626. * Implementation specific of rendering the generating effect on the main canvas.
  62627. * @param effect The effect used to render through
  62628. */
  62629. protected abstract _internalRender(effect: Effect): void;
  62630. /**
  62631. * Sets the required values for both the emissive texture and and the main color.
  62632. */
  62633. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62634. /**
  62635. * Free any resources and references associated to a mesh.
  62636. * Internal use
  62637. * @param mesh The mesh to free.
  62638. */
  62639. abstract _disposeMesh(mesh: Mesh): void;
  62640. /**
  62641. * Serializes this layer (Glow or Highlight for example)
  62642. * @returns a serialized layer object
  62643. */
  62644. abstract serialize?(): any;
  62645. /**
  62646. * Initializes the effect layer with the required options.
  62647. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62648. */
  62649. protected _init(options: Partial<IEffectLayerOptions>): void;
  62650. /**
  62651. * Generates the index buffer of the full screen quad blending to the main canvas.
  62652. */
  62653. private _generateIndexBuffer;
  62654. /**
  62655. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62656. */
  62657. private _generateVertexBuffer;
  62658. /**
  62659. * Sets the main texture desired size which is the closest power of two
  62660. * of the engine canvas size.
  62661. */
  62662. private _setMainTextureSize;
  62663. /**
  62664. * Creates the main texture for the effect layer.
  62665. */
  62666. protected _createMainTexture(): void;
  62667. /**
  62668. * Adds specific effects defines.
  62669. * @param defines The defines to add specifics to.
  62670. */
  62671. protected _addCustomEffectDefines(defines: string[]): void;
  62672. /**
  62673. * Checks for the readiness of the element composing the layer.
  62674. * @param subMesh the mesh to check for
  62675. * @param useInstances specify whether or not to use instances to render the mesh
  62676. * @param emissiveTexture the associated emissive texture used to generate the glow
  62677. * @return true if ready otherwise, false
  62678. */
  62679. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62680. /**
  62681. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62682. */
  62683. render(): void;
  62684. /**
  62685. * Determine if a given mesh will be used in the current effect.
  62686. * @param mesh mesh to test
  62687. * @returns true if the mesh will be used
  62688. */
  62689. hasMesh(mesh: AbstractMesh): boolean;
  62690. /**
  62691. * Returns true if the layer contains information to display, otherwise false.
  62692. * @returns true if the glow layer should be rendered
  62693. */
  62694. shouldRender(): boolean;
  62695. /**
  62696. * Returns true if the mesh should render, otherwise false.
  62697. * @param mesh The mesh to render
  62698. * @returns true if it should render otherwise false
  62699. */
  62700. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62701. /**
  62702. * Returns true if the mesh can be rendered, otherwise false.
  62703. * @param mesh The mesh to render
  62704. * @param material The material used on the mesh
  62705. * @returns true if it can be rendered otherwise false
  62706. */
  62707. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62708. /**
  62709. * Returns true if the mesh should render, otherwise false.
  62710. * @param mesh The mesh to render
  62711. * @returns true if it should render otherwise false
  62712. */
  62713. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62714. /**
  62715. * Renders the submesh passed in parameter to the generation map.
  62716. */
  62717. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62718. /**
  62719. * Defines whether the current material of the mesh should be use to render the effect.
  62720. * @param mesh defines the current mesh to render
  62721. */
  62722. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62723. /**
  62724. * Rebuild the required buffers.
  62725. * @hidden Internal use only.
  62726. */
  62727. _rebuild(): void;
  62728. /**
  62729. * Dispose only the render target textures and post process.
  62730. */
  62731. private _disposeTextureAndPostProcesses;
  62732. /**
  62733. * Dispose the highlight layer and free resources.
  62734. */
  62735. dispose(): void;
  62736. /**
  62737. * Gets the class name of the effect layer
  62738. * @returns the string with the class name of the effect layer
  62739. */
  62740. getClassName(): string;
  62741. /**
  62742. * Creates an effect layer from parsed effect layer data
  62743. * @param parsedEffectLayer defines effect layer data
  62744. * @param scene defines the current scene
  62745. * @param rootUrl defines the root URL containing the effect layer information
  62746. * @returns a parsed effect Layer
  62747. */
  62748. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62749. }
  62750. }
  62751. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  62752. import { Scene } from "babylonjs/scene";
  62753. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62754. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62755. import { AbstractScene } from "babylonjs/abstractScene";
  62756. module "babylonjs/abstractScene" {
  62757. interface AbstractScene {
  62758. /**
  62759. * The list of effect layers (highlights/glow) added to the scene
  62760. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62761. * @see https://doc.babylonjs.com/how_to/glow_layer
  62762. */
  62763. effectLayers: Array<EffectLayer>;
  62764. /**
  62765. * Removes the given effect layer from this scene.
  62766. * @param toRemove defines the effect layer to remove
  62767. * @returns the index of the removed effect layer
  62768. */
  62769. removeEffectLayer(toRemove: EffectLayer): number;
  62770. /**
  62771. * Adds the given effect layer to this scene
  62772. * @param newEffectLayer defines the effect layer to add
  62773. */
  62774. addEffectLayer(newEffectLayer: EffectLayer): void;
  62775. }
  62776. }
  62777. /**
  62778. * Defines the layer scene component responsible to manage any effect layers
  62779. * in a given scene.
  62780. */
  62781. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62782. /**
  62783. * The component name helpfull to identify the component in the list of scene components.
  62784. */
  62785. readonly name: string;
  62786. /**
  62787. * The scene the component belongs to.
  62788. */
  62789. scene: Scene;
  62790. private _engine;
  62791. private _renderEffects;
  62792. private _needStencil;
  62793. private _previousStencilState;
  62794. /**
  62795. * Creates a new instance of the component for the given scene
  62796. * @param scene Defines the scene to register the component in
  62797. */
  62798. constructor(scene: Scene);
  62799. /**
  62800. * Registers the component in a given scene
  62801. */
  62802. register(): void;
  62803. /**
  62804. * Rebuilds the elements related to this component in case of
  62805. * context lost for instance.
  62806. */
  62807. rebuild(): void;
  62808. /**
  62809. * Serializes the component data to the specified json object
  62810. * @param serializationObject The object to serialize to
  62811. */
  62812. serialize(serializationObject: any): void;
  62813. /**
  62814. * Adds all the elements from the container to the scene
  62815. * @param container the container holding the elements
  62816. */
  62817. addFromContainer(container: AbstractScene): void;
  62818. /**
  62819. * Removes all the elements in the container from the scene
  62820. * @param container contains the elements to remove
  62821. * @param dispose if the removed element should be disposed (default: false)
  62822. */
  62823. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62824. /**
  62825. * Disposes the component and the associated ressources.
  62826. */
  62827. dispose(): void;
  62828. private _isReadyForMesh;
  62829. private _renderMainTexture;
  62830. private _setStencil;
  62831. private _setStencilBack;
  62832. private _draw;
  62833. private _drawCamera;
  62834. private _drawRenderingGroup;
  62835. }
  62836. }
  62837. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  62838. /** @hidden */
  62839. export var glowMapMergePixelShader: {
  62840. name: string;
  62841. shader: string;
  62842. };
  62843. }
  62844. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  62845. /** @hidden */
  62846. export var glowMapMergeVertexShader: {
  62847. name: string;
  62848. shader: string;
  62849. };
  62850. }
  62851. declare module "babylonjs/Layers/glowLayer" {
  62852. import { Nullable } from "babylonjs/types";
  62853. import { Camera } from "babylonjs/Cameras/camera";
  62854. import { Scene } from "babylonjs/scene";
  62855. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62857. import { Mesh } from "babylonjs/Meshes/mesh";
  62858. import { Texture } from "babylonjs/Materials/Textures/texture";
  62859. import { Effect } from "babylonjs/Materials/effect";
  62860. import { Material } from "babylonjs/Materials/material";
  62861. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62862. import { Color4 } from "babylonjs/Maths/math.color";
  62863. import "babylonjs/Shaders/glowMapMerge.fragment";
  62864. import "babylonjs/Shaders/glowMapMerge.vertex";
  62865. import "babylonjs/Layers/effectLayerSceneComponent";
  62866. module "babylonjs/abstractScene" {
  62867. interface AbstractScene {
  62868. /**
  62869. * Return a the first highlight layer of the scene with a given name.
  62870. * @param name The name of the highlight layer to look for.
  62871. * @return The highlight layer if found otherwise null.
  62872. */
  62873. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62874. }
  62875. }
  62876. /**
  62877. * Glow layer options. This helps customizing the behaviour
  62878. * of the glow layer.
  62879. */
  62880. export interface IGlowLayerOptions {
  62881. /**
  62882. * Multiplication factor apply to the canvas size to compute the render target size
  62883. * used to generated the glowing objects (the smaller the faster).
  62884. */
  62885. mainTextureRatio: number;
  62886. /**
  62887. * Enforces a fixed size texture to ensure resize independant blur.
  62888. */
  62889. mainTextureFixedSize?: number;
  62890. /**
  62891. * How big is the kernel of the blur texture.
  62892. */
  62893. blurKernelSize: number;
  62894. /**
  62895. * The camera attached to the layer.
  62896. */
  62897. camera: Nullable<Camera>;
  62898. /**
  62899. * Enable MSAA by chosing the number of samples.
  62900. */
  62901. mainTextureSamples?: number;
  62902. /**
  62903. * The rendering group to draw the layer in.
  62904. */
  62905. renderingGroupId: number;
  62906. }
  62907. /**
  62908. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62909. *
  62910. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62911. *
  62912. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62913. */
  62914. export class GlowLayer extends EffectLayer {
  62915. /**
  62916. * Effect Name of the layer.
  62917. */
  62918. static readonly EffectName: string;
  62919. /**
  62920. * The default blur kernel size used for the glow.
  62921. */
  62922. static DefaultBlurKernelSize: number;
  62923. /**
  62924. * The default texture size ratio used for the glow.
  62925. */
  62926. static DefaultTextureRatio: number;
  62927. /**
  62928. * Sets the kernel size of the blur.
  62929. */
  62930. set blurKernelSize(value: number);
  62931. /**
  62932. * Gets the kernel size of the blur.
  62933. */
  62934. get blurKernelSize(): number;
  62935. /**
  62936. * Sets the glow intensity.
  62937. */
  62938. set intensity(value: number);
  62939. /**
  62940. * Gets the glow intensity.
  62941. */
  62942. get intensity(): number;
  62943. private _options;
  62944. private _intensity;
  62945. private _horizontalBlurPostprocess1;
  62946. private _verticalBlurPostprocess1;
  62947. private _horizontalBlurPostprocess2;
  62948. private _verticalBlurPostprocess2;
  62949. private _blurTexture1;
  62950. private _blurTexture2;
  62951. private _postProcesses1;
  62952. private _postProcesses2;
  62953. private _includedOnlyMeshes;
  62954. private _excludedMeshes;
  62955. private _meshesUsingTheirOwnMaterials;
  62956. /**
  62957. * Callback used to let the user override the color selection on a per mesh basis
  62958. */
  62959. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62960. /**
  62961. * Callback used to let the user override the texture selection on a per mesh basis
  62962. */
  62963. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62964. /**
  62965. * Instantiates a new glow Layer and references it to the scene.
  62966. * @param name The name of the layer
  62967. * @param scene The scene to use the layer in
  62968. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62969. */
  62970. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62971. /**
  62972. * Get the effect name of the layer.
  62973. * @return The effect name
  62974. */
  62975. getEffectName(): string;
  62976. /**
  62977. * Create the merge effect. This is the shader use to blit the information back
  62978. * to the main canvas at the end of the scene rendering.
  62979. */
  62980. protected _createMergeEffect(): Effect;
  62981. /**
  62982. * Creates the render target textures and post processes used in the glow layer.
  62983. */
  62984. protected _createTextureAndPostProcesses(): void;
  62985. /**
  62986. * Checks for the readiness of the element composing the layer.
  62987. * @param subMesh the mesh to check for
  62988. * @param useInstances specify wether or not to use instances to render the mesh
  62989. * @param emissiveTexture the associated emissive texture used to generate the glow
  62990. * @return true if ready otherwise, false
  62991. */
  62992. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62993. /**
  62994. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62995. */
  62996. needStencil(): boolean;
  62997. /**
  62998. * Returns true if the mesh can be rendered, otherwise false.
  62999. * @param mesh The mesh to render
  63000. * @param material The material used on the mesh
  63001. * @returns true if it can be rendered otherwise false
  63002. */
  63003. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63004. /**
  63005. * Implementation specific of rendering the generating effect on the main canvas.
  63006. * @param effect The effect used to render through
  63007. */
  63008. protected _internalRender(effect: Effect): void;
  63009. /**
  63010. * Sets the required values for both the emissive texture and and the main color.
  63011. */
  63012. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63013. /**
  63014. * Returns true if the mesh should render, otherwise false.
  63015. * @param mesh The mesh to render
  63016. * @returns true if it should render otherwise false
  63017. */
  63018. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63019. /**
  63020. * Adds specific effects defines.
  63021. * @param defines The defines to add specifics to.
  63022. */
  63023. protected _addCustomEffectDefines(defines: string[]): void;
  63024. /**
  63025. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63026. * @param mesh The mesh to exclude from the glow layer
  63027. */
  63028. addExcludedMesh(mesh: Mesh): void;
  63029. /**
  63030. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63031. * @param mesh The mesh to remove
  63032. */
  63033. removeExcludedMesh(mesh: Mesh): void;
  63034. /**
  63035. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63036. * @param mesh The mesh to include in the glow layer
  63037. */
  63038. addIncludedOnlyMesh(mesh: Mesh): void;
  63039. /**
  63040. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63041. * @param mesh The mesh to remove
  63042. */
  63043. removeIncludedOnlyMesh(mesh: Mesh): void;
  63044. /**
  63045. * Determine if a given mesh will be used in the glow layer
  63046. * @param mesh The mesh to test
  63047. * @returns true if the mesh will be highlighted by the current glow layer
  63048. */
  63049. hasMesh(mesh: AbstractMesh): boolean;
  63050. /**
  63051. * Defines whether the current material of the mesh should be use to render the effect.
  63052. * @param mesh defines the current mesh to render
  63053. */
  63054. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63055. /**
  63056. * Add a mesh to be rendered through its own material and not with emissive only.
  63057. * @param mesh The mesh for which we need to use its material
  63058. */
  63059. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63060. /**
  63061. * Remove a mesh from being rendered through its own material and not with emissive only.
  63062. * @param mesh The mesh for which we need to not use its material
  63063. */
  63064. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63065. /**
  63066. * Free any resources and references associated to a mesh.
  63067. * Internal use
  63068. * @param mesh The mesh to free.
  63069. * @hidden
  63070. */
  63071. _disposeMesh(mesh: Mesh): void;
  63072. /**
  63073. * Gets the class name of the effect layer
  63074. * @returns the string with the class name of the effect layer
  63075. */
  63076. getClassName(): string;
  63077. /**
  63078. * Serializes this glow layer
  63079. * @returns a serialized glow layer object
  63080. */
  63081. serialize(): any;
  63082. /**
  63083. * Creates a Glow Layer from parsed glow layer data
  63084. * @param parsedGlowLayer defines glow layer data
  63085. * @param scene defines the current scene
  63086. * @param rootUrl defines the root URL containing the glow layer information
  63087. * @returns a parsed Glow Layer
  63088. */
  63089. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63090. }
  63091. }
  63092. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  63093. /** @hidden */
  63094. export var glowBlurPostProcessPixelShader: {
  63095. name: string;
  63096. shader: string;
  63097. };
  63098. }
  63099. declare module "babylonjs/Layers/highlightLayer" {
  63100. import { Observable } from "babylonjs/Misc/observable";
  63101. import { Nullable } from "babylonjs/types";
  63102. import { Camera } from "babylonjs/Cameras/camera";
  63103. import { Scene } from "babylonjs/scene";
  63104. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63106. import { Mesh } from "babylonjs/Meshes/mesh";
  63107. import { Effect } from "babylonjs/Materials/effect";
  63108. import { Material } from "babylonjs/Materials/material";
  63109. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  63110. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63111. import "babylonjs/Shaders/glowMapMerge.fragment";
  63112. import "babylonjs/Shaders/glowMapMerge.vertex";
  63113. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  63114. module "babylonjs/abstractScene" {
  63115. interface AbstractScene {
  63116. /**
  63117. * Return a the first highlight layer of the scene with a given name.
  63118. * @param name The name of the highlight layer to look for.
  63119. * @return The highlight layer if found otherwise null.
  63120. */
  63121. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63122. }
  63123. }
  63124. /**
  63125. * Highlight layer options. This helps customizing the behaviour
  63126. * of the highlight layer.
  63127. */
  63128. export interface IHighlightLayerOptions {
  63129. /**
  63130. * Multiplication factor apply to the canvas size to compute the render target size
  63131. * used to generated the glowing objects (the smaller the faster).
  63132. */
  63133. mainTextureRatio: number;
  63134. /**
  63135. * Enforces a fixed size texture to ensure resize independant blur.
  63136. */
  63137. mainTextureFixedSize?: number;
  63138. /**
  63139. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63140. * of the picture to blur (the smaller the faster).
  63141. */
  63142. blurTextureSizeRatio: number;
  63143. /**
  63144. * How big in texel of the blur texture is the vertical blur.
  63145. */
  63146. blurVerticalSize: number;
  63147. /**
  63148. * How big in texel of the blur texture is the horizontal blur.
  63149. */
  63150. blurHorizontalSize: number;
  63151. /**
  63152. * Alpha blending mode used to apply the blur. Default is combine.
  63153. */
  63154. alphaBlendingMode: number;
  63155. /**
  63156. * The camera attached to the layer.
  63157. */
  63158. camera: Nullable<Camera>;
  63159. /**
  63160. * Should we display highlight as a solid stroke?
  63161. */
  63162. isStroke?: boolean;
  63163. /**
  63164. * The rendering group to draw the layer in.
  63165. */
  63166. renderingGroupId: number;
  63167. }
  63168. /**
  63169. * The highlight layer Helps adding a glow effect around a mesh.
  63170. *
  63171. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63172. * glowy meshes to your scene.
  63173. *
  63174. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63175. */
  63176. export class HighlightLayer extends EffectLayer {
  63177. name: string;
  63178. /**
  63179. * Effect Name of the highlight layer.
  63180. */
  63181. static readonly EffectName: string;
  63182. /**
  63183. * The neutral color used during the preparation of the glow effect.
  63184. * This is black by default as the blend operation is a blend operation.
  63185. */
  63186. static NeutralColor: Color4;
  63187. /**
  63188. * Stencil value used for glowing meshes.
  63189. */
  63190. static GlowingMeshStencilReference: number;
  63191. /**
  63192. * Stencil value used for the other meshes in the scene.
  63193. */
  63194. static NormalMeshStencilReference: number;
  63195. /**
  63196. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63197. */
  63198. innerGlow: boolean;
  63199. /**
  63200. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63201. */
  63202. outerGlow: boolean;
  63203. /**
  63204. * Specifies the horizontal size of the blur.
  63205. */
  63206. set blurHorizontalSize(value: number);
  63207. /**
  63208. * Specifies the vertical size of the blur.
  63209. */
  63210. set blurVerticalSize(value: number);
  63211. /**
  63212. * Gets the horizontal size of the blur.
  63213. */
  63214. get blurHorizontalSize(): number;
  63215. /**
  63216. * Gets the vertical size of the blur.
  63217. */
  63218. get blurVerticalSize(): number;
  63219. /**
  63220. * An event triggered when the highlight layer is being blurred.
  63221. */
  63222. onBeforeBlurObservable: Observable<HighlightLayer>;
  63223. /**
  63224. * An event triggered when the highlight layer has been blurred.
  63225. */
  63226. onAfterBlurObservable: Observable<HighlightLayer>;
  63227. private _instanceGlowingMeshStencilReference;
  63228. private _options;
  63229. private _downSamplePostprocess;
  63230. private _horizontalBlurPostprocess;
  63231. private _verticalBlurPostprocess;
  63232. private _blurTexture;
  63233. private _meshes;
  63234. private _excludedMeshes;
  63235. /**
  63236. * Instantiates a new highlight Layer and references it to the scene..
  63237. * @param name The name of the layer
  63238. * @param scene The scene to use the layer in
  63239. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63240. */
  63241. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63242. /**
  63243. * Get the effect name of the layer.
  63244. * @return The effect name
  63245. */
  63246. getEffectName(): string;
  63247. /**
  63248. * Create the merge effect. This is the shader use to blit the information back
  63249. * to the main canvas at the end of the scene rendering.
  63250. */
  63251. protected _createMergeEffect(): Effect;
  63252. /**
  63253. * Creates the render target textures and post processes used in the highlight layer.
  63254. */
  63255. protected _createTextureAndPostProcesses(): void;
  63256. /**
  63257. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  63258. */
  63259. needStencil(): boolean;
  63260. /**
  63261. * Checks for the readiness of the element composing the layer.
  63262. * @param subMesh the mesh to check for
  63263. * @param useInstances specify wether or not to use instances to render the mesh
  63264. * @param emissiveTexture the associated emissive texture used to generate the glow
  63265. * @return true if ready otherwise, false
  63266. */
  63267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63268. /**
  63269. * Implementation specific of rendering the generating effect on the main canvas.
  63270. * @param effect The effect used to render through
  63271. */
  63272. protected _internalRender(effect: Effect): void;
  63273. /**
  63274. * Returns true if the layer contains information to display, otherwise false.
  63275. */
  63276. shouldRender(): boolean;
  63277. /**
  63278. * Returns true if the mesh should render, otherwise false.
  63279. * @param mesh The mesh to render
  63280. * @returns true if it should render otherwise false
  63281. */
  63282. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63283. /**
  63284. * Returns true if the mesh can be rendered, otherwise false.
  63285. * @param mesh The mesh to render
  63286. * @param material The material used on the mesh
  63287. * @returns true if it can be rendered otherwise false
  63288. */
  63289. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63290. /**
  63291. * Adds specific effects defines.
  63292. * @param defines The defines to add specifics to.
  63293. */
  63294. protected _addCustomEffectDefines(defines: string[]): void;
  63295. /**
  63296. * Sets the required values for both the emissive texture and and the main color.
  63297. */
  63298. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63299. /**
  63300. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63301. * @param mesh The mesh to exclude from the highlight layer
  63302. */
  63303. addExcludedMesh(mesh: Mesh): void;
  63304. /**
  63305. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63306. * @param mesh The mesh to highlight
  63307. */
  63308. removeExcludedMesh(mesh: Mesh): void;
  63309. /**
  63310. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63311. * @param mesh mesh to test
  63312. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63313. */
  63314. hasMesh(mesh: AbstractMesh): boolean;
  63315. /**
  63316. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63317. * @param mesh The mesh to highlight
  63318. * @param color The color of the highlight
  63319. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63320. */
  63321. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63322. /**
  63323. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63324. * @param mesh The mesh to highlight
  63325. */
  63326. removeMesh(mesh: Mesh): void;
  63327. /**
  63328. * Remove all the meshes currently referenced in the highlight layer
  63329. */
  63330. removeAllMeshes(): void;
  63331. /**
  63332. * Force the stencil to the normal expected value for none glowing parts
  63333. */
  63334. private _defaultStencilReference;
  63335. /**
  63336. * Free any resources and references associated to a mesh.
  63337. * Internal use
  63338. * @param mesh The mesh to free.
  63339. * @hidden
  63340. */
  63341. _disposeMesh(mesh: Mesh): void;
  63342. /**
  63343. * Dispose the highlight layer and free resources.
  63344. */
  63345. dispose(): void;
  63346. /**
  63347. * Gets the class name of the effect layer
  63348. * @returns the string with the class name of the effect layer
  63349. */
  63350. getClassName(): string;
  63351. /**
  63352. * Serializes this Highlight layer
  63353. * @returns a serialized Highlight layer object
  63354. */
  63355. serialize(): any;
  63356. /**
  63357. * Creates a Highlight layer from parsed Highlight layer data
  63358. * @param parsedHightlightLayer defines the Highlight layer data
  63359. * @param scene defines the current scene
  63360. * @param rootUrl defines the root URL containing the Highlight layer information
  63361. * @returns a parsed Highlight layer
  63362. */
  63363. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63364. }
  63365. }
  63366. declare module "babylonjs/Layers/layerSceneComponent" {
  63367. import { Scene } from "babylonjs/scene";
  63368. import { ISceneComponent } from "babylonjs/sceneComponent";
  63369. import { Layer } from "babylonjs/Layers/layer";
  63370. import { AbstractScene } from "babylonjs/abstractScene";
  63371. module "babylonjs/abstractScene" {
  63372. interface AbstractScene {
  63373. /**
  63374. * The list of layers (background and foreground) of the scene
  63375. */
  63376. layers: Array<Layer>;
  63377. }
  63378. }
  63379. /**
  63380. * Defines the layer scene component responsible to manage any layers
  63381. * in a given scene.
  63382. */
  63383. export class LayerSceneComponent implements ISceneComponent {
  63384. /**
  63385. * The component name helpfull to identify the component in the list of scene components.
  63386. */
  63387. readonly name: string;
  63388. /**
  63389. * The scene the component belongs to.
  63390. */
  63391. scene: Scene;
  63392. private _engine;
  63393. /**
  63394. * Creates a new instance of the component for the given scene
  63395. * @param scene Defines the scene to register the component in
  63396. */
  63397. constructor(scene: Scene);
  63398. /**
  63399. * Registers the component in a given scene
  63400. */
  63401. register(): void;
  63402. /**
  63403. * Rebuilds the elements related to this component in case of
  63404. * context lost for instance.
  63405. */
  63406. rebuild(): void;
  63407. /**
  63408. * Disposes the component and the associated ressources.
  63409. */
  63410. dispose(): void;
  63411. private _draw;
  63412. private _drawCameraPredicate;
  63413. private _drawCameraBackground;
  63414. private _drawCameraForeground;
  63415. private _drawRenderTargetPredicate;
  63416. private _drawRenderTargetBackground;
  63417. private _drawRenderTargetForeground;
  63418. /**
  63419. * Adds all the elements from the container to the scene
  63420. * @param container the container holding the elements
  63421. */
  63422. addFromContainer(container: AbstractScene): void;
  63423. /**
  63424. * Removes all the elements in the container from the scene
  63425. * @param container contains the elements to remove
  63426. * @param dispose if the removed element should be disposed (default: false)
  63427. */
  63428. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63429. }
  63430. }
  63431. declare module "babylonjs/Shaders/layer.fragment" {
  63432. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63433. /** @hidden */
  63434. export var layerPixelShader: {
  63435. name: string;
  63436. shader: string;
  63437. };
  63438. }
  63439. declare module "babylonjs/Shaders/layer.vertex" {
  63440. /** @hidden */
  63441. export var layerVertexShader: {
  63442. name: string;
  63443. shader: string;
  63444. };
  63445. }
  63446. declare module "babylonjs/Layers/layer" {
  63447. import { Observable } from "babylonjs/Misc/observable";
  63448. import { Nullable } from "babylonjs/types";
  63449. import { Scene } from "babylonjs/scene";
  63450. import { Vector2 } from "babylonjs/Maths/math.vector";
  63451. import { Color4 } from "babylonjs/Maths/math.color";
  63452. import { Texture } from "babylonjs/Materials/Textures/texture";
  63453. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63454. import "babylonjs/Shaders/layer.fragment";
  63455. import "babylonjs/Shaders/layer.vertex";
  63456. /**
  63457. * This represents a full screen 2d layer.
  63458. * This can be useful to display a picture in the background of your scene for instance.
  63459. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63460. */
  63461. export class Layer {
  63462. /**
  63463. * Define the name of the layer.
  63464. */
  63465. name: string;
  63466. /**
  63467. * Define the texture the layer should display.
  63468. */
  63469. texture: Nullable<Texture>;
  63470. /**
  63471. * Is the layer in background or foreground.
  63472. */
  63473. isBackground: boolean;
  63474. /**
  63475. * Define the color of the layer (instead of texture).
  63476. */
  63477. color: Color4;
  63478. /**
  63479. * Define the scale of the layer in order to zoom in out of the texture.
  63480. */
  63481. scale: Vector2;
  63482. /**
  63483. * Define an offset for the layer in order to shift the texture.
  63484. */
  63485. offset: Vector2;
  63486. /**
  63487. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63488. */
  63489. alphaBlendingMode: number;
  63490. /**
  63491. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63492. * Alpha test will not mix with the background color in case of transparency.
  63493. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63494. */
  63495. alphaTest: boolean;
  63496. /**
  63497. * Define a mask to restrict the layer to only some of the scene cameras.
  63498. */
  63499. layerMask: number;
  63500. /**
  63501. * Define the list of render target the layer is visible into.
  63502. */
  63503. renderTargetTextures: RenderTargetTexture[];
  63504. /**
  63505. * Define if the layer is only used in renderTarget or if it also
  63506. * renders in the main frame buffer of the canvas.
  63507. */
  63508. renderOnlyInRenderTargetTextures: boolean;
  63509. private _scene;
  63510. private _vertexBuffers;
  63511. private _indexBuffer;
  63512. private _effect;
  63513. private _previousDefines;
  63514. /**
  63515. * An event triggered when the layer is disposed.
  63516. */
  63517. onDisposeObservable: Observable<Layer>;
  63518. private _onDisposeObserver;
  63519. /**
  63520. * Back compatibility with callback before the onDisposeObservable existed.
  63521. * The set callback will be triggered when the layer has been disposed.
  63522. */
  63523. set onDispose(callback: () => void);
  63524. /**
  63525. * An event triggered before rendering the scene
  63526. */
  63527. onBeforeRenderObservable: Observable<Layer>;
  63528. private _onBeforeRenderObserver;
  63529. /**
  63530. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63531. * The set callback will be triggered just before rendering the layer.
  63532. */
  63533. set onBeforeRender(callback: () => void);
  63534. /**
  63535. * An event triggered after rendering the scene
  63536. */
  63537. onAfterRenderObservable: Observable<Layer>;
  63538. private _onAfterRenderObserver;
  63539. /**
  63540. * Back compatibility with callback before the onAfterRenderObservable existed.
  63541. * The set callback will be triggered just after rendering the layer.
  63542. */
  63543. set onAfterRender(callback: () => void);
  63544. /**
  63545. * Instantiates a new layer.
  63546. * This represents a full screen 2d layer.
  63547. * This can be useful to display a picture in the background of your scene for instance.
  63548. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63549. * @param name Define the name of the layer in the scene
  63550. * @param imgUrl Define the url of the texture to display in the layer
  63551. * @param scene Define the scene the layer belongs to
  63552. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63553. * @param color Defines a color for the layer
  63554. */
  63555. constructor(
  63556. /**
  63557. * Define the name of the layer.
  63558. */
  63559. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63560. private _createIndexBuffer;
  63561. /** @hidden */
  63562. _rebuild(): void;
  63563. /**
  63564. * Renders the layer in the scene.
  63565. */
  63566. render(): void;
  63567. /**
  63568. * Disposes and releases the associated ressources.
  63569. */
  63570. dispose(): void;
  63571. }
  63572. }
  63573. declare module "babylonjs/Layers/index" {
  63574. export * from "babylonjs/Layers/effectLayer";
  63575. export * from "babylonjs/Layers/effectLayerSceneComponent";
  63576. export * from "babylonjs/Layers/glowLayer";
  63577. export * from "babylonjs/Layers/highlightLayer";
  63578. export * from "babylonjs/Layers/layer";
  63579. export * from "babylonjs/Layers/layerSceneComponent";
  63580. }
  63581. declare module "babylonjs/Shaders/lensFlare.fragment" {
  63582. /** @hidden */
  63583. export var lensFlarePixelShader: {
  63584. name: string;
  63585. shader: string;
  63586. };
  63587. }
  63588. declare module "babylonjs/Shaders/lensFlare.vertex" {
  63589. /** @hidden */
  63590. export var lensFlareVertexShader: {
  63591. name: string;
  63592. shader: string;
  63593. };
  63594. }
  63595. declare module "babylonjs/LensFlares/lensFlareSystem" {
  63596. import { Scene } from "babylonjs/scene";
  63597. import { Vector3 } from "babylonjs/Maths/math.vector";
  63598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63599. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  63600. import "babylonjs/Shaders/lensFlare.fragment";
  63601. import "babylonjs/Shaders/lensFlare.vertex";
  63602. import { Viewport } from "babylonjs/Maths/math.viewport";
  63603. /**
  63604. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63605. * It is usually composed of several `lensFlare`.
  63606. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63607. */
  63608. export class LensFlareSystem {
  63609. /**
  63610. * Define the name of the lens flare system
  63611. */
  63612. name: string;
  63613. /**
  63614. * List of lens flares used in this system.
  63615. */
  63616. lensFlares: LensFlare[];
  63617. /**
  63618. * Define a limit from the border the lens flare can be visible.
  63619. */
  63620. borderLimit: number;
  63621. /**
  63622. * Define a viewport border we do not want to see the lens flare in.
  63623. */
  63624. viewportBorder: number;
  63625. /**
  63626. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63627. */
  63628. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63629. /**
  63630. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63631. */
  63632. layerMask: number;
  63633. /**
  63634. * Define the id of the lens flare system in the scene.
  63635. * (equal to name by default)
  63636. */
  63637. id: string;
  63638. private _scene;
  63639. private _emitter;
  63640. private _vertexBuffers;
  63641. private _indexBuffer;
  63642. private _effect;
  63643. private _positionX;
  63644. private _positionY;
  63645. private _isEnabled;
  63646. /** @hidden */
  63647. static _SceneComponentInitialization: (scene: Scene) => void;
  63648. /**
  63649. * Instantiates a lens flare system.
  63650. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63651. * It is usually composed of several `lensFlare`.
  63652. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63653. * @param name Define the name of the lens flare system in the scene
  63654. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63655. * @param scene Define the scene the lens flare system belongs to
  63656. */
  63657. constructor(
  63658. /**
  63659. * Define the name of the lens flare system
  63660. */
  63661. name: string, emitter: any, scene: Scene);
  63662. /**
  63663. * Define if the lens flare system is enabled.
  63664. */
  63665. get isEnabled(): boolean;
  63666. set isEnabled(value: boolean);
  63667. /**
  63668. * Get the scene the effects belongs to.
  63669. * @returns the scene holding the lens flare system
  63670. */
  63671. getScene(): Scene;
  63672. /**
  63673. * Get the emitter of the lens flare system.
  63674. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63675. * @returns the emitter of the lens flare system
  63676. */
  63677. getEmitter(): any;
  63678. /**
  63679. * Set the emitter of the lens flare system.
  63680. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63681. * @param newEmitter Define the new emitter of the system
  63682. */
  63683. setEmitter(newEmitter: any): void;
  63684. /**
  63685. * Get the lens flare system emitter position.
  63686. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63687. * @returns the position
  63688. */
  63689. getEmitterPosition(): Vector3;
  63690. /**
  63691. * @hidden
  63692. */
  63693. computeEffectivePosition(globalViewport: Viewport): boolean;
  63694. /** @hidden */
  63695. _isVisible(): boolean;
  63696. /**
  63697. * @hidden
  63698. */
  63699. render(): boolean;
  63700. /**
  63701. * Dispose and release the lens flare with its associated resources.
  63702. */
  63703. dispose(): void;
  63704. /**
  63705. * Parse a lens flare system from a JSON repressentation
  63706. * @param parsedLensFlareSystem Define the JSON to parse
  63707. * @param scene Define the scene the parsed system should be instantiated in
  63708. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63709. * @returns the parsed system
  63710. */
  63711. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63712. /**
  63713. * Serialize the current Lens Flare System into a JSON representation.
  63714. * @returns the serialized JSON
  63715. */
  63716. serialize(): any;
  63717. }
  63718. }
  63719. declare module "babylonjs/LensFlares/lensFlare" {
  63720. import { Nullable } from "babylonjs/types";
  63721. import { Color3 } from "babylonjs/Maths/math.color";
  63722. import { Texture } from "babylonjs/Materials/Textures/texture";
  63723. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63724. /**
  63725. * This represents one of the lens effect in a `lensFlareSystem`.
  63726. * It controls one of the indiviual texture used in the effect.
  63727. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63728. */
  63729. export class LensFlare {
  63730. /**
  63731. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63732. */
  63733. size: number;
  63734. /**
  63735. * 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.
  63736. */
  63737. position: number;
  63738. /**
  63739. * Define the lens color.
  63740. */
  63741. color: Color3;
  63742. /**
  63743. * Define the lens texture.
  63744. */
  63745. texture: Nullable<Texture>;
  63746. /**
  63747. * Define the alpha mode to render this particular lens.
  63748. */
  63749. alphaMode: number;
  63750. private _system;
  63751. /**
  63752. * Creates a new Lens Flare.
  63753. * This represents one of the lens effect in a `lensFlareSystem`.
  63754. * It controls one of the indiviual texture used in the effect.
  63755. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63756. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63757. * @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.
  63758. * @param color Define the lens color
  63759. * @param imgUrl Define the lens texture url
  63760. * @param system Define the `lensFlareSystem` this flare is part of
  63761. * @returns The newly created Lens Flare
  63762. */
  63763. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63764. /**
  63765. * Instantiates a new Lens Flare.
  63766. * This represents one of the lens effect in a `lensFlareSystem`.
  63767. * It controls one of the indiviual texture used in the effect.
  63768. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63769. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63770. * @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.
  63771. * @param color Define the lens color
  63772. * @param imgUrl Define the lens texture url
  63773. * @param system Define the `lensFlareSystem` this flare is part of
  63774. */
  63775. constructor(
  63776. /**
  63777. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63778. */
  63779. size: number,
  63780. /**
  63781. * 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.
  63782. */
  63783. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63784. /**
  63785. * Dispose and release the lens flare with its associated resources.
  63786. */
  63787. dispose(): void;
  63788. }
  63789. }
  63790. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  63791. import { Nullable } from "babylonjs/types";
  63792. import { Scene } from "babylonjs/scene";
  63793. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63794. import { AbstractScene } from "babylonjs/abstractScene";
  63795. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63796. module "babylonjs/abstractScene" {
  63797. interface AbstractScene {
  63798. /**
  63799. * The list of lens flare system added to the scene
  63800. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63801. */
  63802. lensFlareSystems: Array<LensFlareSystem>;
  63803. /**
  63804. * Removes the given lens flare system from this scene.
  63805. * @param toRemove The lens flare system to remove
  63806. * @returns The index of the removed lens flare system
  63807. */
  63808. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63809. /**
  63810. * Adds the given lens flare system to this scene
  63811. * @param newLensFlareSystem The lens flare system to add
  63812. */
  63813. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63814. /**
  63815. * Gets a lens flare system using its name
  63816. * @param name defines the name to look for
  63817. * @returns the lens flare system or null if not found
  63818. */
  63819. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63820. /**
  63821. * Gets a lens flare system using its id
  63822. * @param id defines the id to look for
  63823. * @returns the lens flare system or null if not found
  63824. */
  63825. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63826. }
  63827. }
  63828. /**
  63829. * Defines the lens flare scene component responsible to manage any lens flares
  63830. * in a given scene.
  63831. */
  63832. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63833. /**
  63834. * The component name helpfull to identify the component in the list of scene components.
  63835. */
  63836. readonly name: string;
  63837. /**
  63838. * The scene the component belongs to.
  63839. */
  63840. scene: Scene;
  63841. /**
  63842. * Creates a new instance of the component for the given scene
  63843. * @param scene Defines the scene to register the component in
  63844. */
  63845. constructor(scene: Scene);
  63846. /**
  63847. * Registers the component in a given scene
  63848. */
  63849. register(): void;
  63850. /**
  63851. * Rebuilds the elements related to this component in case of
  63852. * context lost for instance.
  63853. */
  63854. rebuild(): void;
  63855. /**
  63856. * Adds all the elements from the container to the scene
  63857. * @param container the container holding the elements
  63858. */
  63859. addFromContainer(container: AbstractScene): void;
  63860. /**
  63861. * Removes all the elements in the container from the scene
  63862. * @param container contains the elements to remove
  63863. * @param dispose if the removed element should be disposed (default: false)
  63864. */
  63865. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63866. /**
  63867. * Serializes the component data to the specified json object
  63868. * @param serializationObject The object to serialize to
  63869. */
  63870. serialize(serializationObject: any): void;
  63871. /**
  63872. * Disposes the component and the associated ressources.
  63873. */
  63874. dispose(): void;
  63875. private _draw;
  63876. }
  63877. }
  63878. declare module "babylonjs/LensFlares/index" {
  63879. export * from "babylonjs/LensFlares/lensFlare";
  63880. export * from "babylonjs/LensFlares/lensFlareSystem";
  63881. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  63882. }
  63883. declare module "babylonjs/Shaders/depth.fragment" {
  63884. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63885. /** @hidden */
  63886. export var depthPixelShader: {
  63887. name: string;
  63888. shader: string;
  63889. };
  63890. }
  63891. declare module "babylonjs/Shaders/depth.vertex" {
  63892. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63893. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63894. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63895. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63896. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63897. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63898. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63899. /** @hidden */
  63900. export var depthVertexShader: {
  63901. name: string;
  63902. shader: string;
  63903. };
  63904. }
  63905. declare module "babylonjs/Rendering/depthRenderer" {
  63906. import { Nullable } from "babylonjs/types";
  63907. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63908. import { Scene } from "babylonjs/scene";
  63909. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63910. import { Camera } from "babylonjs/Cameras/camera";
  63911. import "babylonjs/Shaders/depth.fragment";
  63912. import "babylonjs/Shaders/depth.vertex";
  63913. /**
  63914. * This represents a depth renderer in Babylon.
  63915. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63916. */
  63917. export class DepthRenderer {
  63918. private _scene;
  63919. private _depthMap;
  63920. private _effect;
  63921. private readonly _storeNonLinearDepth;
  63922. private readonly _clearColor;
  63923. /** Get if the depth renderer is using packed depth or not */
  63924. readonly isPacked: boolean;
  63925. private _cachedDefines;
  63926. private _camera;
  63927. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63928. enabled: boolean;
  63929. /**
  63930. * Specifiess that the depth renderer will only be used within
  63931. * the camera it is created for.
  63932. * This can help forcing its rendering during the camera processing.
  63933. */
  63934. useOnlyInActiveCamera: boolean;
  63935. /** @hidden */
  63936. static _SceneComponentInitialization: (scene: Scene) => void;
  63937. /**
  63938. * Instantiates a depth renderer
  63939. * @param scene The scene the renderer belongs to
  63940. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63941. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63942. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63943. */
  63944. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63945. /**
  63946. * Creates the depth rendering effect and checks if the effect is ready.
  63947. * @param subMesh The submesh to be used to render the depth map of
  63948. * @param useInstances If multiple world instances should be used
  63949. * @returns if the depth renderer is ready to render the depth map
  63950. */
  63951. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63952. /**
  63953. * Gets the texture which the depth map will be written to.
  63954. * @returns The depth map texture
  63955. */
  63956. getDepthMap(): RenderTargetTexture;
  63957. /**
  63958. * Disposes of the depth renderer.
  63959. */
  63960. dispose(): void;
  63961. }
  63962. }
  63963. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63964. /** @hidden */
  63965. export var minmaxReduxPixelShader: {
  63966. name: string;
  63967. shader: string;
  63968. };
  63969. }
  63970. declare module "babylonjs/Misc/minMaxReducer" {
  63971. import { Nullable } from "babylonjs/types";
  63972. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63973. import { Camera } from "babylonjs/Cameras/camera";
  63974. import { Observer } from "babylonjs/Misc/observable";
  63975. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63976. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63977. import { Observable } from "babylonjs/Misc/observable";
  63978. import "babylonjs/Shaders/minmaxRedux.fragment";
  63979. /**
  63980. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63981. * and maximum values from all values of the texture.
  63982. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63983. * The source values are read from the red channel of the texture.
  63984. */
  63985. export class MinMaxReducer {
  63986. /**
  63987. * Observable triggered when the computation has been performed
  63988. */
  63989. onAfterReductionPerformed: Observable<{
  63990. min: number;
  63991. max: number;
  63992. }>;
  63993. protected _camera: Camera;
  63994. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63995. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63996. protected _postProcessManager: PostProcessManager;
  63997. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63998. protected _forceFullscreenViewport: boolean;
  63999. /**
  64000. * Creates a min/max reducer
  64001. * @param camera The camera to use for the post processes
  64002. */
  64003. constructor(camera: Camera);
  64004. /**
  64005. * Gets the texture used to read the values from.
  64006. */
  64007. get sourceTexture(): Nullable<RenderTargetTexture>;
  64008. /**
  64009. * Sets the source texture to read the values from.
  64010. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64011. * because in such textures '1' value must not be taken into account to compute the maximum
  64012. * as this value is used to clear the texture.
  64013. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64014. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64015. * @param depthRedux Indicates if the texture is a depth texture or not
  64016. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64017. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64018. */
  64019. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64020. /**
  64021. * Defines the refresh rate of the computation.
  64022. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64023. */
  64024. get refreshRate(): number;
  64025. set refreshRate(value: number);
  64026. protected _activated: boolean;
  64027. /**
  64028. * Gets the activation status of the reducer
  64029. */
  64030. get activated(): boolean;
  64031. /**
  64032. * Activates the reduction computation.
  64033. * When activated, the observers registered in onAfterReductionPerformed are
  64034. * called after the compuation is performed
  64035. */
  64036. activate(): void;
  64037. /**
  64038. * Deactivates the reduction computation.
  64039. */
  64040. deactivate(): void;
  64041. /**
  64042. * Disposes the min/max reducer
  64043. * @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.
  64044. */
  64045. dispose(disposeAll?: boolean): void;
  64046. }
  64047. }
  64048. declare module "babylonjs/Misc/depthReducer" {
  64049. import { Nullable } from "babylonjs/types";
  64050. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64051. import { Camera } from "babylonjs/Cameras/camera";
  64052. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64053. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  64054. /**
  64055. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64056. */
  64057. export class DepthReducer extends MinMaxReducer {
  64058. private _depthRenderer;
  64059. private _depthRendererId;
  64060. /**
  64061. * Gets the depth renderer used for the computation.
  64062. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64063. */
  64064. get depthRenderer(): Nullable<DepthRenderer>;
  64065. /**
  64066. * Creates a depth reducer
  64067. * @param camera The camera used to render the depth texture
  64068. */
  64069. constructor(camera: Camera);
  64070. /**
  64071. * Sets the depth renderer to use to generate the depth map
  64072. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64073. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64074. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64075. */
  64076. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64077. /** @hidden */
  64078. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64079. /**
  64080. * Activates the reduction computation.
  64081. * When activated, the observers registered in onAfterReductionPerformed are
  64082. * called after the compuation is performed
  64083. */
  64084. activate(): void;
  64085. /**
  64086. * Deactivates the reduction computation.
  64087. */
  64088. deactivate(): void;
  64089. /**
  64090. * Disposes the depth reducer
  64091. * @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.
  64092. */
  64093. dispose(disposeAll?: boolean): void;
  64094. }
  64095. }
  64096. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  64097. import { Nullable } from "babylonjs/types";
  64098. import { Scene } from "babylonjs/scene";
  64099. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64100. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64102. import { Effect } from "babylonjs/Materials/effect";
  64103. import "babylonjs/Shaders/shadowMap.fragment";
  64104. import "babylonjs/Shaders/shadowMap.vertex";
  64105. import "babylonjs/Shaders/depthBoxBlur.fragment";
  64106. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  64107. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64108. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  64109. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64110. /**
  64111. * A CSM implementation allowing casting shadows on large scenes.
  64112. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64113. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64114. */
  64115. export class CascadedShadowGenerator extends ShadowGenerator {
  64116. private static readonly frustumCornersNDCSpace;
  64117. /**
  64118. * Name of the CSM class
  64119. */
  64120. static CLASSNAME: string;
  64121. /**
  64122. * Defines the default number of cascades used by the CSM.
  64123. */
  64124. static readonly DEFAULT_CASCADES_COUNT: number;
  64125. /**
  64126. * Defines the minimum number of cascades used by the CSM.
  64127. */
  64128. static readonly MIN_CASCADES_COUNT: number;
  64129. /**
  64130. * Defines the maximum number of cascades used by the CSM.
  64131. */
  64132. static readonly MAX_CASCADES_COUNT: number;
  64133. protected _validateFilter(filter: number): number;
  64134. /**
  64135. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64136. */
  64137. penumbraDarkness: number;
  64138. private _numCascades;
  64139. /**
  64140. * Gets or set the number of cascades used by the CSM.
  64141. */
  64142. get numCascades(): number;
  64143. set numCascades(value: number);
  64144. /**
  64145. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64146. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64147. */
  64148. stabilizeCascades: boolean;
  64149. private _freezeShadowCastersBoundingInfo;
  64150. private _freezeShadowCastersBoundingInfoObservable;
  64151. /**
  64152. * Enables or disables the shadow casters bounding info computation.
  64153. * If your shadow casters don't move, you can disable this feature.
  64154. * If it is enabled, the bounding box computation is done every frame.
  64155. */
  64156. get freezeShadowCastersBoundingInfo(): boolean;
  64157. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64158. private _scbiMin;
  64159. private _scbiMax;
  64160. protected _computeShadowCastersBoundingInfo(): void;
  64161. protected _shadowCastersBoundingInfo: BoundingInfo;
  64162. /**
  64163. * Gets or sets the shadow casters bounding info.
  64164. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64165. * so that the system won't overwrite the bounds you provide
  64166. */
  64167. get shadowCastersBoundingInfo(): BoundingInfo;
  64168. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64169. protected _breaksAreDirty: boolean;
  64170. protected _minDistance: number;
  64171. protected _maxDistance: number;
  64172. /**
  64173. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64174. *
  64175. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64176. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64177. * @param min minimal distance for the breaks (default to 0.)
  64178. * @param max maximal distance for the breaks (default to 1.)
  64179. */
  64180. setMinMaxDistance(min: number, max: number): void;
  64181. /** Gets the minimal distance used in the cascade break computation */
  64182. get minDistance(): number;
  64183. /** Gets the maximal distance used in the cascade break computation */
  64184. get maxDistance(): number;
  64185. /**
  64186. * Gets the class name of that object
  64187. * @returns "CascadedShadowGenerator"
  64188. */
  64189. getClassName(): string;
  64190. private _cascadeMinExtents;
  64191. private _cascadeMaxExtents;
  64192. /**
  64193. * Gets a cascade minimum extents
  64194. * @param cascadeIndex index of the cascade
  64195. * @returns the minimum cascade extents
  64196. */
  64197. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64198. /**
  64199. * Gets a cascade maximum extents
  64200. * @param cascadeIndex index of the cascade
  64201. * @returns the maximum cascade extents
  64202. */
  64203. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64204. private _cascades;
  64205. private _currentLayer;
  64206. private _viewSpaceFrustumsZ;
  64207. private _viewMatrices;
  64208. private _projectionMatrices;
  64209. private _transformMatrices;
  64210. private _transformMatricesAsArray;
  64211. private _frustumLengths;
  64212. private _lightSizeUVCorrection;
  64213. private _depthCorrection;
  64214. private _frustumCornersWorldSpace;
  64215. private _frustumCenter;
  64216. private _shadowCameraPos;
  64217. private _shadowMaxZ;
  64218. /**
  64219. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64220. * It defaults to camera.maxZ
  64221. */
  64222. get shadowMaxZ(): number;
  64223. /**
  64224. * Sets the shadow max z distance.
  64225. */
  64226. set shadowMaxZ(value: number);
  64227. protected _debug: boolean;
  64228. /**
  64229. * Gets or sets the debug flag.
  64230. * When enabled, the cascades are materialized by different colors on the screen.
  64231. */
  64232. get debug(): boolean;
  64233. set debug(dbg: boolean);
  64234. private _depthClamp;
  64235. /**
  64236. * Gets or sets the depth clamping value.
  64237. *
  64238. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64239. * to account for the shadow casters far away.
  64240. *
  64241. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64242. */
  64243. get depthClamp(): boolean;
  64244. set depthClamp(value: boolean);
  64245. private _cascadeBlendPercentage;
  64246. /**
  64247. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64248. * It defaults to 0.1 (10% blending).
  64249. */
  64250. get cascadeBlendPercentage(): number;
  64251. set cascadeBlendPercentage(value: number);
  64252. private _lambda;
  64253. /**
  64254. * Gets or set the lambda parameter.
  64255. * This parameter is used to split the camera frustum and create the cascades.
  64256. * 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.
  64257. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64258. */
  64259. get lambda(): number;
  64260. set lambda(value: number);
  64261. /**
  64262. * Gets the view matrix corresponding to a given cascade
  64263. * @param cascadeNum cascade to retrieve the view matrix from
  64264. * @returns the cascade view matrix
  64265. */
  64266. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64267. /**
  64268. * Gets the projection matrix corresponding to a given cascade
  64269. * @param cascadeNum cascade to retrieve the projection matrix from
  64270. * @returns the cascade projection matrix
  64271. */
  64272. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64273. /**
  64274. * Gets the transformation matrix corresponding to a given cascade
  64275. * @param cascadeNum cascade to retrieve the transformation matrix from
  64276. * @returns the cascade transformation matrix
  64277. */
  64278. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64279. private _depthRenderer;
  64280. /**
  64281. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64282. *
  64283. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64284. *
  64285. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64286. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64287. * @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
  64288. */
  64289. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64290. private _depthReducer;
  64291. private _autoCalcDepthBounds;
  64292. /**
  64293. * Gets or sets the autoCalcDepthBounds property.
  64294. *
  64295. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64296. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64297. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64298. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64299. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64300. */
  64301. get autoCalcDepthBounds(): boolean;
  64302. set autoCalcDepthBounds(value: boolean);
  64303. /**
  64304. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64305. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64306. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64307. * for setting the refresh rate on the renderer yourself!
  64308. */
  64309. get autoCalcDepthBoundsRefreshRate(): number;
  64310. set autoCalcDepthBoundsRefreshRate(value: number);
  64311. /**
  64312. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64313. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64314. * you change the camera near/far planes!
  64315. */
  64316. splitFrustum(): void;
  64317. private _splitFrustum;
  64318. private _computeMatrices;
  64319. private _computeFrustumInWorldSpace;
  64320. private _computeCascadeFrustum;
  64321. /**
  64322. * Support test.
  64323. */
  64324. static get IsSupported(): boolean;
  64325. /** @hidden */
  64326. static _SceneComponentInitialization: (scene: Scene) => void;
  64327. /**
  64328. * Creates a Cascaded Shadow Generator object.
  64329. * A ShadowGenerator is the required tool to use the shadows.
  64330. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64331. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64332. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64333. * @param light The directional light object generating the shadows.
  64334. * @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.
  64335. */
  64336. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64337. protected _initializeGenerator(): void;
  64338. protected _createTargetRenderTexture(): void;
  64339. protected _initializeShadowMap(): void;
  64340. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64341. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64342. /**
  64343. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64344. * @param defines Defines of the material we want to update
  64345. * @param lightIndex Index of the light in the enabled light list of the material
  64346. */
  64347. prepareDefines(defines: any, lightIndex: number): void;
  64348. /**
  64349. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64350. * defined in the generator but impacting the effect).
  64351. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64352. * @param effect The effect we are binfing the information for
  64353. */
  64354. bindShadowLight(lightIndex: string, effect: Effect): void;
  64355. /**
  64356. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64357. * (eq to view projection * shadow projection matrices)
  64358. * @returns The transform matrix used to create the shadow map
  64359. */
  64360. getTransformMatrix(): Matrix;
  64361. /**
  64362. * Disposes the ShadowGenerator.
  64363. * Returns nothing.
  64364. */
  64365. dispose(): void;
  64366. /**
  64367. * Serializes the shadow generator setup to a json object.
  64368. * @returns The serialized JSON object
  64369. */
  64370. serialize(): any;
  64371. /**
  64372. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64373. * @param parsedShadowGenerator The JSON object to parse
  64374. * @param scene The scene to create the shadow map for
  64375. * @returns The parsed shadow generator
  64376. */
  64377. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64378. }
  64379. }
  64380. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  64381. import { Scene } from "babylonjs/scene";
  64382. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  64383. import { AbstractScene } from "babylonjs/abstractScene";
  64384. /**
  64385. * Defines the shadow generator component responsible to manage any shadow generators
  64386. * in a given scene.
  64387. */
  64388. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64389. /**
  64390. * The component name helpfull to identify the component in the list of scene components.
  64391. */
  64392. readonly name: string;
  64393. /**
  64394. * The scene the component belongs to.
  64395. */
  64396. scene: Scene;
  64397. /**
  64398. * Creates a new instance of the component for the given scene
  64399. * @param scene Defines the scene to register the component in
  64400. */
  64401. constructor(scene: Scene);
  64402. /**
  64403. * Registers the component in a given scene
  64404. */
  64405. register(): void;
  64406. /**
  64407. * Rebuilds the elements related to this component in case of
  64408. * context lost for instance.
  64409. */
  64410. rebuild(): void;
  64411. /**
  64412. * Serializes the component data to the specified json object
  64413. * @param serializationObject The object to serialize to
  64414. */
  64415. serialize(serializationObject: any): void;
  64416. /**
  64417. * Adds all the elements from the container to the scene
  64418. * @param container the container holding the elements
  64419. */
  64420. addFromContainer(container: AbstractScene): void;
  64421. /**
  64422. * Removes all the elements in the container from the scene
  64423. * @param container contains the elements to remove
  64424. * @param dispose if the removed element should be disposed (default: false)
  64425. */
  64426. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64427. /**
  64428. * Rebuilds the elements related to this component in case of
  64429. * context lost for instance.
  64430. */
  64431. dispose(): void;
  64432. private _gatherRenderTargets;
  64433. }
  64434. }
  64435. declare module "babylonjs/Lights/Shadows/index" {
  64436. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  64437. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  64438. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  64439. }
  64440. declare module "babylonjs/Lights/pointLight" {
  64441. import { Scene } from "babylonjs/scene";
  64442. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64444. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  64445. import { Effect } from "babylonjs/Materials/effect";
  64446. /**
  64447. * A point light is a light defined by an unique point in world space.
  64448. * The light is emitted in every direction from this point.
  64449. * A good example of a point light is a standard light bulb.
  64450. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64451. */
  64452. export class PointLight extends ShadowLight {
  64453. private _shadowAngle;
  64454. /**
  64455. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64456. * This specifies what angle the shadow will use to be created.
  64457. *
  64458. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64459. */
  64460. get shadowAngle(): number;
  64461. /**
  64462. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64463. * This specifies what angle the shadow will use to be created.
  64464. *
  64465. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64466. */
  64467. set shadowAngle(value: number);
  64468. /**
  64469. * Gets the direction if it has been set.
  64470. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64471. */
  64472. get direction(): Vector3;
  64473. /**
  64474. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64475. */
  64476. set direction(value: Vector3);
  64477. /**
  64478. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64479. * A PointLight emits the light in every direction.
  64480. * It can cast shadows.
  64481. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64482. * ```javascript
  64483. * var pointLight = new PointLight("pl", camera.position, scene);
  64484. * ```
  64485. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64486. * @param name The light friendly name
  64487. * @param position The position of the point light in the scene
  64488. * @param scene The scene the lights belongs to
  64489. */
  64490. constructor(name: string, position: Vector3, scene: Scene);
  64491. /**
  64492. * Returns the string "PointLight"
  64493. * @returns the class name
  64494. */
  64495. getClassName(): string;
  64496. /**
  64497. * Returns the integer 0.
  64498. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64499. */
  64500. getTypeID(): number;
  64501. /**
  64502. * Specifies wether or not the shadowmap should be a cube texture.
  64503. * @returns true if the shadowmap needs to be a cube texture.
  64504. */
  64505. needCube(): boolean;
  64506. /**
  64507. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64508. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64509. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64510. */
  64511. getShadowDirection(faceIndex?: number): Vector3;
  64512. /**
  64513. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64514. * - fov = PI / 2
  64515. * - aspect ratio : 1.0
  64516. * - z-near and far equal to the active camera minZ and maxZ.
  64517. * Returns the PointLight.
  64518. */
  64519. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64520. protected _buildUniformLayout(): void;
  64521. /**
  64522. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64523. * @param effect The effect to update
  64524. * @param lightIndex The index of the light in the effect to update
  64525. * @returns The point light
  64526. */
  64527. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64528. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64529. /**
  64530. * Prepares the list of defines specific to the light type.
  64531. * @param defines the list of defines
  64532. * @param lightIndex defines the index of the light for the effect
  64533. */
  64534. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64535. }
  64536. }
  64537. declare module "babylonjs/Lights/index" {
  64538. export * from "babylonjs/Lights/light";
  64539. export * from "babylonjs/Lights/shadowLight";
  64540. export * from "babylonjs/Lights/Shadows/index";
  64541. export * from "babylonjs/Lights/directionalLight";
  64542. export * from "babylonjs/Lights/hemisphericLight";
  64543. export * from "babylonjs/Lights/pointLight";
  64544. export * from "babylonjs/Lights/spotLight";
  64545. }
  64546. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  64547. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64548. /**
  64549. * Header information of HDR texture files.
  64550. */
  64551. export interface HDRInfo {
  64552. /**
  64553. * The height of the texture in pixels.
  64554. */
  64555. height: number;
  64556. /**
  64557. * The width of the texture in pixels.
  64558. */
  64559. width: number;
  64560. /**
  64561. * The index of the beginning of the data in the binary file.
  64562. */
  64563. dataPosition: number;
  64564. }
  64565. /**
  64566. * This groups tools to convert HDR texture to native colors array.
  64567. */
  64568. export class HDRTools {
  64569. private static Ldexp;
  64570. private static Rgbe2float;
  64571. private static readStringLine;
  64572. /**
  64573. * Reads header information from an RGBE texture stored in a native array.
  64574. * More information on this format are available here:
  64575. * https://en.wikipedia.org/wiki/RGBE_image_format
  64576. *
  64577. * @param uint8array The binary file stored in native array.
  64578. * @return The header information.
  64579. */
  64580. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64581. /**
  64582. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64583. * This RGBE texture needs to store the information as a panorama.
  64584. *
  64585. * More information on this format are available here:
  64586. * https://en.wikipedia.org/wiki/RGBE_image_format
  64587. *
  64588. * @param buffer The binary file stored in an array buffer.
  64589. * @param size The expected size of the extracted cubemap.
  64590. * @return The Cube Map information.
  64591. */
  64592. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64593. /**
  64594. * Returns the pixels data extracted from an RGBE texture.
  64595. * This pixels will be stored left to right up to down in the R G B order in one array.
  64596. *
  64597. * More information on this format are available here:
  64598. * https://en.wikipedia.org/wiki/RGBE_image_format
  64599. *
  64600. * @param uint8array The binary file stored in an array buffer.
  64601. * @param hdrInfo The header information of the file.
  64602. * @return The pixels data in RGB right to left up to down order.
  64603. */
  64604. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64605. private static RGBE_ReadPixels_RLE;
  64606. private static RGBE_ReadPixels_NOT_RLE;
  64607. }
  64608. }
  64609. declare module "babylonjs/Materials/effectRenderer" {
  64610. import { Nullable } from "babylonjs/types";
  64611. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64612. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64613. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64614. import { Viewport } from "babylonjs/Maths/math.viewport";
  64615. import { Observable } from "babylonjs/Misc/observable";
  64616. import { Effect } from "babylonjs/Materials/effect";
  64617. import "babylonjs/Shaders/postprocess.vertex";
  64618. /**
  64619. * Effect Render Options
  64620. */
  64621. export interface IEffectRendererOptions {
  64622. /**
  64623. * Defines the vertices positions.
  64624. */
  64625. positions?: number[];
  64626. /**
  64627. * Defines the indices.
  64628. */
  64629. indices?: number[];
  64630. }
  64631. /**
  64632. * Helper class to render one or more effects.
  64633. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64634. */
  64635. export class EffectRenderer {
  64636. private engine;
  64637. private static _DefaultOptions;
  64638. private _vertexBuffers;
  64639. private _indexBuffer;
  64640. private _fullscreenViewport;
  64641. /**
  64642. * Creates an effect renderer
  64643. * @param engine the engine to use for rendering
  64644. * @param options defines the options of the effect renderer
  64645. */
  64646. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64647. /**
  64648. * Sets the current viewport in normalized coordinates 0-1
  64649. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64650. */
  64651. setViewport(viewport?: Viewport): void;
  64652. /**
  64653. * Binds the embedded attributes buffer to the effect.
  64654. * @param effect Defines the effect to bind the attributes for
  64655. */
  64656. bindBuffers(effect: Effect): void;
  64657. /**
  64658. * Sets the current effect wrapper to use during draw.
  64659. * The effect needs to be ready before calling this api.
  64660. * This also sets the default full screen position attribute.
  64661. * @param effectWrapper Defines the effect to draw with
  64662. */
  64663. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64664. /**
  64665. * Restores engine states
  64666. */
  64667. restoreStates(): void;
  64668. /**
  64669. * Draws a full screen quad.
  64670. */
  64671. draw(): void;
  64672. private isRenderTargetTexture;
  64673. /**
  64674. * renders one or more effects to a specified texture
  64675. * @param effectWrapper the effect to renderer
  64676. * @param outputTexture texture to draw to, if null it will render to the screen.
  64677. */
  64678. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64679. /**
  64680. * Disposes of the effect renderer
  64681. */
  64682. dispose(): void;
  64683. }
  64684. /**
  64685. * Options to create an EffectWrapper
  64686. */
  64687. interface EffectWrapperCreationOptions {
  64688. /**
  64689. * Engine to use to create the effect
  64690. */
  64691. engine: ThinEngine;
  64692. /**
  64693. * Fragment shader for the effect
  64694. */
  64695. fragmentShader: string;
  64696. /**
  64697. * Use the shader store instead of direct source code
  64698. */
  64699. useShaderStore?: boolean;
  64700. /**
  64701. * Vertex shader for the effect
  64702. */
  64703. vertexShader?: string;
  64704. /**
  64705. * Attributes to use in the shader
  64706. */
  64707. attributeNames?: Array<string>;
  64708. /**
  64709. * Uniforms to use in the shader
  64710. */
  64711. uniformNames?: Array<string>;
  64712. /**
  64713. * Texture sampler names to use in the shader
  64714. */
  64715. samplerNames?: Array<string>;
  64716. /**
  64717. * Defines to use in the shader
  64718. */
  64719. defines?: Array<string>;
  64720. /**
  64721. * Callback when effect is compiled
  64722. */
  64723. onCompiled?: Nullable<(effect: Effect) => void>;
  64724. /**
  64725. * The friendly name of the effect displayed in Spector.
  64726. */
  64727. name?: string;
  64728. }
  64729. /**
  64730. * Wraps an effect to be used for rendering
  64731. */
  64732. export class EffectWrapper {
  64733. /**
  64734. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64735. */
  64736. onApplyObservable: Observable<{}>;
  64737. /**
  64738. * The underlying effect
  64739. */
  64740. effect: Effect;
  64741. /**
  64742. * Creates an effect to be renderer
  64743. * @param creationOptions options to create the effect
  64744. */
  64745. constructor(creationOptions: EffectWrapperCreationOptions);
  64746. /**
  64747. * Disposes of the effect wrapper
  64748. */
  64749. dispose(): void;
  64750. }
  64751. }
  64752. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  64753. /** @hidden */
  64754. export var hdrFilteringVertexShader: {
  64755. name: string;
  64756. shader: string;
  64757. };
  64758. }
  64759. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  64760. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64761. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  64762. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  64763. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  64764. /** @hidden */
  64765. export var hdrFilteringPixelShader: {
  64766. name: string;
  64767. shader: string;
  64768. };
  64769. }
  64770. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  64771. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64772. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64773. import { Nullable } from "babylonjs/types";
  64774. import "babylonjs/Shaders/hdrFiltering.vertex";
  64775. import "babylonjs/Shaders/hdrFiltering.fragment";
  64776. /**
  64777. * Options for texture filtering
  64778. */
  64779. interface IHDRFilteringOptions {
  64780. /**
  64781. * Scales pixel intensity for the input HDR map.
  64782. */
  64783. hdrScale?: number;
  64784. /**
  64785. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64786. */
  64787. quality?: number;
  64788. }
  64789. /**
  64790. * Filters HDR maps to get correct renderings of PBR reflections
  64791. */
  64792. export class HDRFiltering {
  64793. private _engine;
  64794. private _effectRenderer;
  64795. private _effectWrapper;
  64796. private _lodGenerationOffset;
  64797. private _lodGenerationScale;
  64798. /**
  64799. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64800. * you care about baking speed.
  64801. */
  64802. quality: number;
  64803. /**
  64804. * Scales pixel intensity for the input HDR map.
  64805. */
  64806. hdrScale: number;
  64807. /**
  64808. * Instantiates HDR filter for reflection maps
  64809. *
  64810. * @param engine Thin engine
  64811. * @param options Options
  64812. */
  64813. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64814. private _createRenderTarget;
  64815. private _prefilterInternal;
  64816. private _createEffect;
  64817. /**
  64818. * Get a value indicating if the filter is ready to be used
  64819. * @param texture Texture to filter
  64820. * @returns true if the filter is ready
  64821. */
  64822. isReady(texture: BaseTexture): boolean;
  64823. /**
  64824. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64825. * Prefiltering will be invoked at the end of next rendering pass.
  64826. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64827. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64828. * @param texture Texture to filter
  64829. * @param onFinished Callback when filtering is done
  64830. * @return Promise called when prefiltering is done
  64831. */
  64832. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  64833. }
  64834. }
  64835. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  64836. import { Nullable } from "babylonjs/types";
  64837. import { Scene } from "babylonjs/scene";
  64838. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64839. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64840. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64841. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64842. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  64843. /**
  64844. * This represents a texture coming from an HDR input.
  64845. *
  64846. * The only supported format is currently panorama picture stored in RGBE format.
  64847. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64848. */
  64849. export class HDRCubeTexture extends BaseTexture {
  64850. private static _facesMapping;
  64851. private _generateHarmonics;
  64852. private _noMipmap;
  64853. private _prefilterOnLoad;
  64854. private _textureMatrix;
  64855. private _size;
  64856. private _onLoad;
  64857. private _onError;
  64858. /**
  64859. * The texture URL.
  64860. */
  64861. url: string;
  64862. protected _isBlocking: boolean;
  64863. /**
  64864. * Sets wether or not the texture is blocking during loading.
  64865. */
  64866. set isBlocking(value: boolean);
  64867. /**
  64868. * Gets wether or not the texture is blocking during loading.
  64869. */
  64870. get isBlocking(): boolean;
  64871. protected _rotationY: number;
  64872. /**
  64873. * Sets texture matrix rotation angle around Y axis in radians.
  64874. */
  64875. set rotationY(value: number);
  64876. /**
  64877. * Gets texture matrix rotation angle around Y axis radians.
  64878. */
  64879. get rotationY(): number;
  64880. /**
  64881. * Gets or sets the center of the bounding box associated with the cube texture
  64882. * It must define where the camera used to render the texture was set
  64883. */
  64884. boundingBoxPosition: Vector3;
  64885. private _boundingBoxSize;
  64886. /**
  64887. * Gets or sets the size of the bounding box associated with the cube texture
  64888. * When defined, the cubemap will switch to local mode
  64889. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64890. * @example https://www.babylonjs-playground.com/#RNASML
  64891. */
  64892. set boundingBoxSize(value: Vector3);
  64893. get boundingBoxSize(): Vector3;
  64894. /**
  64895. * Instantiates an HDRTexture from the following parameters.
  64896. *
  64897. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64898. * @param sceneOrEngine The scene or engine the texture will be used in
  64899. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64900. * @param noMipmap Forces to not generate the mipmap if true
  64901. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64902. * @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)
  64903. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64904. */
  64905. 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>);
  64906. /**
  64907. * Get the current class name of the texture useful for serialization or dynamic coding.
  64908. * @returns "HDRCubeTexture"
  64909. */
  64910. getClassName(): string;
  64911. /**
  64912. * Occurs when the file is raw .hdr file.
  64913. */
  64914. private loadTexture;
  64915. clone(): HDRCubeTexture;
  64916. delayLoad(): void;
  64917. /**
  64918. * Get the texture reflection matrix used to rotate/transform the reflection.
  64919. * @returns the reflection matrix
  64920. */
  64921. getReflectionTextureMatrix(): Matrix;
  64922. /**
  64923. * Set the texture reflection matrix used to rotate/transform the reflection.
  64924. * @param value Define the reflection matrix to set
  64925. */
  64926. setReflectionTextureMatrix(value: Matrix): void;
  64927. /**
  64928. * Parses a JSON representation of an HDR Texture in order to create the texture
  64929. * @param parsedTexture Define the JSON representation
  64930. * @param scene Define the scene the texture should be created in
  64931. * @param rootUrl Define the root url in case we need to load relative dependencies
  64932. * @returns the newly created texture after parsing
  64933. */
  64934. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64935. serialize(): any;
  64936. }
  64937. }
  64938. declare module "babylonjs/Physics/physicsEngine" {
  64939. import { Nullable } from "babylonjs/types";
  64940. import { Vector3 } from "babylonjs/Maths/math.vector";
  64941. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64942. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64943. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64944. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64945. /**
  64946. * Class used to control physics engine
  64947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64948. */
  64949. export class PhysicsEngine implements IPhysicsEngine {
  64950. private _physicsPlugin;
  64951. /**
  64952. * Global value used to control the smallest number supported by the simulation
  64953. */
  64954. static Epsilon: number;
  64955. private _impostors;
  64956. private _joints;
  64957. private _subTimeStep;
  64958. /**
  64959. * Gets the gravity vector used by the simulation
  64960. */
  64961. gravity: Vector3;
  64962. /**
  64963. * Factory used to create the default physics plugin.
  64964. * @returns The default physics plugin
  64965. */
  64966. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64967. /**
  64968. * Creates a new Physics Engine
  64969. * @param gravity defines the gravity vector used by the simulation
  64970. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64971. */
  64972. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64973. /**
  64974. * Sets the gravity vector used by the simulation
  64975. * @param gravity defines the gravity vector to use
  64976. */
  64977. setGravity(gravity: Vector3): void;
  64978. /**
  64979. * Set the time step of the physics engine.
  64980. * Default is 1/60.
  64981. * To slow it down, enter 1/600 for example.
  64982. * To speed it up, 1/30
  64983. * @param newTimeStep defines the new timestep to apply to this world.
  64984. */
  64985. setTimeStep(newTimeStep?: number): void;
  64986. /**
  64987. * Get the time step of the physics engine.
  64988. * @returns the current time step
  64989. */
  64990. getTimeStep(): number;
  64991. /**
  64992. * Set the sub time step of the physics engine.
  64993. * Default is 0 meaning there is no sub steps
  64994. * To increase physics resolution precision, set a small value (like 1 ms)
  64995. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64996. */
  64997. setSubTimeStep(subTimeStep?: number): void;
  64998. /**
  64999. * Get the sub time step of the physics engine.
  65000. * @returns the current sub time step
  65001. */
  65002. getSubTimeStep(): number;
  65003. /**
  65004. * Release all resources
  65005. */
  65006. dispose(): void;
  65007. /**
  65008. * Gets the name of the current physics plugin
  65009. * @returns the name of the plugin
  65010. */
  65011. getPhysicsPluginName(): string;
  65012. /**
  65013. * Adding a new impostor for the impostor tracking.
  65014. * This will be done by the impostor itself.
  65015. * @param impostor the impostor to add
  65016. */
  65017. addImpostor(impostor: PhysicsImpostor): void;
  65018. /**
  65019. * Remove an impostor from the engine.
  65020. * This impostor and its mesh will not longer be updated by the physics engine.
  65021. * @param impostor the impostor to remove
  65022. */
  65023. removeImpostor(impostor: PhysicsImpostor): void;
  65024. /**
  65025. * Add a joint to the physics engine
  65026. * @param mainImpostor defines the main impostor to which the joint is added.
  65027. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65028. * @param joint defines the joint that will connect both impostors.
  65029. */
  65030. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65031. /**
  65032. * Removes a joint from the simulation
  65033. * @param mainImpostor defines the impostor used with the joint
  65034. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65035. * @param joint defines the joint to remove
  65036. */
  65037. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65038. /**
  65039. * Called by the scene. No need to call it.
  65040. * @param delta defines the timespam between frames
  65041. */
  65042. _step(delta: number): void;
  65043. /**
  65044. * Gets the current plugin used to run the simulation
  65045. * @returns current plugin
  65046. */
  65047. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65048. /**
  65049. * Gets the list of physic impostors
  65050. * @returns an array of PhysicsImpostor
  65051. */
  65052. getImpostors(): Array<PhysicsImpostor>;
  65053. /**
  65054. * Gets the impostor for a physics enabled object
  65055. * @param object defines the object impersonated by the impostor
  65056. * @returns the PhysicsImpostor or null if not found
  65057. */
  65058. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65059. /**
  65060. * Gets the impostor for a physics body object
  65061. * @param body defines physics body used by the impostor
  65062. * @returns the PhysicsImpostor or null if not found
  65063. */
  65064. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65065. /**
  65066. * Does a raycast in the physics world
  65067. * @param from when should the ray start?
  65068. * @param to when should the ray end?
  65069. * @returns PhysicsRaycastResult
  65070. */
  65071. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65072. }
  65073. }
  65074. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  65075. import { Nullable } from "babylonjs/types";
  65076. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  65077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65078. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65079. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65080. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65081. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65082. /** @hidden */
  65083. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65084. private _useDeltaForWorldStep;
  65085. world: any;
  65086. name: string;
  65087. private _physicsMaterials;
  65088. private _fixedTimeStep;
  65089. private _cannonRaycastResult;
  65090. private _raycastResult;
  65091. private _physicsBodysToRemoveAfterStep;
  65092. private _firstFrame;
  65093. BJSCANNON: any;
  65094. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65095. setGravity(gravity: Vector3): void;
  65096. setTimeStep(timeStep: number): void;
  65097. getTimeStep(): number;
  65098. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65099. private _removeMarkedPhysicsBodiesFromWorld;
  65100. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65101. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65102. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65103. private _processChildMeshes;
  65104. removePhysicsBody(impostor: PhysicsImpostor): void;
  65105. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65106. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65107. private _addMaterial;
  65108. private _checkWithEpsilon;
  65109. private _createShape;
  65110. private _createHeightmap;
  65111. private _minus90X;
  65112. private _plus90X;
  65113. private _tmpPosition;
  65114. private _tmpDeltaPosition;
  65115. private _tmpUnityRotation;
  65116. private _updatePhysicsBodyTransformation;
  65117. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65118. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65119. isSupported(): boolean;
  65120. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65121. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65122. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65123. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65124. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65125. getBodyMass(impostor: PhysicsImpostor): number;
  65126. getBodyFriction(impostor: PhysicsImpostor): number;
  65127. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65128. getBodyRestitution(impostor: PhysicsImpostor): number;
  65129. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65130. sleepBody(impostor: PhysicsImpostor): void;
  65131. wakeUpBody(impostor: PhysicsImpostor): void;
  65132. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65133. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65134. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65135. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65136. getRadius(impostor: PhysicsImpostor): number;
  65137. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65138. dispose(): void;
  65139. private _extendNamespace;
  65140. /**
  65141. * Does a raycast in the physics world
  65142. * @param from when should the ray start?
  65143. * @param to when should the ray end?
  65144. * @returns PhysicsRaycastResult
  65145. */
  65146. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65147. }
  65148. }
  65149. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  65150. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65151. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65152. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65153. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65154. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  65155. import { Nullable } from "babylonjs/types";
  65156. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65157. /** @hidden */
  65158. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65159. private _useDeltaForWorldStep;
  65160. world: any;
  65161. name: string;
  65162. BJSOIMO: any;
  65163. private _raycastResult;
  65164. private _fixedTimeStep;
  65165. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65166. setGravity(gravity: Vector3): void;
  65167. setTimeStep(timeStep: number): void;
  65168. getTimeStep(): number;
  65169. private _tmpImpostorsArray;
  65170. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65171. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65172. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65173. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65174. private _tmpPositionVector;
  65175. removePhysicsBody(impostor: PhysicsImpostor): void;
  65176. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65177. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65178. isSupported(): boolean;
  65179. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65180. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65181. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65182. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65183. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65184. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65185. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65186. getBodyMass(impostor: PhysicsImpostor): number;
  65187. getBodyFriction(impostor: PhysicsImpostor): number;
  65188. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65189. getBodyRestitution(impostor: PhysicsImpostor): number;
  65190. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65191. sleepBody(impostor: PhysicsImpostor): void;
  65192. wakeUpBody(impostor: PhysicsImpostor): void;
  65193. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65194. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65195. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65196. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65197. getRadius(impostor: PhysicsImpostor): number;
  65198. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65199. dispose(): void;
  65200. /**
  65201. * Does a raycast in the physics world
  65202. * @param from when should the ray start?
  65203. * @param to when should the ray end?
  65204. * @returns PhysicsRaycastResult
  65205. */
  65206. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65207. }
  65208. }
  65209. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  65210. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  65211. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65212. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65213. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65214. import { Nullable } from "babylonjs/types";
  65215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65216. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65217. /**
  65218. * AmmoJS Physics plugin
  65219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65220. * @see https://github.com/kripken/ammo.js/
  65221. */
  65222. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65223. private _useDeltaForWorldStep;
  65224. /**
  65225. * Reference to the Ammo library
  65226. */
  65227. bjsAMMO: any;
  65228. /**
  65229. * Created ammoJS world which physics bodies are added to
  65230. */
  65231. world: any;
  65232. /**
  65233. * Name of the plugin
  65234. */
  65235. name: string;
  65236. private _timeStep;
  65237. private _fixedTimeStep;
  65238. private _maxSteps;
  65239. private _tmpQuaternion;
  65240. private _tmpAmmoTransform;
  65241. private _tmpAmmoQuaternion;
  65242. private _tmpAmmoConcreteContactResultCallback;
  65243. private _collisionConfiguration;
  65244. private _dispatcher;
  65245. private _overlappingPairCache;
  65246. private _solver;
  65247. private _softBodySolver;
  65248. private _tmpAmmoVectorA;
  65249. private _tmpAmmoVectorB;
  65250. private _tmpAmmoVectorC;
  65251. private _tmpAmmoVectorD;
  65252. private _tmpContactCallbackResult;
  65253. private _tmpAmmoVectorRCA;
  65254. private _tmpAmmoVectorRCB;
  65255. private _raycastResult;
  65256. private _tmpContactPoint;
  65257. private static readonly DISABLE_COLLISION_FLAG;
  65258. private static readonly KINEMATIC_FLAG;
  65259. private static readonly DISABLE_DEACTIVATION_FLAG;
  65260. /**
  65261. * Initializes the ammoJS plugin
  65262. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65263. * @param ammoInjection can be used to inject your own ammo reference
  65264. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65265. */
  65266. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65267. /**
  65268. * Sets the gravity of the physics world (m/(s^2))
  65269. * @param gravity Gravity to set
  65270. */
  65271. setGravity(gravity: Vector3): void;
  65272. /**
  65273. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65274. * @param timeStep timestep to use in seconds
  65275. */
  65276. setTimeStep(timeStep: number): void;
  65277. /**
  65278. * 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)
  65279. * @param fixedTimeStep fixedTimeStep to use in seconds
  65280. */
  65281. setFixedTimeStep(fixedTimeStep: number): void;
  65282. /**
  65283. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65284. * @param maxSteps the maximum number of steps by the physics engine per frame
  65285. */
  65286. setMaxSteps(maxSteps: number): void;
  65287. /**
  65288. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65289. * @returns the current timestep in seconds
  65290. */
  65291. getTimeStep(): number;
  65292. /**
  65293. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65294. */
  65295. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65296. private _isImpostorInContact;
  65297. private _isImpostorPairInContact;
  65298. private _stepSimulation;
  65299. /**
  65300. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65301. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65302. * After the step the babylon meshes are set to the position of the physics imposters
  65303. * @param delta amount of time to step forward
  65304. * @param impostors array of imposters to update before/after the step
  65305. */
  65306. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65307. /**
  65308. * Update babylon mesh to match physics world object
  65309. * @param impostor imposter to match
  65310. */
  65311. private _afterSoftStep;
  65312. /**
  65313. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65314. * @param impostor imposter to match
  65315. */
  65316. private _ropeStep;
  65317. /**
  65318. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65319. * @param impostor imposter to match
  65320. */
  65321. private _softbodyOrClothStep;
  65322. private _tmpMatrix;
  65323. /**
  65324. * Applies an impulse on the imposter
  65325. * @param impostor imposter to apply impulse to
  65326. * @param force amount of force to be applied to the imposter
  65327. * @param contactPoint the location to apply the impulse on the imposter
  65328. */
  65329. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65330. /**
  65331. * Applies a force on the imposter
  65332. * @param impostor imposter to apply force
  65333. * @param force amount of force to be applied to the imposter
  65334. * @param contactPoint the location to apply the force on the imposter
  65335. */
  65336. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65337. /**
  65338. * Creates a physics body using the plugin
  65339. * @param impostor the imposter to create the physics body on
  65340. */
  65341. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65342. /**
  65343. * Removes the physics body from the imposter and disposes of the body's memory
  65344. * @param impostor imposter to remove the physics body from
  65345. */
  65346. removePhysicsBody(impostor: PhysicsImpostor): void;
  65347. /**
  65348. * Generates a joint
  65349. * @param impostorJoint the imposter joint to create the joint with
  65350. */
  65351. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65352. /**
  65353. * Removes a joint
  65354. * @param impostorJoint the imposter joint to remove the joint from
  65355. */
  65356. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65357. private _addMeshVerts;
  65358. /**
  65359. * Initialise the soft body vertices to match its object's (mesh) vertices
  65360. * Softbody vertices (nodes) are in world space and to match this
  65361. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65362. * @param impostor to create the softbody for
  65363. */
  65364. private _softVertexData;
  65365. /**
  65366. * Create an impostor's soft body
  65367. * @param impostor to create the softbody for
  65368. */
  65369. private _createSoftbody;
  65370. /**
  65371. * Create cloth for an impostor
  65372. * @param impostor to create the softbody for
  65373. */
  65374. private _createCloth;
  65375. /**
  65376. * Create rope for an impostor
  65377. * @param impostor to create the softbody for
  65378. */
  65379. private _createRope;
  65380. /**
  65381. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65382. * @param impostor to create the custom physics shape for
  65383. */
  65384. private _createCustom;
  65385. private _addHullVerts;
  65386. private _createShape;
  65387. /**
  65388. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65389. * @param impostor imposter containing the physics body and babylon object
  65390. */
  65391. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65392. /**
  65393. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65394. * @param impostor imposter containing the physics body and babylon object
  65395. * @param newPosition new position
  65396. * @param newRotation new rotation
  65397. */
  65398. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65399. /**
  65400. * If this plugin is supported
  65401. * @returns true if its supported
  65402. */
  65403. isSupported(): boolean;
  65404. /**
  65405. * Sets the linear velocity of the physics body
  65406. * @param impostor imposter to set the velocity on
  65407. * @param velocity velocity to set
  65408. */
  65409. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65410. /**
  65411. * Sets the angular velocity of the physics body
  65412. * @param impostor imposter to set the velocity on
  65413. * @param velocity velocity to set
  65414. */
  65415. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65416. /**
  65417. * gets the linear velocity
  65418. * @param impostor imposter to get linear velocity from
  65419. * @returns linear velocity
  65420. */
  65421. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65422. /**
  65423. * gets the angular velocity
  65424. * @param impostor imposter to get angular velocity from
  65425. * @returns angular velocity
  65426. */
  65427. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65428. /**
  65429. * Sets the mass of physics body
  65430. * @param impostor imposter to set the mass on
  65431. * @param mass mass to set
  65432. */
  65433. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65434. /**
  65435. * Gets the mass of the physics body
  65436. * @param impostor imposter to get the mass from
  65437. * @returns mass
  65438. */
  65439. getBodyMass(impostor: PhysicsImpostor): number;
  65440. /**
  65441. * Gets friction of the impostor
  65442. * @param impostor impostor to get friction from
  65443. * @returns friction value
  65444. */
  65445. getBodyFriction(impostor: PhysicsImpostor): number;
  65446. /**
  65447. * Sets friction of the impostor
  65448. * @param impostor impostor to set friction on
  65449. * @param friction friction value
  65450. */
  65451. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65452. /**
  65453. * Gets restitution of the impostor
  65454. * @param impostor impostor to get restitution from
  65455. * @returns restitution value
  65456. */
  65457. getBodyRestitution(impostor: PhysicsImpostor): number;
  65458. /**
  65459. * Sets resitution of the impostor
  65460. * @param impostor impostor to set resitution on
  65461. * @param restitution resitution value
  65462. */
  65463. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65464. /**
  65465. * Gets pressure inside the impostor
  65466. * @param impostor impostor to get pressure from
  65467. * @returns pressure value
  65468. */
  65469. getBodyPressure(impostor: PhysicsImpostor): number;
  65470. /**
  65471. * Sets pressure inside a soft body impostor
  65472. * Cloth and rope must remain 0 pressure
  65473. * @param impostor impostor to set pressure on
  65474. * @param pressure pressure value
  65475. */
  65476. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65477. /**
  65478. * Gets stiffness of the impostor
  65479. * @param impostor impostor to get stiffness from
  65480. * @returns pressure value
  65481. */
  65482. getBodyStiffness(impostor: PhysicsImpostor): number;
  65483. /**
  65484. * Sets stiffness of the impostor
  65485. * @param impostor impostor to set stiffness on
  65486. * @param stiffness stiffness value from 0 to 1
  65487. */
  65488. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65489. /**
  65490. * Gets velocityIterations of the impostor
  65491. * @param impostor impostor to get velocity iterations from
  65492. * @returns velocityIterations value
  65493. */
  65494. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65495. /**
  65496. * Sets velocityIterations of the impostor
  65497. * @param impostor impostor to set velocity iterations on
  65498. * @param velocityIterations velocityIterations value
  65499. */
  65500. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65501. /**
  65502. * Gets positionIterations of the impostor
  65503. * @param impostor impostor to get position iterations from
  65504. * @returns positionIterations value
  65505. */
  65506. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65507. /**
  65508. * Sets positionIterations of the impostor
  65509. * @param impostor impostor to set position on
  65510. * @param positionIterations positionIterations value
  65511. */
  65512. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65513. /**
  65514. * Append an anchor to a cloth object
  65515. * @param impostor is the cloth impostor to add anchor to
  65516. * @param otherImpostor is the rigid impostor to anchor to
  65517. * @param width ratio across width from 0 to 1
  65518. * @param height ratio up height from 0 to 1
  65519. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65520. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65521. */
  65522. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65523. /**
  65524. * Append an hook to a rope object
  65525. * @param impostor is the rope impostor to add hook to
  65526. * @param otherImpostor is the rigid impostor to hook to
  65527. * @param length ratio along the rope from 0 to 1
  65528. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65529. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65530. */
  65531. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65532. /**
  65533. * Sleeps the physics body and stops it from being active
  65534. * @param impostor impostor to sleep
  65535. */
  65536. sleepBody(impostor: PhysicsImpostor): void;
  65537. /**
  65538. * Activates the physics body
  65539. * @param impostor impostor to activate
  65540. */
  65541. wakeUpBody(impostor: PhysicsImpostor): void;
  65542. /**
  65543. * Updates the distance parameters of the joint
  65544. * @param joint joint to update
  65545. * @param maxDistance maximum distance of the joint
  65546. * @param minDistance minimum distance of the joint
  65547. */
  65548. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65549. /**
  65550. * Sets a motor on the joint
  65551. * @param joint joint to set motor on
  65552. * @param speed speed of the motor
  65553. * @param maxForce maximum force of the motor
  65554. * @param motorIndex index of the motor
  65555. */
  65556. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65557. /**
  65558. * Sets the motors limit
  65559. * @param joint joint to set limit on
  65560. * @param upperLimit upper limit
  65561. * @param lowerLimit lower limit
  65562. */
  65563. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65564. /**
  65565. * Syncs the position and rotation of a mesh with the impostor
  65566. * @param mesh mesh to sync
  65567. * @param impostor impostor to update the mesh with
  65568. */
  65569. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65570. /**
  65571. * Gets the radius of the impostor
  65572. * @param impostor impostor to get radius from
  65573. * @returns the radius
  65574. */
  65575. getRadius(impostor: PhysicsImpostor): number;
  65576. /**
  65577. * Gets the box size of the impostor
  65578. * @param impostor impostor to get box size from
  65579. * @param result the resulting box size
  65580. */
  65581. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65582. /**
  65583. * Disposes of the impostor
  65584. */
  65585. dispose(): void;
  65586. /**
  65587. * Does a raycast in the physics world
  65588. * @param from when should the ray start?
  65589. * @param to when should the ray end?
  65590. * @returns PhysicsRaycastResult
  65591. */
  65592. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65593. }
  65594. }
  65595. declare module "babylonjs/Probes/reflectionProbe" {
  65596. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65597. import { Vector3 } from "babylonjs/Maths/math.vector";
  65598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65599. import { Nullable } from "babylonjs/types";
  65600. import { Scene } from "babylonjs/scene";
  65601. module "babylonjs/abstractScene" {
  65602. interface AbstractScene {
  65603. /**
  65604. * The list of reflection probes added to the scene
  65605. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65606. */
  65607. reflectionProbes: Array<ReflectionProbe>;
  65608. /**
  65609. * Removes the given reflection probe from this scene.
  65610. * @param toRemove The reflection probe to remove
  65611. * @returns The index of the removed reflection probe
  65612. */
  65613. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65614. /**
  65615. * Adds the given reflection probe to this scene.
  65616. * @param newReflectionProbe The reflection probe to add
  65617. */
  65618. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65619. }
  65620. }
  65621. /**
  65622. * Class used to generate realtime reflection / refraction cube textures
  65623. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65624. */
  65625. export class ReflectionProbe {
  65626. /** defines the name of the probe */
  65627. name: string;
  65628. private _scene;
  65629. private _renderTargetTexture;
  65630. private _projectionMatrix;
  65631. private _viewMatrix;
  65632. private _target;
  65633. private _add;
  65634. private _attachedMesh;
  65635. private _invertYAxis;
  65636. /** Gets or sets probe position (center of the cube map) */
  65637. position: Vector3;
  65638. /**
  65639. * Creates a new reflection probe
  65640. * @param name defines the name of the probe
  65641. * @param size defines the texture resolution (for each face)
  65642. * @param scene defines the hosting scene
  65643. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65644. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65645. */
  65646. constructor(
  65647. /** defines the name of the probe */
  65648. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65649. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65650. get samples(): number;
  65651. set samples(value: number);
  65652. /** Gets or sets the refresh rate to use (on every frame by default) */
  65653. get refreshRate(): number;
  65654. set refreshRate(value: number);
  65655. /**
  65656. * Gets the hosting scene
  65657. * @returns a Scene
  65658. */
  65659. getScene(): Scene;
  65660. /** Gets the internal CubeTexture used to render to */
  65661. get cubeTexture(): RenderTargetTexture;
  65662. /** Gets the list of meshes to render */
  65663. get renderList(): Nullable<AbstractMesh[]>;
  65664. /**
  65665. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65666. * @param mesh defines the mesh to attach to
  65667. */
  65668. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65669. /**
  65670. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65671. * @param renderingGroupId The rendering group id corresponding to its index
  65672. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65673. */
  65674. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65675. /**
  65676. * Clean all associated resources
  65677. */
  65678. dispose(): void;
  65679. /**
  65680. * Converts the reflection probe information to a readable string for debug purpose.
  65681. * @param fullDetails Supports for multiple levels of logging within scene loading
  65682. * @returns the human readable reflection probe info
  65683. */
  65684. toString(fullDetails?: boolean): string;
  65685. /**
  65686. * Get the class name of the relfection probe.
  65687. * @returns "ReflectionProbe"
  65688. */
  65689. getClassName(): string;
  65690. /**
  65691. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65692. * @returns The JSON representation of the texture
  65693. */
  65694. serialize(): any;
  65695. /**
  65696. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65697. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65698. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65699. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65700. * @returns The parsed reflection probe if successful
  65701. */
  65702. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65703. }
  65704. }
  65705. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  65706. /** @hidden */
  65707. export var _BabylonLoaderRegistered: boolean;
  65708. /**
  65709. * Helps setting up some configuration for the babylon file loader.
  65710. */
  65711. export class BabylonFileLoaderConfiguration {
  65712. /**
  65713. * The loader does not allow injecting custom physix engine into the plugins.
  65714. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65715. * So you could set this variable to your engine import to make it work.
  65716. */
  65717. static LoaderInjectedPhysicsEngine: any;
  65718. }
  65719. }
  65720. declare module "babylonjs/Loading/Plugins/index" {
  65721. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  65722. }
  65723. declare module "babylonjs/Loading/index" {
  65724. export * from "babylonjs/Loading/loadingScreen";
  65725. export * from "babylonjs/Loading/Plugins/index";
  65726. export * from "babylonjs/Loading/sceneLoader";
  65727. export * from "babylonjs/Loading/sceneLoaderFlags";
  65728. }
  65729. declare module "babylonjs/Materials/Background/index" {
  65730. export * from "babylonjs/Materials/Background/backgroundMaterial";
  65731. }
  65732. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  65733. import { Scene } from "babylonjs/scene";
  65734. import { Color3 } from "babylonjs/Maths/math.color";
  65735. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65736. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65737. /**
  65738. * The Physically based simple base material of BJS.
  65739. *
  65740. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65741. * It is used as the base class for both the specGloss and metalRough conventions.
  65742. */
  65743. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65744. /**
  65745. * Number of Simultaneous lights allowed on the material.
  65746. */
  65747. maxSimultaneousLights: number;
  65748. /**
  65749. * If sets to true, disables all the lights affecting the material.
  65750. */
  65751. disableLighting: boolean;
  65752. /**
  65753. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65754. */
  65755. environmentTexture: BaseTexture;
  65756. /**
  65757. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65758. */
  65759. invertNormalMapX: boolean;
  65760. /**
  65761. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65762. */
  65763. invertNormalMapY: boolean;
  65764. /**
  65765. * Normal map used in the model.
  65766. */
  65767. normalTexture: BaseTexture;
  65768. /**
  65769. * Emissivie color used to self-illuminate the model.
  65770. */
  65771. emissiveColor: Color3;
  65772. /**
  65773. * Emissivie texture used to self-illuminate the model.
  65774. */
  65775. emissiveTexture: BaseTexture;
  65776. /**
  65777. * Occlusion Channel Strenght.
  65778. */
  65779. occlusionStrength: number;
  65780. /**
  65781. * Occlusion Texture of the material (adding extra occlusion effects).
  65782. */
  65783. occlusionTexture: BaseTexture;
  65784. /**
  65785. * Defines the alpha limits in alpha test mode.
  65786. */
  65787. alphaCutOff: number;
  65788. /**
  65789. * Gets the current double sided mode.
  65790. */
  65791. get doubleSided(): boolean;
  65792. /**
  65793. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65794. */
  65795. set doubleSided(value: boolean);
  65796. /**
  65797. * Stores the pre-calculated light information of a mesh in a texture.
  65798. */
  65799. lightmapTexture: BaseTexture;
  65800. /**
  65801. * If true, the light map contains occlusion information instead of lighting info.
  65802. */
  65803. useLightmapAsShadowmap: boolean;
  65804. /**
  65805. * Instantiates a new PBRMaterial instance.
  65806. *
  65807. * @param name The material name
  65808. * @param scene The scene the material will be use in.
  65809. */
  65810. constructor(name: string, scene: Scene);
  65811. getClassName(): string;
  65812. }
  65813. }
  65814. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  65815. import { Scene } from "babylonjs/scene";
  65816. import { Color3 } from "babylonjs/Maths/math.color";
  65817. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65818. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65819. /**
  65820. * The PBR material of BJS following the metal roughness convention.
  65821. *
  65822. * This fits to the PBR convention in the GLTF definition:
  65823. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65824. */
  65825. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65826. /**
  65827. * The base color has two different interpretations depending on the value of metalness.
  65828. * When the material is a metal, the base color is the specific measured reflectance value
  65829. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65830. * of the material.
  65831. */
  65832. baseColor: Color3;
  65833. /**
  65834. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65835. * well as opacity information in the alpha channel.
  65836. */
  65837. baseTexture: BaseTexture;
  65838. /**
  65839. * Specifies the metallic scalar value of the material.
  65840. * Can also be used to scale the metalness values of the metallic texture.
  65841. */
  65842. metallic: number;
  65843. /**
  65844. * Specifies the roughness scalar value of the material.
  65845. * Can also be used to scale the roughness values of the metallic texture.
  65846. */
  65847. roughness: number;
  65848. /**
  65849. * Texture containing both the metallic value in the B channel and the
  65850. * roughness value in the G channel to keep better precision.
  65851. */
  65852. metallicRoughnessTexture: BaseTexture;
  65853. /**
  65854. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65855. *
  65856. * @param name The material name
  65857. * @param scene The scene the material will be use in.
  65858. */
  65859. constructor(name: string, scene: Scene);
  65860. /**
  65861. * Return the currrent class name of the material.
  65862. */
  65863. getClassName(): string;
  65864. /**
  65865. * Makes a duplicate of the current material.
  65866. * @param name - name to use for the new material.
  65867. */
  65868. clone(name: string): PBRMetallicRoughnessMaterial;
  65869. /**
  65870. * Serialize the material to a parsable JSON object.
  65871. */
  65872. serialize(): any;
  65873. /**
  65874. * Parses a JSON object correponding to the serialize function.
  65875. */
  65876. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65877. }
  65878. }
  65879. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  65880. import { Scene } from "babylonjs/scene";
  65881. import { Color3 } from "babylonjs/Maths/math.color";
  65882. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65883. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65884. /**
  65885. * The PBR material of BJS following the specular glossiness convention.
  65886. *
  65887. * This fits to the PBR convention in the GLTF definition:
  65888. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65889. */
  65890. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65891. /**
  65892. * Specifies the diffuse color of the material.
  65893. */
  65894. diffuseColor: Color3;
  65895. /**
  65896. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65897. * channel.
  65898. */
  65899. diffuseTexture: BaseTexture;
  65900. /**
  65901. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65902. */
  65903. specularColor: Color3;
  65904. /**
  65905. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65906. */
  65907. glossiness: number;
  65908. /**
  65909. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65910. */
  65911. specularGlossinessTexture: BaseTexture;
  65912. /**
  65913. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65914. *
  65915. * @param name The material name
  65916. * @param scene The scene the material will be use in.
  65917. */
  65918. constructor(name: string, scene: Scene);
  65919. /**
  65920. * Return the currrent class name of the material.
  65921. */
  65922. getClassName(): string;
  65923. /**
  65924. * Makes a duplicate of the current material.
  65925. * @param name - name to use for the new material.
  65926. */
  65927. clone(name: string): PBRSpecularGlossinessMaterial;
  65928. /**
  65929. * Serialize the material to a parsable JSON object.
  65930. */
  65931. serialize(): any;
  65932. /**
  65933. * Parses a JSON object correponding to the serialize function.
  65934. */
  65935. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65936. }
  65937. }
  65938. declare module "babylonjs/Materials/PBR/index" {
  65939. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65940. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65941. export * from "babylonjs/Materials/PBR/pbrMaterial";
  65942. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  65943. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  65944. }
  65945. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  65946. import { Nullable } from "babylonjs/types";
  65947. import { Scene } from "babylonjs/scene";
  65948. import { Matrix } from "babylonjs/Maths/math.vector";
  65949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65950. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65951. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65952. /**
  65953. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65954. * It can help converting any input color in a desired output one. This can then be used to create effects
  65955. * from sepia, black and white to sixties or futuristic rendering...
  65956. *
  65957. * The only supported format is currently 3dl.
  65958. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65959. */
  65960. export class ColorGradingTexture extends BaseTexture {
  65961. /**
  65962. * The texture URL.
  65963. */
  65964. url: string;
  65965. /**
  65966. * Empty line regex stored for GC.
  65967. */
  65968. private static _noneEmptyLineRegex;
  65969. private _textureMatrix;
  65970. private _onLoad;
  65971. /**
  65972. * Instantiates a ColorGradingTexture from the following parameters.
  65973. *
  65974. * @param url The location of the color gradind data (currently only supporting 3dl)
  65975. * @param sceneOrEngine The scene or engine the texture will be used in
  65976. * @param onLoad defines a callback triggered when the texture has been loaded
  65977. */
  65978. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65979. /**
  65980. * Fires the onload event from the constructor if requested.
  65981. */
  65982. private _triggerOnLoad;
  65983. /**
  65984. * Returns the texture matrix used in most of the material.
  65985. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65986. */
  65987. getTextureMatrix(): Matrix;
  65988. /**
  65989. * Occurs when the file being loaded is a .3dl LUT file.
  65990. */
  65991. private load3dlTexture;
  65992. /**
  65993. * Starts the loading process of the texture.
  65994. */
  65995. private loadTexture;
  65996. /**
  65997. * Clones the color gradind texture.
  65998. */
  65999. clone(): ColorGradingTexture;
  66000. /**
  66001. * Called during delayed load for textures.
  66002. */
  66003. delayLoad(): void;
  66004. /**
  66005. * Parses a color grading texture serialized by Babylon.
  66006. * @param parsedTexture The texture information being parsedTexture
  66007. * @param scene The scene to load the texture in
  66008. * @param rootUrl The root url of the data assets to load
  66009. * @return A color gradind texture
  66010. */
  66011. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  66012. /**
  66013. * Serializes the LUT texture to json format.
  66014. */
  66015. serialize(): any;
  66016. }
  66017. }
  66018. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  66019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66020. import { Scene } from "babylonjs/scene";
  66021. import { Nullable } from "babylonjs/types";
  66022. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66023. /**
  66024. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66025. */
  66026. export class EquiRectangularCubeTexture extends BaseTexture {
  66027. /** The six faces of the cube. */
  66028. private static _FacesMapping;
  66029. private _noMipmap;
  66030. private _onLoad;
  66031. private _onError;
  66032. /** The size of the cubemap. */
  66033. private _size;
  66034. /** The buffer of the image. */
  66035. private _buffer;
  66036. /** The width of the input image. */
  66037. private _width;
  66038. /** The height of the input image. */
  66039. private _height;
  66040. /** The URL to the image. */
  66041. url: string;
  66042. /**
  66043. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66044. * @param url The location of the image
  66045. * @param scene The scene the texture will be used in
  66046. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66047. * @param noMipmap Forces to not generate the mipmap if true
  66048. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66049. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66050. * @param onLoad — defines a callback called when texture is loaded
  66051. * @param onError — defines a callback called if there is an error
  66052. */
  66053. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66054. /**
  66055. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66056. */
  66057. private loadImage;
  66058. /**
  66059. * Convert the image buffer into a cubemap and create a CubeTexture.
  66060. */
  66061. private loadTexture;
  66062. /**
  66063. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66064. * @param buffer The ArrayBuffer that should be converted.
  66065. * @returns The buffer as Float32Array.
  66066. */
  66067. private getFloat32ArrayFromArrayBuffer;
  66068. /**
  66069. * Get the current class name of the texture useful for serialization or dynamic coding.
  66070. * @returns "EquiRectangularCubeTexture"
  66071. */
  66072. getClassName(): string;
  66073. /**
  66074. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66075. * @returns A clone of the current EquiRectangularCubeTexture.
  66076. */
  66077. clone(): EquiRectangularCubeTexture;
  66078. }
  66079. }
  66080. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  66081. import { Nullable } from "babylonjs/types";
  66082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66083. import { Matrix } from "babylonjs/Maths/math.vector";
  66084. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  66085. import "babylonjs/Engines/Extensions/engine.videoTexture";
  66086. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  66087. import { Scene } from "babylonjs/scene";
  66088. /**
  66089. * Defines the options related to the creation of an HtmlElementTexture
  66090. */
  66091. export interface IHtmlElementTextureOptions {
  66092. /**
  66093. * Defines wether mip maps should be created or not.
  66094. */
  66095. generateMipMaps?: boolean;
  66096. /**
  66097. * Defines the sampling mode of the texture.
  66098. */
  66099. samplingMode?: number;
  66100. /**
  66101. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66102. */
  66103. engine: Nullable<ThinEngine>;
  66104. /**
  66105. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66106. */
  66107. scene: Nullable<Scene>;
  66108. }
  66109. /**
  66110. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66111. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66112. * is automatically managed.
  66113. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66114. * in your application.
  66115. *
  66116. * As the update is not automatic, you need to call them manually.
  66117. */
  66118. export class HtmlElementTexture extends BaseTexture {
  66119. /**
  66120. * The texture URL.
  66121. */
  66122. element: HTMLVideoElement | HTMLCanvasElement;
  66123. private static readonly DefaultOptions;
  66124. private _textureMatrix;
  66125. private _isVideo;
  66126. private _generateMipMaps;
  66127. private _samplingMode;
  66128. /**
  66129. * Instantiates a HtmlElementTexture from the following parameters.
  66130. *
  66131. * @param name Defines the name of the texture
  66132. * @param element Defines the video or canvas the texture is filled with
  66133. * @param options Defines the other none mandatory texture creation options
  66134. */
  66135. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66136. private _createInternalTexture;
  66137. /**
  66138. * Returns the texture matrix used in most of the material.
  66139. */
  66140. getTextureMatrix(): Matrix;
  66141. /**
  66142. * Updates the content of the texture.
  66143. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  66144. */
  66145. update(invertY?: Nullable<boolean>): void;
  66146. }
  66147. }
  66148. declare module "babylonjs/Misc/tga" {
  66149. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66150. /**
  66151. * Based on jsTGALoader - Javascript loader for TGA file
  66152. * By Vincent Thibault
  66153. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66154. */
  66155. export class TGATools {
  66156. private static _TYPE_INDEXED;
  66157. private static _TYPE_RGB;
  66158. private static _TYPE_GREY;
  66159. private static _TYPE_RLE_INDEXED;
  66160. private static _TYPE_RLE_RGB;
  66161. private static _TYPE_RLE_GREY;
  66162. private static _ORIGIN_MASK;
  66163. private static _ORIGIN_SHIFT;
  66164. private static _ORIGIN_BL;
  66165. private static _ORIGIN_BR;
  66166. private static _ORIGIN_UL;
  66167. private static _ORIGIN_UR;
  66168. /**
  66169. * Gets the header of a TGA file
  66170. * @param data defines the TGA data
  66171. * @returns the header
  66172. */
  66173. static GetTGAHeader(data: Uint8Array): any;
  66174. /**
  66175. * Uploads TGA content to a Babylon Texture
  66176. * @hidden
  66177. */
  66178. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66179. /** @hidden */
  66180. 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;
  66181. /** @hidden */
  66182. 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;
  66183. /** @hidden */
  66184. 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;
  66185. /** @hidden */
  66186. 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;
  66187. /** @hidden */
  66188. 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;
  66189. /** @hidden */
  66190. 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;
  66191. }
  66192. }
  66193. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  66194. import { Nullable } from "babylonjs/types";
  66195. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66196. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  66197. /**
  66198. * Implementation of the TGA Texture Loader.
  66199. * @hidden
  66200. */
  66201. export class _TGATextureLoader implements IInternalTextureLoader {
  66202. /**
  66203. * Defines wether the loader supports cascade loading the different faces.
  66204. */
  66205. readonly supportCascades: boolean;
  66206. /**
  66207. * This returns if the loader support the current file information.
  66208. * @param extension defines the file extension of the file being loaded
  66209. * @returns true if the loader can load the specified file
  66210. */
  66211. canLoad(extension: string): boolean;
  66212. /**
  66213. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66214. * @param data contains the texture data
  66215. * @param texture defines the BabylonJS internal texture
  66216. * @param createPolynomials will be true if polynomials have been requested
  66217. * @param onLoad defines the callback to trigger once the texture is ready
  66218. * @param onError defines the callback to trigger in case of error
  66219. */
  66220. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66221. /**
  66222. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66223. * @param data contains the texture data
  66224. * @param texture defines the BabylonJS internal texture
  66225. * @param callback defines the method to call once ready to upload
  66226. */
  66227. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66228. }
  66229. }
  66230. declare module "babylonjs/Misc/basis" {
  66231. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66232. /**
  66233. * Info about the .basis files
  66234. */
  66235. class BasisFileInfo {
  66236. /**
  66237. * If the file has alpha
  66238. */
  66239. hasAlpha: boolean;
  66240. /**
  66241. * Info about each image of the basis file
  66242. */
  66243. images: Array<{
  66244. levels: Array<{
  66245. width: number;
  66246. height: number;
  66247. transcodedPixels: ArrayBufferView;
  66248. }>;
  66249. }>;
  66250. }
  66251. /**
  66252. * Result of transcoding a basis file
  66253. */
  66254. class TranscodeResult {
  66255. /**
  66256. * Info about the .basis file
  66257. */
  66258. fileInfo: BasisFileInfo;
  66259. /**
  66260. * Format to use when loading the file
  66261. */
  66262. format: number;
  66263. }
  66264. /**
  66265. * Configuration options for the Basis transcoder
  66266. */
  66267. export class BasisTranscodeConfiguration {
  66268. /**
  66269. * Supported compression formats used to determine the supported output format of the transcoder
  66270. */
  66271. supportedCompressionFormats?: {
  66272. /**
  66273. * etc1 compression format
  66274. */
  66275. etc1?: boolean;
  66276. /**
  66277. * s3tc compression format
  66278. */
  66279. s3tc?: boolean;
  66280. /**
  66281. * pvrtc compression format
  66282. */
  66283. pvrtc?: boolean;
  66284. /**
  66285. * etc2 compression format
  66286. */
  66287. etc2?: boolean;
  66288. };
  66289. /**
  66290. * If mipmap levels should be loaded for transcoded images (Default: true)
  66291. */
  66292. loadMipmapLevels?: boolean;
  66293. /**
  66294. * Index of a single image to load (Default: all images)
  66295. */
  66296. loadSingleImage?: number;
  66297. }
  66298. /**
  66299. * Used to load .Basis files
  66300. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66301. */
  66302. export class BasisTools {
  66303. private static _IgnoreSupportedFormats;
  66304. /**
  66305. * URL to use when loading the basis transcoder
  66306. */
  66307. static JSModuleURL: string;
  66308. /**
  66309. * URL to use when loading the wasm module for the transcoder
  66310. */
  66311. static WasmModuleURL: string;
  66312. /**
  66313. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66314. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66315. * @returns internal format corresponding to the Basis format
  66316. */
  66317. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66318. private static _WorkerPromise;
  66319. private static _Worker;
  66320. private static _actionId;
  66321. private static _CreateWorkerAsync;
  66322. /**
  66323. * Transcodes a loaded image file to compressed pixel data
  66324. * @param data image data to transcode
  66325. * @param config configuration options for the transcoding
  66326. * @returns a promise resulting in the transcoded image
  66327. */
  66328. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66329. /**
  66330. * Loads a texture from the transcode result
  66331. * @param texture texture load to
  66332. * @param transcodeResult the result of transcoding the basis file to load from
  66333. */
  66334. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66335. }
  66336. }
  66337. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  66338. import { Nullable } from "babylonjs/types";
  66339. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66340. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  66341. /**
  66342. * Loader for .basis file format
  66343. */
  66344. export class _BasisTextureLoader implements IInternalTextureLoader {
  66345. /**
  66346. * Defines whether the loader supports cascade loading the different faces.
  66347. */
  66348. readonly supportCascades: boolean;
  66349. /**
  66350. * This returns if the loader support the current file information.
  66351. * @param extension defines the file extension of the file being loaded
  66352. * @returns true if the loader can load the specified file
  66353. */
  66354. canLoad(extension: string): boolean;
  66355. /**
  66356. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66357. * @param data contains the texture data
  66358. * @param texture defines the BabylonJS internal texture
  66359. * @param createPolynomials will be true if polynomials have been requested
  66360. * @param onLoad defines the callback to trigger once the texture is ready
  66361. * @param onError defines the callback to trigger in case of error
  66362. */
  66363. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66364. /**
  66365. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66366. * @param data contains the texture data
  66367. * @param texture defines the BabylonJS internal texture
  66368. * @param callback defines the method to call once ready to upload
  66369. */
  66370. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66371. }
  66372. }
  66373. declare module "babylonjs/Materials/Textures/Loaders/index" {
  66374. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  66375. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  66376. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  66377. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  66378. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  66379. }
  66380. declare module "babylonjs/Materials/Textures/Packer/frame" {
  66381. import { Vector2 } from "babylonjs/Maths/math.vector";
  66382. /**
  66383. * Defines the basic options interface of a TexturePacker Frame
  66384. */
  66385. export interface ITexturePackerFrame {
  66386. /**
  66387. * The frame ID
  66388. */
  66389. id: number;
  66390. /**
  66391. * The frames Scale
  66392. */
  66393. scale: Vector2;
  66394. /**
  66395. * The Frames offset
  66396. */
  66397. offset: Vector2;
  66398. }
  66399. /**
  66400. * This is a support class for frame Data on texture packer sets.
  66401. */
  66402. export class TexturePackerFrame implements ITexturePackerFrame {
  66403. /**
  66404. * The frame ID
  66405. */
  66406. id: number;
  66407. /**
  66408. * The frames Scale
  66409. */
  66410. scale: Vector2;
  66411. /**
  66412. * The Frames offset
  66413. */
  66414. offset: Vector2;
  66415. /**
  66416. * Initializes a texture package frame.
  66417. * @param id The numerical frame identifier
  66418. * @param scale Scalar Vector2 for UV frame
  66419. * @param offset Vector2 for the frame position in UV units.
  66420. * @returns TexturePackerFrame
  66421. */
  66422. constructor(id: number, scale: Vector2, offset: Vector2);
  66423. }
  66424. }
  66425. declare module "babylonjs/Materials/Textures/Packer/packer" {
  66426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66427. import { Scene } from "babylonjs/scene";
  66428. import { Nullable } from "babylonjs/types";
  66429. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  66430. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  66431. /**
  66432. * Defines the basic options interface of a TexturePacker
  66433. */
  66434. export interface ITexturePackerOptions {
  66435. /**
  66436. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66437. */
  66438. map?: string[];
  66439. /**
  66440. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66441. */
  66442. uvsIn?: string;
  66443. /**
  66444. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66445. */
  66446. uvsOut?: string;
  66447. /**
  66448. * number representing the layout style. Defaults to LAYOUT_STRIP
  66449. */
  66450. layout?: number;
  66451. /**
  66452. * number of columns if using custom column count layout(2). This defaults to 4.
  66453. */
  66454. colnum?: number;
  66455. /**
  66456. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66457. */
  66458. updateInputMeshes?: boolean;
  66459. /**
  66460. * boolean flag to dispose all the source textures. Defaults to true.
  66461. */
  66462. disposeSources?: boolean;
  66463. /**
  66464. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66465. */
  66466. fillBlanks?: boolean;
  66467. /**
  66468. * string value representing the context fill style color. Defaults to 'black'.
  66469. */
  66470. customFillColor?: string;
  66471. /**
  66472. * Width and Height Value of each Frame in the TexturePacker Sets
  66473. */
  66474. frameSize?: number;
  66475. /**
  66476. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66477. */
  66478. paddingRatio?: number;
  66479. /**
  66480. * Number that declares the fill method for the padding gutter.
  66481. */
  66482. paddingMode?: number;
  66483. /**
  66484. * If in SUBUV_COLOR padding mode what color to use.
  66485. */
  66486. paddingColor?: Color3 | Color4;
  66487. }
  66488. /**
  66489. * Defines the basic interface of a TexturePacker JSON File
  66490. */
  66491. export interface ITexturePackerJSON {
  66492. /**
  66493. * The frame ID
  66494. */
  66495. name: string;
  66496. /**
  66497. * The base64 channel data
  66498. */
  66499. sets: any;
  66500. /**
  66501. * The options of the Packer
  66502. */
  66503. options: ITexturePackerOptions;
  66504. /**
  66505. * The frame data of the Packer
  66506. */
  66507. frames: Array<number>;
  66508. }
  66509. /**
  66510. * This is a support class that generates a series of packed texture sets.
  66511. * @see https://doc.babylonjs.com/babylon101/materials
  66512. */
  66513. export class TexturePacker {
  66514. /** Packer Layout Constant 0 */
  66515. static readonly LAYOUT_STRIP: number;
  66516. /** Packer Layout Constant 1 */
  66517. static readonly LAYOUT_POWER2: number;
  66518. /** Packer Layout Constant 2 */
  66519. static readonly LAYOUT_COLNUM: number;
  66520. /** Packer Layout Constant 0 */
  66521. static readonly SUBUV_WRAP: number;
  66522. /** Packer Layout Constant 1 */
  66523. static readonly SUBUV_EXTEND: number;
  66524. /** Packer Layout Constant 2 */
  66525. static readonly SUBUV_COLOR: number;
  66526. /** The Name of the Texture Package */
  66527. name: string;
  66528. /** The scene scope of the TexturePacker */
  66529. scene: Scene;
  66530. /** The Meshes to target */
  66531. meshes: AbstractMesh[];
  66532. /** Arguments passed with the Constructor */
  66533. options: ITexturePackerOptions;
  66534. /** The promise that is started upon initialization */
  66535. promise: Nullable<Promise<TexturePacker | string>>;
  66536. /** The Container object for the channel sets that are generated */
  66537. sets: object;
  66538. /** The Container array for the frames that are generated */
  66539. frames: TexturePackerFrame[];
  66540. /** The expected number of textures the system is parsing. */
  66541. private _expecting;
  66542. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66543. private _paddingValue;
  66544. /**
  66545. * Initializes a texture package series from an array of meshes or a single mesh.
  66546. * @param name The name of the package
  66547. * @param meshes The target meshes to compose the package from
  66548. * @param options The arguments that texture packer should follow while building.
  66549. * @param scene The scene which the textures are scoped to.
  66550. * @returns TexturePacker
  66551. */
  66552. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66553. /**
  66554. * Starts the package process
  66555. * @param resolve The promises resolution function
  66556. * @returns TexturePacker
  66557. */
  66558. private _createFrames;
  66559. /**
  66560. * Calculates the Size of the Channel Sets
  66561. * @returns Vector2
  66562. */
  66563. private _calculateSize;
  66564. /**
  66565. * Calculates the UV data for the frames.
  66566. * @param baseSize the base frameSize
  66567. * @param padding the base frame padding
  66568. * @param dtSize size of the Dynamic Texture for that channel
  66569. * @param dtUnits is 1/dtSize
  66570. * @param update flag to update the input meshes
  66571. */
  66572. private _calculateMeshUVFrames;
  66573. /**
  66574. * Calculates the frames Offset.
  66575. * @param index of the frame
  66576. * @returns Vector2
  66577. */
  66578. private _getFrameOffset;
  66579. /**
  66580. * Updates a Mesh to the frame data
  66581. * @param mesh that is the target
  66582. * @param frameID or the frame index
  66583. */
  66584. private _updateMeshUV;
  66585. /**
  66586. * Updates a Meshes materials to use the texture packer channels
  66587. * @param m is the mesh to target
  66588. * @param force all channels on the packer to be set.
  66589. */
  66590. private _updateTextureReferences;
  66591. /**
  66592. * Public method to set a Mesh to a frame
  66593. * @param m that is the target
  66594. * @param frameID or the frame index
  66595. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66596. */
  66597. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66598. /**
  66599. * Starts the async promise to compile the texture packer.
  66600. * @returns Promise<void>
  66601. */
  66602. processAsync(): Promise<void>;
  66603. /**
  66604. * Disposes all textures associated with this packer
  66605. */
  66606. dispose(): void;
  66607. /**
  66608. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66609. * @param imageType is the image type to use.
  66610. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66611. */
  66612. download(imageType?: string, quality?: number): void;
  66613. /**
  66614. * Public method to load a texturePacker JSON file.
  66615. * @param data of the JSON file in string format.
  66616. */
  66617. updateFromJSON(data: string): void;
  66618. }
  66619. }
  66620. declare module "babylonjs/Materials/Textures/Packer/index" {
  66621. export * from "babylonjs/Materials/Textures/Packer/packer";
  66622. export * from "babylonjs/Materials/Textures/Packer/frame";
  66623. }
  66624. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  66625. import { Scene } from "babylonjs/scene";
  66626. import { Texture } from "babylonjs/Materials/Textures/texture";
  66627. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66628. /**
  66629. * 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.
  66630. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66631. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66632. */
  66633. export class CustomProceduralTexture extends ProceduralTexture {
  66634. private _animate;
  66635. private _time;
  66636. private _config;
  66637. private _texturePath;
  66638. /**
  66639. * Instantiates a new Custom Procedural Texture.
  66640. * 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.
  66641. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66642. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66643. * @param name Define the name of the texture
  66644. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66645. * @param size Define the size of the texture to create
  66646. * @param scene Define the scene the texture belongs to
  66647. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66648. * @param generateMipMaps Define if the texture should creates mip maps or not
  66649. */
  66650. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66651. private _loadJson;
  66652. /**
  66653. * Is the texture ready to be used ? (rendered at least once)
  66654. * @returns true if ready, otherwise, false.
  66655. */
  66656. isReady(): boolean;
  66657. /**
  66658. * Render the texture to its associated render target.
  66659. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66660. */
  66661. render(useCameraPostProcess?: boolean): void;
  66662. /**
  66663. * Update the list of dependant textures samplers in the shader.
  66664. */
  66665. updateTextures(): void;
  66666. /**
  66667. * Update the uniform values of the procedural texture in the shader.
  66668. */
  66669. updateShaderUniforms(): void;
  66670. /**
  66671. * Define if the texture animates or not.
  66672. */
  66673. get animate(): boolean;
  66674. set animate(value: boolean);
  66675. }
  66676. }
  66677. declare module "babylonjs/Shaders/noise.fragment" {
  66678. /** @hidden */
  66679. export var noisePixelShader: {
  66680. name: string;
  66681. shader: string;
  66682. };
  66683. }
  66684. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  66685. import { Nullable } from "babylonjs/types";
  66686. import { Scene } from "babylonjs/scene";
  66687. import { Texture } from "babylonjs/Materials/Textures/texture";
  66688. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66689. import "babylonjs/Shaders/noise.fragment";
  66690. /**
  66691. * Class used to generate noise procedural textures
  66692. */
  66693. export class NoiseProceduralTexture extends ProceduralTexture {
  66694. /** Gets or sets the start time (default is 0) */
  66695. time: number;
  66696. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66697. brightness: number;
  66698. /** Defines the number of octaves to process */
  66699. octaves: number;
  66700. /** Defines the level of persistence (0.8 by default) */
  66701. persistence: number;
  66702. /** Gets or sets animation speed factor (default is 1) */
  66703. animationSpeedFactor: number;
  66704. /**
  66705. * Creates a new NoiseProceduralTexture
  66706. * @param name defines the name fo the texture
  66707. * @param size defines the size of the texture (default is 256)
  66708. * @param scene defines the hosting scene
  66709. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66710. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66711. */
  66712. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66713. private _updateShaderUniforms;
  66714. protected _getDefines(): string;
  66715. /** Generate the current state of the procedural texture */
  66716. render(useCameraPostProcess?: boolean): void;
  66717. /**
  66718. * Serializes this noise procedural texture
  66719. * @returns a serialized noise procedural texture object
  66720. */
  66721. serialize(): any;
  66722. /**
  66723. * Clone the texture.
  66724. * @returns the cloned texture
  66725. */
  66726. clone(): NoiseProceduralTexture;
  66727. /**
  66728. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66729. * @param parsedTexture defines parsed texture data
  66730. * @param scene defines the current scene
  66731. * @param rootUrl defines the root URL containing noise procedural texture information
  66732. * @returns a parsed NoiseProceduralTexture
  66733. */
  66734. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66735. }
  66736. }
  66737. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  66738. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  66739. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  66740. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66741. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  66742. }
  66743. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  66744. import { Nullable } from "babylonjs/types";
  66745. import { Scene } from "babylonjs/scene";
  66746. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  66747. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66748. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66749. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66750. /**
  66751. * Raw cube texture where the raw buffers are passed in
  66752. */
  66753. export class RawCubeTexture extends CubeTexture {
  66754. /**
  66755. * Creates a cube texture where the raw buffers are passed in.
  66756. * @param scene defines the scene the texture is attached to
  66757. * @param data defines the array of data to use to create each face
  66758. * @param size defines the size of the textures
  66759. * @param format defines the format of the data
  66760. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66761. * @param generateMipMaps defines if the engine should generate the mip levels
  66762. * @param invertY defines if data must be stored with Y axis inverted
  66763. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66764. * @param compression defines the compression used (null by default)
  66765. */
  66766. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66767. /**
  66768. * Updates the raw cube texture.
  66769. * @param data defines the data to store
  66770. * @param format defines the data format
  66771. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66772. * @param invertY defines if data must be stored with Y axis inverted
  66773. * @param compression defines the compression used (null by default)
  66774. * @param level defines which level of the texture to update
  66775. */
  66776. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66777. /**
  66778. * Updates a raw cube texture with RGBD encoded data.
  66779. * @param data defines the array of data [mipmap][face] to use to create each face
  66780. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66781. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66782. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66783. * @returns a promsie that resolves when the operation is complete
  66784. */
  66785. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66786. /**
  66787. * Clones the raw cube texture.
  66788. * @return a new cube texture
  66789. */
  66790. clone(): CubeTexture;
  66791. /** @hidden */
  66792. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66793. }
  66794. }
  66795. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  66796. import { Scene } from "babylonjs/scene";
  66797. import { Texture } from "babylonjs/Materials/Textures/texture";
  66798. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66799. /**
  66800. * Class used to store 2D array textures containing user data
  66801. */
  66802. export class RawTexture2DArray extends Texture {
  66803. /** Gets or sets the texture format to use */
  66804. format: number;
  66805. /**
  66806. * Create a new RawTexture2DArray
  66807. * @param data defines the data of the texture
  66808. * @param width defines the width of the texture
  66809. * @param height defines the height of the texture
  66810. * @param depth defines the number of layers of the texture
  66811. * @param format defines the texture format to use
  66812. * @param scene defines the hosting scene
  66813. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66814. * @param invertY defines if texture must be stored with Y axis inverted
  66815. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66816. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66817. */
  66818. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66819. /** Gets or sets the texture format to use */
  66820. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66821. /**
  66822. * Update the texture with new data
  66823. * @param data defines the data to store in the texture
  66824. */
  66825. update(data: ArrayBufferView): void;
  66826. }
  66827. }
  66828. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  66829. import { Scene } from "babylonjs/scene";
  66830. import { Texture } from "babylonjs/Materials/Textures/texture";
  66831. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66832. /**
  66833. * Class used to store 3D textures containing user data
  66834. */
  66835. export class RawTexture3D extends Texture {
  66836. /** Gets or sets the texture format to use */
  66837. format: number;
  66838. /**
  66839. * Create a new RawTexture3D
  66840. * @param data defines the data of the texture
  66841. * @param width defines the width of the texture
  66842. * @param height defines the height of the texture
  66843. * @param depth defines the depth of the texture
  66844. * @param format defines the texture format to use
  66845. * @param scene defines the hosting scene
  66846. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66847. * @param invertY defines if texture must be stored with Y axis inverted
  66848. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66849. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66850. */
  66851. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66852. /** Gets or sets the texture format to use */
  66853. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66854. /**
  66855. * Update the texture with new data
  66856. * @param data defines the data to store in the texture
  66857. */
  66858. update(data: ArrayBufferView): void;
  66859. }
  66860. }
  66861. declare module "babylonjs/Materials/Textures/refractionTexture" {
  66862. import { Scene } from "babylonjs/scene";
  66863. import { Plane } from "babylonjs/Maths/math.plane";
  66864. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66865. /**
  66866. * Creates a refraction texture used by refraction channel of the standard material.
  66867. * It is like a mirror but to see through a material.
  66868. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66869. */
  66870. export class RefractionTexture extends RenderTargetTexture {
  66871. /**
  66872. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66873. * 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.
  66874. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66875. */
  66876. refractionPlane: Plane;
  66877. /**
  66878. * Define how deep under the surface we should see.
  66879. */
  66880. depth: number;
  66881. /**
  66882. * Creates a refraction texture used by refraction channel of the standard material.
  66883. * It is like a mirror but to see through a material.
  66884. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66885. * @param name Define the texture name
  66886. * @param size Define the size of the underlying texture
  66887. * @param scene Define the scene the refraction belongs to
  66888. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66889. */
  66890. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66891. /**
  66892. * Clone the refraction texture.
  66893. * @returns the cloned texture
  66894. */
  66895. clone(): RefractionTexture;
  66896. /**
  66897. * Serialize the texture to a JSON representation you could use in Parse later on
  66898. * @returns the serialized JSON representation
  66899. */
  66900. serialize(): any;
  66901. }
  66902. }
  66903. declare module "babylonjs/Materials/Textures/index" {
  66904. export * from "babylonjs/Materials/Textures/baseTexture";
  66905. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66906. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66907. export * from "babylonjs/Materials/Textures/cubeTexture";
  66908. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66909. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66910. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66911. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66912. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66913. export * from "babylonjs/Materials/Textures/internalTexture";
  66914. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66915. export * from "babylonjs/Materials/Textures/Loaders/index";
  66916. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66917. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66918. export * from "babylonjs/Materials/Textures/Packer/index";
  66919. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66920. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66921. export * from "babylonjs/Materials/Textures/rawTexture";
  66922. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66923. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66924. export * from "babylonjs/Materials/Textures/refractionTexture";
  66925. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66926. export * from "babylonjs/Materials/Textures/texture";
  66927. export * from "babylonjs/Materials/Textures/videoTexture";
  66928. }
  66929. declare module "babylonjs/Materials/Node/Enums/index" {
  66930. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66931. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66932. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66933. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66934. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66935. }
  66936. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66937. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66938. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66940. import { Mesh } from "babylonjs/Meshes/mesh";
  66941. import { Effect } from "babylonjs/Materials/effect";
  66942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66943. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66944. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66945. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66946. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66947. /**
  66948. * Block used to add support for vertex skinning (bones)
  66949. */
  66950. export class BonesBlock extends NodeMaterialBlock {
  66951. /**
  66952. * Creates a new BonesBlock
  66953. * @param name defines the block name
  66954. */
  66955. constructor(name: string);
  66956. /**
  66957. * Initialize the block and prepare the context for build
  66958. * @param state defines the state that will be used for the build
  66959. */
  66960. initialize(state: NodeMaterialBuildState): void;
  66961. /**
  66962. * Gets the current class name
  66963. * @returns the class name
  66964. */
  66965. getClassName(): string;
  66966. /**
  66967. * Gets the matrix indices input component
  66968. */
  66969. get matricesIndices(): NodeMaterialConnectionPoint;
  66970. /**
  66971. * Gets the matrix weights input component
  66972. */
  66973. get matricesWeights(): NodeMaterialConnectionPoint;
  66974. /**
  66975. * Gets the extra matrix indices input component
  66976. */
  66977. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66978. /**
  66979. * Gets the extra matrix weights input component
  66980. */
  66981. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66982. /**
  66983. * Gets the world input component
  66984. */
  66985. get world(): NodeMaterialConnectionPoint;
  66986. /**
  66987. * Gets the output component
  66988. */
  66989. get output(): NodeMaterialConnectionPoint;
  66990. autoConfigure(material: NodeMaterial): void;
  66991. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66992. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66993. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66994. protected _buildBlock(state: NodeMaterialBuildState): this;
  66995. }
  66996. }
  66997. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66999. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67000. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67002. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67003. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67004. /**
  67005. * Block used to add support for instances
  67006. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  67007. */
  67008. export class InstancesBlock extends NodeMaterialBlock {
  67009. /**
  67010. * Creates a new InstancesBlock
  67011. * @param name defines the block name
  67012. */
  67013. constructor(name: string);
  67014. /**
  67015. * Gets the current class name
  67016. * @returns the class name
  67017. */
  67018. getClassName(): string;
  67019. /**
  67020. * Gets the first world row input component
  67021. */
  67022. get world0(): NodeMaterialConnectionPoint;
  67023. /**
  67024. * Gets the second world row input component
  67025. */
  67026. get world1(): NodeMaterialConnectionPoint;
  67027. /**
  67028. * Gets the third world row input component
  67029. */
  67030. get world2(): NodeMaterialConnectionPoint;
  67031. /**
  67032. * Gets the forth world row input component
  67033. */
  67034. get world3(): NodeMaterialConnectionPoint;
  67035. /**
  67036. * Gets the world input component
  67037. */
  67038. get world(): NodeMaterialConnectionPoint;
  67039. /**
  67040. * Gets the output component
  67041. */
  67042. get output(): NodeMaterialConnectionPoint;
  67043. /**
  67044. * Gets the isntanceID component
  67045. */
  67046. get instanceID(): NodeMaterialConnectionPoint;
  67047. autoConfigure(material: NodeMaterial): void;
  67048. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  67049. protected _buildBlock(state: NodeMaterialBuildState): this;
  67050. }
  67051. }
  67052. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  67053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67054. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67057. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67058. import { Effect } from "babylonjs/Materials/effect";
  67059. import { Mesh } from "babylonjs/Meshes/mesh";
  67060. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67061. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67062. /**
  67063. * Block used to add morph targets support to vertex shader
  67064. */
  67065. export class MorphTargetsBlock extends NodeMaterialBlock {
  67066. private _repeatableContentAnchor;
  67067. /**
  67068. * Create a new MorphTargetsBlock
  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 position input component
  67079. */
  67080. get position(): NodeMaterialConnectionPoint;
  67081. /**
  67082. * Gets the normal input component
  67083. */
  67084. get normal(): NodeMaterialConnectionPoint;
  67085. /**
  67086. * Gets the tangent input component
  67087. */
  67088. get tangent(): NodeMaterialConnectionPoint;
  67089. /**
  67090. * Gets the tangent input component
  67091. */
  67092. get uv(): NodeMaterialConnectionPoint;
  67093. /**
  67094. * Gets the position output component
  67095. */
  67096. get positionOutput(): NodeMaterialConnectionPoint;
  67097. /**
  67098. * Gets the normal output component
  67099. */
  67100. get normalOutput(): NodeMaterialConnectionPoint;
  67101. /**
  67102. * Gets the tangent output component
  67103. */
  67104. get tangentOutput(): NodeMaterialConnectionPoint;
  67105. /**
  67106. * Gets the tangent output component
  67107. */
  67108. get uvOutput(): NodeMaterialConnectionPoint;
  67109. initialize(state: NodeMaterialBuildState): void;
  67110. autoConfigure(material: NodeMaterial): void;
  67111. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67112. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67113. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67114. protected _buildBlock(state: NodeMaterialBuildState): this;
  67115. }
  67116. }
  67117. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  67118. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67119. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67120. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67121. import { Nullable } from "babylonjs/types";
  67122. import { Scene } from "babylonjs/scene";
  67123. import { Effect } from "babylonjs/Materials/effect";
  67124. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67125. import { Mesh } from "babylonjs/Meshes/mesh";
  67126. import { Light } from "babylonjs/Lights/light";
  67127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67128. /**
  67129. * Block used to get data information from a light
  67130. */
  67131. export class LightInformationBlock extends NodeMaterialBlock {
  67132. private _lightDataUniformName;
  67133. private _lightColorUniformName;
  67134. private _lightTypeDefineName;
  67135. /**
  67136. * Gets or sets the light associated with this block
  67137. */
  67138. light: Nullable<Light>;
  67139. /**
  67140. * Creates a new LightInformationBlock
  67141. * @param name defines the block name
  67142. */
  67143. constructor(name: string);
  67144. /**
  67145. * Gets the current class name
  67146. * @returns the class name
  67147. */
  67148. getClassName(): string;
  67149. /**
  67150. * Gets the world position input component
  67151. */
  67152. get worldPosition(): NodeMaterialConnectionPoint;
  67153. /**
  67154. * Gets the direction output component
  67155. */
  67156. get direction(): NodeMaterialConnectionPoint;
  67157. /**
  67158. * Gets the direction output component
  67159. */
  67160. get color(): NodeMaterialConnectionPoint;
  67161. /**
  67162. * Gets the direction output component
  67163. */
  67164. get intensity(): NodeMaterialConnectionPoint;
  67165. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67166. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67167. protected _buildBlock(state: NodeMaterialBuildState): this;
  67168. serialize(): any;
  67169. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67170. }
  67171. }
  67172. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  67173. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  67174. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  67175. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  67176. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  67177. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  67178. }
  67179. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  67180. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67181. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67182. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67184. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67185. import { Effect } from "babylonjs/Materials/effect";
  67186. import { Mesh } from "babylonjs/Meshes/mesh";
  67187. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67188. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  67189. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  67190. /**
  67191. * Block used to add image processing support to fragment shader
  67192. */
  67193. export class ImageProcessingBlock extends NodeMaterialBlock {
  67194. /**
  67195. * Create a new ImageProcessingBlock
  67196. * @param name defines the block name
  67197. */
  67198. constructor(name: string);
  67199. /**
  67200. * Gets the current class name
  67201. * @returns the class name
  67202. */
  67203. getClassName(): string;
  67204. /**
  67205. * Gets the color input component
  67206. */
  67207. get color(): NodeMaterialConnectionPoint;
  67208. /**
  67209. * Gets the output component
  67210. */
  67211. get output(): NodeMaterialConnectionPoint;
  67212. /**
  67213. * Initialize the block and prepare the context for build
  67214. * @param state defines the state that will be used for the build
  67215. */
  67216. initialize(state: NodeMaterialBuildState): void;
  67217. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67218. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67219. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67220. protected _buildBlock(state: NodeMaterialBuildState): this;
  67221. }
  67222. }
  67223. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  67224. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67225. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67226. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67227. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67229. import { Effect } from "babylonjs/Materials/effect";
  67230. import { Mesh } from "babylonjs/Meshes/mesh";
  67231. import { Scene } from "babylonjs/scene";
  67232. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  67233. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67234. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67235. /**
  67236. * Block used to pertub normals based on a normal map
  67237. */
  67238. export class PerturbNormalBlock extends NodeMaterialBlock {
  67239. private _tangentSpaceParameterName;
  67240. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67241. invertX: boolean;
  67242. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67243. invertY: boolean;
  67244. /**
  67245. * Create a new PerturbNormalBlock
  67246. * @param name defines the block name
  67247. */
  67248. constructor(name: string);
  67249. /**
  67250. * Gets the current class name
  67251. * @returns the class name
  67252. */
  67253. getClassName(): string;
  67254. /**
  67255. * Gets the world position input component
  67256. */
  67257. get worldPosition(): NodeMaterialConnectionPoint;
  67258. /**
  67259. * Gets the world normal input component
  67260. */
  67261. get worldNormal(): NodeMaterialConnectionPoint;
  67262. /**
  67263. * Gets the world tangent input component
  67264. */
  67265. get worldTangent(): NodeMaterialConnectionPoint;
  67266. /**
  67267. * Gets the uv input component
  67268. */
  67269. get uv(): NodeMaterialConnectionPoint;
  67270. /**
  67271. * Gets the normal map color input component
  67272. */
  67273. get normalMapColor(): NodeMaterialConnectionPoint;
  67274. /**
  67275. * Gets the strength input component
  67276. */
  67277. get strength(): NodeMaterialConnectionPoint;
  67278. /**
  67279. * Gets the output component
  67280. */
  67281. get output(): NodeMaterialConnectionPoint;
  67282. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67283. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67284. autoConfigure(material: NodeMaterial): void;
  67285. protected _buildBlock(state: NodeMaterialBuildState): this;
  67286. protected _dumpPropertiesCode(): string;
  67287. serialize(): any;
  67288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67289. }
  67290. }
  67291. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  67292. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67293. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67294. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67295. /**
  67296. * Block used to discard a pixel if a value is smaller than a cutoff
  67297. */
  67298. export class DiscardBlock extends NodeMaterialBlock {
  67299. /**
  67300. * Create a new DiscardBlock
  67301. * @param name defines the block name
  67302. */
  67303. constructor(name: string);
  67304. /**
  67305. * Gets the current class name
  67306. * @returns the class name
  67307. */
  67308. getClassName(): string;
  67309. /**
  67310. * Gets the color input component
  67311. */
  67312. get value(): NodeMaterialConnectionPoint;
  67313. /**
  67314. * Gets the cutoff input component
  67315. */
  67316. get cutoff(): NodeMaterialConnectionPoint;
  67317. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67318. }
  67319. }
  67320. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  67321. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67322. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67323. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67324. /**
  67325. * Block used to test if the fragment shader is front facing
  67326. */
  67327. export class FrontFacingBlock extends NodeMaterialBlock {
  67328. /**
  67329. * Creates a new FrontFacingBlock
  67330. * @param name defines the block name
  67331. */
  67332. constructor(name: string);
  67333. /**
  67334. * Gets the current class name
  67335. * @returns the class name
  67336. */
  67337. getClassName(): string;
  67338. /**
  67339. * Gets the output component
  67340. */
  67341. get output(): NodeMaterialConnectionPoint;
  67342. protected _buildBlock(state: NodeMaterialBuildState): this;
  67343. }
  67344. }
  67345. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  67346. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67347. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67348. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67349. /**
  67350. * Block used to get the derivative value on x and y of a given input
  67351. */
  67352. export class DerivativeBlock extends NodeMaterialBlock {
  67353. /**
  67354. * Create a new DerivativeBlock
  67355. * @param name defines the block name
  67356. */
  67357. constructor(name: string);
  67358. /**
  67359. * Gets the current class name
  67360. * @returns the class name
  67361. */
  67362. getClassName(): string;
  67363. /**
  67364. * Gets the input component
  67365. */
  67366. get input(): NodeMaterialConnectionPoint;
  67367. /**
  67368. * Gets the derivative output on x
  67369. */
  67370. get dx(): NodeMaterialConnectionPoint;
  67371. /**
  67372. * Gets the derivative output on y
  67373. */
  67374. get dy(): NodeMaterialConnectionPoint;
  67375. protected _buildBlock(state: NodeMaterialBuildState): this;
  67376. }
  67377. }
  67378. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  67379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67380. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67381. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67382. /**
  67383. * Block used to make gl_FragCoord available
  67384. */
  67385. export class FragCoordBlock extends NodeMaterialBlock {
  67386. /**
  67387. * Creates a new FragCoordBlock
  67388. * @param name defines the block name
  67389. */
  67390. constructor(name: string);
  67391. /**
  67392. * Gets the current class name
  67393. * @returns the class name
  67394. */
  67395. getClassName(): string;
  67396. /**
  67397. * Gets the xy component
  67398. */
  67399. get xy(): NodeMaterialConnectionPoint;
  67400. /**
  67401. * Gets the xyz component
  67402. */
  67403. get xyz(): NodeMaterialConnectionPoint;
  67404. /**
  67405. * Gets the xyzw component
  67406. */
  67407. get xyzw(): NodeMaterialConnectionPoint;
  67408. /**
  67409. * Gets the x component
  67410. */
  67411. get x(): NodeMaterialConnectionPoint;
  67412. /**
  67413. * Gets the y component
  67414. */
  67415. get y(): NodeMaterialConnectionPoint;
  67416. /**
  67417. * Gets the z component
  67418. */
  67419. get z(): NodeMaterialConnectionPoint;
  67420. /**
  67421. * Gets the w component
  67422. */
  67423. get output(): NodeMaterialConnectionPoint;
  67424. protected writeOutputs(state: NodeMaterialBuildState): string;
  67425. protected _buildBlock(state: NodeMaterialBuildState): this;
  67426. }
  67427. }
  67428. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  67429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67432. import { Effect } from "babylonjs/Materials/effect";
  67433. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67434. import { Mesh } from "babylonjs/Meshes/mesh";
  67435. /**
  67436. * Block used to get the screen sizes
  67437. */
  67438. export class ScreenSizeBlock extends NodeMaterialBlock {
  67439. private _varName;
  67440. private _scene;
  67441. /**
  67442. * Creates a new ScreenSizeBlock
  67443. * @param name defines the block name
  67444. */
  67445. constructor(name: string);
  67446. /**
  67447. * Gets the current class name
  67448. * @returns the class name
  67449. */
  67450. getClassName(): string;
  67451. /**
  67452. * Gets the xy component
  67453. */
  67454. get xy(): NodeMaterialConnectionPoint;
  67455. /**
  67456. * Gets the x component
  67457. */
  67458. get x(): NodeMaterialConnectionPoint;
  67459. /**
  67460. * Gets the y component
  67461. */
  67462. get y(): NodeMaterialConnectionPoint;
  67463. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67464. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67465. protected _buildBlock(state: NodeMaterialBuildState): this;
  67466. }
  67467. }
  67468. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  67469. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  67470. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  67471. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  67472. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  67473. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  67474. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  67475. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  67476. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  67477. }
  67478. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  67479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67480. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67481. import { Mesh } from "babylonjs/Meshes/mesh";
  67482. import { Effect } from "babylonjs/Materials/effect";
  67483. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67485. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67486. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  67487. /**
  67488. * Block used to add support for scene fog
  67489. */
  67490. export class FogBlock extends NodeMaterialBlock {
  67491. private _fogDistanceName;
  67492. private _fogParameters;
  67493. /**
  67494. * Create a new FogBlock
  67495. * @param name defines the block name
  67496. */
  67497. constructor(name: string);
  67498. /**
  67499. * Gets the current class name
  67500. * @returns the class name
  67501. */
  67502. getClassName(): string;
  67503. /**
  67504. * Gets the world position input component
  67505. */
  67506. get worldPosition(): NodeMaterialConnectionPoint;
  67507. /**
  67508. * Gets the view input component
  67509. */
  67510. get view(): NodeMaterialConnectionPoint;
  67511. /**
  67512. * Gets the color input component
  67513. */
  67514. get input(): NodeMaterialConnectionPoint;
  67515. /**
  67516. * Gets the fog color input component
  67517. */
  67518. get fogColor(): NodeMaterialConnectionPoint;
  67519. /**
  67520. * Gets the output component
  67521. */
  67522. get output(): NodeMaterialConnectionPoint;
  67523. autoConfigure(material: NodeMaterial): void;
  67524. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67525. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67526. protected _buildBlock(state: NodeMaterialBuildState): this;
  67527. }
  67528. }
  67529. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  67530. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67531. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67532. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67534. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67535. import { Effect } from "babylonjs/Materials/effect";
  67536. import { Mesh } from "babylonjs/Meshes/mesh";
  67537. import { Light } from "babylonjs/Lights/light";
  67538. import { Nullable } from "babylonjs/types";
  67539. import { Scene } from "babylonjs/scene";
  67540. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  67541. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  67542. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  67543. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67544. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  67545. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  67546. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  67547. /**
  67548. * Block used to add light in the fragment shader
  67549. */
  67550. export class LightBlock extends NodeMaterialBlock {
  67551. private _lightId;
  67552. /**
  67553. * Gets or sets the light associated with this block
  67554. */
  67555. light: Nullable<Light>;
  67556. /**
  67557. * Create a new LightBlock
  67558. * @param name defines the block name
  67559. */
  67560. constructor(name: string);
  67561. /**
  67562. * Gets the current class name
  67563. * @returns the class name
  67564. */
  67565. getClassName(): string;
  67566. /**
  67567. * Gets the world position input component
  67568. */
  67569. get worldPosition(): NodeMaterialConnectionPoint;
  67570. /**
  67571. * Gets the world normal input component
  67572. */
  67573. get worldNormal(): NodeMaterialConnectionPoint;
  67574. /**
  67575. * Gets the camera (or eye) position component
  67576. */
  67577. get cameraPosition(): NodeMaterialConnectionPoint;
  67578. /**
  67579. * Gets the glossiness component
  67580. */
  67581. get glossiness(): NodeMaterialConnectionPoint;
  67582. /**
  67583. * Gets the glossinness power component
  67584. */
  67585. get glossPower(): NodeMaterialConnectionPoint;
  67586. /**
  67587. * Gets the diffuse color component
  67588. */
  67589. get diffuseColor(): NodeMaterialConnectionPoint;
  67590. /**
  67591. * Gets the specular color component
  67592. */
  67593. get specularColor(): NodeMaterialConnectionPoint;
  67594. /**
  67595. * Gets the view matrix component
  67596. */
  67597. get view(): NodeMaterialConnectionPoint;
  67598. /**
  67599. * Gets the diffuse output component
  67600. */
  67601. get diffuseOutput(): NodeMaterialConnectionPoint;
  67602. /**
  67603. * Gets the specular output component
  67604. */
  67605. get specularOutput(): NodeMaterialConnectionPoint;
  67606. /**
  67607. * Gets the shadow output component
  67608. */
  67609. get shadow(): NodeMaterialConnectionPoint;
  67610. autoConfigure(material: NodeMaterial): void;
  67611. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67612. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67613. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67614. private _injectVertexCode;
  67615. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67616. serialize(): any;
  67617. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67618. }
  67619. }
  67620. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  67621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67622. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67623. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67624. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67625. /**
  67626. * Block used to read a reflection texture from a sampler
  67627. */
  67628. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67629. /**
  67630. * Create a new ReflectionTextureBlock
  67631. * @param name defines the block name
  67632. */
  67633. constructor(name: string);
  67634. /**
  67635. * Gets the current class name
  67636. * @returns the class name
  67637. */
  67638. getClassName(): string;
  67639. /**
  67640. * Gets the world position input component
  67641. */
  67642. get position(): NodeMaterialConnectionPoint;
  67643. /**
  67644. * Gets the world position input component
  67645. */
  67646. get worldPosition(): NodeMaterialConnectionPoint;
  67647. /**
  67648. * Gets the world normal input component
  67649. */
  67650. get worldNormal(): NodeMaterialConnectionPoint;
  67651. /**
  67652. * Gets the world input component
  67653. */
  67654. get world(): NodeMaterialConnectionPoint;
  67655. /**
  67656. * Gets the camera (or eye) position component
  67657. */
  67658. get cameraPosition(): NodeMaterialConnectionPoint;
  67659. /**
  67660. * Gets the view input component
  67661. */
  67662. get view(): NodeMaterialConnectionPoint;
  67663. /**
  67664. * Gets the rgb output component
  67665. */
  67666. get rgb(): NodeMaterialConnectionPoint;
  67667. /**
  67668. * Gets the rgba output component
  67669. */
  67670. get rgba(): NodeMaterialConnectionPoint;
  67671. /**
  67672. * Gets the r output component
  67673. */
  67674. get r(): NodeMaterialConnectionPoint;
  67675. /**
  67676. * Gets the g output component
  67677. */
  67678. get g(): NodeMaterialConnectionPoint;
  67679. /**
  67680. * Gets the b output component
  67681. */
  67682. get b(): NodeMaterialConnectionPoint;
  67683. /**
  67684. * Gets the a output component
  67685. */
  67686. get a(): NodeMaterialConnectionPoint;
  67687. autoConfigure(material: NodeMaterial): void;
  67688. protected _buildBlock(state: NodeMaterialBuildState): this;
  67689. }
  67690. }
  67691. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  67692. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  67693. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  67694. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  67695. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  67696. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  67697. }
  67698. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  67699. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  67700. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  67701. }
  67702. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  67703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67704. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67705. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67706. /**
  67707. * Block used to add 2 vectors
  67708. */
  67709. export class AddBlock extends NodeMaterialBlock {
  67710. /**
  67711. * Creates a new AddBlock
  67712. * @param name defines the block name
  67713. */
  67714. constructor(name: string);
  67715. /**
  67716. * Gets the current class name
  67717. * @returns the class name
  67718. */
  67719. getClassName(): string;
  67720. /**
  67721. * Gets the left operand input component
  67722. */
  67723. get left(): NodeMaterialConnectionPoint;
  67724. /**
  67725. * Gets the right operand input component
  67726. */
  67727. get right(): NodeMaterialConnectionPoint;
  67728. /**
  67729. * Gets the output component
  67730. */
  67731. get output(): NodeMaterialConnectionPoint;
  67732. protected _buildBlock(state: NodeMaterialBuildState): this;
  67733. }
  67734. }
  67735. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  67736. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67737. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67738. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67739. /**
  67740. * Block used to scale a vector by a float
  67741. */
  67742. export class ScaleBlock extends NodeMaterialBlock {
  67743. /**
  67744. * Creates a new ScaleBlock
  67745. * @param name defines the block name
  67746. */
  67747. constructor(name: string);
  67748. /**
  67749. * Gets the current class name
  67750. * @returns the class name
  67751. */
  67752. getClassName(): string;
  67753. /**
  67754. * Gets the input component
  67755. */
  67756. get input(): NodeMaterialConnectionPoint;
  67757. /**
  67758. * Gets the factor input component
  67759. */
  67760. get factor(): NodeMaterialConnectionPoint;
  67761. /**
  67762. * Gets the output component
  67763. */
  67764. get output(): NodeMaterialConnectionPoint;
  67765. protected _buildBlock(state: NodeMaterialBuildState): this;
  67766. }
  67767. }
  67768. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  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. import { Scene } from "babylonjs/scene";
  67773. /**
  67774. * Block used to clamp a float
  67775. */
  67776. export class ClampBlock extends NodeMaterialBlock {
  67777. /** Gets or sets the minimum range */
  67778. minimum: number;
  67779. /** Gets or sets the maximum range */
  67780. maximum: number;
  67781. /**
  67782. * Creates a new ClampBlock
  67783. * @param name defines the block name
  67784. */
  67785. constructor(name: string);
  67786. /**
  67787. * Gets the current class name
  67788. * @returns the class name
  67789. */
  67790. getClassName(): string;
  67791. /**
  67792. * Gets the value input component
  67793. */
  67794. get value(): NodeMaterialConnectionPoint;
  67795. /**
  67796. * Gets the output component
  67797. */
  67798. get output(): NodeMaterialConnectionPoint;
  67799. protected _buildBlock(state: NodeMaterialBuildState): this;
  67800. protected _dumpPropertiesCode(): string;
  67801. serialize(): any;
  67802. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67803. }
  67804. }
  67805. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  67806. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67807. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67808. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67809. /**
  67810. * Block used to apply a cross product between 2 vectors
  67811. */
  67812. export class CrossBlock extends NodeMaterialBlock {
  67813. /**
  67814. * Creates a new CrossBlock
  67815. * @param name defines the block name
  67816. */
  67817. constructor(name: string);
  67818. /**
  67819. * Gets the current class name
  67820. * @returns the class name
  67821. */
  67822. getClassName(): string;
  67823. /**
  67824. * Gets the left operand input component
  67825. */
  67826. get left(): NodeMaterialConnectionPoint;
  67827. /**
  67828. * Gets the right operand input component
  67829. */
  67830. get right(): NodeMaterialConnectionPoint;
  67831. /**
  67832. * Gets the output component
  67833. */
  67834. get output(): NodeMaterialConnectionPoint;
  67835. protected _buildBlock(state: NodeMaterialBuildState): this;
  67836. }
  67837. }
  67838. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  67839. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67840. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67841. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67842. /**
  67843. * Block used to apply a dot product between 2 vectors
  67844. */
  67845. export class DotBlock extends NodeMaterialBlock {
  67846. /**
  67847. * Creates a new DotBlock
  67848. * @param name defines the block name
  67849. */
  67850. constructor(name: string);
  67851. /**
  67852. * Gets the current class name
  67853. * @returns the class name
  67854. */
  67855. getClassName(): string;
  67856. /**
  67857. * Gets the left operand input component
  67858. */
  67859. get left(): NodeMaterialConnectionPoint;
  67860. /**
  67861. * Gets the right operand input component
  67862. */
  67863. get right(): NodeMaterialConnectionPoint;
  67864. /**
  67865. * Gets the output component
  67866. */
  67867. get output(): NodeMaterialConnectionPoint;
  67868. protected _buildBlock(state: NodeMaterialBuildState): this;
  67869. }
  67870. }
  67871. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  67872. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67873. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67874. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67875. /**
  67876. * Block used to normalize a vector
  67877. */
  67878. export class NormalizeBlock extends NodeMaterialBlock {
  67879. /**
  67880. * Creates a new NormalizeBlock
  67881. * @param name defines the block name
  67882. */
  67883. constructor(name: string);
  67884. /**
  67885. * Gets the current class name
  67886. * @returns the class name
  67887. */
  67888. getClassName(): string;
  67889. /**
  67890. * Gets the input component
  67891. */
  67892. get input(): NodeMaterialConnectionPoint;
  67893. /**
  67894. * Gets the output component
  67895. */
  67896. get output(): NodeMaterialConnectionPoint;
  67897. protected _buildBlock(state: NodeMaterialBuildState): this;
  67898. }
  67899. }
  67900. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67901. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67902. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67904. /**
  67905. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67906. */
  67907. export class ColorMergerBlock extends NodeMaterialBlock {
  67908. /**
  67909. * Create a new ColorMergerBlock
  67910. * @param name defines the block name
  67911. */
  67912. constructor(name: string);
  67913. /**
  67914. * Gets the current class name
  67915. * @returns the class name
  67916. */
  67917. getClassName(): string;
  67918. /**
  67919. * Gets the rgb component (input)
  67920. */
  67921. get rgbIn(): NodeMaterialConnectionPoint;
  67922. /**
  67923. * Gets the r component (input)
  67924. */
  67925. get r(): NodeMaterialConnectionPoint;
  67926. /**
  67927. * Gets the g component (input)
  67928. */
  67929. get g(): NodeMaterialConnectionPoint;
  67930. /**
  67931. * Gets the b component (input)
  67932. */
  67933. get b(): NodeMaterialConnectionPoint;
  67934. /**
  67935. * Gets the a component (input)
  67936. */
  67937. get a(): NodeMaterialConnectionPoint;
  67938. /**
  67939. * Gets the rgba component (output)
  67940. */
  67941. get rgba(): NodeMaterialConnectionPoint;
  67942. /**
  67943. * Gets the rgb component (output)
  67944. */
  67945. get rgbOut(): NodeMaterialConnectionPoint;
  67946. /**
  67947. * Gets the rgb component (output)
  67948. * @deprecated Please use rgbOut instead.
  67949. */
  67950. get rgb(): NodeMaterialConnectionPoint;
  67951. protected _buildBlock(state: NodeMaterialBuildState): this;
  67952. }
  67953. }
  67954. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67955. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67956. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67958. /**
  67959. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67960. */
  67961. export class VectorSplitterBlock extends NodeMaterialBlock {
  67962. /**
  67963. * Create a new VectorSplitterBlock
  67964. * @param name defines the block name
  67965. */
  67966. constructor(name: string);
  67967. /**
  67968. * Gets the current class name
  67969. * @returns the class name
  67970. */
  67971. getClassName(): string;
  67972. /**
  67973. * Gets the xyzw component (input)
  67974. */
  67975. get xyzw(): NodeMaterialConnectionPoint;
  67976. /**
  67977. * Gets the xyz component (input)
  67978. */
  67979. get xyzIn(): NodeMaterialConnectionPoint;
  67980. /**
  67981. * Gets the xy component (input)
  67982. */
  67983. get xyIn(): NodeMaterialConnectionPoint;
  67984. /**
  67985. * Gets the xyz component (output)
  67986. */
  67987. get xyzOut(): NodeMaterialConnectionPoint;
  67988. /**
  67989. * Gets the xy component (output)
  67990. */
  67991. get xyOut(): NodeMaterialConnectionPoint;
  67992. /**
  67993. * Gets the x component (output)
  67994. */
  67995. get x(): NodeMaterialConnectionPoint;
  67996. /**
  67997. * Gets the y component (output)
  67998. */
  67999. get y(): NodeMaterialConnectionPoint;
  68000. /**
  68001. * Gets the z component (output)
  68002. */
  68003. get z(): NodeMaterialConnectionPoint;
  68004. /**
  68005. * Gets the w component (output)
  68006. */
  68007. get w(): NodeMaterialConnectionPoint;
  68008. protected _inputRename(name: string): string;
  68009. protected _outputRename(name: string): string;
  68010. protected _buildBlock(state: NodeMaterialBuildState): this;
  68011. }
  68012. }
  68013. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  68014. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68016. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68017. /**
  68018. * Block used to lerp between 2 values
  68019. */
  68020. export class LerpBlock extends NodeMaterialBlock {
  68021. /**
  68022. * Creates a new LerpBlock
  68023. * @param name defines the block name
  68024. */
  68025. constructor(name: string);
  68026. /**
  68027. * Gets the current class name
  68028. * @returns the class name
  68029. */
  68030. getClassName(): string;
  68031. /**
  68032. * Gets the left operand input component
  68033. */
  68034. get left(): NodeMaterialConnectionPoint;
  68035. /**
  68036. * Gets the right operand input component
  68037. */
  68038. get right(): NodeMaterialConnectionPoint;
  68039. /**
  68040. * Gets the gradient operand input component
  68041. */
  68042. get gradient(): NodeMaterialConnectionPoint;
  68043. /**
  68044. * Gets the output component
  68045. */
  68046. get output(): NodeMaterialConnectionPoint;
  68047. protected _buildBlock(state: NodeMaterialBuildState): this;
  68048. }
  68049. }
  68050. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  68051. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68052. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68053. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68054. /**
  68055. * Block used to divide 2 vectors
  68056. */
  68057. export class DivideBlock extends NodeMaterialBlock {
  68058. /**
  68059. * Creates a new DivideBlock
  68060. * @param name defines the block name
  68061. */
  68062. constructor(name: string);
  68063. /**
  68064. * Gets the current class name
  68065. * @returns the class name
  68066. */
  68067. getClassName(): string;
  68068. /**
  68069. * Gets the left operand input component
  68070. */
  68071. get left(): NodeMaterialConnectionPoint;
  68072. /**
  68073. * Gets the right operand input component
  68074. */
  68075. get right(): NodeMaterialConnectionPoint;
  68076. /**
  68077. * Gets the output component
  68078. */
  68079. get output(): NodeMaterialConnectionPoint;
  68080. protected _buildBlock(state: NodeMaterialBuildState): this;
  68081. }
  68082. }
  68083. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  68084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68085. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68087. /**
  68088. * Block used to subtract 2 vectors
  68089. */
  68090. export class SubtractBlock extends NodeMaterialBlock {
  68091. /**
  68092. * Creates a new SubtractBlock
  68093. * @param name defines the block name
  68094. */
  68095. constructor(name: string);
  68096. /**
  68097. * Gets the current class name
  68098. * @returns the class name
  68099. */
  68100. getClassName(): string;
  68101. /**
  68102. * Gets the left operand input component
  68103. */
  68104. get left(): NodeMaterialConnectionPoint;
  68105. /**
  68106. * Gets the right operand input component
  68107. */
  68108. get right(): NodeMaterialConnectionPoint;
  68109. /**
  68110. * Gets the output component
  68111. */
  68112. get output(): NodeMaterialConnectionPoint;
  68113. protected _buildBlock(state: NodeMaterialBuildState): this;
  68114. }
  68115. }
  68116. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  68117. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68118. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68119. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68120. /**
  68121. * Block used to step a value
  68122. */
  68123. export class StepBlock extends NodeMaterialBlock {
  68124. /**
  68125. * Creates a new StepBlock
  68126. * @param name defines the block name
  68127. */
  68128. constructor(name: string);
  68129. /**
  68130. * Gets the current class name
  68131. * @returns the class name
  68132. */
  68133. getClassName(): string;
  68134. /**
  68135. * Gets the value operand input component
  68136. */
  68137. get value(): NodeMaterialConnectionPoint;
  68138. /**
  68139. * Gets the edge operand input component
  68140. */
  68141. get edge(): NodeMaterialConnectionPoint;
  68142. /**
  68143. * Gets the output component
  68144. */
  68145. get output(): NodeMaterialConnectionPoint;
  68146. protected _buildBlock(state: NodeMaterialBuildState): this;
  68147. }
  68148. }
  68149. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  68150. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68151. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68152. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68153. /**
  68154. * Block used to get the opposite (1 - x) of a value
  68155. */
  68156. export class OneMinusBlock extends NodeMaterialBlock {
  68157. /**
  68158. * Creates a new OneMinusBlock
  68159. * @param name defines the block name
  68160. */
  68161. constructor(name: string);
  68162. /**
  68163. * Gets the current class name
  68164. * @returns the class name
  68165. */
  68166. getClassName(): string;
  68167. /**
  68168. * Gets the input component
  68169. */
  68170. get input(): NodeMaterialConnectionPoint;
  68171. /**
  68172. * Gets the output component
  68173. */
  68174. get output(): NodeMaterialConnectionPoint;
  68175. protected _buildBlock(state: NodeMaterialBuildState): this;
  68176. }
  68177. }
  68178. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  68179. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68181. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68182. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68183. /**
  68184. * Block used to get the view direction
  68185. */
  68186. export class ViewDirectionBlock extends NodeMaterialBlock {
  68187. /**
  68188. * Creates a new ViewDirectionBlock
  68189. * @param name defines the block name
  68190. */
  68191. constructor(name: string);
  68192. /**
  68193. * Gets the current class name
  68194. * @returns the class name
  68195. */
  68196. getClassName(): string;
  68197. /**
  68198. * Gets the world position component
  68199. */
  68200. get worldPosition(): NodeMaterialConnectionPoint;
  68201. /**
  68202. * Gets the camera position component
  68203. */
  68204. get cameraPosition(): NodeMaterialConnectionPoint;
  68205. /**
  68206. * Gets the output component
  68207. */
  68208. get output(): NodeMaterialConnectionPoint;
  68209. autoConfigure(material: NodeMaterial): void;
  68210. protected _buildBlock(state: NodeMaterialBuildState): this;
  68211. }
  68212. }
  68213. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  68214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68215. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68216. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68217. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68218. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  68219. /**
  68220. * Block used to compute fresnel value
  68221. */
  68222. export class FresnelBlock extends NodeMaterialBlock {
  68223. /**
  68224. * Create a new FresnelBlock
  68225. * @param name defines the block name
  68226. */
  68227. constructor(name: string);
  68228. /**
  68229. * Gets the current class name
  68230. * @returns the class name
  68231. */
  68232. getClassName(): string;
  68233. /**
  68234. * Gets the world normal input component
  68235. */
  68236. get worldNormal(): NodeMaterialConnectionPoint;
  68237. /**
  68238. * Gets the view direction input component
  68239. */
  68240. get viewDirection(): NodeMaterialConnectionPoint;
  68241. /**
  68242. * Gets the bias input component
  68243. */
  68244. get bias(): NodeMaterialConnectionPoint;
  68245. /**
  68246. * Gets the camera (or eye) position component
  68247. */
  68248. get power(): NodeMaterialConnectionPoint;
  68249. /**
  68250. * Gets the fresnel output component
  68251. */
  68252. get fresnel(): NodeMaterialConnectionPoint;
  68253. autoConfigure(material: NodeMaterial): void;
  68254. protected _buildBlock(state: NodeMaterialBuildState): this;
  68255. }
  68256. }
  68257. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  68258. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68259. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68260. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68261. /**
  68262. * Block used to get the max of 2 values
  68263. */
  68264. export class MaxBlock extends NodeMaterialBlock {
  68265. /**
  68266. * Creates a new MaxBlock
  68267. * @param name defines the block name
  68268. */
  68269. constructor(name: string);
  68270. /**
  68271. * Gets the current class name
  68272. * @returns the class name
  68273. */
  68274. getClassName(): string;
  68275. /**
  68276. * Gets the left operand input component
  68277. */
  68278. get left(): NodeMaterialConnectionPoint;
  68279. /**
  68280. * Gets the right operand input component
  68281. */
  68282. get right(): NodeMaterialConnectionPoint;
  68283. /**
  68284. * Gets the output component
  68285. */
  68286. get output(): NodeMaterialConnectionPoint;
  68287. protected _buildBlock(state: NodeMaterialBuildState): this;
  68288. }
  68289. }
  68290. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  68291. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68292. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68293. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68294. /**
  68295. * Block used to get the min of 2 values
  68296. */
  68297. export class MinBlock extends NodeMaterialBlock {
  68298. /**
  68299. * Creates a new MinBlock
  68300. * @param name defines the block name
  68301. */
  68302. constructor(name: string);
  68303. /**
  68304. * Gets the current class name
  68305. * @returns the class name
  68306. */
  68307. getClassName(): string;
  68308. /**
  68309. * Gets the left operand input component
  68310. */
  68311. get left(): NodeMaterialConnectionPoint;
  68312. /**
  68313. * Gets the right operand input component
  68314. */
  68315. get right(): NodeMaterialConnectionPoint;
  68316. /**
  68317. * Gets the output component
  68318. */
  68319. get output(): NodeMaterialConnectionPoint;
  68320. protected _buildBlock(state: NodeMaterialBuildState): this;
  68321. }
  68322. }
  68323. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  68324. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68325. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68326. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68327. /**
  68328. * Block used to get the distance between 2 values
  68329. */
  68330. export class DistanceBlock extends NodeMaterialBlock {
  68331. /**
  68332. * Creates a new DistanceBlock
  68333. * @param name defines the block name
  68334. */
  68335. constructor(name: string);
  68336. /**
  68337. * Gets the current class name
  68338. * @returns the class name
  68339. */
  68340. getClassName(): string;
  68341. /**
  68342. * Gets the left operand input component
  68343. */
  68344. get left(): NodeMaterialConnectionPoint;
  68345. /**
  68346. * Gets the right operand input component
  68347. */
  68348. get right(): NodeMaterialConnectionPoint;
  68349. /**
  68350. * Gets the output component
  68351. */
  68352. get output(): NodeMaterialConnectionPoint;
  68353. protected _buildBlock(state: NodeMaterialBuildState): this;
  68354. }
  68355. }
  68356. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  68357. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68358. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68359. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68360. /**
  68361. * Block used to get the length of a vector
  68362. */
  68363. export class LengthBlock extends NodeMaterialBlock {
  68364. /**
  68365. * Creates a new LengthBlock
  68366. * @param name defines the block name
  68367. */
  68368. constructor(name: string);
  68369. /**
  68370. * Gets the current class name
  68371. * @returns the class name
  68372. */
  68373. getClassName(): string;
  68374. /**
  68375. * Gets the value input component
  68376. */
  68377. get value(): NodeMaterialConnectionPoint;
  68378. /**
  68379. * Gets the output component
  68380. */
  68381. get output(): NodeMaterialConnectionPoint;
  68382. protected _buildBlock(state: NodeMaterialBuildState): this;
  68383. }
  68384. }
  68385. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  68386. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68387. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68388. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68389. /**
  68390. * Block used to get negative version of a value (i.e. x * -1)
  68391. */
  68392. export class NegateBlock extends NodeMaterialBlock {
  68393. /**
  68394. * Creates a new NegateBlock
  68395. * @param name defines the block name
  68396. */
  68397. constructor(name: string);
  68398. /**
  68399. * Gets the current class name
  68400. * @returns the class name
  68401. */
  68402. getClassName(): string;
  68403. /**
  68404. * Gets the value input component
  68405. */
  68406. get value(): NodeMaterialConnectionPoint;
  68407. /**
  68408. * Gets the output component
  68409. */
  68410. get output(): NodeMaterialConnectionPoint;
  68411. protected _buildBlock(state: NodeMaterialBuildState): this;
  68412. }
  68413. }
  68414. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  68415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68416. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68417. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68418. /**
  68419. * Block used to get the value of the first parameter raised to the power of the second
  68420. */
  68421. export class PowBlock extends NodeMaterialBlock {
  68422. /**
  68423. * Creates a new PowBlock
  68424. * @param name defines the block name
  68425. */
  68426. constructor(name: string);
  68427. /**
  68428. * Gets the current class name
  68429. * @returns the class name
  68430. */
  68431. getClassName(): string;
  68432. /**
  68433. * Gets the value operand input component
  68434. */
  68435. get value(): NodeMaterialConnectionPoint;
  68436. /**
  68437. * Gets the power operand input component
  68438. */
  68439. get power(): NodeMaterialConnectionPoint;
  68440. /**
  68441. * Gets the output component
  68442. */
  68443. get output(): NodeMaterialConnectionPoint;
  68444. protected _buildBlock(state: NodeMaterialBuildState): this;
  68445. }
  68446. }
  68447. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  68448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68450. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68451. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68452. /**
  68453. * Block used to get a random number
  68454. */
  68455. export class RandomNumberBlock extends NodeMaterialBlock {
  68456. /**
  68457. * Creates a new RandomNumberBlock
  68458. * @param name defines the block name
  68459. */
  68460. constructor(name: string);
  68461. /**
  68462. * Gets the current class name
  68463. * @returns the class name
  68464. */
  68465. getClassName(): string;
  68466. /**
  68467. * Gets the seed input component
  68468. */
  68469. get seed(): NodeMaterialConnectionPoint;
  68470. /**
  68471. * Gets the output component
  68472. */
  68473. get output(): NodeMaterialConnectionPoint;
  68474. protected _buildBlock(state: NodeMaterialBuildState): this;
  68475. }
  68476. }
  68477. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  68478. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68479. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68480. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68481. /**
  68482. * Block used to compute arc tangent of 2 values
  68483. */
  68484. export class ArcTan2Block extends NodeMaterialBlock {
  68485. /**
  68486. * Creates a new ArcTan2Block
  68487. * @param name defines the block name
  68488. */
  68489. constructor(name: string);
  68490. /**
  68491. * Gets the current class name
  68492. * @returns the class name
  68493. */
  68494. getClassName(): string;
  68495. /**
  68496. * Gets the x operand input component
  68497. */
  68498. get x(): NodeMaterialConnectionPoint;
  68499. /**
  68500. * Gets the y operand input component
  68501. */
  68502. get y(): NodeMaterialConnectionPoint;
  68503. /**
  68504. * Gets the output component
  68505. */
  68506. get output(): NodeMaterialConnectionPoint;
  68507. protected _buildBlock(state: NodeMaterialBuildState): this;
  68508. }
  68509. }
  68510. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  68511. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68512. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68513. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68514. /**
  68515. * Block used to smooth step a value
  68516. */
  68517. export class SmoothStepBlock extends NodeMaterialBlock {
  68518. /**
  68519. * Creates a new SmoothStepBlock
  68520. * @param name defines the block name
  68521. */
  68522. constructor(name: string);
  68523. /**
  68524. * Gets the current class name
  68525. * @returns the class name
  68526. */
  68527. getClassName(): string;
  68528. /**
  68529. * Gets the value operand input component
  68530. */
  68531. get value(): NodeMaterialConnectionPoint;
  68532. /**
  68533. * Gets the first edge operand input component
  68534. */
  68535. get edge0(): NodeMaterialConnectionPoint;
  68536. /**
  68537. * Gets the second edge operand input component
  68538. */
  68539. get edge1(): NodeMaterialConnectionPoint;
  68540. /**
  68541. * Gets the output component
  68542. */
  68543. get output(): NodeMaterialConnectionPoint;
  68544. protected _buildBlock(state: NodeMaterialBuildState): this;
  68545. }
  68546. }
  68547. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  68548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68551. /**
  68552. * Block used to get the reciprocal (1 / x) of a value
  68553. */
  68554. export class ReciprocalBlock extends NodeMaterialBlock {
  68555. /**
  68556. * Creates a new ReciprocalBlock
  68557. * @param name defines the block name
  68558. */
  68559. constructor(name: string);
  68560. /**
  68561. * Gets the current class name
  68562. * @returns the class name
  68563. */
  68564. getClassName(): string;
  68565. /**
  68566. * Gets the input component
  68567. */
  68568. get input(): NodeMaterialConnectionPoint;
  68569. /**
  68570. * Gets the output component
  68571. */
  68572. get output(): NodeMaterialConnectionPoint;
  68573. protected _buildBlock(state: NodeMaterialBuildState): this;
  68574. }
  68575. }
  68576. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  68577. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68578. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68579. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68580. /**
  68581. * Block used to replace a color by another one
  68582. */
  68583. export class ReplaceColorBlock extends NodeMaterialBlock {
  68584. /**
  68585. * Creates a new ReplaceColorBlock
  68586. * @param name defines the block name
  68587. */
  68588. constructor(name: string);
  68589. /**
  68590. * Gets the current class name
  68591. * @returns the class name
  68592. */
  68593. getClassName(): string;
  68594. /**
  68595. * Gets the value input component
  68596. */
  68597. get value(): NodeMaterialConnectionPoint;
  68598. /**
  68599. * Gets the reference input component
  68600. */
  68601. get reference(): NodeMaterialConnectionPoint;
  68602. /**
  68603. * Gets the distance input component
  68604. */
  68605. get distance(): NodeMaterialConnectionPoint;
  68606. /**
  68607. * Gets the replacement input component
  68608. */
  68609. get replacement(): NodeMaterialConnectionPoint;
  68610. /**
  68611. * Gets the output component
  68612. */
  68613. get output(): NodeMaterialConnectionPoint;
  68614. protected _buildBlock(state: NodeMaterialBuildState): this;
  68615. }
  68616. }
  68617. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  68618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68621. /**
  68622. * Block used to posterize a value
  68623. * @see https://en.wikipedia.org/wiki/Posterization
  68624. */
  68625. export class PosterizeBlock extends NodeMaterialBlock {
  68626. /**
  68627. * Creates a new PosterizeBlock
  68628. * @param name defines the block name
  68629. */
  68630. constructor(name: string);
  68631. /**
  68632. * Gets the current class name
  68633. * @returns the class name
  68634. */
  68635. getClassName(): string;
  68636. /**
  68637. * Gets the value input component
  68638. */
  68639. get value(): NodeMaterialConnectionPoint;
  68640. /**
  68641. * Gets the steps input component
  68642. */
  68643. get steps(): NodeMaterialConnectionPoint;
  68644. /**
  68645. * Gets the output component
  68646. */
  68647. get output(): NodeMaterialConnectionPoint;
  68648. protected _buildBlock(state: NodeMaterialBuildState): this;
  68649. }
  68650. }
  68651. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  68652. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68653. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68654. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68655. import { Scene } from "babylonjs/scene";
  68656. /**
  68657. * Operations supported by the Wave block
  68658. */
  68659. export enum WaveBlockKind {
  68660. /** SawTooth */
  68661. SawTooth = 0,
  68662. /** Square */
  68663. Square = 1,
  68664. /** Triangle */
  68665. Triangle = 2
  68666. }
  68667. /**
  68668. * Block used to apply wave operation to floats
  68669. */
  68670. export class WaveBlock extends NodeMaterialBlock {
  68671. /**
  68672. * Gets or sets the kibnd of wave to be applied by the block
  68673. */
  68674. kind: WaveBlockKind;
  68675. /**
  68676. * Creates a new WaveBlock
  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 input component
  68687. */
  68688. get input(): NodeMaterialConnectionPoint;
  68689. /**
  68690. * Gets the output component
  68691. */
  68692. get output(): NodeMaterialConnectionPoint;
  68693. protected _buildBlock(state: NodeMaterialBuildState): this;
  68694. serialize(): any;
  68695. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68696. }
  68697. }
  68698. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  68699. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68700. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68701. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68702. import { Color3 } from "babylonjs/Maths/math.color";
  68703. import { Scene } from "babylonjs/scene";
  68704. import { Observable } from "babylonjs/Misc/observable";
  68705. /**
  68706. * Class used to store a color step for the GradientBlock
  68707. */
  68708. export class GradientBlockColorStep {
  68709. private _step;
  68710. /**
  68711. * Gets value indicating which step this color is associated with (between 0 and 1)
  68712. */
  68713. get step(): number;
  68714. /**
  68715. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68716. */
  68717. set step(val: number);
  68718. private _color;
  68719. /**
  68720. * Gets the color associated with this step
  68721. */
  68722. get color(): Color3;
  68723. /**
  68724. * Sets the color associated with this step
  68725. */
  68726. set color(val: Color3);
  68727. /**
  68728. * Creates a new GradientBlockColorStep
  68729. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68730. * @param color defines the color associated with this step
  68731. */
  68732. constructor(step: number, color: Color3);
  68733. }
  68734. /**
  68735. * Block used to return a color from a gradient based on an input value between 0 and 1
  68736. */
  68737. export class GradientBlock extends NodeMaterialBlock {
  68738. /**
  68739. * Gets or sets the list of color steps
  68740. */
  68741. colorSteps: GradientBlockColorStep[];
  68742. /** Gets an observable raised when the value is changed */
  68743. onValueChangedObservable: Observable<GradientBlock>;
  68744. /** calls observable when the value is changed*/
  68745. colorStepsUpdated(): void;
  68746. /**
  68747. * Creates a new GradientBlock
  68748. * @param name defines the block name
  68749. */
  68750. constructor(name: string);
  68751. /**
  68752. * Gets the current class name
  68753. * @returns the class name
  68754. */
  68755. getClassName(): string;
  68756. /**
  68757. * Gets the gradient input component
  68758. */
  68759. get gradient(): NodeMaterialConnectionPoint;
  68760. /**
  68761. * Gets the output component
  68762. */
  68763. get output(): NodeMaterialConnectionPoint;
  68764. private _writeColorConstant;
  68765. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68766. serialize(): any;
  68767. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68768. protected _dumpPropertiesCode(): string;
  68769. }
  68770. }
  68771. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  68772. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68773. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68774. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68775. /**
  68776. * Block used to normalize lerp between 2 values
  68777. */
  68778. export class NLerpBlock extends NodeMaterialBlock {
  68779. /**
  68780. * Creates a new NLerpBlock
  68781. * @param name defines the block name
  68782. */
  68783. constructor(name: string);
  68784. /**
  68785. * Gets the current class name
  68786. * @returns the class name
  68787. */
  68788. getClassName(): string;
  68789. /**
  68790. * Gets the left operand input component
  68791. */
  68792. get left(): NodeMaterialConnectionPoint;
  68793. /**
  68794. * Gets the right operand input component
  68795. */
  68796. get right(): NodeMaterialConnectionPoint;
  68797. /**
  68798. * Gets the gradient operand input component
  68799. */
  68800. get gradient(): NodeMaterialConnectionPoint;
  68801. /**
  68802. * Gets the output component
  68803. */
  68804. get output(): NodeMaterialConnectionPoint;
  68805. protected _buildBlock(state: NodeMaterialBuildState): this;
  68806. }
  68807. }
  68808. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  68809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68812. import { Scene } from "babylonjs/scene";
  68813. /**
  68814. * block used to Generate a Worley Noise 3D Noise Pattern
  68815. */
  68816. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68817. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68818. manhattanDistance: boolean;
  68819. /**
  68820. * Creates a new WorleyNoise3DBlock
  68821. * @param name defines the block name
  68822. */
  68823. constructor(name: string);
  68824. /**
  68825. * Gets the current class name
  68826. * @returns the class name
  68827. */
  68828. getClassName(): string;
  68829. /**
  68830. * Gets the seed input component
  68831. */
  68832. get seed(): NodeMaterialConnectionPoint;
  68833. /**
  68834. * Gets the jitter input component
  68835. */
  68836. get jitter(): NodeMaterialConnectionPoint;
  68837. /**
  68838. * Gets the output component
  68839. */
  68840. get output(): NodeMaterialConnectionPoint;
  68841. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68842. /**
  68843. * Exposes the properties to the UI?
  68844. */
  68845. protected _dumpPropertiesCode(): string;
  68846. /**
  68847. * Exposes the properties to the Seralize?
  68848. */
  68849. serialize(): any;
  68850. /**
  68851. * Exposes the properties to the deseralize?
  68852. */
  68853. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68854. }
  68855. }
  68856. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  68857. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68858. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68859. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68860. /**
  68861. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68862. */
  68863. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68864. /**
  68865. * Creates a new SimplexPerlin3DBlock
  68866. * @param name defines the block name
  68867. */
  68868. constructor(name: string);
  68869. /**
  68870. * Gets the current class name
  68871. * @returns the class name
  68872. */
  68873. getClassName(): string;
  68874. /**
  68875. * Gets the seed operand input component
  68876. */
  68877. get seed(): NodeMaterialConnectionPoint;
  68878. /**
  68879. * Gets the output component
  68880. */
  68881. get output(): NodeMaterialConnectionPoint;
  68882. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68883. }
  68884. }
  68885. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  68886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68888. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68889. /**
  68890. * Block used to blend normals
  68891. */
  68892. export class NormalBlendBlock extends NodeMaterialBlock {
  68893. /**
  68894. * Creates a new NormalBlendBlock
  68895. * @param name defines the block name
  68896. */
  68897. constructor(name: string);
  68898. /**
  68899. * Gets the current class name
  68900. * @returns the class name
  68901. */
  68902. getClassName(): string;
  68903. /**
  68904. * Gets the first input component
  68905. */
  68906. get normalMap0(): NodeMaterialConnectionPoint;
  68907. /**
  68908. * Gets the second input component
  68909. */
  68910. get normalMap1(): NodeMaterialConnectionPoint;
  68911. /**
  68912. * Gets the output component
  68913. */
  68914. get output(): NodeMaterialConnectionPoint;
  68915. protected _buildBlock(state: NodeMaterialBuildState): this;
  68916. }
  68917. }
  68918. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68919. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68920. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68921. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68922. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68923. /**
  68924. * Block used to rotate a 2d vector by a given angle
  68925. */
  68926. export class Rotate2dBlock extends NodeMaterialBlock {
  68927. /**
  68928. * Creates a new Rotate2dBlock
  68929. * @param name defines the block name
  68930. */
  68931. constructor(name: string);
  68932. /**
  68933. * Gets the current class name
  68934. * @returns the class name
  68935. */
  68936. getClassName(): string;
  68937. /**
  68938. * Gets the input vector
  68939. */
  68940. get input(): NodeMaterialConnectionPoint;
  68941. /**
  68942. * Gets the input angle
  68943. */
  68944. get angle(): NodeMaterialConnectionPoint;
  68945. /**
  68946. * Gets the output component
  68947. */
  68948. get output(): NodeMaterialConnectionPoint;
  68949. autoConfigure(material: NodeMaterial): void;
  68950. protected _buildBlock(state: NodeMaterialBuildState): this;
  68951. }
  68952. }
  68953. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68954. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68955. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68956. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68957. /**
  68958. * Block used to get the reflected vector from a direction and a normal
  68959. */
  68960. export class ReflectBlock extends NodeMaterialBlock {
  68961. /**
  68962. * Creates a new ReflectBlock
  68963. * @param name defines the block name
  68964. */
  68965. constructor(name: string);
  68966. /**
  68967. * Gets the current class name
  68968. * @returns the class name
  68969. */
  68970. getClassName(): string;
  68971. /**
  68972. * Gets the incident component
  68973. */
  68974. get incident(): NodeMaterialConnectionPoint;
  68975. /**
  68976. * Gets the normal component
  68977. */
  68978. get normal(): NodeMaterialConnectionPoint;
  68979. /**
  68980. * Gets the output component
  68981. */
  68982. get output(): NodeMaterialConnectionPoint;
  68983. protected _buildBlock(state: NodeMaterialBuildState): this;
  68984. }
  68985. }
  68986. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68987. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68988. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68989. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68990. /**
  68991. * Block used to get the refracted vector from a direction and a normal
  68992. */
  68993. export class RefractBlock extends NodeMaterialBlock {
  68994. /**
  68995. * Creates a new RefractBlock
  68996. * @param name defines the block name
  68997. */
  68998. constructor(name: string);
  68999. /**
  69000. * Gets the current class name
  69001. * @returns the class name
  69002. */
  69003. getClassName(): string;
  69004. /**
  69005. * Gets the incident component
  69006. */
  69007. get incident(): NodeMaterialConnectionPoint;
  69008. /**
  69009. * Gets the normal component
  69010. */
  69011. get normal(): NodeMaterialConnectionPoint;
  69012. /**
  69013. * Gets the index of refraction component
  69014. */
  69015. get ior(): NodeMaterialConnectionPoint;
  69016. /**
  69017. * Gets the output component
  69018. */
  69019. get output(): NodeMaterialConnectionPoint;
  69020. protected _buildBlock(state: NodeMaterialBuildState): this;
  69021. }
  69022. }
  69023. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  69024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69027. /**
  69028. * Block used to desaturate a color
  69029. */
  69030. export class DesaturateBlock extends NodeMaterialBlock {
  69031. /**
  69032. * Creates a new DesaturateBlock
  69033. * @param name defines the block name
  69034. */
  69035. constructor(name: string);
  69036. /**
  69037. * Gets the current class name
  69038. * @returns the class name
  69039. */
  69040. getClassName(): string;
  69041. /**
  69042. * Gets the color operand input component
  69043. */
  69044. get color(): NodeMaterialConnectionPoint;
  69045. /**
  69046. * Gets the level operand input component
  69047. */
  69048. get level(): NodeMaterialConnectionPoint;
  69049. /**
  69050. * Gets the output component
  69051. */
  69052. get output(): NodeMaterialConnectionPoint;
  69053. protected _buildBlock(state: NodeMaterialBuildState): this;
  69054. }
  69055. }
  69056. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  69057. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69058. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69059. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69060. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  69061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69062. import { Nullable } from "babylonjs/types";
  69063. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69064. import { Mesh } from "babylonjs/Meshes/mesh";
  69065. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69066. import { Effect } from "babylonjs/Materials/effect";
  69067. import { Scene } from "babylonjs/scene";
  69068. /**
  69069. * Block used to implement the reflection module of the PBR material
  69070. */
  69071. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  69072. /** @hidden */
  69073. _defineLODReflectionAlpha: string;
  69074. /** @hidden */
  69075. _defineLinearSpecularReflection: string;
  69076. private _vEnvironmentIrradianceName;
  69077. /** @hidden */
  69078. _vReflectionMicrosurfaceInfosName: string;
  69079. /** @hidden */
  69080. _vReflectionInfosName: string;
  69081. /** @hidden */
  69082. _vReflectionFilteringInfoName: string;
  69083. private _scene;
  69084. /**
  69085. * The properties below are set by the main PBR block prior to calling methods of this class.
  69086. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69087. * It's less burden on the user side in the editor part.
  69088. */
  69089. /** @hidden */
  69090. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69091. /** @hidden */
  69092. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69093. /** @hidden */
  69094. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  69095. /** @hidden */
  69096. viewConnectionPoint: NodeMaterialConnectionPoint;
  69097. /**
  69098. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  69099. * diffuse part of the IBL.
  69100. */
  69101. useSphericalHarmonics: boolean;
  69102. /**
  69103. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  69104. */
  69105. forceIrradianceInFragment: boolean;
  69106. /**
  69107. * Create a new ReflectionBlock
  69108. * @param name defines the block name
  69109. */
  69110. constructor(name: string);
  69111. /**
  69112. * Gets the current class name
  69113. * @returns the class name
  69114. */
  69115. getClassName(): string;
  69116. /**
  69117. * Gets the position input component
  69118. */
  69119. get position(): NodeMaterialConnectionPoint;
  69120. /**
  69121. * Gets the world position input component
  69122. */
  69123. get worldPosition(): NodeMaterialConnectionPoint;
  69124. /**
  69125. * Gets the world normal input component
  69126. */
  69127. get worldNormal(): NodeMaterialConnectionPoint;
  69128. /**
  69129. * Gets the world input component
  69130. */
  69131. get world(): NodeMaterialConnectionPoint;
  69132. /**
  69133. * Gets the camera (or eye) position component
  69134. */
  69135. get cameraPosition(): NodeMaterialConnectionPoint;
  69136. /**
  69137. * Gets the view input component
  69138. */
  69139. get view(): NodeMaterialConnectionPoint;
  69140. /**
  69141. * Gets the color input component
  69142. */
  69143. get color(): NodeMaterialConnectionPoint;
  69144. /**
  69145. * Gets the reflection object output component
  69146. */
  69147. get reflection(): NodeMaterialConnectionPoint;
  69148. /**
  69149. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  69150. */
  69151. get hasTexture(): boolean;
  69152. /**
  69153. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  69154. */
  69155. get reflectionColor(): string;
  69156. protected _getTexture(): Nullable<BaseTexture>;
  69157. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69158. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69159. /**
  69160. * Gets the code to inject in the vertex shader
  69161. * @param state current state of the node material building
  69162. * @returns the shader code
  69163. */
  69164. handleVertexSide(state: NodeMaterialBuildState): string;
  69165. /**
  69166. * Gets the main code of the block (fragment side)
  69167. * @param state current state of the node material building
  69168. * @param normalVarName name of the existing variable corresponding to the normal
  69169. * @returns the shader code
  69170. */
  69171. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  69172. protected _buildBlock(state: NodeMaterialBuildState): this;
  69173. protected _dumpPropertiesCode(): string;
  69174. serialize(): any;
  69175. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69176. }
  69177. }
  69178. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  69179. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69181. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69182. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69184. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69185. import { Scene } from "babylonjs/scene";
  69186. import { Nullable } from "babylonjs/types";
  69187. /**
  69188. * Block used to implement the sheen module of the PBR material
  69189. */
  69190. export class SheenBlock extends NodeMaterialBlock {
  69191. /**
  69192. * Create a new SheenBlock
  69193. * @param name defines the block name
  69194. */
  69195. constructor(name: string);
  69196. /**
  69197. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  69198. * It allows the strength of the sheen effect to not depend on the base color of the material,
  69199. * making it easier to setup and tweak the effect
  69200. */
  69201. albedoScaling: boolean;
  69202. /**
  69203. * Defines if the sheen is linked to the sheen color.
  69204. */
  69205. linkSheenWithAlbedo: boolean;
  69206. /**
  69207. * Initialize the block and prepare the context for build
  69208. * @param state defines the state that will be used for the build
  69209. */
  69210. initialize(state: NodeMaterialBuildState): void;
  69211. /**
  69212. * Gets the current class name
  69213. * @returns the class name
  69214. */
  69215. getClassName(): string;
  69216. /**
  69217. * Gets the intensity input component
  69218. */
  69219. get intensity(): NodeMaterialConnectionPoint;
  69220. /**
  69221. * Gets the color input component
  69222. */
  69223. get color(): NodeMaterialConnectionPoint;
  69224. /**
  69225. * Gets the roughness input component
  69226. */
  69227. get roughness(): NodeMaterialConnectionPoint;
  69228. /**
  69229. * Gets the sheen object output component
  69230. */
  69231. get sheen(): NodeMaterialConnectionPoint;
  69232. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69233. /**
  69234. * Gets the main code of the block (fragment side)
  69235. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69236. * @returns the shader code
  69237. */
  69238. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  69239. protected _buildBlock(state: NodeMaterialBuildState): this;
  69240. protected _dumpPropertiesCode(): string;
  69241. serialize(): any;
  69242. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69243. }
  69244. }
  69245. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  69246. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69247. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69248. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69249. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69251. /**
  69252. * Block used to implement the anisotropy module of the PBR material
  69253. */
  69254. export class AnisotropyBlock extends NodeMaterialBlock {
  69255. /**
  69256. * The two properties below are set by the main PBR block prior to calling methods of this class.
  69257. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69258. * It's less burden on the user side in the editor part.
  69259. */
  69260. /** @hidden */
  69261. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69262. /** @hidden */
  69263. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69264. /**
  69265. * Create a new AnisotropyBlock
  69266. * @param name defines the block name
  69267. */
  69268. constructor(name: string);
  69269. /**
  69270. * Initialize the block and prepare the context for build
  69271. * @param state defines the state that will be used for the build
  69272. */
  69273. initialize(state: NodeMaterialBuildState): void;
  69274. /**
  69275. * Gets the current class name
  69276. * @returns the class name
  69277. */
  69278. getClassName(): string;
  69279. /**
  69280. * Gets the intensity input component
  69281. */
  69282. get intensity(): NodeMaterialConnectionPoint;
  69283. /**
  69284. * Gets the direction input component
  69285. */
  69286. get direction(): NodeMaterialConnectionPoint;
  69287. /**
  69288. * Gets the uv input component
  69289. */
  69290. get uv(): NodeMaterialConnectionPoint;
  69291. /**
  69292. * Gets the worldTangent input component
  69293. */
  69294. get worldTangent(): NodeMaterialConnectionPoint;
  69295. /**
  69296. * Gets the anisotropy object output component
  69297. */
  69298. get anisotropy(): NodeMaterialConnectionPoint;
  69299. private _generateTBNSpace;
  69300. /**
  69301. * Gets the main code of the block (fragment side)
  69302. * @param state current state of the node material building
  69303. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69304. * @returns the shader code
  69305. */
  69306. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69307. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69308. protected _buildBlock(state: NodeMaterialBuildState): this;
  69309. }
  69310. }
  69311. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  69312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69313. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69314. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69315. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69316. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69317. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69318. import { Scene } from "babylonjs/scene";
  69319. import { Nullable } from "babylonjs/types";
  69320. import { Mesh } from "babylonjs/Meshes/mesh";
  69321. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69322. import { Effect } from "babylonjs/Materials/effect";
  69323. /**
  69324. * Block used to implement the clear coat module of the PBR material
  69325. */
  69326. export class ClearCoatBlock extends NodeMaterialBlock {
  69327. private _scene;
  69328. /**
  69329. * Create a new ClearCoatBlock
  69330. * @param name defines the block name
  69331. */
  69332. constructor(name: string);
  69333. /**
  69334. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69335. */
  69336. remapF0OnInterfaceChange: boolean;
  69337. /**
  69338. * Initialize the block and prepare the context for build
  69339. * @param state defines the state that will be used for the build
  69340. */
  69341. initialize(state: NodeMaterialBuildState): void;
  69342. /**
  69343. * Gets the current class name
  69344. * @returns the class name
  69345. */
  69346. getClassName(): string;
  69347. /**
  69348. * Gets the intensity input component
  69349. */
  69350. get intensity(): NodeMaterialConnectionPoint;
  69351. /**
  69352. * Gets the roughness input component
  69353. */
  69354. get roughness(): NodeMaterialConnectionPoint;
  69355. /**
  69356. * Gets the ior input component
  69357. */
  69358. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69359. /**
  69360. * Gets the bump texture input component
  69361. */
  69362. get normalMapColor(): NodeMaterialConnectionPoint;
  69363. /**
  69364. * Gets the uv input component
  69365. */
  69366. get uv(): NodeMaterialConnectionPoint;
  69367. /**
  69368. * Gets the tint color input component
  69369. */
  69370. get tintColor(): NodeMaterialConnectionPoint;
  69371. /**
  69372. * Gets the tint "at distance" input component
  69373. */
  69374. get tintAtDistance(): NodeMaterialConnectionPoint;
  69375. /**
  69376. * Gets the tint thickness input component
  69377. */
  69378. get tintThickness(): NodeMaterialConnectionPoint;
  69379. /**
  69380. * Gets the world tangent input component
  69381. */
  69382. get worldTangent(): NodeMaterialConnectionPoint;
  69383. /**
  69384. * Gets the clear coat object output component
  69385. */
  69386. get clearcoat(): NodeMaterialConnectionPoint;
  69387. autoConfigure(material: NodeMaterial): void;
  69388. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69389. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69390. private _generateTBNSpace;
  69391. /**
  69392. * Gets the main code of the block (fragment side)
  69393. * @param state current state of the node material building
  69394. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69395. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69396. * @param worldPosVarName name of the variable holding the world position
  69397. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69398. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69399. * @param worldNormalVarName name of the variable holding the world normal
  69400. * @returns the shader code
  69401. */
  69402. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69403. protected _buildBlock(state: NodeMaterialBuildState): this;
  69404. protected _dumpPropertiesCode(): string;
  69405. serialize(): any;
  69406. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69407. }
  69408. }
  69409. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  69410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69411. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69412. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69413. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69415. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69416. import { Nullable } from "babylonjs/types";
  69417. /**
  69418. * Block used to implement the sub surface module of the PBR material
  69419. */
  69420. export class SubSurfaceBlock extends NodeMaterialBlock {
  69421. /**
  69422. * Create a new SubSurfaceBlock
  69423. * @param name defines the block name
  69424. */
  69425. constructor(name: string);
  69426. /**
  69427. * Initialize the block and prepare the context for build
  69428. * @param state defines the state that will be used for the build
  69429. */
  69430. initialize(state: NodeMaterialBuildState): void;
  69431. /**
  69432. * Gets the current class name
  69433. * @returns the class name
  69434. */
  69435. getClassName(): string;
  69436. /**
  69437. * Gets the thickness component
  69438. */
  69439. get thickness(): NodeMaterialConnectionPoint;
  69440. /**
  69441. * Gets the tint color input component
  69442. */
  69443. get tintColor(): NodeMaterialConnectionPoint;
  69444. /**
  69445. * Gets the translucency intensity input component
  69446. */
  69447. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69448. /**
  69449. * Gets the translucency diffusion distance input component
  69450. */
  69451. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69452. /**
  69453. * Gets the refraction object parameters
  69454. */
  69455. get refraction(): NodeMaterialConnectionPoint;
  69456. /**
  69457. * Gets the sub surface object output component
  69458. */
  69459. get subsurface(): NodeMaterialConnectionPoint;
  69460. autoConfigure(material: NodeMaterial): void;
  69461. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69462. /**
  69463. * Gets the main code of the block (fragment side)
  69464. * @param state current state of the node material building
  69465. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69466. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69467. * @param worldPosVarName name of the variable holding the world position
  69468. * @returns the shader code
  69469. */
  69470. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69471. protected _buildBlock(state: NodeMaterialBuildState): this;
  69472. }
  69473. }
  69474. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  69475. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69476. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69477. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69478. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69479. import { Light } from "babylonjs/Lights/light";
  69480. import { Nullable } from "babylonjs/types";
  69481. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69482. import { Effect } from "babylonjs/Materials/effect";
  69483. import { Mesh } from "babylonjs/Meshes/mesh";
  69484. import { Scene } from "babylonjs/scene";
  69485. /**
  69486. * Block used to implement the PBR metallic/roughness model
  69487. */
  69488. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69489. /**
  69490. * Gets or sets the light associated with this block
  69491. */
  69492. light: Nullable<Light>;
  69493. private _lightId;
  69494. private _scene;
  69495. private _environmentBRDFTexture;
  69496. private _environmentBrdfSamplerName;
  69497. private _vNormalWName;
  69498. private _invertNormalName;
  69499. private _metallicReflectanceColor;
  69500. private _metallicF0Factor;
  69501. private _vMetallicReflectanceFactorsName;
  69502. /**
  69503. * Create a new ReflectionBlock
  69504. * @param name defines the block name
  69505. */
  69506. constructor(name: string);
  69507. /**
  69508. * Intensity of the direct lights e.g. the four lights available in your scene.
  69509. * This impacts both the direct diffuse and specular highlights.
  69510. */
  69511. directIntensity: number;
  69512. /**
  69513. * Intensity of the environment e.g. how much the environment will light the object
  69514. * either through harmonics for rough material or through the refelction for shiny ones.
  69515. */
  69516. environmentIntensity: number;
  69517. /**
  69518. * This is a special control allowing the reduction of the specular highlights coming from the
  69519. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69520. */
  69521. specularIntensity: number;
  69522. /**
  69523. * Defines the falloff type used in this material.
  69524. * It by default is Physical.
  69525. */
  69526. lightFalloff: number;
  69527. /**
  69528. * Specifies that alpha test should be used
  69529. */
  69530. useAlphaTest: boolean;
  69531. /**
  69532. * Defines the alpha limits in alpha test mode.
  69533. */
  69534. alphaTestCutoff: number;
  69535. /**
  69536. * Specifies that alpha blending should be used
  69537. */
  69538. useAlphaBlending: boolean;
  69539. /**
  69540. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69541. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  69542. */
  69543. useRadianceOverAlpha: boolean;
  69544. /**
  69545. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69546. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  69547. */
  69548. useSpecularOverAlpha: boolean;
  69549. /**
  69550. * Enables specular anti aliasing in the PBR shader.
  69551. * It will both interacts on the Geometry for analytical and IBL lighting.
  69552. * It also prefilter the roughness map based on the bump values.
  69553. */
  69554. enableSpecularAntiAliasing: boolean;
  69555. /**
  69556. * Enables realtime filtering on the texture.
  69557. */
  69558. realTimeFiltering: boolean;
  69559. /**
  69560. * Quality switch for realtime filtering
  69561. */
  69562. realTimeFilteringQuality: number;
  69563. /**
  69564. * Defines if the material uses energy conservation.
  69565. */
  69566. useEnergyConservation: boolean;
  69567. /**
  69568. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69569. * too much the area relying on ambient texture to define their ambient occlusion.
  69570. */
  69571. useRadianceOcclusion: boolean;
  69572. /**
  69573. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69574. * makes the reflect vector face the model (under horizon).
  69575. */
  69576. useHorizonOcclusion: boolean;
  69577. /**
  69578. * If set to true, no lighting calculations will be applied.
  69579. */
  69580. unlit: boolean;
  69581. /**
  69582. * Force normal to face away from face.
  69583. */
  69584. forceNormalForward: boolean;
  69585. /**
  69586. * Defines the material debug mode.
  69587. * It helps seeing only some components of the material while troubleshooting.
  69588. */
  69589. debugMode: number;
  69590. /**
  69591. * Specify from where on screen the debug mode should start.
  69592. * The value goes from -1 (full screen) to 1 (not visible)
  69593. * It helps with side by side comparison against the final render
  69594. * This defaults to 0
  69595. */
  69596. debugLimit: number;
  69597. /**
  69598. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69599. * You can use the factor to better multiply the final value.
  69600. */
  69601. debugFactor: number;
  69602. /**
  69603. * Initialize the block and prepare the context for build
  69604. * @param state defines the state that will be used for the build
  69605. */
  69606. initialize(state: NodeMaterialBuildState): void;
  69607. /**
  69608. * Gets the current class name
  69609. * @returns the class name
  69610. */
  69611. getClassName(): string;
  69612. /**
  69613. * Gets the world position input component
  69614. */
  69615. get worldPosition(): NodeMaterialConnectionPoint;
  69616. /**
  69617. * Gets the world normal input component
  69618. */
  69619. get worldNormal(): NodeMaterialConnectionPoint;
  69620. /**
  69621. * Gets the view matrix parameter
  69622. */
  69623. get view(): NodeMaterialConnectionPoint;
  69624. /**
  69625. * Gets the camera position input component
  69626. */
  69627. get cameraPosition(): NodeMaterialConnectionPoint;
  69628. /**
  69629. * Gets the perturbed normal input component
  69630. */
  69631. get perturbedNormal(): NodeMaterialConnectionPoint;
  69632. /**
  69633. * Gets the base color input component
  69634. */
  69635. get baseColor(): NodeMaterialConnectionPoint;
  69636. /**
  69637. * Gets the metallic input component
  69638. */
  69639. get metallic(): NodeMaterialConnectionPoint;
  69640. /**
  69641. * Gets the roughness input component
  69642. */
  69643. get roughness(): NodeMaterialConnectionPoint;
  69644. /**
  69645. * Gets the ambient occlusion input component
  69646. */
  69647. get ambientOcc(): NodeMaterialConnectionPoint;
  69648. /**
  69649. * Gets the opacity input component
  69650. */
  69651. get opacity(): NodeMaterialConnectionPoint;
  69652. /**
  69653. * Gets the index of refraction input component
  69654. */
  69655. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69656. /**
  69657. * Gets the ambient color input component
  69658. */
  69659. get ambientColor(): NodeMaterialConnectionPoint;
  69660. /**
  69661. * Gets the reflection object parameters
  69662. */
  69663. get reflection(): NodeMaterialConnectionPoint;
  69664. /**
  69665. * Gets the clear coat object parameters
  69666. */
  69667. get clearcoat(): NodeMaterialConnectionPoint;
  69668. /**
  69669. * Gets the sheen object parameters
  69670. */
  69671. get sheen(): NodeMaterialConnectionPoint;
  69672. /**
  69673. * Gets the sub surface object parameters
  69674. */
  69675. get subsurface(): NodeMaterialConnectionPoint;
  69676. /**
  69677. * Gets the anisotropy object parameters
  69678. */
  69679. get anisotropy(): NodeMaterialConnectionPoint;
  69680. /**
  69681. * Gets the ambient output component
  69682. */
  69683. get ambientClr(): NodeMaterialConnectionPoint;
  69684. /**
  69685. * Gets the diffuse output component
  69686. */
  69687. get diffuseDir(): NodeMaterialConnectionPoint;
  69688. /**
  69689. * Gets the specular output component
  69690. */
  69691. get specularDir(): NodeMaterialConnectionPoint;
  69692. /**
  69693. * Gets the clear coat output component
  69694. */
  69695. get clearcoatDir(): NodeMaterialConnectionPoint;
  69696. /**
  69697. * Gets the sheen output component
  69698. */
  69699. get sheenDir(): NodeMaterialConnectionPoint;
  69700. /**
  69701. * Gets the indirect diffuse output component
  69702. */
  69703. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69704. /**
  69705. * Gets the indirect specular output component
  69706. */
  69707. get specularIndirect(): NodeMaterialConnectionPoint;
  69708. /**
  69709. * Gets the indirect clear coat output component
  69710. */
  69711. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69712. /**
  69713. * Gets the indirect sheen output component
  69714. */
  69715. get sheenIndirect(): NodeMaterialConnectionPoint;
  69716. /**
  69717. * Gets the refraction output component
  69718. */
  69719. get refraction(): NodeMaterialConnectionPoint;
  69720. /**
  69721. * Gets the global lighting output component
  69722. */
  69723. get lighting(): NodeMaterialConnectionPoint;
  69724. /**
  69725. * Gets the shadow output component
  69726. */
  69727. get shadow(): NodeMaterialConnectionPoint;
  69728. /**
  69729. * Gets the alpha output component
  69730. */
  69731. get alpha(): NodeMaterialConnectionPoint;
  69732. autoConfigure(material: NodeMaterial): void;
  69733. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69734. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69735. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69736. private _injectVertexCode;
  69737. private _getAlbedoOpacityCode;
  69738. private _getAmbientOcclusionCode;
  69739. private _getReflectivityCode;
  69740. protected _buildBlock(state: NodeMaterialBuildState): this;
  69741. protected _dumpPropertiesCode(): string;
  69742. serialize(): any;
  69743. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69744. }
  69745. }
  69746. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69747. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69748. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69749. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69750. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69751. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69752. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69753. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69754. }
  69755. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69756. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69757. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69758. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69759. }
  69760. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69761. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69762. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69763. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69764. /**
  69765. * Block used to compute value of one parameter modulo another
  69766. */
  69767. export class ModBlock extends NodeMaterialBlock {
  69768. /**
  69769. * Creates a new ModBlock
  69770. * @param name defines the block name
  69771. */
  69772. constructor(name: string);
  69773. /**
  69774. * Gets the current class name
  69775. * @returns the class name
  69776. */
  69777. getClassName(): string;
  69778. /**
  69779. * Gets the left operand input component
  69780. */
  69781. get left(): NodeMaterialConnectionPoint;
  69782. /**
  69783. * Gets the right operand input component
  69784. */
  69785. get right(): NodeMaterialConnectionPoint;
  69786. /**
  69787. * Gets the output component
  69788. */
  69789. get output(): NodeMaterialConnectionPoint;
  69790. protected _buildBlock(state: NodeMaterialBuildState): this;
  69791. }
  69792. }
  69793. declare module "babylonjs/Materials/Node/Blocks/index" {
  69794. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69795. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69796. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69797. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69798. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69799. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69800. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69801. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69802. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69803. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69804. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69805. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69806. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69807. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69808. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69809. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69810. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69811. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69812. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69813. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69814. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69815. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69816. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69817. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69818. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69819. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69820. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69821. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69822. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69823. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69824. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69825. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69826. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69827. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69828. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69829. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69830. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69831. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69832. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69833. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69834. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69835. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69836. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69837. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69838. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69839. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69840. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69841. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69842. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69843. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69844. }
  69845. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69846. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69847. }
  69848. declare module "babylonjs/Materials/Node/index" {
  69849. export * from "babylonjs/Materials/Node/Enums/index";
  69850. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69851. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69852. export * from "babylonjs/Materials/Node/nodeMaterial";
  69853. export * from "babylonjs/Materials/Node/Blocks/index";
  69854. export * from "babylonjs/Materials/Node/Optimizers/index";
  69855. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69856. }
  69857. declare module "babylonjs/Materials/index" {
  69858. export * from "babylonjs/Materials/Background/index";
  69859. export * from "babylonjs/Materials/colorCurves";
  69860. export * from "babylonjs/Materials/iEffectFallbacks";
  69861. export * from "babylonjs/Materials/effectFallbacks";
  69862. export * from "babylonjs/Materials/effect";
  69863. export * from "babylonjs/Materials/fresnelParameters";
  69864. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69865. export * from "babylonjs/Materials/material";
  69866. export * from "babylonjs/Materials/materialDefines";
  69867. export * from "babylonjs/Materials/thinMaterialHelper";
  69868. export * from "babylonjs/Materials/materialHelper";
  69869. export * from "babylonjs/Materials/multiMaterial";
  69870. export * from "babylonjs/Materials/PBR/index";
  69871. export * from "babylonjs/Materials/pushMaterial";
  69872. export * from "babylonjs/Materials/shaderMaterial";
  69873. export * from "babylonjs/Materials/standardMaterial";
  69874. export * from "babylonjs/Materials/Textures/index";
  69875. export * from "babylonjs/Materials/uniformBuffer";
  69876. export * from "babylonjs/Materials/materialFlags";
  69877. export * from "babylonjs/Materials/Node/index";
  69878. export * from "babylonjs/Materials/effectRenderer";
  69879. export * from "babylonjs/Materials/shadowDepthWrapper";
  69880. }
  69881. declare module "babylonjs/Maths/index" {
  69882. export * from "babylonjs/Maths/math.scalar";
  69883. export * from "babylonjs/Maths/math.functions";
  69884. export * from "babylonjs/Maths/math";
  69885. export * from "babylonjs/Maths/sphericalPolynomial";
  69886. }
  69887. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69888. import { IDisposable } from "babylonjs/scene";
  69889. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69890. /**
  69891. * Configuration for Draco compression
  69892. */
  69893. export interface IDracoCompressionConfiguration {
  69894. /**
  69895. * Configuration for the decoder.
  69896. */
  69897. decoder: {
  69898. /**
  69899. * The url to the WebAssembly module.
  69900. */
  69901. wasmUrl?: string;
  69902. /**
  69903. * The url to the WebAssembly binary.
  69904. */
  69905. wasmBinaryUrl?: string;
  69906. /**
  69907. * The url to the fallback JavaScript module.
  69908. */
  69909. fallbackUrl?: string;
  69910. };
  69911. }
  69912. /**
  69913. * Draco compression (https://google.github.io/draco/)
  69914. *
  69915. * This class wraps the Draco module.
  69916. *
  69917. * **Encoder**
  69918. *
  69919. * The encoder is not currently implemented.
  69920. *
  69921. * **Decoder**
  69922. *
  69923. * 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.
  69924. *
  69925. * To update the configuration, use the following code:
  69926. * ```javascript
  69927. * DracoCompression.Configuration = {
  69928. * decoder: {
  69929. * wasmUrl: "<url to the WebAssembly library>",
  69930. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69931. * fallbackUrl: "<url to the fallback JavaScript library>",
  69932. * }
  69933. * };
  69934. * ```
  69935. *
  69936. * 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.
  69937. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69938. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69939. *
  69940. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69941. * ```javascript
  69942. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69943. * ```
  69944. *
  69945. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69946. */
  69947. export class DracoCompression implements IDisposable {
  69948. private _workerPoolPromise?;
  69949. private _decoderModulePromise?;
  69950. /**
  69951. * The configuration. Defaults to the following urls:
  69952. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69953. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69954. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69955. */
  69956. static Configuration: IDracoCompressionConfiguration;
  69957. /**
  69958. * Returns true if the decoder configuration is available.
  69959. */
  69960. static get DecoderAvailable(): boolean;
  69961. /**
  69962. * Default number of workers to create when creating the draco compression object.
  69963. */
  69964. static DefaultNumWorkers: number;
  69965. private static GetDefaultNumWorkers;
  69966. private static _Default;
  69967. /**
  69968. * Default instance for the draco compression object.
  69969. */
  69970. static get Default(): DracoCompression;
  69971. /**
  69972. * Constructor
  69973. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69974. */
  69975. constructor(numWorkers?: number);
  69976. /**
  69977. * Stop all async operations and release resources.
  69978. */
  69979. dispose(): void;
  69980. /**
  69981. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69982. * @returns a promise that resolves when ready
  69983. */
  69984. whenReadyAsync(): Promise<void>;
  69985. /**
  69986. * Decode Draco compressed mesh data to vertex data.
  69987. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69988. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69989. * @returns A promise that resolves with the decoded vertex data
  69990. */
  69991. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69992. [kind: string]: number;
  69993. }): Promise<VertexData>;
  69994. }
  69995. }
  69996. declare module "babylonjs/Meshes/Compression/index" {
  69997. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69998. }
  69999. declare module "babylonjs/Meshes/csg" {
  70000. import { Nullable } from "babylonjs/types";
  70001. import { Scene } from "babylonjs/scene";
  70002. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  70003. import { Mesh } from "babylonjs/Meshes/mesh";
  70004. import { Material } from "babylonjs/Materials/material";
  70005. /**
  70006. * Class for building Constructive Solid Geometry
  70007. */
  70008. export class CSG {
  70009. private polygons;
  70010. /**
  70011. * The world matrix
  70012. */
  70013. matrix: Matrix;
  70014. /**
  70015. * Stores the position
  70016. */
  70017. position: Vector3;
  70018. /**
  70019. * Stores the rotation
  70020. */
  70021. rotation: Vector3;
  70022. /**
  70023. * Stores the rotation quaternion
  70024. */
  70025. rotationQuaternion: Nullable<Quaternion>;
  70026. /**
  70027. * Stores the scaling vector
  70028. */
  70029. scaling: Vector3;
  70030. /**
  70031. * Convert the Mesh to CSG
  70032. * @param mesh The Mesh to convert to CSG
  70033. * @returns A new CSG from the Mesh
  70034. */
  70035. static FromMesh(mesh: Mesh): CSG;
  70036. /**
  70037. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  70038. * @param polygons Polygons used to construct a CSG solid
  70039. */
  70040. private static FromPolygons;
  70041. /**
  70042. * Clones, or makes a deep copy, of the CSG
  70043. * @returns A new CSG
  70044. */
  70045. clone(): CSG;
  70046. /**
  70047. * Unions this CSG with another CSG
  70048. * @param csg The CSG to union against this CSG
  70049. * @returns The unioned CSG
  70050. */
  70051. union(csg: CSG): CSG;
  70052. /**
  70053. * Unions this CSG with another CSG in place
  70054. * @param csg The CSG to union against this CSG
  70055. */
  70056. unionInPlace(csg: CSG): void;
  70057. /**
  70058. * Subtracts this CSG with another CSG
  70059. * @param csg The CSG to subtract against this CSG
  70060. * @returns A new CSG
  70061. */
  70062. subtract(csg: CSG): CSG;
  70063. /**
  70064. * Subtracts this CSG with another CSG in place
  70065. * @param csg The CSG to subtact against this CSG
  70066. */
  70067. subtractInPlace(csg: CSG): void;
  70068. /**
  70069. * Intersect this CSG with another CSG
  70070. * @param csg The CSG to intersect against this CSG
  70071. * @returns A new CSG
  70072. */
  70073. intersect(csg: CSG): CSG;
  70074. /**
  70075. * Intersects this CSG with another CSG in place
  70076. * @param csg The CSG to intersect against this CSG
  70077. */
  70078. intersectInPlace(csg: CSG): void;
  70079. /**
  70080. * Return a new CSG solid with solid and empty space switched. This solid is
  70081. * not modified.
  70082. * @returns A new CSG solid with solid and empty space switched
  70083. */
  70084. inverse(): CSG;
  70085. /**
  70086. * Inverses the CSG in place
  70087. */
  70088. inverseInPlace(): void;
  70089. /**
  70090. * This is used to keep meshes transformations so they can be restored
  70091. * when we build back a Babylon Mesh
  70092. * NB : All CSG operations are performed in world coordinates
  70093. * @param csg The CSG to copy the transform attributes from
  70094. * @returns This CSG
  70095. */
  70096. copyTransformAttributes(csg: CSG): CSG;
  70097. /**
  70098. * Build Raw mesh from CSG
  70099. * Coordinates here are in world space
  70100. * @param name The name of the mesh geometry
  70101. * @param scene The Scene
  70102. * @param keepSubMeshes Specifies if the submeshes should be kept
  70103. * @returns A new Mesh
  70104. */
  70105. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70106. /**
  70107. * Build Mesh from CSG taking material and transforms into account
  70108. * @param name The name of the Mesh
  70109. * @param material The material of the Mesh
  70110. * @param scene The Scene
  70111. * @param keepSubMeshes Specifies if submeshes should be kept
  70112. * @returns The new Mesh
  70113. */
  70114. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70115. }
  70116. }
  70117. declare module "babylonjs/Meshes/trailMesh" {
  70118. import { Mesh } from "babylonjs/Meshes/mesh";
  70119. import { Scene } from "babylonjs/scene";
  70120. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70121. /**
  70122. * Class used to create a trail following a mesh
  70123. */
  70124. export class TrailMesh extends Mesh {
  70125. private _generator;
  70126. private _autoStart;
  70127. private _running;
  70128. private _diameter;
  70129. private _length;
  70130. private _sectionPolygonPointsCount;
  70131. private _sectionVectors;
  70132. private _sectionNormalVectors;
  70133. private _beforeRenderObserver;
  70134. /**
  70135. * @constructor
  70136. * @param name The value used by scene.getMeshByName() to do a lookup.
  70137. * @param generator The mesh or transform node to generate a trail.
  70138. * @param scene The scene to add this mesh to.
  70139. * @param diameter Diameter of trailing mesh. Default is 1.
  70140. * @param length Length of trailing mesh. Default is 60.
  70141. * @param autoStart Automatically start trailing mesh. Default true.
  70142. */
  70143. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  70144. /**
  70145. * "TrailMesh"
  70146. * @returns "TrailMesh"
  70147. */
  70148. getClassName(): string;
  70149. private _createMesh;
  70150. /**
  70151. * Start trailing mesh.
  70152. */
  70153. start(): void;
  70154. /**
  70155. * Stop trailing mesh.
  70156. */
  70157. stop(): void;
  70158. /**
  70159. * Update trailing mesh geometry.
  70160. */
  70161. update(): void;
  70162. /**
  70163. * Returns a new TrailMesh object.
  70164. * @param name is a string, the name given to the new mesh
  70165. * @param newGenerator use new generator object for cloned trail mesh
  70166. * @returns a new mesh
  70167. */
  70168. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  70169. /**
  70170. * Serializes this trail mesh
  70171. * @param serializationObject object to write serialization to
  70172. */
  70173. serialize(serializationObject: any): void;
  70174. /**
  70175. * Parses a serialized trail mesh
  70176. * @param parsedMesh the serialized mesh
  70177. * @param scene the scene to create the trail mesh in
  70178. * @returns the created trail mesh
  70179. */
  70180. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  70181. }
  70182. }
  70183. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  70184. import { Nullable } from "babylonjs/types";
  70185. import { Scene } from "babylonjs/scene";
  70186. import { Vector4 } from "babylonjs/Maths/math.vector";
  70187. import { Color4 } from "babylonjs/Maths/math.color";
  70188. import { Mesh } from "babylonjs/Meshes/mesh";
  70189. /**
  70190. * Class containing static functions to help procedurally build meshes
  70191. */
  70192. export class TiledBoxBuilder {
  70193. /**
  70194. * Creates a box mesh
  70195. * 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)
  70196. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70198. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70200. * @param name defines the name of the mesh
  70201. * @param options defines the options used to create the mesh
  70202. * @param scene defines the hosting scene
  70203. * @returns the box mesh
  70204. */
  70205. static CreateTiledBox(name: string, options: {
  70206. pattern?: number;
  70207. width?: number;
  70208. height?: number;
  70209. depth?: number;
  70210. tileSize?: number;
  70211. tileWidth?: number;
  70212. tileHeight?: number;
  70213. alignHorizontal?: number;
  70214. alignVertical?: number;
  70215. faceUV?: Vector4[];
  70216. faceColors?: Color4[];
  70217. sideOrientation?: number;
  70218. updatable?: boolean;
  70219. }, scene?: Nullable<Scene>): Mesh;
  70220. }
  70221. }
  70222. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  70223. import { Vector4 } from "babylonjs/Maths/math.vector";
  70224. import { Mesh } from "babylonjs/Meshes/mesh";
  70225. /**
  70226. * Class containing static functions to help procedurally build meshes
  70227. */
  70228. export class TorusKnotBuilder {
  70229. /**
  70230. * Creates a torus knot mesh
  70231. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70232. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70233. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70234. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70236. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70238. * @param name defines the name of the mesh
  70239. * @param options defines the options used to create the mesh
  70240. * @param scene defines the hosting scene
  70241. * @returns the torus knot mesh
  70242. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70243. */
  70244. static CreateTorusKnot(name: string, options: {
  70245. radius?: number;
  70246. tube?: number;
  70247. radialSegments?: number;
  70248. tubularSegments?: number;
  70249. p?: number;
  70250. q?: number;
  70251. updatable?: boolean;
  70252. sideOrientation?: number;
  70253. frontUVs?: Vector4;
  70254. backUVs?: Vector4;
  70255. }, scene: any): Mesh;
  70256. }
  70257. }
  70258. declare module "babylonjs/Meshes/polygonMesh" {
  70259. import { Scene } from "babylonjs/scene";
  70260. import { Vector2 } from "babylonjs/Maths/math.vector";
  70261. import { Mesh } from "babylonjs/Meshes/mesh";
  70262. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  70263. import { Path2 } from "babylonjs/Maths/math.path";
  70264. /**
  70265. * Polygon
  70266. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  70267. */
  70268. export class Polygon {
  70269. /**
  70270. * Creates a rectangle
  70271. * @param xmin bottom X coord
  70272. * @param ymin bottom Y coord
  70273. * @param xmax top X coord
  70274. * @param ymax top Y coord
  70275. * @returns points that make the resulting rectation
  70276. */
  70277. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  70278. /**
  70279. * Creates a circle
  70280. * @param radius radius of circle
  70281. * @param cx scale in x
  70282. * @param cy scale in y
  70283. * @param numberOfSides number of sides that make up the circle
  70284. * @returns points that make the resulting circle
  70285. */
  70286. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70287. /**
  70288. * Creates a polygon from input string
  70289. * @param input Input polygon data
  70290. * @returns the parsed points
  70291. */
  70292. static Parse(input: string): Vector2[];
  70293. /**
  70294. * Starts building a polygon from x and y coordinates
  70295. * @param x x coordinate
  70296. * @param y y coordinate
  70297. * @returns the started path2
  70298. */
  70299. static StartingAt(x: number, y: number): Path2;
  70300. }
  70301. /**
  70302. * Builds a polygon
  70303. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70304. */
  70305. export class PolygonMeshBuilder {
  70306. private _points;
  70307. private _outlinepoints;
  70308. private _holes;
  70309. private _name;
  70310. private _scene;
  70311. private _epoints;
  70312. private _eholes;
  70313. private _addToepoint;
  70314. /**
  70315. * Babylon reference to the earcut plugin.
  70316. */
  70317. bjsEarcut: any;
  70318. /**
  70319. * Creates a PolygonMeshBuilder
  70320. * @param name name of the builder
  70321. * @param contours Path of the polygon
  70322. * @param scene scene to add to when creating the mesh
  70323. * @param earcutInjection can be used to inject your own earcut reference
  70324. */
  70325. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70326. /**
  70327. * Adds a whole within the polygon
  70328. * @param hole Array of points defining the hole
  70329. * @returns this
  70330. */
  70331. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70332. /**
  70333. * Creates the polygon
  70334. * @param updatable If the mesh should be updatable
  70335. * @param depth The depth of the mesh created
  70336. * @returns the created mesh
  70337. */
  70338. build(updatable?: boolean, depth?: number): Mesh;
  70339. /**
  70340. * Creates the polygon
  70341. * @param depth The depth of the mesh created
  70342. * @returns the created VertexData
  70343. */
  70344. buildVertexData(depth?: number): VertexData;
  70345. /**
  70346. * Adds a side to the polygon
  70347. * @param positions points that make the polygon
  70348. * @param normals normals of the polygon
  70349. * @param uvs uvs of the polygon
  70350. * @param indices indices of the polygon
  70351. * @param bounds bounds of the polygon
  70352. * @param points points of the polygon
  70353. * @param depth depth of the polygon
  70354. * @param flip flip of the polygon
  70355. */
  70356. private addSide;
  70357. }
  70358. }
  70359. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  70360. import { Scene } from "babylonjs/scene";
  70361. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70362. import { Color4 } from "babylonjs/Maths/math.color";
  70363. import { Mesh } from "babylonjs/Meshes/mesh";
  70364. import { Nullable } from "babylonjs/types";
  70365. /**
  70366. * Class containing static functions to help procedurally build meshes
  70367. */
  70368. export class PolygonBuilder {
  70369. /**
  70370. * Creates a polygon mesh
  70371. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70372. * * 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
  70373. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70376. * * Remember you can only change the shape positions, not their number when updating a polygon
  70377. * @param name defines the name of the mesh
  70378. * @param options defines the options used to create the mesh
  70379. * @param scene defines the hosting scene
  70380. * @param earcutInjection can be used to inject your own earcut reference
  70381. * @returns the polygon mesh
  70382. */
  70383. static CreatePolygon(name: string, options: {
  70384. shape: Vector3[];
  70385. holes?: Vector3[][];
  70386. depth?: number;
  70387. faceUV?: Vector4[];
  70388. faceColors?: Color4[];
  70389. updatable?: boolean;
  70390. sideOrientation?: number;
  70391. frontUVs?: Vector4;
  70392. backUVs?: Vector4;
  70393. wrap?: boolean;
  70394. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70395. /**
  70396. * Creates an extruded polygon mesh, with depth in the Y direction.
  70397. * * 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)
  70398. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70399. * @param name defines the name of the mesh
  70400. * @param options defines the options used to create the mesh
  70401. * @param scene defines the hosting scene
  70402. * @param earcutInjection can be used to inject your own earcut reference
  70403. * @returns the polygon mesh
  70404. */
  70405. static ExtrudePolygon(name: string, options: {
  70406. shape: Vector3[];
  70407. holes?: Vector3[][];
  70408. depth?: number;
  70409. faceUV?: Vector4[];
  70410. faceColors?: Color4[];
  70411. updatable?: boolean;
  70412. sideOrientation?: number;
  70413. frontUVs?: Vector4;
  70414. backUVs?: Vector4;
  70415. wrap?: boolean;
  70416. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70417. }
  70418. }
  70419. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  70420. import { Scene } from "babylonjs/scene";
  70421. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70422. import { Mesh } from "babylonjs/Meshes/mesh";
  70423. import { Nullable } from "babylonjs/types";
  70424. /**
  70425. * Class containing static functions to help procedurally build meshes
  70426. */
  70427. export class LatheBuilder {
  70428. /**
  70429. * Creates lathe mesh.
  70430. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70431. * * 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
  70432. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70433. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70434. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70435. * * 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
  70436. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70437. * * 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
  70438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70440. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70442. * @param name defines the name of the mesh
  70443. * @param options defines the options used to create the mesh
  70444. * @param scene defines the hosting scene
  70445. * @returns the lathe mesh
  70446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70447. */
  70448. static CreateLathe(name: string, options: {
  70449. shape: Vector3[];
  70450. radius?: number;
  70451. tessellation?: number;
  70452. clip?: number;
  70453. arc?: number;
  70454. closed?: boolean;
  70455. updatable?: boolean;
  70456. sideOrientation?: number;
  70457. frontUVs?: Vector4;
  70458. backUVs?: Vector4;
  70459. cap?: number;
  70460. invertUV?: boolean;
  70461. }, scene?: Nullable<Scene>): Mesh;
  70462. }
  70463. }
  70464. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  70465. import { Nullable } from "babylonjs/types";
  70466. import { Scene } from "babylonjs/scene";
  70467. import { Vector4 } from "babylonjs/Maths/math.vector";
  70468. import { Mesh } from "babylonjs/Meshes/mesh";
  70469. /**
  70470. * Class containing static functions to help procedurally build meshes
  70471. */
  70472. export class TiledPlaneBuilder {
  70473. /**
  70474. * Creates a tiled plane mesh
  70475. * * The parameter `pattern` will, depending on value, do nothing or
  70476. * * * flip (reflect about central vertical) alternate tiles across and up
  70477. * * * flip every tile on alternate rows
  70478. * * * rotate (180 degs) alternate tiles across and up
  70479. * * * rotate every tile on alternate rows
  70480. * * * flip and rotate alternate tiles across and up
  70481. * * * flip and rotate every tile on alternate rows
  70482. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70483. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70485. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70486. * * 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)
  70487. * * 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)
  70488. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70489. * @param name defines the name of the mesh
  70490. * @param options defines the options used to create the mesh
  70491. * @param scene defines the hosting scene
  70492. * @returns the box mesh
  70493. */
  70494. static CreateTiledPlane(name: string, options: {
  70495. pattern?: number;
  70496. tileSize?: number;
  70497. tileWidth?: number;
  70498. tileHeight?: number;
  70499. size?: number;
  70500. width?: number;
  70501. height?: number;
  70502. alignHorizontal?: number;
  70503. alignVertical?: number;
  70504. sideOrientation?: number;
  70505. frontUVs?: Vector4;
  70506. backUVs?: Vector4;
  70507. updatable?: boolean;
  70508. }, scene?: Nullable<Scene>): Mesh;
  70509. }
  70510. }
  70511. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  70512. import { Nullable } from "babylonjs/types";
  70513. import { Scene } from "babylonjs/scene";
  70514. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70515. import { Mesh } from "babylonjs/Meshes/mesh";
  70516. /**
  70517. * Class containing static functions to help procedurally build meshes
  70518. */
  70519. export class TubeBuilder {
  70520. /**
  70521. * Creates a tube mesh.
  70522. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70523. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70524. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70525. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70526. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70527. * * 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)
  70528. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70529. * * 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
  70530. * * 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
  70531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70535. * @param name defines the name of the mesh
  70536. * @param options defines the options used to create the mesh
  70537. * @param scene defines the hosting scene
  70538. * @returns the tube mesh
  70539. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70540. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70541. */
  70542. static CreateTube(name: string, options: {
  70543. path: Vector3[];
  70544. radius?: number;
  70545. tessellation?: number;
  70546. radiusFunction?: {
  70547. (i: number, distance: number): number;
  70548. };
  70549. cap?: number;
  70550. arc?: number;
  70551. updatable?: boolean;
  70552. sideOrientation?: number;
  70553. frontUVs?: Vector4;
  70554. backUVs?: Vector4;
  70555. instance?: Mesh;
  70556. invertUV?: boolean;
  70557. }, scene?: Nullable<Scene>): Mesh;
  70558. }
  70559. }
  70560. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  70561. import { Scene } from "babylonjs/scene";
  70562. import { Vector4 } from "babylonjs/Maths/math.vector";
  70563. import { Mesh } from "babylonjs/Meshes/mesh";
  70564. import { Nullable } from "babylonjs/types";
  70565. /**
  70566. * Class containing static functions to help procedurally build meshes
  70567. */
  70568. export class IcoSphereBuilder {
  70569. /**
  70570. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70571. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70572. * * 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`)
  70573. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70574. * * 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
  70575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70578. * @param name defines the name of the mesh
  70579. * @param options defines the options used to create the mesh
  70580. * @param scene defines the hosting scene
  70581. * @returns the icosahedron mesh
  70582. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70583. */
  70584. static CreateIcoSphere(name: string, options: {
  70585. radius?: number;
  70586. radiusX?: number;
  70587. radiusY?: number;
  70588. radiusZ?: number;
  70589. flat?: boolean;
  70590. subdivisions?: number;
  70591. sideOrientation?: number;
  70592. frontUVs?: Vector4;
  70593. backUVs?: Vector4;
  70594. updatable?: boolean;
  70595. }, scene?: Nullable<Scene>): Mesh;
  70596. }
  70597. }
  70598. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  70599. import { Vector3 } from "babylonjs/Maths/math.vector";
  70600. import { Mesh } from "babylonjs/Meshes/mesh";
  70601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70602. /**
  70603. * Class containing static functions to help procedurally build meshes
  70604. */
  70605. export class DecalBuilder {
  70606. /**
  70607. * Creates a decal mesh.
  70608. * 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
  70609. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70610. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70611. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70612. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70613. * @param name defines the name of the mesh
  70614. * @param sourceMesh defines the mesh where the decal must be applied
  70615. * @param options defines the options used to create the mesh
  70616. * @param scene defines the hosting scene
  70617. * @returns the decal mesh
  70618. * @see https://doc.babylonjs.com/how_to/decals
  70619. */
  70620. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70621. position?: Vector3;
  70622. normal?: Vector3;
  70623. size?: Vector3;
  70624. angle?: number;
  70625. }): Mesh;
  70626. }
  70627. }
  70628. declare module "babylonjs/Meshes/meshBuilder" {
  70629. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  70630. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  70631. import { Nullable } from "babylonjs/types";
  70632. import { Scene } from "babylonjs/scene";
  70633. import { Mesh } from "babylonjs/Meshes/mesh";
  70634. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  70635. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  70636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70637. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70638. import { Plane } from "babylonjs/Maths/math.plane";
  70639. /**
  70640. * Class containing static functions to help procedurally build meshes
  70641. */
  70642. export class MeshBuilder {
  70643. /**
  70644. * Creates a box mesh
  70645. * * The parameter `size` sets the size (float) of each box side (default 1)
  70646. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70647. * * 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)
  70648. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70652. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70653. * @param name defines the name of the mesh
  70654. * @param options defines the options used to create the mesh
  70655. * @param scene defines the hosting scene
  70656. * @returns the box mesh
  70657. */
  70658. static CreateBox(name: string, options: {
  70659. size?: number;
  70660. width?: number;
  70661. height?: number;
  70662. depth?: number;
  70663. faceUV?: Vector4[];
  70664. faceColors?: Color4[];
  70665. sideOrientation?: number;
  70666. frontUVs?: Vector4;
  70667. backUVs?: Vector4;
  70668. wrap?: boolean;
  70669. topBaseAt?: number;
  70670. bottomBaseAt?: number;
  70671. updatable?: boolean;
  70672. }, scene?: Nullable<Scene>): Mesh;
  70673. /**
  70674. * Creates a tiled box mesh
  70675. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70677. * @param name defines the name of the mesh
  70678. * @param options defines the options used to create the mesh
  70679. * @param scene defines the hosting scene
  70680. * @returns the tiled box mesh
  70681. */
  70682. static CreateTiledBox(name: string, options: {
  70683. pattern?: number;
  70684. size?: number;
  70685. width?: number;
  70686. height?: number;
  70687. depth: number;
  70688. tileSize?: number;
  70689. tileWidth?: number;
  70690. tileHeight?: number;
  70691. faceUV?: Vector4[];
  70692. faceColors?: Color4[];
  70693. alignHorizontal?: number;
  70694. alignVertical?: number;
  70695. sideOrientation?: number;
  70696. updatable?: boolean;
  70697. }, scene?: Nullable<Scene>): Mesh;
  70698. /**
  70699. * Creates a sphere mesh
  70700. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70701. * * 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`)
  70702. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70703. * * 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
  70704. * * 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)
  70705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70708. * @param name defines the name of the mesh
  70709. * @param options defines the options used to create the mesh
  70710. * @param scene defines the hosting scene
  70711. * @returns the sphere mesh
  70712. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70713. */
  70714. static CreateSphere(name: string, options: {
  70715. segments?: number;
  70716. diameter?: number;
  70717. diameterX?: number;
  70718. diameterY?: number;
  70719. diameterZ?: number;
  70720. arc?: number;
  70721. slice?: number;
  70722. sideOrientation?: number;
  70723. frontUVs?: Vector4;
  70724. backUVs?: Vector4;
  70725. updatable?: boolean;
  70726. }, scene?: Nullable<Scene>): Mesh;
  70727. /**
  70728. * Creates a plane polygonal mesh. By default, this is a disc
  70729. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70730. * * 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
  70731. * * 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
  70732. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70735. * @param name defines the name of the mesh
  70736. * @param options defines the options used to create the mesh
  70737. * @param scene defines the hosting scene
  70738. * @returns the plane polygonal mesh
  70739. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70740. */
  70741. static CreateDisc(name: string, options: {
  70742. radius?: number;
  70743. tessellation?: number;
  70744. arc?: number;
  70745. updatable?: boolean;
  70746. sideOrientation?: number;
  70747. frontUVs?: Vector4;
  70748. backUVs?: Vector4;
  70749. }, scene?: Nullable<Scene>): Mesh;
  70750. /**
  70751. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70752. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70753. * * 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`)
  70754. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70755. * * 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
  70756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70757. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70759. * @param name defines the name of the mesh
  70760. * @param options defines the options used to create the mesh
  70761. * @param scene defines the hosting scene
  70762. * @returns the icosahedron mesh
  70763. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70764. */
  70765. static CreateIcoSphere(name: string, options: {
  70766. radius?: number;
  70767. radiusX?: number;
  70768. radiusY?: number;
  70769. radiusZ?: number;
  70770. flat?: boolean;
  70771. subdivisions?: number;
  70772. sideOrientation?: number;
  70773. frontUVs?: Vector4;
  70774. backUVs?: Vector4;
  70775. updatable?: boolean;
  70776. }, scene?: Nullable<Scene>): Mesh;
  70777. /**
  70778. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70779. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70780. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70781. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70782. * * 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
  70783. * * 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
  70784. * * 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
  70785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70787. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70788. * * 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
  70789. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70790. * * 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
  70791. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70793. * @param name defines the name of the mesh
  70794. * @param options defines the options used to create the mesh
  70795. * @param scene defines the hosting scene
  70796. * @returns the ribbon mesh
  70797. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70798. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70799. */
  70800. static CreateRibbon(name: string, options: {
  70801. pathArray: Vector3[][];
  70802. closeArray?: boolean;
  70803. closePath?: boolean;
  70804. offset?: number;
  70805. updatable?: boolean;
  70806. sideOrientation?: number;
  70807. frontUVs?: Vector4;
  70808. backUVs?: Vector4;
  70809. instance?: Mesh;
  70810. invertUV?: boolean;
  70811. uvs?: Vector2[];
  70812. colors?: Color4[];
  70813. }, scene?: Nullable<Scene>): Mesh;
  70814. /**
  70815. * Creates a cylinder or a cone mesh
  70816. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70817. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70818. * * 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.
  70819. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70820. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70821. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70822. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70823. * * 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).
  70824. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70825. * * 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).
  70826. * * 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
  70827. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70828. * * 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
  70829. * * 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.
  70830. * * If `enclose` is false, a ring surface is one element.
  70831. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70832. * * 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
  70833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70834. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70836. * @param name defines the name of the mesh
  70837. * @param options defines the options used to create the mesh
  70838. * @param scene defines the hosting scene
  70839. * @returns the cylinder mesh
  70840. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70841. */
  70842. static CreateCylinder(name: string, options: {
  70843. height?: number;
  70844. diameterTop?: number;
  70845. diameterBottom?: number;
  70846. diameter?: number;
  70847. tessellation?: number;
  70848. subdivisions?: number;
  70849. arc?: number;
  70850. faceColors?: Color4[];
  70851. faceUV?: Vector4[];
  70852. updatable?: boolean;
  70853. hasRings?: boolean;
  70854. enclose?: boolean;
  70855. cap?: number;
  70856. sideOrientation?: number;
  70857. frontUVs?: Vector4;
  70858. backUVs?: Vector4;
  70859. }, scene?: Nullable<Scene>): Mesh;
  70860. /**
  70861. * Creates a torus mesh
  70862. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70863. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70864. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70868. * @param name defines the name of the mesh
  70869. * @param options defines the options used to create the mesh
  70870. * @param scene defines the hosting scene
  70871. * @returns the torus mesh
  70872. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70873. */
  70874. static CreateTorus(name: string, options: {
  70875. diameter?: number;
  70876. thickness?: number;
  70877. tessellation?: number;
  70878. updatable?: boolean;
  70879. sideOrientation?: number;
  70880. frontUVs?: Vector4;
  70881. backUVs?: Vector4;
  70882. }, scene?: Nullable<Scene>): Mesh;
  70883. /**
  70884. * Creates a torus knot mesh
  70885. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70886. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70887. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70888. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70892. * @param name defines the name of the mesh
  70893. * @param options defines the options used to create the mesh
  70894. * @param scene defines the hosting scene
  70895. * @returns the torus knot mesh
  70896. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70897. */
  70898. static CreateTorusKnot(name: string, options: {
  70899. radius?: number;
  70900. tube?: number;
  70901. radialSegments?: number;
  70902. tubularSegments?: number;
  70903. p?: number;
  70904. q?: number;
  70905. updatable?: boolean;
  70906. sideOrientation?: number;
  70907. frontUVs?: Vector4;
  70908. backUVs?: Vector4;
  70909. }, scene?: Nullable<Scene>): Mesh;
  70910. /**
  70911. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70912. * * 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
  70913. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70914. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70915. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70916. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70917. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70918. * * 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
  70919. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70921. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70922. * @param name defines the name of the new line system
  70923. * @param options defines the options used to create the line system
  70924. * @param scene defines the hosting scene
  70925. * @returns a new line system mesh
  70926. */
  70927. static CreateLineSystem(name: string, options: {
  70928. lines: Vector3[][];
  70929. updatable?: boolean;
  70930. instance?: Nullable<LinesMesh>;
  70931. colors?: Nullable<Color4[][]>;
  70932. useVertexAlpha?: boolean;
  70933. }, scene: Nullable<Scene>): LinesMesh;
  70934. /**
  70935. * Creates a line mesh
  70936. * 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
  70937. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70938. * * The parameter `points` is an array successive Vector3
  70939. * * 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
  70940. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70941. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70942. * * When updating an instance, remember that only point positions can change, not the number of points
  70943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70945. * @param name defines the name of the new line system
  70946. * @param options defines the options used to create the line system
  70947. * @param scene defines the hosting scene
  70948. * @returns a new line mesh
  70949. */
  70950. static CreateLines(name: string, options: {
  70951. points: Vector3[];
  70952. updatable?: boolean;
  70953. instance?: Nullable<LinesMesh>;
  70954. colors?: Color4[];
  70955. useVertexAlpha?: boolean;
  70956. }, scene?: Nullable<Scene>): LinesMesh;
  70957. /**
  70958. * Creates a dashed line mesh
  70959. * * 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
  70960. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70961. * * The parameter `points` is an array successive Vector3
  70962. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70963. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70964. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70965. * * 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
  70966. * * When updating an instance, remember that only point positions can change, not the number of points
  70967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70968. * @param name defines the name of the mesh
  70969. * @param options defines the options used to create the mesh
  70970. * @param scene defines the hosting scene
  70971. * @returns the dashed line mesh
  70972. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70973. */
  70974. static CreateDashedLines(name: string, options: {
  70975. points: Vector3[];
  70976. dashSize?: number;
  70977. gapSize?: number;
  70978. dashNb?: number;
  70979. updatable?: boolean;
  70980. instance?: LinesMesh;
  70981. }, scene?: Nullable<Scene>): LinesMesh;
  70982. /**
  70983. * 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.
  70984. * * 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.
  70985. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70986. * * 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.
  70987. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70988. * * 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
  70989. * * 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
  70990. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70992. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70993. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70995. * @param name defines the name of the mesh
  70996. * @param options defines the options used to create the mesh
  70997. * @param scene defines the hosting scene
  70998. * @returns the extruded shape mesh
  70999. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71000. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  71001. */
  71002. static ExtrudeShape(name: string, options: {
  71003. shape: Vector3[];
  71004. path: Vector3[];
  71005. scale?: number;
  71006. rotation?: number;
  71007. cap?: number;
  71008. updatable?: boolean;
  71009. sideOrientation?: number;
  71010. frontUVs?: Vector4;
  71011. backUVs?: Vector4;
  71012. instance?: Mesh;
  71013. invertUV?: boolean;
  71014. }, scene?: Nullable<Scene>): Mesh;
  71015. /**
  71016. * Creates an custom extruded shape mesh.
  71017. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  71018. * * 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.
  71019. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  71020. * * 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
  71021. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  71022. * * 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
  71023. * * It must returns a float value that will be the scale value applied to the shape on each path point
  71024. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  71025. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  71026. * * 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
  71027. * * 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
  71028. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  71029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71030. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71031. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71033. * @param name defines the name of the mesh
  71034. * @param options defines the options used to create the mesh
  71035. * @param scene defines the hosting scene
  71036. * @returns the custom extruded shape mesh
  71037. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  71038. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71039. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  71040. */
  71041. static ExtrudeShapeCustom(name: string, options: {
  71042. shape: Vector3[];
  71043. path: Vector3[];
  71044. scaleFunction?: any;
  71045. rotationFunction?: any;
  71046. ribbonCloseArray?: boolean;
  71047. ribbonClosePath?: boolean;
  71048. cap?: number;
  71049. updatable?: boolean;
  71050. sideOrientation?: number;
  71051. frontUVs?: Vector4;
  71052. backUVs?: Vector4;
  71053. instance?: Mesh;
  71054. invertUV?: boolean;
  71055. }, scene?: Nullable<Scene>): Mesh;
  71056. /**
  71057. * Creates lathe mesh.
  71058. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  71059. * * 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
  71060. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  71061. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  71062. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  71063. * * 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
  71064. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  71065. * * 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
  71066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71067. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71068. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71070. * @param name defines the name of the mesh
  71071. * @param options defines the options used to create the mesh
  71072. * @param scene defines the hosting scene
  71073. * @returns the lathe mesh
  71074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  71075. */
  71076. static CreateLathe(name: string, options: {
  71077. shape: Vector3[];
  71078. radius?: number;
  71079. tessellation?: number;
  71080. clip?: number;
  71081. arc?: number;
  71082. closed?: boolean;
  71083. updatable?: boolean;
  71084. sideOrientation?: number;
  71085. frontUVs?: Vector4;
  71086. backUVs?: Vector4;
  71087. cap?: number;
  71088. invertUV?: boolean;
  71089. }, scene?: Nullable<Scene>): Mesh;
  71090. /**
  71091. * Creates a tiled plane mesh
  71092. * * You can set a limited pattern arrangement with the tiles
  71093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71096. * @param name defines the name of the mesh
  71097. * @param options defines the options used to create the mesh
  71098. * @param scene defines the hosting scene
  71099. * @returns the plane mesh
  71100. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71101. */
  71102. static CreateTiledPlane(name: string, options: {
  71103. pattern?: number;
  71104. tileSize?: number;
  71105. tileWidth?: number;
  71106. tileHeight?: number;
  71107. size?: number;
  71108. width?: number;
  71109. height?: number;
  71110. alignHorizontal?: number;
  71111. alignVertical?: number;
  71112. sideOrientation?: number;
  71113. frontUVs?: Vector4;
  71114. backUVs?: Vector4;
  71115. updatable?: boolean;
  71116. }, scene?: Nullable<Scene>): Mesh;
  71117. /**
  71118. * Creates a plane mesh
  71119. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  71120. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  71121. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  71122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71125. * @param name defines the name of the mesh
  71126. * @param options defines the options used to create the mesh
  71127. * @param scene defines the hosting scene
  71128. * @returns the plane mesh
  71129. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71130. */
  71131. static CreatePlane(name: string, options: {
  71132. size?: number;
  71133. width?: number;
  71134. height?: number;
  71135. sideOrientation?: number;
  71136. frontUVs?: Vector4;
  71137. backUVs?: Vector4;
  71138. updatable?: boolean;
  71139. sourcePlane?: Plane;
  71140. }, scene?: Nullable<Scene>): Mesh;
  71141. /**
  71142. * Creates a ground mesh
  71143. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  71144. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  71145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71146. * @param name defines the name of the mesh
  71147. * @param options defines the options used to create the mesh
  71148. * @param scene defines the hosting scene
  71149. * @returns the ground mesh
  71150. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  71151. */
  71152. static CreateGround(name: string, options: {
  71153. width?: number;
  71154. height?: number;
  71155. subdivisions?: number;
  71156. subdivisionsX?: number;
  71157. subdivisionsY?: number;
  71158. updatable?: boolean;
  71159. }, scene?: Nullable<Scene>): Mesh;
  71160. /**
  71161. * Creates a tiled ground mesh
  71162. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  71163. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  71164. * * 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
  71165. * * 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
  71166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71167. * @param name defines the name of the mesh
  71168. * @param options defines the options used to create the mesh
  71169. * @param scene defines the hosting scene
  71170. * @returns the tiled ground mesh
  71171. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  71172. */
  71173. static CreateTiledGround(name: string, options: {
  71174. xmin: number;
  71175. zmin: number;
  71176. xmax: number;
  71177. zmax: number;
  71178. subdivisions?: {
  71179. w: number;
  71180. h: number;
  71181. };
  71182. precision?: {
  71183. w: number;
  71184. h: number;
  71185. };
  71186. updatable?: boolean;
  71187. }, scene?: Nullable<Scene>): Mesh;
  71188. /**
  71189. * Creates a ground mesh from a height map
  71190. * * The parameter `url` sets the URL of the height map image resource.
  71191. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  71192. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  71193. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  71194. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  71195. * * 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.
  71196. * * 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).
  71197. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  71198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71199. * @param name defines the name of the mesh
  71200. * @param url defines the url to the height map
  71201. * @param options defines the options used to create the mesh
  71202. * @param scene defines the hosting scene
  71203. * @returns the ground mesh
  71204. * @see https://doc.babylonjs.com/babylon101/height_map
  71205. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  71206. */
  71207. static CreateGroundFromHeightMap(name: string, url: string, options: {
  71208. width?: number;
  71209. height?: number;
  71210. subdivisions?: number;
  71211. minHeight?: number;
  71212. maxHeight?: number;
  71213. colorFilter?: Color3;
  71214. alphaFilter?: number;
  71215. updatable?: boolean;
  71216. onReady?: (mesh: GroundMesh) => void;
  71217. }, scene?: Nullable<Scene>): GroundMesh;
  71218. /**
  71219. * Creates a polygon mesh
  71220. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  71221. * * 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
  71222. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  71223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71224. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  71225. * * Remember you can only change the shape positions, not their number when updating a polygon
  71226. * @param name defines the name of the mesh
  71227. * @param options defines the options used to create the mesh
  71228. * @param scene defines the hosting scene
  71229. * @param earcutInjection can be used to inject your own earcut reference
  71230. * @returns the polygon mesh
  71231. */
  71232. static CreatePolygon(name: string, options: {
  71233. shape: Vector3[];
  71234. holes?: Vector3[][];
  71235. depth?: number;
  71236. faceUV?: Vector4[];
  71237. faceColors?: Color4[];
  71238. updatable?: boolean;
  71239. sideOrientation?: number;
  71240. frontUVs?: Vector4;
  71241. backUVs?: Vector4;
  71242. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71243. /**
  71244. * Creates an extruded polygon mesh, with depth in the Y direction.
  71245. * * 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)
  71246. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  71247. * @param name defines the name of the mesh
  71248. * @param options defines the options used to create the mesh
  71249. * @param scene defines the hosting scene
  71250. * @param earcutInjection can be used to inject your own earcut reference
  71251. * @returns the polygon mesh
  71252. */
  71253. static ExtrudePolygon(name: string, options: {
  71254. shape: Vector3[];
  71255. holes?: Vector3[][];
  71256. depth?: number;
  71257. faceUV?: Vector4[];
  71258. faceColors?: Color4[];
  71259. updatable?: boolean;
  71260. sideOrientation?: number;
  71261. frontUVs?: Vector4;
  71262. backUVs?: Vector4;
  71263. wrap?: boolean;
  71264. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71265. /**
  71266. * Creates a tube mesh.
  71267. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71268. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  71269. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  71270. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  71271. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  71272. * * 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)
  71273. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  71274. * * 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
  71275. * * 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
  71276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71278. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71280. * @param name defines the name of the mesh
  71281. * @param options defines the options used to create the mesh
  71282. * @param scene defines the hosting scene
  71283. * @returns the tube mesh
  71284. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71285. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71286. */
  71287. static CreateTube(name: string, options: {
  71288. path: Vector3[];
  71289. radius?: number;
  71290. tessellation?: number;
  71291. radiusFunction?: {
  71292. (i: number, distance: number): number;
  71293. };
  71294. cap?: number;
  71295. arc?: number;
  71296. updatable?: boolean;
  71297. sideOrientation?: number;
  71298. frontUVs?: Vector4;
  71299. backUVs?: Vector4;
  71300. instance?: Mesh;
  71301. invertUV?: boolean;
  71302. }, scene?: Nullable<Scene>): Mesh;
  71303. /**
  71304. * Creates a polyhedron mesh
  71305. * * 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
  71306. * * The parameter `size` (positive float, default 1) sets the polygon size
  71307. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71308. * * 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`
  71309. * * 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
  71310. * * 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)`)
  71311. * * 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
  71312. * * 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
  71313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71314. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71316. * @param name defines the name of the mesh
  71317. * @param options defines the options used to create the mesh
  71318. * @param scene defines the hosting scene
  71319. * @returns the polyhedron mesh
  71320. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71321. */
  71322. static CreatePolyhedron(name: string, options: {
  71323. type?: number;
  71324. size?: number;
  71325. sizeX?: number;
  71326. sizeY?: number;
  71327. sizeZ?: number;
  71328. custom?: any;
  71329. faceUV?: Vector4[];
  71330. faceColors?: Color4[];
  71331. flat?: boolean;
  71332. updatable?: boolean;
  71333. sideOrientation?: number;
  71334. frontUVs?: Vector4;
  71335. backUVs?: Vector4;
  71336. }, scene?: Nullable<Scene>): Mesh;
  71337. /**
  71338. * Creates a decal mesh.
  71339. * 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
  71340. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71341. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71342. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71343. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71344. * @param name defines the name of the mesh
  71345. * @param sourceMesh defines the mesh where the decal must be applied
  71346. * @param options defines the options used to create the mesh
  71347. * @param scene defines the hosting scene
  71348. * @returns the decal mesh
  71349. * @see https://doc.babylonjs.com/how_to/decals
  71350. */
  71351. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71352. position?: Vector3;
  71353. normal?: Vector3;
  71354. size?: Vector3;
  71355. angle?: number;
  71356. }): Mesh;
  71357. /**
  71358. * Creates a Capsule Mesh
  71359. * @param name defines the name of the mesh.
  71360. * @param options the constructors options used to shape the mesh.
  71361. * @param scene defines the scene the mesh is scoped to.
  71362. * @returns the capsule mesh
  71363. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71364. */
  71365. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71366. }
  71367. }
  71368. declare module "babylonjs/Meshes/meshSimplification" {
  71369. import { Mesh } from "babylonjs/Meshes/mesh";
  71370. /**
  71371. * A simplifier interface for future simplification implementations
  71372. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71373. */
  71374. export interface ISimplifier {
  71375. /**
  71376. * Simplification of a given mesh according to the given settings.
  71377. * Since this requires computation, it is assumed that the function runs async.
  71378. * @param settings The settings of the simplification, including quality and distance
  71379. * @param successCallback A callback that will be called after the mesh was simplified.
  71380. * @param errorCallback in case of an error, this callback will be called. optional.
  71381. */
  71382. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71383. }
  71384. /**
  71385. * Expected simplification settings.
  71386. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71387. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71388. */
  71389. export interface ISimplificationSettings {
  71390. /**
  71391. * Gets or sets the expected quality
  71392. */
  71393. quality: number;
  71394. /**
  71395. * Gets or sets the distance when this optimized version should be used
  71396. */
  71397. distance: number;
  71398. /**
  71399. * Gets an already optimized mesh
  71400. */
  71401. optimizeMesh?: boolean;
  71402. }
  71403. /**
  71404. * Class used to specify simplification options
  71405. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71406. */
  71407. export class SimplificationSettings implements ISimplificationSettings {
  71408. /** expected quality */
  71409. quality: number;
  71410. /** distance when this optimized version should be used */
  71411. distance: number;
  71412. /** already optimized mesh */
  71413. optimizeMesh?: boolean | undefined;
  71414. /**
  71415. * Creates a SimplificationSettings
  71416. * @param quality expected quality
  71417. * @param distance distance when this optimized version should be used
  71418. * @param optimizeMesh already optimized mesh
  71419. */
  71420. constructor(
  71421. /** expected quality */
  71422. quality: number,
  71423. /** distance when this optimized version should be used */
  71424. distance: number,
  71425. /** already optimized mesh */
  71426. optimizeMesh?: boolean | undefined);
  71427. }
  71428. /**
  71429. * Interface used to define a simplification task
  71430. */
  71431. export interface ISimplificationTask {
  71432. /**
  71433. * Array of settings
  71434. */
  71435. settings: Array<ISimplificationSettings>;
  71436. /**
  71437. * Simplification type
  71438. */
  71439. simplificationType: SimplificationType;
  71440. /**
  71441. * Mesh to simplify
  71442. */
  71443. mesh: Mesh;
  71444. /**
  71445. * Callback called on success
  71446. */
  71447. successCallback?: () => void;
  71448. /**
  71449. * Defines if parallel processing can be used
  71450. */
  71451. parallelProcessing: boolean;
  71452. }
  71453. /**
  71454. * Queue used to order the simplification tasks
  71455. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71456. */
  71457. export class SimplificationQueue {
  71458. private _simplificationArray;
  71459. /**
  71460. * Gets a boolean indicating that the process is still running
  71461. */
  71462. running: boolean;
  71463. /**
  71464. * Creates a new queue
  71465. */
  71466. constructor();
  71467. /**
  71468. * Adds a new simplification task
  71469. * @param task defines a task to add
  71470. */
  71471. addTask(task: ISimplificationTask): void;
  71472. /**
  71473. * Execute next task
  71474. */
  71475. executeNext(): void;
  71476. /**
  71477. * Execute a simplification task
  71478. * @param task defines the task to run
  71479. */
  71480. runSimplification(task: ISimplificationTask): void;
  71481. private getSimplifier;
  71482. }
  71483. /**
  71484. * The implemented types of simplification
  71485. * At the moment only Quadratic Error Decimation is implemented
  71486. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71487. */
  71488. export enum SimplificationType {
  71489. /** Quadratic error decimation */
  71490. QUADRATIC = 0
  71491. }
  71492. /**
  71493. * An implementation of the Quadratic Error simplification algorithm.
  71494. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71495. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71496. * @author RaananW
  71497. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71498. */
  71499. export class QuadraticErrorSimplification implements ISimplifier {
  71500. private _mesh;
  71501. private triangles;
  71502. private vertices;
  71503. private references;
  71504. private _reconstructedMesh;
  71505. /** Gets or sets the number pf sync interations */
  71506. syncIterations: number;
  71507. /** Gets or sets the aggressiveness of the simplifier */
  71508. aggressiveness: number;
  71509. /** Gets or sets the number of allowed iterations for decimation */
  71510. decimationIterations: number;
  71511. /** Gets or sets the espilon to use for bounding box computation */
  71512. boundingBoxEpsilon: number;
  71513. /**
  71514. * Creates a new QuadraticErrorSimplification
  71515. * @param _mesh defines the target mesh
  71516. */
  71517. constructor(_mesh: Mesh);
  71518. /**
  71519. * Simplification of a given mesh according to the given settings.
  71520. * Since this requires computation, it is assumed that the function runs async.
  71521. * @param settings The settings of the simplification, including quality and distance
  71522. * @param successCallback A callback that will be called after the mesh was simplified.
  71523. */
  71524. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71525. private runDecimation;
  71526. private initWithMesh;
  71527. private init;
  71528. private reconstructMesh;
  71529. private initDecimatedMesh;
  71530. private isFlipped;
  71531. private updateTriangles;
  71532. private identifyBorder;
  71533. private updateMesh;
  71534. private vertexError;
  71535. private calculateError;
  71536. }
  71537. }
  71538. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  71539. import { Scene } from "babylonjs/scene";
  71540. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  71541. import { ISceneComponent } from "babylonjs/sceneComponent";
  71542. module "babylonjs/scene" {
  71543. interface Scene {
  71544. /** @hidden (Backing field) */
  71545. _simplificationQueue: SimplificationQueue;
  71546. /**
  71547. * Gets or sets the simplification queue attached to the scene
  71548. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71549. */
  71550. simplificationQueue: SimplificationQueue;
  71551. }
  71552. }
  71553. module "babylonjs/Meshes/mesh" {
  71554. interface Mesh {
  71555. /**
  71556. * Simplify the mesh according to the given array of settings.
  71557. * Function will return immediately and will simplify async
  71558. * @param settings a collection of simplification settings
  71559. * @param parallelProcessing should all levels calculate parallel or one after the other
  71560. * @param simplificationType the type of simplification to run
  71561. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71562. * @returns the current mesh
  71563. */
  71564. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71565. }
  71566. }
  71567. /**
  71568. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71569. * created in a scene
  71570. */
  71571. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71572. /**
  71573. * The component name helpfull to identify the component in the list of scene components.
  71574. */
  71575. readonly name: string;
  71576. /**
  71577. * The scene the component belongs to.
  71578. */
  71579. scene: Scene;
  71580. /**
  71581. * Creates a new instance of the component for the given scene
  71582. * @param scene Defines the scene to register the component in
  71583. */
  71584. constructor(scene: Scene);
  71585. /**
  71586. * Registers the component in a given scene
  71587. */
  71588. register(): void;
  71589. /**
  71590. * Rebuilds the elements related to this component in case of
  71591. * context lost for instance.
  71592. */
  71593. rebuild(): void;
  71594. /**
  71595. * Disposes the component and the associated ressources
  71596. */
  71597. dispose(): void;
  71598. private _beforeCameraUpdate;
  71599. }
  71600. }
  71601. declare module "babylonjs/Meshes/Builders/index" {
  71602. export * from "babylonjs/Meshes/Builders/boxBuilder";
  71603. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  71604. export * from "babylonjs/Meshes/Builders/discBuilder";
  71605. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  71606. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  71607. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  71608. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  71609. export * from "babylonjs/Meshes/Builders/torusBuilder";
  71610. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  71611. export * from "babylonjs/Meshes/Builders/linesBuilder";
  71612. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  71613. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  71614. export * from "babylonjs/Meshes/Builders/latheBuilder";
  71615. export * from "babylonjs/Meshes/Builders/planeBuilder";
  71616. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  71617. export * from "babylonjs/Meshes/Builders/groundBuilder";
  71618. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  71619. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  71620. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71621. export * from "babylonjs/Meshes/Builders/decalBuilder";
  71622. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71623. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  71624. }
  71625. declare module "babylonjs/Meshes/thinInstanceMesh" {
  71626. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  71627. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  71628. import { Matrix } from "babylonjs/Maths/math.vector";
  71629. module "babylonjs/Meshes/mesh" {
  71630. interface Mesh {
  71631. /**
  71632. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71633. */
  71634. thinInstanceEnablePicking: boolean;
  71635. /**
  71636. * Creates a new thin instance
  71637. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71638. * @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
  71639. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71640. */
  71641. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71642. /**
  71643. * Adds the transformation (matrix) of the current mesh as a thin instance
  71644. * @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
  71645. * @returns the thin instance index number
  71646. */
  71647. thinInstanceAddSelf(refresh: boolean): number;
  71648. /**
  71649. * Registers a custom attribute to be used with thin instances
  71650. * @param kind name of the attribute
  71651. * @param stride size in floats of the attribute
  71652. */
  71653. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71654. /**
  71655. * Sets the matrix of a thin instance
  71656. * @param index index of the thin instance
  71657. * @param matrix matrix to set
  71658. * @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
  71659. */
  71660. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71661. /**
  71662. * Sets the value of a custom attribute for a thin instance
  71663. * @param kind name of the attribute
  71664. * @param index index of the thin instance
  71665. * @param value value to set
  71666. * @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
  71667. */
  71668. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71669. /**
  71670. * 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.
  71671. */
  71672. thinInstanceCount: number;
  71673. /**
  71674. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71675. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71676. * @param buffer buffer to set
  71677. * @param stride size in floats of each value of the buffer
  71678. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71679. */
  71680. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71681. /**
  71682. * Gets the list of world matrices
  71683. * @return an array containing all the world matrices from the thin instances
  71684. */
  71685. thinInstanceGetWorldMatrices(): Matrix[];
  71686. /**
  71687. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71688. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71689. */
  71690. thinInstanceBufferUpdated(kind: string): void;
  71691. /**
  71692. * Applies a partial update to a buffer directly on the GPU
  71693. * 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
  71694. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71695. * @param data the data to set in the GPU buffer
  71696. * @param offset the offset in the GPU buffer where to update the data
  71697. */
  71698. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71699. /**
  71700. * Refreshes the bounding info, taking into account all the thin instances defined
  71701. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71702. */
  71703. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71704. /** @hidden */
  71705. _thinInstanceInitializeUserStorage(): void;
  71706. /** @hidden */
  71707. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71708. /** @hidden */
  71709. _userThinInstanceBuffersStorage: {
  71710. data: {
  71711. [key: string]: Float32Array;
  71712. };
  71713. sizes: {
  71714. [key: string]: number;
  71715. };
  71716. vertexBuffers: {
  71717. [key: string]: Nullable<VertexBuffer>;
  71718. };
  71719. strides: {
  71720. [key: string]: number;
  71721. };
  71722. };
  71723. }
  71724. }
  71725. }
  71726. declare module "babylonjs/Meshes/index" {
  71727. export * from "babylonjs/Meshes/abstractMesh";
  71728. export * from "babylonjs/Meshes/buffer";
  71729. export * from "babylonjs/Meshes/Compression/index";
  71730. export * from "babylonjs/Meshes/csg";
  71731. export * from "babylonjs/Meshes/geometry";
  71732. export * from "babylonjs/Meshes/groundMesh";
  71733. export * from "babylonjs/Meshes/trailMesh";
  71734. export * from "babylonjs/Meshes/instancedMesh";
  71735. export * from "babylonjs/Meshes/linesMesh";
  71736. export * from "babylonjs/Meshes/mesh";
  71737. export * from "babylonjs/Meshes/mesh.vertexData";
  71738. export * from "babylonjs/Meshes/meshBuilder";
  71739. export * from "babylonjs/Meshes/meshSimplification";
  71740. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71741. export * from "babylonjs/Meshes/polygonMesh";
  71742. export * from "babylonjs/Meshes/subMesh";
  71743. export * from "babylonjs/Meshes/meshLODLevel";
  71744. export * from "babylonjs/Meshes/transformNode";
  71745. export * from "babylonjs/Meshes/Builders/index";
  71746. export * from "babylonjs/Meshes/dataBuffer";
  71747. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71748. import "babylonjs/Meshes/thinInstanceMesh";
  71749. export * from "babylonjs/Meshes/thinInstanceMesh";
  71750. }
  71751. declare module "babylonjs/Morph/index" {
  71752. export * from "babylonjs/Morph/morphTarget";
  71753. export * from "babylonjs/Morph/morphTargetManager";
  71754. }
  71755. declare module "babylonjs/Navigation/INavigationEngine" {
  71756. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71757. import { Vector3 } from "babylonjs/Maths/math";
  71758. import { Mesh } from "babylonjs/Meshes/mesh";
  71759. import { Scene } from "babylonjs/scene";
  71760. /**
  71761. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71762. */
  71763. export interface INavigationEnginePlugin {
  71764. /**
  71765. * plugin name
  71766. */
  71767. name: string;
  71768. /**
  71769. * Creates a navigation mesh
  71770. * @param meshes array of all the geometry used to compute the navigatio mesh
  71771. * @param parameters bunch of parameters used to filter geometry
  71772. */
  71773. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71774. /**
  71775. * Create a navigation mesh debug mesh
  71776. * @param scene is where the mesh will be added
  71777. * @returns debug display mesh
  71778. */
  71779. createDebugNavMesh(scene: Scene): Mesh;
  71780. /**
  71781. * Get a navigation mesh constrained position, closest to the parameter position
  71782. * @param position world position
  71783. * @returns the closest point to position constrained by the navigation mesh
  71784. */
  71785. getClosestPoint(position: Vector3): Vector3;
  71786. /**
  71787. * Get a navigation mesh constrained position, closest to the parameter position
  71788. * @param position world position
  71789. * @param result output the closest point to position constrained by the navigation mesh
  71790. */
  71791. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71792. /**
  71793. * Get a navigation mesh constrained position, within a particular radius
  71794. * @param position world position
  71795. * @param maxRadius the maximum distance to the constrained world position
  71796. * @returns the closest point to position constrained by the navigation mesh
  71797. */
  71798. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71799. /**
  71800. * Get a navigation mesh constrained position, within a particular radius
  71801. * @param position world position
  71802. * @param maxRadius the maximum distance to the constrained world position
  71803. * @param result output the closest point to position constrained by the navigation mesh
  71804. */
  71805. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71806. /**
  71807. * Compute the final position from a segment made of destination-position
  71808. * @param position world position
  71809. * @param destination world position
  71810. * @returns the resulting point along the navmesh
  71811. */
  71812. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71813. /**
  71814. * Compute the final position from a segment made of destination-position
  71815. * @param position world position
  71816. * @param destination world position
  71817. * @param result output the resulting point along the navmesh
  71818. */
  71819. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71820. /**
  71821. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71822. * @param start world position
  71823. * @param end world position
  71824. * @returns array containing world position composing the path
  71825. */
  71826. computePath(start: Vector3, end: Vector3): Vector3[];
  71827. /**
  71828. * If this plugin is supported
  71829. * @returns true if plugin is supported
  71830. */
  71831. isSupported(): boolean;
  71832. /**
  71833. * Create a new Crowd so you can add agents
  71834. * @param maxAgents the maximum agent count in the crowd
  71835. * @param maxAgentRadius the maximum radius an agent can have
  71836. * @param scene to attach the crowd to
  71837. * @returns the crowd you can add agents to
  71838. */
  71839. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71840. /**
  71841. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71842. * The queries will try to find a solution within those bounds
  71843. * default is (1,1,1)
  71844. * @param extent x,y,z value that define the extent around the queries point of reference
  71845. */
  71846. setDefaultQueryExtent(extent: Vector3): void;
  71847. /**
  71848. * Get the Bounding box extent specified by setDefaultQueryExtent
  71849. * @returns the box extent values
  71850. */
  71851. getDefaultQueryExtent(): Vector3;
  71852. /**
  71853. * build the navmesh from a previously saved state using getNavmeshData
  71854. * @param data the Uint8Array returned by getNavmeshData
  71855. */
  71856. buildFromNavmeshData(data: Uint8Array): void;
  71857. /**
  71858. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71859. * @returns data the Uint8Array that can be saved and reused
  71860. */
  71861. getNavmeshData(): Uint8Array;
  71862. /**
  71863. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71864. * @param result output the box extent values
  71865. */
  71866. getDefaultQueryExtentToRef(result: Vector3): void;
  71867. /**
  71868. * Release all resources
  71869. */
  71870. dispose(): void;
  71871. }
  71872. /**
  71873. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71874. */
  71875. export interface ICrowd {
  71876. /**
  71877. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71878. * You can attach anything to that node. The node position is updated in the scene update tick.
  71879. * @param pos world position that will be constrained by the navigation mesh
  71880. * @param parameters agent parameters
  71881. * @param transform hooked to the agent that will be update by the scene
  71882. * @returns agent index
  71883. */
  71884. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71885. /**
  71886. * Returns the agent position in world space
  71887. * @param index agent index returned by addAgent
  71888. * @returns world space position
  71889. */
  71890. getAgentPosition(index: number): Vector3;
  71891. /**
  71892. * Gets the agent position result in world space
  71893. * @param index agent index returned by addAgent
  71894. * @param result output world space position
  71895. */
  71896. getAgentPositionToRef(index: number, result: Vector3): void;
  71897. /**
  71898. * Gets the agent velocity in world space
  71899. * @param index agent index returned by addAgent
  71900. * @returns world space velocity
  71901. */
  71902. getAgentVelocity(index: number): Vector3;
  71903. /**
  71904. * Gets the agent velocity result in world space
  71905. * @param index agent index returned by addAgent
  71906. * @param result output world space velocity
  71907. */
  71908. getAgentVelocityToRef(index: number, result: Vector3): void;
  71909. /**
  71910. * Gets the agent next target point on the path
  71911. * @param index agent index returned by addAgent
  71912. * @returns world space position
  71913. */
  71914. getAgentNextTargetPath(index: number): Vector3;
  71915. /**
  71916. * Gets the agent state
  71917. * @param index agent index returned by addAgent
  71918. * @returns agent state
  71919. */
  71920. getAgentState(index: number): number;
  71921. /**
  71922. * returns true if the agent in over an off mesh link connection
  71923. * @param index agent index returned by addAgent
  71924. * @returns true if over an off mesh link connection
  71925. */
  71926. overOffmeshConnection(index: number): boolean;
  71927. /**
  71928. * Gets the agent next target point on the path
  71929. * @param index agent index returned by addAgent
  71930. * @param result output world space position
  71931. */
  71932. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71933. /**
  71934. * remove a particular agent previously created
  71935. * @param index agent index returned by addAgent
  71936. */
  71937. removeAgent(index: number): void;
  71938. /**
  71939. * get the list of all agents attached to this crowd
  71940. * @returns list of agent indices
  71941. */
  71942. getAgents(): number[];
  71943. /**
  71944. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71945. * @param deltaTime in seconds
  71946. */
  71947. update(deltaTime: number): void;
  71948. /**
  71949. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71950. * @param index agent index returned by addAgent
  71951. * @param destination targeted world position
  71952. */
  71953. agentGoto(index: number, destination: Vector3): void;
  71954. /**
  71955. * Teleport the agent to a new position
  71956. * @param index agent index returned by addAgent
  71957. * @param destination targeted world position
  71958. */
  71959. agentTeleport(index: number, destination: Vector3): void;
  71960. /**
  71961. * Update agent parameters
  71962. * @param index agent index returned by addAgent
  71963. * @param parameters agent parameters
  71964. */
  71965. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71966. /**
  71967. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71968. * The queries will try to find a solution within those bounds
  71969. * default is (1,1,1)
  71970. * @param extent x,y,z value that define the extent around the queries point of reference
  71971. */
  71972. setDefaultQueryExtent(extent: Vector3): void;
  71973. /**
  71974. * Get the Bounding box extent specified by setDefaultQueryExtent
  71975. * @returns the box extent values
  71976. */
  71977. getDefaultQueryExtent(): Vector3;
  71978. /**
  71979. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71980. * @param result output the box extent values
  71981. */
  71982. getDefaultQueryExtentToRef(result: Vector3): void;
  71983. /**
  71984. * Release all resources
  71985. */
  71986. dispose(): void;
  71987. }
  71988. /**
  71989. * Configures an agent
  71990. */
  71991. export interface IAgentParameters {
  71992. /**
  71993. * Agent radius. [Limit: >= 0]
  71994. */
  71995. radius: number;
  71996. /**
  71997. * Agent height. [Limit: > 0]
  71998. */
  71999. height: number;
  72000. /**
  72001. * Maximum allowed acceleration. [Limit: >= 0]
  72002. */
  72003. maxAcceleration: number;
  72004. /**
  72005. * Maximum allowed speed. [Limit: >= 0]
  72006. */
  72007. maxSpeed: number;
  72008. /**
  72009. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  72010. */
  72011. collisionQueryRange: number;
  72012. /**
  72013. * The path visibility optimization range. [Limit: > 0]
  72014. */
  72015. pathOptimizationRange: number;
  72016. /**
  72017. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  72018. */
  72019. separationWeight: number;
  72020. }
  72021. /**
  72022. * Configures the navigation mesh creation
  72023. */
  72024. export interface INavMeshParameters {
  72025. /**
  72026. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  72027. */
  72028. cs: number;
  72029. /**
  72030. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  72031. */
  72032. ch: number;
  72033. /**
  72034. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  72035. */
  72036. walkableSlopeAngle: number;
  72037. /**
  72038. * Minimum floor to 'ceiling' height that will still allow the floor area to
  72039. * be considered walkable. [Limit: >= 3] [Units: vx]
  72040. */
  72041. walkableHeight: number;
  72042. /**
  72043. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  72044. */
  72045. walkableClimb: number;
  72046. /**
  72047. * The distance to erode/shrink the walkable area of the heightfield away from
  72048. * obstructions. [Limit: >=0] [Units: vx]
  72049. */
  72050. walkableRadius: number;
  72051. /**
  72052. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  72053. */
  72054. maxEdgeLen: number;
  72055. /**
  72056. * The maximum distance a simplfied contour's border edges should deviate
  72057. * the original raw contour. [Limit: >=0] [Units: vx]
  72058. */
  72059. maxSimplificationError: number;
  72060. /**
  72061. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  72062. */
  72063. minRegionArea: number;
  72064. /**
  72065. * Any regions with a span count smaller than this value will, if possible,
  72066. * be merged with larger regions. [Limit: >=0] [Units: vx]
  72067. */
  72068. mergeRegionArea: number;
  72069. /**
  72070. * The maximum number of vertices allowed for polygons generated during the
  72071. * contour to polygon conversion process. [Limit: >= 3]
  72072. */
  72073. maxVertsPerPoly: number;
  72074. /**
  72075. * Sets the sampling distance to use when generating the detail mesh.
  72076. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  72077. */
  72078. detailSampleDist: number;
  72079. /**
  72080. * The maximum distance the detail mesh surface should deviate from heightfield
  72081. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  72082. */
  72083. detailSampleMaxError: number;
  72084. }
  72085. }
  72086. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  72087. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  72088. import { Mesh } from "babylonjs/Meshes/mesh";
  72089. import { Scene } from "babylonjs/scene";
  72090. import { Vector3 } from "babylonjs/Maths/math";
  72091. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72092. /**
  72093. * RecastJS navigation plugin
  72094. */
  72095. export class RecastJSPlugin implements INavigationEnginePlugin {
  72096. /**
  72097. * Reference to the Recast library
  72098. */
  72099. bjsRECAST: any;
  72100. /**
  72101. * plugin name
  72102. */
  72103. name: string;
  72104. /**
  72105. * the first navmesh created. We might extend this to support multiple navmeshes
  72106. */
  72107. navMesh: any;
  72108. /**
  72109. * Initializes the recastJS plugin
  72110. * @param recastInjection can be used to inject your own recast reference
  72111. */
  72112. constructor(recastInjection?: any);
  72113. /**
  72114. * Creates a navigation mesh
  72115. * @param meshes array of all the geometry used to compute the navigatio mesh
  72116. * @param parameters bunch of parameters used to filter geometry
  72117. */
  72118. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  72119. /**
  72120. * Create a navigation mesh debug mesh
  72121. * @param scene is where the mesh will be added
  72122. * @returns debug display mesh
  72123. */
  72124. createDebugNavMesh(scene: Scene): Mesh;
  72125. /**
  72126. * Get a navigation mesh constrained position, closest to the parameter position
  72127. * @param position world position
  72128. * @returns the closest point to position constrained by the navigation mesh
  72129. */
  72130. getClosestPoint(position: Vector3): Vector3;
  72131. /**
  72132. * Get a navigation mesh constrained position, closest to the parameter position
  72133. * @param position world position
  72134. * @param result output the closest point to position constrained by the navigation mesh
  72135. */
  72136. getClosestPointToRef(position: Vector3, result: Vector3): void;
  72137. /**
  72138. * Get a navigation mesh constrained position, within a particular radius
  72139. * @param position world position
  72140. * @param maxRadius the maximum distance to the constrained world position
  72141. * @returns the closest point to position constrained by the navigation mesh
  72142. */
  72143. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  72144. /**
  72145. * Get a navigation mesh constrained position, within a particular radius
  72146. * @param position world position
  72147. * @param maxRadius the maximum distance to the constrained world position
  72148. * @param result output the closest point to position constrained by the navigation mesh
  72149. */
  72150. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  72151. /**
  72152. * Compute the final position from a segment made of destination-position
  72153. * @param position world position
  72154. * @param destination world position
  72155. * @returns the resulting point along the navmesh
  72156. */
  72157. moveAlong(position: Vector3, destination: Vector3): Vector3;
  72158. /**
  72159. * Compute the final position from a segment made of destination-position
  72160. * @param position world position
  72161. * @param destination world position
  72162. * @param result output the resulting point along the navmesh
  72163. */
  72164. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  72165. /**
  72166. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  72167. * @param start world position
  72168. * @param end world position
  72169. * @returns array containing world position composing the path
  72170. */
  72171. computePath(start: Vector3, end: Vector3): Vector3[];
  72172. /**
  72173. * Create a new Crowd so you can add agents
  72174. * @param maxAgents the maximum agent count in the crowd
  72175. * @param maxAgentRadius the maximum radius an agent can have
  72176. * @param scene to attach the crowd to
  72177. * @returns the crowd you can add agents to
  72178. */
  72179. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  72180. /**
  72181. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72182. * The queries will try to find a solution within those bounds
  72183. * default is (1,1,1)
  72184. * @param extent x,y,z value that define the extent around the queries point of reference
  72185. */
  72186. setDefaultQueryExtent(extent: Vector3): void;
  72187. /**
  72188. * Get the Bounding box extent specified by setDefaultQueryExtent
  72189. * @returns the box extent values
  72190. */
  72191. getDefaultQueryExtent(): Vector3;
  72192. /**
  72193. * build the navmesh from a previously saved state using getNavmeshData
  72194. * @param data the Uint8Array returned by getNavmeshData
  72195. */
  72196. buildFromNavmeshData(data: Uint8Array): void;
  72197. /**
  72198. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  72199. * @returns data the Uint8Array that can be saved and reused
  72200. */
  72201. getNavmeshData(): Uint8Array;
  72202. /**
  72203. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72204. * @param result output the box extent values
  72205. */
  72206. getDefaultQueryExtentToRef(result: Vector3): void;
  72207. /**
  72208. * Disposes
  72209. */
  72210. dispose(): void;
  72211. /**
  72212. * If this plugin is supported
  72213. * @returns true if plugin is supported
  72214. */
  72215. isSupported(): boolean;
  72216. }
  72217. /**
  72218. * Recast detour crowd implementation
  72219. */
  72220. export class RecastJSCrowd implements ICrowd {
  72221. /**
  72222. * Recast/detour plugin
  72223. */
  72224. bjsRECASTPlugin: RecastJSPlugin;
  72225. /**
  72226. * Link to the detour crowd
  72227. */
  72228. recastCrowd: any;
  72229. /**
  72230. * One transform per agent
  72231. */
  72232. transforms: TransformNode[];
  72233. /**
  72234. * All agents created
  72235. */
  72236. agents: number[];
  72237. /**
  72238. * Link to the scene is kept to unregister the crowd from the scene
  72239. */
  72240. private _scene;
  72241. /**
  72242. * Observer for crowd updates
  72243. */
  72244. private _onBeforeAnimationsObserver;
  72245. /**
  72246. * Constructor
  72247. * @param plugin recastJS plugin
  72248. * @param maxAgents the maximum agent count in the crowd
  72249. * @param maxAgentRadius the maximum radius an agent can have
  72250. * @param scene to attach the crowd to
  72251. * @returns the crowd you can add agents to
  72252. */
  72253. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  72254. /**
  72255. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72256. * You can attach anything to that node. The node position is updated in the scene update tick.
  72257. * @param pos world position that will be constrained by the navigation mesh
  72258. * @param parameters agent parameters
  72259. * @param transform hooked to the agent that will be update by the scene
  72260. * @returns agent index
  72261. */
  72262. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72263. /**
  72264. * Returns the agent position in world space
  72265. * @param index agent index returned by addAgent
  72266. * @returns world space position
  72267. */
  72268. getAgentPosition(index: number): Vector3;
  72269. /**
  72270. * Returns the agent position result in world space
  72271. * @param index agent index returned by addAgent
  72272. * @param result output world space position
  72273. */
  72274. getAgentPositionToRef(index: number, result: Vector3): void;
  72275. /**
  72276. * Returns the agent velocity in world space
  72277. * @param index agent index returned by addAgent
  72278. * @returns world space velocity
  72279. */
  72280. getAgentVelocity(index: number): Vector3;
  72281. /**
  72282. * Returns the agent velocity result in world space
  72283. * @param index agent index returned by addAgent
  72284. * @param result output world space velocity
  72285. */
  72286. getAgentVelocityToRef(index: number, result: Vector3): void;
  72287. /**
  72288. * Returns the agent next target point on the path
  72289. * @param index agent index returned by addAgent
  72290. * @returns world space position
  72291. */
  72292. getAgentNextTargetPath(index: number): Vector3;
  72293. /**
  72294. * Returns the agent next target point on the path
  72295. * @param index agent index returned by addAgent
  72296. * @param result output world space position
  72297. */
  72298. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72299. /**
  72300. * Gets the agent state
  72301. * @param index agent index returned by addAgent
  72302. * @returns agent state
  72303. */
  72304. getAgentState(index: number): number;
  72305. /**
  72306. * returns true if the agent in over an off mesh link connection
  72307. * @param index agent index returned by addAgent
  72308. * @returns true if over an off mesh link connection
  72309. */
  72310. overOffmeshConnection(index: number): boolean;
  72311. /**
  72312. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72313. * @param index agent index returned by addAgent
  72314. * @param destination targeted world position
  72315. */
  72316. agentGoto(index: number, destination: Vector3): void;
  72317. /**
  72318. * Teleport the agent to a new position
  72319. * @param index agent index returned by addAgent
  72320. * @param destination targeted world position
  72321. */
  72322. agentTeleport(index: number, destination: Vector3): void;
  72323. /**
  72324. * Update agent parameters
  72325. * @param index agent index returned by addAgent
  72326. * @param parameters agent parameters
  72327. */
  72328. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72329. /**
  72330. * remove a particular agent previously created
  72331. * @param index agent index returned by addAgent
  72332. */
  72333. removeAgent(index: number): void;
  72334. /**
  72335. * get the list of all agents attached to this crowd
  72336. * @returns list of agent indices
  72337. */
  72338. getAgents(): number[];
  72339. /**
  72340. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72341. * @param deltaTime in seconds
  72342. */
  72343. update(deltaTime: number): void;
  72344. /**
  72345. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72346. * The queries will try to find a solution within those bounds
  72347. * default is (1,1,1)
  72348. * @param extent x,y,z value that define the extent around the queries point of reference
  72349. */
  72350. setDefaultQueryExtent(extent: Vector3): void;
  72351. /**
  72352. * Get the Bounding box extent specified by setDefaultQueryExtent
  72353. * @returns the box extent values
  72354. */
  72355. getDefaultQueryExtent(): Vector3;
  72356. /**
  72357. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72358. * @param result output the box extent values
  72359. */
  72360. getDefaultQueryExtentToRef(result: Vector3): void;
  72361. /**
  72362. * Release all resources
  72363. */
  72364. dispose(): void;
  72365. }
  72366. }
  72367. declare module "babylonjs/Navigation/Plugins/index" {
  72368. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  72369. }
  72370. declare module "babylonjs/Navigation/index" {
  72371. export * from "babylonjs/Navigation/INavigationEngine";
  72372. export * from "babylonjs/Navigation/Plugins/index";
  72373. }
  72374. declare module "babylonjs/Offline/database" {
  72375. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  72376. /**
  72377. * Class used to enable access to IndexedDB
  72378. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72379. */
  72380. export class Database implements IOfflineProvider {
  72381. private _callbackManifestChecked;
  72382. private _currentSceneUrl;
  72383. private _db;
  72384. private _enableSceneOffline;
  72385. private _enableTexturesOffline;
  72386. private _manifestVersionFound;
  72387. private _mustUpdateRessources;
  72388. private _hasReachedQuota;
  72389. private _isSupported;
  72390. private _idbFactory;
  72391. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72392. private static IsUASupportingBlobStorage;
  72393. /**
  72394. * Gets a boolean indicating if Database storate is enabled (off by default)
  72395. */
  72396. static IDBStorageEnabled: boolean;
  72397. /**
  72398. * Gets a boolean indicating if scene must be saved in the database
  72399. */
  72400. get enableSceneOffline(): boolean;
  72401. /**
  72402. * Gets a boolean indicating if textures must be saved in the database
  72403. */
  72404. get enableTexturesOffline(): boolean;
  72405. /**
  72406. * Creates a new Database
  72407. * @param urlToScene defines the url to load the scene
  72408. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72409. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72410. */
  72411. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72412. private static _ParseURL;
  72413. private static _ReturnFullUrlLocation;
  72414. private _checkManifestFile;
  72415. /**
  72416. * Open the database and make it available
  72417. * @param successCallback defines the callback to call on success
  72418. * @param errorCallback defines the callback to call on error
  72419. */
  72420. open(successCallback: () => void, errorCallback: () => void): void;
  72421. /**
  72422. * Loads an image from the database
  72423. * @param url defines the url to load from
  72424. * @param image defines the target DOM image
  72425. */
  72426. loadImage(url: string, image: HTMLImageElement): void;
  72427. private _loadImageFromDBAsync;
  72428. private _saveImageIntoDBAsync;
  72429. private _checkVersionFromDB;
  72430. private _loadVersionFromDBAsync;
  72431. private _saveVersionIntoDBAsync;
  72432. /**
  72433. * Loads a file from database
  72434. * @param url defines the URL to load from
  72435. * @param sceneLoaded defines a callback to call on success
  72436. * @param progressCallBack defines a callback to call when progress changed
  72437. * @param errorCallback defines a callback to call on error
  72438. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72439. */
  72440. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72441. private _loadFileAsync;
  72442. private _saveFileAsync;
  72443. /**
  72444. * Validates if xhr data is correct
  72445. * @param xhr defines the request to validate
  72446. * @param dataType defines the expected data type
  72447. * @returns true if data is correct
  72448. */
  72449. private static _ValidateXHRData;
  72450. }
  72451. }
  72452. declare module "babylonjs/Offline/index" {
  72453. export * from "babylonjs/Offline/database";
  72454. export * from "babylonjs/Offline/IOfflineProvider";
  72455. }
  72456. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  72457. /** @hidden */
  72458. export var gpuUpdateParticlesPixelShader: {
  72459. name: string;
  72460. shader: string;
  72461. };
  72462. }
  72463. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  72464. /** @hidden */
  72465. export var gpuUpdateParticlesVertexShader: {
  72466. name: string;
  72467. shader: string;
  72468. };
  72469. }
  72470. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  72471. /** @hidden */
  72472. export var clipPlaneFragmentDeclaration2: {
  72473. name: string;
  72474. shader: string;
  72475. };
  72476. }
  72477. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  72478. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  72479. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  72480. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72481. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  72482. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  72483. /** @hidden */
  72484. export var gpuRenderParticlesPixelShader: {
  72485. name: string;
  72486. shader: string;
  72487. };
  72488. }
  72489. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  72490. /** @hidden */
  72491. export var clipPlaneVertexDeclaration2: {
  72492. name: string;
  72493. shader: string;
  72494. };
  72495. }
  72496. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  72497. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  72498. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  72499. /** @hidden */
  72500. export var gpuRenderParticlesVertexShader: {
  72501. name: string;
  72502. shader: string;
  72503. };
  72504. }
  72505. declare module "babylonjs/Particles/gpuParticleSystem" {
  72506. import { Nullable } from "babylonjs/types";
  72507. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  72508. import { Observable } from "babylonjs/Misc/observable";
  72509. import { Matrix } from "babylonjs/Maths/math.vector";
  72510. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  72511. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72512. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  72513. import { IDisposable } from "babylonjs/scene";
  72514. import { Effect } from "babylonjs/Materials/effect";
  72515. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72516. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72517. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  72518. import { Scene } from "babylonjs/scene";
  72519. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  72520. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  72521. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  72522. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  72523. /**
  72524. * This represents a GPU particle system in Babylon
  72525. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72526. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72527. */
  72528. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72529. /**
  72530. * The layer mask we are rendering the particles through.
  72531. */
  72532. layerMask: number;
  72533. private _capacity;
  72534. private _activeCount;
  72535. private _currentActiveCount;
  72536. private _accumulatedCount;
  72537. private _renderEffect;
  72538. private _updateEffect;
  72539. private _buffer0;
  72540. private _buffer1;
  72541. private _spriteBuffer;
  72542. private _updateVAO;
  72543. private _renderVAO;
  72544. private _targetIndex;
  72545. private _sourceBuffer;
  72546. private _targetBuffer;
  72547. private _currentRenderId;
  72548. private _started;
  72549. private _stopped;
  72550. private _timeDelta;
  72551. private _randomTexture;
  72552. private _randomTexture2;
  72553. private _attributesStrideSize;
  72554. private _updateEffectOptions;
  72555. private _randomTextureSize;
  72556. private _actualFrame;
  72557. private _customEffect;
  72558. private readonly _rawTextureWidth;
  72559. /**
  72560. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72561. */
  72562. static get IsSupported(): boolean;
  72563. /**
  72564. * An event triggered when the system is disposed.
  72565. */
  72566. onDisposeObservable: Observable<IParticleSystem>;
  72567. /**
  72568. * An event triggered when the system is stopped
  72569. */
  72570. onStoppedObservable: Observable<IParticleSystem>;
  72571. /**
  72572. * Gets the maximum number of particles active at the same time.
  72573. * @returns The max number of active particles.
  72574. */
  72575. getCapacity(): number;
  72576. /**
  72577. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72578. * to override the particles.
  72579. */
  72580. forceDepthWrite: boolean;
  72581. /**
  72582. * Gets or set the number of active particles
  72583. */
  72584. get activeParticleCount(): number;
  72585. set activeParticleCount(value: number);
  72586. private _preWarmDone;
  72587. /**
  72588. * Specifies if the particles are updated in emitter local space or world space.
  72589. */
  72590. isLocal: boolean;
  72591. /** Gets or sets a matrix to use to compute projection */
  72592. defaultProjectionMatrix: Matrix;
  72593. /**
  72594. * Is this system ready to be used/rendered
  72595. * @return true if the system is ready
  72596. */
  72597. isReady(): boolean;
  72598. /**
  72599. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72600. * @returns True if it has been started, otherwise false.
  72601. */
  72602. isStarted(): boolean;
  72603. /**
  72604. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72605. * @returns True if it has been stopped, otherwise false.
  72606. */
  72607. isStopped(): boolean;
  72608. /**
  72609. * Gets a boolean indicating that the system is stopping
  72610. * @returns true if the system is currently stopping
  72611. */
  72612. isStopping(): boolean;
  72613. /**
  72614. * Gets the number of particles active at the same time.
  72615. * @returns The number of active particles.
  72616. */
  72617. getActiveCount(): number;
  72618. /**
  72619. * Starts the particle system and begins to emit
  72620. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72621. */
  72622. start(delay?: number): void;
  72623. /**
  72624. * Stops the particle system.
  72625. */
  72626. stop(): void;
  72627. /**
  72628. * Remove all active particles
  72629. */
  72630. reset(): void;
  72631. /**
  72632. * Returns the string "GPUParticleSystem"
  72633. * @returns a string containing the class name
  72634. */
  72635. getClassName(): string;
  72636. /**
  72637. * Gets the custom effect used to render the particles
  72638. * @param blendMode Blend mode for which the effect should be retrieved
  72639. * @returns The effect
  72640. */
  72641. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72642. /**
  72643. * Sets the custom effect used to render the particles
  72644. * @param effect The effect to set
  72645. * @param blendMode Blend mode for which the effect should be set
  72646. */
  72647. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72648. /** @hidden */
  72649. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72650. /**
  72651. * Observable that will be called just before the particles are drawn
  72652. */
  72653. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72654. /**
  72655. * Gets the name of the particle vertex shader
  72656. */
  72657. get vertexShaderName(): string;
  72658. private _colorGradientsTexture;
  72659. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72660. /**
  72661. * Adds a new color gradient
  72662. * @param gradient defines the gradient to use (between 0 and 1)
  72663. * @param color1 defines the color to affect to the specified gradient
  72664. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72665. * @returns the current particle system
  72666. */
  72667. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72668. private _refreshColorGradient;
  72669. /** Force the system to rebuild all gradients that need to be resync */
  72670. forceRefreshGradients(): void;
  72671. /**
  72672. * Remove a specific color gradient
  72673. * @param gradient defines the gradient to remove
  72674. * @returns the current particle system
  72675. */
  72676. removeColorGradient(gradient: number): GPUParticleSystem;
  72677. private _angularSpeedGradientsTexture;
  72678. private _sizeGradientsTexture;
  72679. private _velocityGradientsTexture;
  72680. private _limitVelocityGradientsTexture;
  72681. private _dragGradientsTexture;
  72682. private _addFactorGradient;
  72683. /**
  72684. * Adds a new size gradient
  72685. * @param gradient defines the gradient to use (between 0 and 1)
  72686. * @param factor defines the size factor to affect to the specified gradient
  72687. * @returns the current particle system
  72688. */
  72689. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72690. /**
  72691. * Remove a specific size gradient
  72692. * @param gradient defines the gradient to remove
  72693. * @returns the current particle system
  72694. */
  72695. removeSizeGradient(gradient: number): GPUParticleSystem;
  72696. private _refreshFactorGradient;
  72697. /**
  72698. * Adds a new angular speed gradient
  72699. * @param gradient defines the gradient to use (between 0 and 1)
  72700. * @param factor defines the angular speed to affect to the specified gradient
  72701. * @returns the current particle system
  72702. */
  72703. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72704. /**
  72705. * Remove a specific angular speed gradient
  72706. * @param gradient defines the gradient to remove
  72707. * @returns the current particle system
  72708. */
  72709. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72710. /**
  72711. * Adds a new velocity gradient
  72712. * @param gradient defines the gradient to use (between 0 and 1)
  72713. * @param factor defines the velocity to affect to the specified gradient
  72714. * @returns the current particle system
  72715. */
  72716. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72717. /**
  72718. * Remove a specific velocity gradient
  72719. * @param gradient defines the gradient to remove
  72720. * @returns the current particle system
  72721. */
  72722. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72723. /**
  72724. * Adds a new limit velocity gradient
  72725. * @param gradient defines the gradient to use (between 0 and 1)
  72726. * @param factor defines the limit velocity value to affect to the specified gradient
  72727. * @returns the current particle system
  72728. */
  72729. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72730. /**
  72731. * Remove a specific limit velocity gradient
  72732. * @param gradient defines the gradient to remove
  72733. * @returns the current particle system
  72734. */
  72735. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72736. /**
  72737. * Adds a new drag gradient
  72738. * @param gradient defines the gradient to use (between 0 and 1)
  72739. * @param factor defines the drag value to affect to the specified gradient
  72740. * @returns the current particle system
  72741. */
  72742. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72743. /**
  72744. * Remove a specific drag gradient
  72745. * @param gradient defines the gradient to remove
  72746. * @returns the current particle system
  72747. */
  72748. removeDragGradient(gradient: number): GPUParticleSystem;
  72749. /**
  72750. * Not supported by GPUParticleSystem
  72751. * @param gradient defines the gradient to use (between 0 and 1)
  72752. * @param factor defines the emit rate value to affect to the specified gradient
  72753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72754. * @returns the current particle system
  72755. */
  72756. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72757. /**
  72758. * Not supported by GPUParticleSystem
  72759. * @param gradient defines the gradient to remove
  72760. * @returns the current particle system
  72761. */
  72762. removeEmitRateGradient(gradient: number): IParticleSystem;
  72763. /**
  72764. * Not supported by GPUParticleSystem
  72765. * @param gradient defines the gradient to use (between 0 and 1)
  72766. * @param factor defines the start size value to affect to the specified gradient
  72767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72768. * @returns the current particle system
  72769. */
  72770. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72771. /**
  72772. * Not supported by GPUParticleSystem
  72773. * @param gradient defines the gradient to remove
  72774. * @returns the current particle system
  72775. */
  72776. removeStartSizeGradient(gradient: number): IParticleSystem;
  72777. /**
  72778. * Not supported by GPUParticleSystem
  72779. * @param gradient defines the gradient to use (between 0 and 1)
  72780. * @param min defines the color remap minimal range
  72781. * @param max defines the color remap maximal range
  72782. * @returns the current particle system
  72783. */
  72784. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72785. /**
  72786. * Not supported by GPUParticleSystem
  72787. * @param gradient defines the gradient to remove
  72788. * @returns the current particle system
  72789. */
  72790. removeColorRemapGradient(): IParticleSystem;
  72791. /**
  72792. * Not supported by GPUParticleSystem
  72793. * @param gradient defines the gradient to use (between 0 and 1)
  72794. * @param min defines the alpha remap minimal range
  72795. * @param max defines the alpha remap maximal range
  72796. * @returns the current particle system
  72797. */
  72798. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72799. /**
  72800. * Not supported by GPUParticleSystem
  72801. * @param gradient defines the gradient to remove
  72802. * @returns the current particle system
  72803. */
  72804. removeAlphaRemapGradient(): IParticleSystem;
  72805. /**
  72806. * Not supported by GPUParticleSystem
  72807. * @param gradient defines the gradient to use (between 0 and 1)
  72808. * @param color defines the color to affect to the specified gradient
  72809. * @returns the current particle system
  72810. */
  72811. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72812. /**
  72813. * Not supported by GPUParticleSystem
  72814. * @param gradient defines the gradient to remove
  72815. * @returns the current particle system
  72816. */
  72817. removeRampGradient(): IParticleSystem;
  72818. /**
  72819. * Not supported by GPUParticleSystem
  72820. * @returns the list of ramp gradients
  72821. */
  72822. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72823. /**
  72824. * Not supported by GPUParticleSystem
  72825. * Gets or sets a boolean indicating that ramp gradients must be used
  72826. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72827. */
  72828. get useRampGradients(): boolean;
  72829. set useRampGradients(value: boolean);
  72830. /**
  72831. * Not supported by GPUParticleSystem
  72832. * @param gradient defines the gradient to use (between 0 and 1)
  72833. * @param factor defines the life time factor to affect to the specified gradient
  72834. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72835. * @returns the current particle system
  72836. */
  72837. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72838. /**
  72839. * Not supported by GPUParticleSystem
  72840. * @param gradient defines the gradient to remove
  72841. * @returns the current particle system
  72842. */
  72843. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72844. /**
  72845. * Instantiates a GPU particle system.
  72846. * 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.
  72847. * @param name The name of the particle system
  72848. * @param options The options used to create the system
  72849. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72850. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72851. * @param customEffect a custom effect used to change the way particles are rendered by default
  72852. */
  72853. constructor(name: string, options: Partial<{
  72854. capacity: number;
  72855. randomTextureSize: number;
  72856. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72857. protected _reset(): void;
  72858. private _createUpdateVAO;
  72859. private _createRenderVAO;
  72860. private _initialize;
  72861. /** @hidden */
  72862. _recreateUpdateEffect(): void;
  72863. private _getEffect;
  72864. /**
  72865. * Fill the defines array according to the current settings of the particle system
  72866. * @param defines Array to be updated
  72867. * @param blendMode blend mode to take into account when updating the array
  72868. */
  72869. fillDefines(defines: Array<string>, blendMode?: number): void;
  72870. /**
  72871. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72872. * @param uniforms Uniforms array to fill
  72873. * @param attributes Attributes array to fill
  72874. * @param samplers Samplers array to fill
  72875. */
  72876. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72877. /** @hidden */
  72878. _recreateRenderEffect(): Effect;
  72879. /**
  72880. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72881. * @param preWarm defines if we are in the pre-warmimg phase
  72882. */
  72883. animate(preWarm?: boolean): void;
  72884. private _createFactorGradientTexture;
  72885. private _createSizeGradientTexture;
  72886. private _createAngularSpeedGradientTexture;
  72887. private _createVelocityGradientTexture;
  72888. private _createLimitVelocityGradientTexture;
  72889. private _createDragGradientTexture;
  72890. private _createColorGradientTexture;
  72891. /**
  72892. * Renders the particle system in its current state
  72893. * @param preWarm defines if the system should only update the particles but not render them
  72894. * @returns the current number of particles
  72895. */
  72896. render(preWarm?: boolean): number;
  72897. /**
  72898. * Rebuilds the particle system
  72899. */
  72900. rebuild(): void;
  72901. private _releaseBuffers;
  72902. private _releaseVAOs;
  72903. /**
  72904. * Disposes the particle system and free the associated resources
  72905. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72906. */
  72907. dispose(disposeTexture?: boolean): void;
  72908. /**
  72909. * Clones the particle system.
  72910. * @param name The name of the cloned object
  72911. * @param newEmitter The new emitter to use
  72912. * @returns the cloned particle system
  72913. */
  72914. clone(name: string, newEmitter: any): GPUParticleSystem;
  72915. /**
  72916. * Serializes the particle system to a JSON object
  72917. * @param serializeTexture defines if the texture must be serialized as well
  72918. * @returns the JSON object
  72919. */
  72920. serialize(serializeTexture?: boolean): any;
  72921. /**
  72922. * Parses a JSON object to create a GPU particle system.
  72923. * @param parsedParticleSystem The JSON object to parse
  72924. * @param sceneOrEngine The scene or the engine to create the particle system in
  72925. * @param rootUrl The root url to use to load external dependencies like texture
  72926. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72927. * @returns the parsed GPU particle system
  72928. */
  72929. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72930. }
  72931. }
  72932. declare module "babylonjs/Particles/particleSystemSet" {
  72933. import { Nullable } from "babylonjs/types";
  72934. import { Color3 } from "babylonjs/Maths/math.color";
  72935. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72937. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72938. import { Scene, IDisposable } from "babylonjs/scene";
  72939. /**
  72940. * Represents a set of particle systems working together to create a specific effect
  72941. */
  72942. export class ParticleSystemSet implements IDisposable {
  72943. /**
  72944. * Gets or sets base Assets URL
  72945. */
  72946. static BaseAssetsUrl: string;
  72947. private _emitterCreationOptions;
  72948. private _emitterNode;
  72949. /**
  72950. * Gets the particle system list
  72951. */
  72952. systems: IParticleSystem[];
  72953. /**
  72954. * Gets the emitter node used with this set
  72955. */
  72956. get emitterNode(): Nullable<TransformNode>;
  72957. /**
  72958. * Creates a new emitter mesh as a sphere
  72959. * @param options defines the options used to create the sphere
  72960. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72961. * @param scene defines the hosting scene
  72962. */
  72963. setEmitterAsSphere(options: {
  72964. diameter: number;
  72965. segments: number;
  72966. color: Color3;
  72967. }, renderingGroupId: number, scene: Scene): void;
  72968. /**
  72969. * Starts all particle systems of the set
  72970. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72971. */
  72972. start(emitter?: AbstractMesh): void;
  72973. /**
  72974. * Release all associated resources
  72975. */
  72976. dispose(): void;
  72977. /**
  72978. * Serialize the set into a JSON compatible object
  72979. * @param serializeTexture defines if the texture must be serialized as well
  72980. * @returns a JSON compatible representation of the set
  72981. */
  72982. serialize(serializeTexture?: boolean): any;
  72983. /**
  72984. * Parse a new ParticleSystemSet from a serialized source
  72985. * @param data defines a JSON compatible representation of the set
  72986. * @param scene defines the hosting scene
  72987. * @param gpu defines if we want GPU particles or CPU particles
  72988. * @returns a new ParticleSystemSet
  72989. */
  72990. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72991. }
  72992. }
  72993. declare module "babylonjs/Particles/particleHelper" {
  72994. import { Nullable } from "babylonjs/types";
  72995. import { Scene } from "babylonjs/scene";
  72996. import { Vector3 } from "babylonjs/Maths/math.vector";
  72997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72998. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72999. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  73000. /**
  73001. * This class is made for on one-liner static method to help creating particle system set.
  73002. */
  73003. export class ParticleHelper {
  73004. /**
  73005. * Gets or sets base Assets URL
  73006. */
  73007. static BaseAssetsUrl: string;
  73008. /** Define the Url to load snippets */
  73009. static SnippetUrl: string;
  73010. /**
  73011. * Create a default particle system that you can tweak
  73012. * @param emitter defines the emitter to use
  73013. * @param capacity defines the system capacity (default is 500 particles)
  73014. * @param scene defines the hosting scene
  73015. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  73016. * @returns the new Particle system
  73017. */
  73018. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  73019. /**
  73020. * This is the main static method (one-liner) of this helper to create different particle systems
  73021. * @param type This string represents the type to the particle system to create
  73022. * @param scene The scene where the particle system should live
  73023. * @param gpu If the system will use gpu
  73024. * @returns the ParticleSystemSet created
  73025. */
  73026. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  73027. /**
  73028. * Static function used to export a particle system to a ParticleSystemSet variable.
  73029. * Please note that the emitter shape is not exported
  73030. * @param systems defines the particle systems to export
  73031. * @returns the created particle system set
  73032. */
  73033. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  73034. /**
  73035. * Creates a particle system from a snippet saved in a remote file
  73036. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  73037. * @param url defines the url to load from
  73038. * @param scene defines the hosting scene
  73039. * @param gpu If the system will use gpu
  73040. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73041. * @returns a promise that will resolve to the new particle system
  73042. */
  73043. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  73044. /**
  73045. * Creates a particle system from a snippet saved by the particle system editor
  73046. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  73047. * @param scene defines the hosting scene
  73048. * @param gpu If the system will use gpu
  73049. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73050. * @returns a promise that will resolve to the new particle system
  73051. */
  73052. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  73053. }
  73054. }
  73055. declare module "babylonjs/Particles/particleSystemComponent" {
  73056. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  73057. import { Effect } from "babylonjs/Materials/effect";
  73058. import "babylonjs/Shaders/particles.vertex";
  73059. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  73060. module "babylonjs/Engines/engine" {
  73061. interface Engine {
  73062. /**
  73063. * Create an effect to use with particle systems.
  73064. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  73065. * the particle system for which you want to create a custom effect in the last parameter
  73066. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  73067. * @param uniformsNames defines a list of attribute names
  73068. * @param samplers defines an array of string used to represent textures
  73069. * @param defines defines the string containing the defines to use to compile the shaders
  73070. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  73071. * @param onCompiled defines a function to call when the effect creation is successful
  73072. * @param onError defines a function to call when the effect creation has failed
  73073. * @param particleSystem the particle system you want to create the effect for
  73074. * @returns the new Effect
  73075. */
  73076. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  73077. }
  73078. }
  73079. module "babylonjs/Meshes/mesh" {
  73080. interface Mesh {
  73081. /**
  73082. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  73083. * @returns an array of IParticleSystem
  73084. */
  73085. getEmittedParticleSystems(): IParticleSystem[];
  73086. /**
  73087. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  73088. * @returns an array of IParticleSystem
  73089. */
  73090. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  73091. }
  73092. }
  73093. }
  73094. declare module "babylonjs/Particles/pointsCloudSystem" {
  73095. import { Color4 } from "babylonjs/Maths/math";
  73096. import { Mesh } from "babylonjs/Meshes/mesh";
  73097. import { Scene, IDisposable } from "babylonjs/scene";
  73098. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  73099. /** Defines the 4 color options */
  73100. export enum PointColor {
  73101. /** color value */
  73102. Color = 2,
  73103. /** uv value */
  73104. UV = 1,
  73105. /** random value */
  73106. Random = 0,
  73107. /** stated value */
  73108. Stated = 3
  73109. }
  73110. /**
  73111. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  73112. * 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.
  73113. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  73114. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  73115. *
  73116. * Full documentation here : TO BE ENTERED
  73117. */
  73118. export class PointsCloudSystem implements IDisposable {
  73119. /**
  73120. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  73121. * Example : var p = SPS.particles[i];
  73122. */
  73123. particles: CloudPoint[];
  73124. /**
  73125. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  73126. */
  73127. nbParticles: number;
  73128. /**
  73129. * This a counter for your own usage. It's not set by any SPS functions.
  73130. */
  73131. counter: number;
  73132. /**
  73133. * The PCS name. This name is also given to the underlying mesh.
  73134. */
  73135. name: string;
  73136. /**
  73137. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  73138. */
  73139. mesh: Mesh;
  73140. /**
  73141. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  73142. * Please read :
  73143. */
  73144. vars: any;
  73145. /**
  73146. * @hidden
  73147. */
  73148. _size: number;
  73149. private _scene;
  73150. private _promises;
  73151. private _positions;
  73152. private _indices;
  73153. private _normals;
  73154. private _colors;
  73155. private _uvs;
  73156. private _indices32;
  73157. private _positions32;
  73158. private _colors32;
  73159. private _uvs32;
  73160. private _updatable;
  73161. private _isVisibilityBoxLocked;
  73162. private _alwaysVisible;
  73163. private _groups;
  73164. private _groupCounter;
  73165. private _computeParticleColor;
  73166. private _computeParticleTexture;
  73167. private _computeParticleRotation;
  73168. private _computeBoundingBox;
  73169. private _isReady;
  73170. /**
  73171. * Creates a PCS (Points Cloud System) object
  73172. * @param name (String) is the PCS name, this will be the underlying mesh name
  73173. * @param pointSize (number) is the size for each point
  73174. * @param scene (Scene) is the scene in which the PCS is added
  73175. * @param options defines the options of the PCS e.g.
  73176. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  73177. */
  73178. constructor(name: string, pointSize: number, scene: Scene, options?: {
  73179. updatable?: boolean;
  73180. });
  73181. /**
  73182. * Builds the PCS underlying mesh. Returns a standard Mesh.
  73183. * If no points were added to the PCS, the returned mesh is just a single point.
  73184. * @returns a promise for the created mesh
  73185. */
  73186. buildMeshAsync(): Promise<Mesh>;
  73187. /**
  73188. * @hidden
  73189. */
  73190. private _buildMesh;
  73191. private _addParticle;
  73192. private _randomUnitVector;
  73193. private _getColorIndicesForCoord;
  73194. private _setPointsColorOrUV;
  73195. private _colorFromTexture;
  73196. private _calculateDensity;
  73197. /**
  73198. * Adds points to the PCS in random positions within a unit sphere
  73199. * @param nb (positive integer) the number of particles to be created from this model
  73200. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  73201. * @returns the number of groups in the system
  73202. */
  73203. addPoints(nb: number, pointFunction?: any): number;
  73204. /**
  73205. * Adds points to the PCS from the surface of the model shape
  73206. * @param mesh is any Mesh object that will be used as a surface model for the points
  73207. * @param nb (positive integer) the number of particles to be created from this model
  73208. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73209. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73210. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73211. * @returns the number of groups in the system
  73212. */
  73213. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73214. /**
  73215. * Adds points to the PCS inside the model shape
  73216. * @param mesh is any Mesh object that will be used as a surface model for the points
  73217. * @param nb (positive integer) the number of particles to be created from this model
  73218. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73219. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73220. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73221. * @returns the number of groups in the system
  73222. */
  73223. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73224. /**
  73225. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  73226. * This method calls `updateParticle()` for each particle of the SPS.
  73227. * For an animated SPS, it is usually called within the render loop.
  73228. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  73229. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  73230. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  73231. * @returns the PCS.
  73232. */
  73233. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  73234. /**
  73235. * Disposes the PCS.
  73236. */
  73237. dispose(): void;
  73238. /**
  73239. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  73240. * doc :
  73241. * @returns the PCS.
  73242. */
  73243. refreshVisibleSize(): PointsCloudSystem;
  73244. /**
  73245. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  73246. * @param size the size (float) of the visibility box
  73247. * note : this doesn't lock the PCS mesh bounding box.
  73248. * doc :
  73249. */
  73250. setVisibilityBox(size: number): void;
  73251. /**
  73252. * Gets whether the PCS is always visible or not
  73253. * doc :
  73254. */
  73255. get isAlwaysVisible(): boolean;
  73256. /**
  73257. * Sets the PCS as always visible or not
  73258. * doc :
  73259. */
  73260. set isAlwaysVisible(val: boolean);
  73261. /**
  73262. * Tells to `setParticles()` to compute the particle rotations or not
  73263. * Default value : false. The PCS is faster when it's set to false
  73264. * Note : particle rotations are only applied to parent particles
  73265. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  73266. */
  73267. set computeParticleRotation(val: boolean);
  73268. /**
  73269. * Tells to `setParticles()` to compute the particle colors or not.
  73270. * Default value : true. The PCS is faster when it's set to false.
  73271. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73272. */
  73273. set computeParticleColor(val: boolean);
  73274. set computeParticleTexture(val: boolean);
  73275. /**
  73276. * Gets if `setParticles()` computes the particle colors or not.
  73277. * Default value : false. The PCS is faster when it's set to false.
  73278. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73279. */
  73280. get computeParticleColor(): boolean;
  73281. /**
  73282. * Gets if `setParticles()` computes the particle textures or not.
  73283. * Default value : false. The PCS is faster when it's set to false.
  73284. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  73285. */
  73286. get computeParticleTexture(): boolean;
  73287. /**
  73288. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  73289. */
  73290. set computeBoundingBox(val: boolean);
  73291. /**
  73292. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  73293. */
  73294. get computeBoundingBox(): boolean;
  73295. /**
  73296. * This function does nothing. It may be overwritten to set all the particle first values.
  73297. * The PCS doesn't call this function, you may have to call it by your own.
  73298. * doc :
  73299. */
  73300. initParticles(): void;
  73301. /**
  73302. * This function does nothing. It may be overwritten to recycle a particle
  73303. * The PCS doesn't call this function, you can to call it
  73304. * doc :
  73305. * @param particle The particle to recycle
  73306. * @returns the recycled particle
  73307. */
  73308. recycleParticle(particle: CloudPoint): CloudPoint;
  73309. /**
  73310. * Updates a particle : this function should be overwritten by the user.
  73311. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  73312. * doc :
  73313. * @example : just set a particle position or velocity and recycle conditions
  73314. * @param particle The particle to update
  73315. * @returns the updated particle
  73316. */
  73317. updateParticle(particle: CloudPoint): CloudPoint;
  73318. /**
  73319. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  73320. * This does nothing and may be overwritten by the user.
  73321. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73322. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73323. * @param update the boolean update value actually passed to setParticles()
  73324. */
  73325. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73326. /**
  73327. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  73328. * This will be passed three parameters.
  73329. * This does nothing and may be overwritten by the user.
  73330. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73331. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73332. * @param update the boolean update value actually passed to setParticles()
  73333. */
  73334. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73335. }
  73336. }
  73337. declare module "babylonjs/Particles/cloudPoint" {
  73338. import { Nullable } from "babylonjs/types";
  73339. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  73340. import { Mesh } from "babylonjs/Meshes/mesh";
  73341. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  73342. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  73343. /**
  73344. * Represents one particle of a points cloud system.
  73345. */
  73346. export class CloudPoint {
  73347. /**
  73348. * particle global index
  73349. */
  73350. idx: number;
  73351. /**
  73352. * The color of the particle
  73353. */
  73354. color: Nullable<Color4>;
  73355. /**
  73356. * The world space position of the particle.
  73357. */
  73358. position: Vector3;
  73359. /**
  73360. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73361. */
  73362. rotation: Vector3;
  73363. /**
  73364. * The world space rotation quaternion of the particle.
  73365. */
  73366. rotationQuaternion: Nullable<Quaternion>;
  73367. /**
  73368. * The uv of the particle.
  73369. */
  73370. uv: Nullable<Vector2>;
  73371. /**
  73372. * The current speed of the particle.
  73373. */
  73374. velocity: Vector3;
  73375. /**
  73376. * The pivot point in the particle local space.
  73377. */
  73378. pivot: Vector3;
  73379. /**
  73380. * Must the particle be translated from its pivot point in its local space ?
  73381. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73382. * Default : false
  73383. */
  73384. translateFromPivot: boolean;
  73385. /**
  73386. * Index of this particle in the global "positions" array (Internal use)
  73387. * @hidden
  73388. */
  73389. _pos: number;
  73390. /**
  73391. * @hidden Index of this particle in the global "indices" array (Internal use)
  73392. */
  73393. _ind: number;
  73394. /**
  73395. * Group this particle belongs to
  73396. */
  73397. _group: PointsGroup;
  73398. /**
  73399. * Group id of this particle
  73400. */
  73401. groupId: number;
  73402. /**
  73403. * Index of the particle in its group id (Internal use)
  73404. */
  73405. idxInGroup: number;
  73406. /**
  73407. * @hidden Particle BoundingInfo object (Internal use)
  73408. */
  73409. _boundingInfo: BoundingInfo;
  73410. /**
  73411. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73412. */
  73413. _pcs: PointsCloudSystem;
  73414. /**
  73415. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73416. */
  73417. _stillInvisible: boolean;
  73418. /**
  73419. * @hidden Last computed particle rotation matrix
  73420. */
  73421. _rotationMatrix: number[];
  73422. /**
  73423. * Parent particle Id, if any.
  73424. * Default null.
  73425. */
  73426. parentId: Nullable<number>;
  73427. /**
  73428. * @hidden Internal global position in the PCS.
  73429. */
  73430. _globalPosition: Vector3;
  73431. /**
  73432. * Creates a Point Cloud object.
  73433. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73434. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73435. * @param group (PointsGroup) is the group the particle belongs to
  73436. * @param groupId (integer) is the group identifier in the PCS.
  73437. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73438. * @param pcs defines the PCS it is associated to
  73439. */
  73440. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73441. /**
  73442. * get point size
  73443. */
  73444. get size(): Vector3;
  73445. /**
  73446. * Set point size
  73447. */
  73448. set size(scale: Vector3);
  73449. /**
  73450. * Legacy support, changed quaternion to rotationQuaternion
  73451. */
  73452. get quaternion(): Nullable<Quaternion>;
  73453. /**
  73454. * Legacy support, changed quaternion to rotationQuaternion
  73455. */
  73456. set quaternion(q: Nullable<Quaternion>);
  73457. /**
  73458. * Returns a boolean. True if the particle intersects a mesh, else false
  73459. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73460. * @param target is the object (point or mesh) what the intersection is computed against
  73461. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  73462. * @returns true if it intersects
  73463. */
  73464. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73465. /**
  73466. * get the rotation matrix of the particle
  73467. * @hidden
  73468. */
  73469. getRotationMatrix(m: Matrix): void;
  73470. }
  73471. /**
  73472. * Represents a group of points in a points cloud system
  73473. * * PCS internal tool, don't use it manually.
  73474. */
  73475. export class PointsGroup {
  73476. /**
  73477. * The group id
  73478. * @hidden
  73479. */
  73480. groupID: number;
  73481. /**
  73482. * image data for group (internal use)
  73483. * @hidden
  73484. */
  73485. _groupImageData: Nullable<ArrayBufferView>;
  73486. /**
  73487. * Image Width (internal use)
  73488. * @hidden
  73489. */
  73490. _groupImgWidth: number;
  73491. /**
  73492. * Image Height (internal use)
  73493. * @hidden
  73494. */
  73495. _groupImgHeight: number;
  73496. /**
  73497. * Custom position function (internal use)
  73498. * @hidden
  73499. */
  73500. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73501. /**
  73502. * density per facet for surface points
  73503. * @hidden
  73504. */
  73505. _groupDensity: number[];
  73506. /**
  73507. * Only when points are colored by texture carries pointer to texture list array
  73508. * @hidden
  73509. */
  73510. _textureNb: number;
  73511. /**
  73512. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73513. * PCS internal tool, don't use it manually.
  73514. * @hidden
  73515. */
  73516. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73517. }
  73518. }
  73519. declare module "babylonjs/Particles/index" {
  73520. export * from "babylonjs/Particles/baseParticleSystem";
  73521. export * from "babylonjs/Particles/EmitterTypes/index";
  73522. export * from "babylonjs/Particles/gpuParticleSystem";
  73523. export * from "babylonjs/Particles/IParticleSystem";
  73524. export * from "babylonjs/Particles/particle";
  73525. export * from "babylonjs/Particles/particleHelper";
  73526. export * from "babylonjs/Particles/particleSystem";
  73527. import "babylonjs/Particles/particleSystemComponent";
  73528. export * from "babylonjs/Particles/particleSystemComponent";
  73529. export * from "babylonjs/Particles/particleSystemSet";
  73530. export * from "babylonjs/Particles/solidParticle";
  73531. export * from "babylonjs/Particles/solidParticleSystem";
  73532. export * from "babylonjs/Particles/cloudPoint";
  73533. export * from "babylonjs/Particles/pointsCloudSystem";
  73534. export * from "babylonjs/Particles/subEmitter";
  73535. }
  73536. declare module "babylonjs/Physics/physicsEngineComponent" {
  73537. import { Nullable } from "babylonjs/types";
  73538. import { Observable, Observer } from "babylonjs/Misc/observable";
  73539. import { Vector3 } from "babylonjs/Maths/math.vector";
  73540. import { Mesh } from "babylonjs/Meshes/mesh";
  73541. import { ISceneComponent } from "babylonjs/sceneComponent";
  73542. import { Scene } from "babylonjs/scene";
  73543. import { Node } from "babylonjs/node";
  73544. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  73545. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73546. module "babylonjs/scene" {
  73547. interface Scene {
  73548. /** @hidden (Backing field) */
  73549. _physicsEngine: Nullable<IPhysicsEngine>;
  73550. /** @hidden */
  73551. _physicsTimeAccumulator: number;
  73552. /**
  73553. * Gets the current physics engine
  73554. * @returns a IPhysicsEngine or null if none attached
  73555. */
  73556. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73557. /**
  73558. * Enables physics to the current scene
  73559. * @param gravity defines the scene's gravity for the physics engine
  73560. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73561. * @return a boolean indicating if the physics engine was initialized
  73562. */
  73563. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73564. /**
  73565. * Disables and disposes the physics engine associated with the scene
  73566. */
  73567. disablePhysicsEngine(): void;
  73568. /**
  73569. * Gets a boolean indicating if there is an active physics engine
  73570. * @returns a boolean indicating if there is an active physics engine
  73571. */
  73572. isPhysicsEnabled(): boolean;
  73573. /**
  73574. * Deletes a physics compound impostor
  73575. * @param compound defines the compound to delete
  73576. */
  73577. deleteCompoundImpostor(compound: any): void;
  73578. /**
  73579. * An event triggered when physic simulation is about to be run
  73580. */
  73581. onBeforePhysicsObservable: Observable<Scene>;
  73582. /**
  73583. * An event triggered when physic simulation has been done
  73584. */
  73585. onAfterPhysicsObservable: Observable<Scene>;
  73586. }
  73587. }
  73588. module "babylonjs/Meshes/abstractMesh" {
  73589. interface AbstractMesh {
  73590. /** @hidden */
  73591. _physicsImpostor: Nullable<PhysicsImpostor>;
  73592. /**
  73593. * Gets or sets impostor used for physic simulation
  73594. * @see https://doc.babylonjs.com/features/physics_engine
  73595. */
  73596. physicsImpostor: Nullable<PhysicsImpostor>;
  73597. /**
  73598. * Gets the current physics impostor
  73599. * @see https://doc.babylonjs.com/features/physics_engine
  73600. * @returns a physics impostor or null
  73601. */
  73602. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73603. /** Apply a physic impulse to the mesh
  73604. * @param force defines the force to apply
  73605. * @param contactPoint defines where to apply the force
  73606. * @returns the current mesh
  73607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73608. */
  73609. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73610. /**
  73611. * Creates a physic joint between two meshes
  73612. * @param otherMesh defines the other mesh to use
  73613. * @param pivot1 defines the pivot to use on this mesh
  73614. * @param pivot2 defines the pivot to use on the other mesh
  73615. * @param options defines additional options (can be plugin dependent)
  73616. * @returns the current mesh
  73617. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73618. */
  73619. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73620. /** @hidden */
  73621. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73622. }
  73623. }
  73624. /**
  73625. * Defines the physics engine scene component responsible to manage a physics engine
  73626. */
  73627. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73628. /**
  73629. * The component name helpful to identify the component in the list of scene components.
  73630. */
  73631. readonly name: string;
  73632. /**
  73633. * The scene the component belongs to.
  73634. */
  73635. scene: Scene;
  73636. /**
  73637. * Creates a new instance of the component for the given scene
  73638. * @param scene Defines the scene to register the component in
  73639. */
  73640. constructor(scene: Scene);
  73641. /**
  73642. * Registers the component in a given scene
  73643. */
  73644. register(): void;
  73645. /**
  73646. * Rebuilds the elements related to this component in case of
  73647. * context lost for instance.
  73648. */
  73649. rebuild(): void;
  73650. /**
  73651. * Disposes the component and the associated ressources
  73652. */
  73653. dispose(): void;
  73654. }
  73655. }
  73656. declare module "babylonjs/Physics/physicsHelper" {
  73657. import { Nullable } from "babylonjs/types";
  73658. import { Vector3 } from "babylonjs/Maths/math.vector";
  73659. import { Mesh } from "babylonjs/Meshes/mesh";
  73660. import { Scene } from "babylonjs/scene";
  73661. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73662. /**
  73663. * A helper for physics simulations
  73664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73665. */
  73666. export class PhysicsHelper {
  73667. private _scene;
  73668. private _physicsEngine;
  73669. /**
  73670. * Initializes the Physics helper
  73671. * @param scene Babylon.js scene
  73672. */
  73673. constructor(scene: Scene);
  73674. /**
  73675. * Applies a radial explosion impulse
  73676. * @param origin the origin of the explosion
  73677. * @param radiusOrEventOptions the radius or the options of radial explosion
  73678. * @param strength the explosion strength
  73679. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73680. * @returns A physics radial explosion event, or null
  73681. */
  73682. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73683. /**
  73684. * Applies a radial explosion force
  73685. * @param origin the origin of the explosion
  73686. * @param radiusOrEventOptions the radius or the options of radial explosion
  73687. * @param strength the explosion strength
  73688. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73689. * @returns A physics radial explosion event, or null
  73690. */
  73691. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73692. /**
  73693. * Creates a gravitational field
  73694. * @param origin the origin of the explosion
  73695. * @param radiusOrEventOptions the radius or the options of radial explosion
  73696. * @param strength the explosion strength
  73697. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73698. * @returns A physics gravitational field event, or null
  73699. */
  73700. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73701. /**
  73702. * Creates a physics updraft event
  73703. * @param origin the origin of the updraft
  73704. * @param radiusOrEventOptions the radius or the options of the updraft
  73705. * @param strength the strength of the updraft
  73706. * @param height the height of the updraft
  73707. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73708. * @returns A physics updraft event, or null
  73709. */
  73710. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73711. /**
  73712. * Creates a physics vortex event
  73713. * @param origin the of the vortex
  73714. * @param radiusOrEventOptions the radius or the options of the vortex
  73715. * @param strength the strength of the vortex
  73716. * @param height the height of the vortex
  73717. * @returns a Physics vortex event, or null
  73718. * A physics vortex event or null
  73719. */
  73720. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73721. }
  73722. /**
  73723. * Represents a physics radial explosion event
  73724. */
  73725. class PhysicsRadialExplosionEvent {
  73726. private _scene;
  73727. private _options;
  73728. private _sphere;
  73729. private _dataFetched;
  73730. /**
  73731. * Initializes a radial explosioin event
  73732. * @param _scene BabylonJS scene
  73733. * @param _options The options for the vortex event
  73734. */
  73735. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73736. /**
  73737. * Returns the data related to the radial explosion event (sphere).
  73738. * @returns The radial explosion event data
  73739. */
  73740. getData(): PhysicsRadialExplosionEventData;
  73741. /**
  73742. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73743. * @param impostor A physics imposter
  73744. * @param origin the origin of the explosion
  73745. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73746. */
  73747. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73748. /**
  73749. * Triggers affecterd impostors callbacks
  73750. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73751. */
  73752. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73753. /**
  73754. * Disposes the sphere.
  73755. * @param force Specifies if the sphere should be disposed by force
  73756. */
  73757. dispose(force?: boolean): void;
  73758. /*** Helpers ***/
  73759. private _prepareSphere;
  73760. private _intersectsWithSphere;
  73761. }
  73762. /**
  73763. * Represents a gravitational field event
  73764. */
  73765. class PhysicsGravitationalFieldEvent {
  73766. private _physicsHelper;
  73767. private _scene;
  73768. private _origin;
  73769. private _options;
  73770. private _tickCallback;
  73771. private _sphere;
  73772. private _dataFetched;
  73773. /**
  73774. * Initializes the physics gravitational field event
  73775. * @param _physicsHelper A physics helper
  73776. * @param _scene BabylonJS scene
  73777. * @param _origin The origin position of the gravitational field event
  73778. * @param _options The options for the vortex event
  73779. */
  73780. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73781. /**
  73782. * Returns the data related to the gravitational field event (sphere).
  73783. * @returns A gravitational field event
  73784. */
  73785. getData(): PhysicsGravitationalFieldEventData;
  73786. /**
  73787. * Enables the gravitational field.
  73788. */
  73789. enable(): void;
  73790. /**
  73791. * Disables the gravitational field.
  73792. */
  73793. disable(): void;
  73794. /**
  73795. * Disposes the sphere.
  73796. * @param force The force to dispose from the gravitational field event
  73797. */
  73798. dispose(force?: boolean): void;
  73799. private _tick;
  73800. }
  73801. /**
  73802. * Represents a physics updraft event
  73803. */
  73804. class PhysicsUpdraftEvent {
  73805. private _scene;
  73806. private _origin;
  73807. private _options;
  73808. private _physicsEngine;
  73809. private _originTop;
  73810. private _originDirection;
  73811. private _tickCallback;
  73812. private _cylinder;
  73813. private _cylinderPosition;
  73814. private _dataFetched;
  73815. /**
  73816. * Initializes the physics updraft event
  73817. * @param _scene BabylonJS scene
  73818. * @param _origin The origin position of the updraft
  73819. * @param _options The options for the updraft event
  73820. */
  73821. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73822. /**
  73823. * Returns the data related to the updraft event (cylinder).
  73824. * @returns A physics updraft event
  73825. */
  73826. getData(): PhysicsUpdraftEventData;
  73827. /**
  73828. * Enables the updraft.
  73829. */
  73830. enable(): void;
  73831. /**
  73832. * Disables the updraft.
  73833. */
  73834. disable(): void;
  73835. /**
  73836. * Disposes the cylinder.
  73837. * @param force Specifies if the updraft should be disposed by force
  73838. */
  73839. dispose(force?: boolean): void;
  73840. private getImpostorHitData;
  73841. private _tick;
  73842. /*** Helpers ***/
  73843. private _prepareCylinder;
  73844. private _intersectsWithCylinder;
  73845. }
  73846. /**
  73847. * Represents a physics vortex event
  73848. */
  73849. class PhysicsVortexEvent {
  73850. private _scene;
  73851. private _origin;
  73852. private _options;
  73853. private _physicsEngine;
  73854. private _originTop;
  73855. private _tickCallback;
  73856. private _cylinder;
  73857. private _cylinderPosition;
  73858. private _dataFetched;
  73859. /**
  73860. * Initializes the physics vortex event
  73861. * @param _scene The BabylonJS scene
  73862. * @param _origin The origin position of the vortex
  73863. * @param _options The options for the vortex event
  73864. */
  73865. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73866. /**
  73867. * Returns the data related to the vortex event (cylinder).
  73868. * @returns The physics vortex event data
  73869. */
  73870. getData(): PhysicsVortexEventData;
  73871. /**
  73872. * Enables the vortex.
  73873. */
  73874. enable(): void;
  73875. /**
  73876. * Disables the cortex.
  73877. */
  73878. disable(): void;
  73879. /**
  73880. * Disposes the sphere.
  73881. * @param force
  73882. */
  73883. dispose(force?: boolean): void;
  73884. private getImpostorHitData;
  73885. private _tick;
  73886. /*** Helpers ***/
  73887. private _prepareCylinder;
  73888. private _intersectsWithCylinder;
  73889. }
  73890. /**
  73891. * Options fot the radial explosion event
  73892. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73893. */
  73894. export class PhysicsRadialExplosionEventOptions {
  73895. /**
  73896. * The radius of the sphere for the radial explosion.
  73897. */
  73898. radius: number;
  73899. /**
  73900. * The strenth of the explosion.
  73901. */
  73902. strength: number;
  73903. /**
  73904. * The strenght of the force in correspondence to the distance of the affected object
  73905. */
  73906. falloff: PhysicsRadialImpulseFalloff;
  73907. /**
  73908. * Sphere options for the radial explosion.
  73909. */
  73910. sphere: {
  73911. segments: number;
  73912. diameter: number;
  73913. };
  73914. /**
  73915. * Sphere options for the radial explosion.
  73916. */
  73917. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73918. }
  73919. /**
  73920. * Options fot the updraft event
  73921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73922. */
  73923. export class PhysicsUpdraftEventOptions {
  73924. /**
  73925. * The radius of the cylinder for the vortex
  73926. */
  73927. radius: number;
  73928. /**
  73929. * The strenth of the updraft.
  73930. */
  73931. strength: number;
  73932. /**
  73933. * The height of the cylinder for the updraft.
  73934. */
  73935. height: number;
  73936. /**
  73937. * The mode for the the updraft.
  73938. */
  73939. updraftMode: PhysicsUpdraftMode;
  73940. }
  73941. /**
  73942. * Options fot the vortex event
  73943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73944. */
  73945. export class PhysicsVortexEventOptions {
  73946. /**
  73947. * The radius of the cylinder for the vortex
  73948. */
  73949. radius: number;
  73950. /**
  73951. * The strenth of the vortex.
  73952. */
  73953. strength: number;
  73954. /**
  73955. * The height of the cylinder for the vortex.
  73956. */
  73957. height: number;
  73958. /**
  73959. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73960. */
  73961. centripetalForceThreshold: number;
  73962. /**
  73963. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73964. */
  73965. centripetalForceMultiplier: number;
  73966. /**
  73967. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73968. */
  73969. centrifugalForceMultiplier: number;
  73970. /**
  73971. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73972. */
  73973. updraftForceMultiplier: number;
  73974. }
  73975. /**
  73976. * The strenght of the force in correspondence to the distance of the affected object
  73977. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73978. */
  73979. export enum PhysicsRadialImpulseFalloff {
  73980. /** Defines that impulse is constant in strength across it's whole radius */
  73981. Constant = 0,
  73982. /** Defines that impulse gets weaker if it's further from the origin */
  73983. Linear = 1
  73984. }
  73985. /**
  73986. * The strength of the force in correspondence to the distance of the affected object
  73987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73988. */
  73989. export enum PhysicsUpdraftMode {
  73990. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73991. Center = 0,
  73992. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73993. Perpendicular = 1
  73994. }
  73995. /**
  73996. * Interface for a physics hit data
  73997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73998. */
  73999. export interface PhysicsHitData {
  74000. /**
  74001. * The force applied at the contact point
  74002. */
  74003. force: Vector3;
  74004. /**
  74005. * The contact point
  74006. */
  74007. contactPoint: Vector3;
  74008. /**
  74009. * The distance from the origin to the contact point
  74010. */
  74011. distanceFromOrigin: number;
  74012. }
  74013. /**
  74014. * Interface for radial explosion event data
  74015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74016. */
  74017. export interface PhysicsRadialExplosionEventData {
  74018. /**
  74019. * A sphere used for the radial explosion event
  74020. */
  74021. sphere: Mesh;
  74022. }
  74023. /**
  74024. * Interface for gravitational field event data
  74025. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74026. */
  74027. export interface PhysicsGravitationalFieldEventData {
  74028. /**
  74029. * A sphere mesh used for the gravitational field event
  74030. */
  74031. sphere: Mesh;
  74032. }
  74033. /**
  74034. * Interface for updraft event data
  74035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74036. */
  74037. export interface PhysicsUpdraftEventData {
  74038. /**
  74039. * A cylinder used for the updraft event
  74040. */
  74041. cylinder: Mesh;
  74042. }
  74043. /**
  74044. * Interface for vortex event data
  74045. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74046. */
  74047. export interface PhysicsVortexEventData {
  74048. /**
  74049. * A cylinder used for the vortex event
  74050. */
  74051. cylinder: Mesh;
  74052. }
  74053. /**
  74054. * Interface for an affected physics impostor
  74055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74056. */
  74057. export interface PhysicsAffectedImpostorWithData {
  74058. /**
  74059. * The impostor affected by the effect
  74060. */
  74061. impostor: PhysicsImpostor;
  74062. /**
  74063. * The data about the hit/horce from the explosion
  74064. */
  74065. hitData: PhysicsHitData;
  74066. }
  74067. }
  74068. declare module "babylonjs/Physics/Plugins/index" {
  74069. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  74070. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  74071. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  74072. }
  74073. declare module "babylonjs/Physics/index" {
  74074. export * from "babylonjs/Physics/IPhysicsEngine";
  74075. export * from "babylonjs/Physics/physicsEngine";
  74076. export * from "babylonjs/Physics/physicsEngineComponent";
  74077. export * from "babylonjs/Physics/physicsHelper";
  74078. export * from "babylonjs/Physics/physicsImpostor";
  74079. export * from "babylonjs/Physics/physicsJoint";
  74080. export * from "babylonjs/Physics/Plugins/index";
  74081. }
  74082. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  74083. /** @hidden */
  74084. export var blackAndWhitePixelShader: {
  74085. name: string;
  74086. shader: string;
  74087. };
  74088. }
  74089. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  74090. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74091. import { Camera } from "babylonjs/Cameras/camera";
  74092. import { Engine } from "babylonjs/Engines/engine";
  74093. import "babylonjs/Shaders/blackAndWhite.fragment";
  74094. import { Nullable } from "babylonjs/types";
  74095. import { Scene } from "babylonjs/scene";
  74096. /**
  74097. * Post process used to render in black and white
  74098. */
  74099. export class BlackAndWhitePostProcess extends PostProcess {
  74100. /**
  74101. * Linear about to convert he result to black and white (default: 1)
  74102. */
  74103. degree: number;
  74104. /**
  74105. * Gets a string identifying the name of the class
  74106. * @returns "BlackAndWhitePostProcess" string
  74107. */
  74108. getClassName(): string;
  74109. /**
  74110. * Creates a black and white post process
  74111. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  74112. * @param name The name of the effect.
  74113. * @param options The required width/height ratio to downsize to before computing the render pass.
  74114. * @param camera The camera to apply the render pass to.
  74115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74116. * @param engine The engine which the post process will be applied. (default: current engine)
  74117. * @param reusable If the post process can be reused on the same frame. (default: false)
  74118. */
  74119. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74120. /** @hidden */
  74121. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  74122. }
  74123. }
  74124. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  74125. import { Nullable } from "babylonjs/types";
  74126. import { Camera } from "babylonjs/Cameras/camera";
  74127. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74128. import { Engine } from "babylonjs/Engines/engine";
  74129. /**
  74130. * This represents a set of one or more post processes in Babylon.
  74131. * A post process can be used to apply a shader to a texture after it is rendered.
  74132. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74133. */
  74134. export class PostProcessRenderEffect {
  74135. private _postProcesses;
  74136. private _getPostProcesses;
  74137. private _singleInstance;
  74138. private _cameras;
  74139. private _indicesForCamera;
  74140. /**
  74141. * Name of the effect
  74142. * @hidden
  74143. */
  74144. _name: string;
  74145. /**
  74146. * Instantiates a post process render effect.
  74147. * A post process can be used to apply a shader to a texture after it is rendered.
  74148. * @param engine The engine the effect is tied to
  74149. * @param name The name of the effect
  74150. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  74151. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  74152. */
  74153. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  74154. /**
  74155. * Checks if all the post processes in the effect are supported.
  74156. */
  74157. get isSupported(): boolean;
  74158. /**
  74159. * Updates the current state of the effect
  74160. * @hidden
  74161. */
  74162. _update(): void;
  74163. /**
  74164. * Attaches the effect on cameras
  74165. * @param cameras The camera to attach to.
  74166. * @hidden
  74167. */
  74168. _attachCameras(cameras: Camera): void;
  74169. /**
  74170. * Attaches the effect on cameras
  74171. * @param cameras The camera to attach to.
  74172. * @hidden
  74173. */
  74174. _attachCameras(cameras: Camera[]): void;
  74175. /**
  74176. * Detaches the effect on cameras
  74177. * @param cameras The camera to detatch from.
  74178. * @hidden
  74179. */
  74180. _detachCameras(cameras: Camera): void;
  74181. /**
  74182. * Detatches the effect on cameras
  74183. * @param cameras The camera to detatch from.
  74184. * @hidden
  74185. */
  74186. _detachCameras(cameras: Camera[]): void;
  74187. /**
  74188. * Enables the effect on given cameras
  74189. * @param cameras The camera to enable.
  74190. * @hidden
  74191. */
  74192. _enable(cameras: Camera): void;
  74193. /**
  74194. * Enables the effect on given cameras
  74195. * @param cameras The camera to enable.
  74196. * @hidden
  74197. */
  74198. _enable(cameras: Nullable<Camera[]>): void;
  74199. /**
  74200. * Disables the effect on the given cameras
  74201. * @param cameras The camera to disable.
  74202. * @hidden
  74203. */
  74204. _disable(cameras: Camera): void;
  74205. /**
  74206. * Disables the effect on the given cameras
  74207. * @param cameras The camera to disable.
  74208. * @hidden
  74209. */
  74210. _disable(cameras: Nullable<Camera[]>): void;
  74211. /**
  74212. * Gets a list of the post processes contained in the effect.
  74213. * @param camera The camera to get the post processes on.
  74214. * @returns The list of the post processes in the effect.
  74215. */
  74216. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  74217. }
  74218. }
  74219. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  74220. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74221. /** @hidden */
  74222. export var extractHighlightsPixelShader: {
  74223. name: string;
  74224. shader: string;
  74225. };
  74226. }
  74227. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  74228. import { Nullable } from "babylonjs/types";
  74229. import { Camera } from "babylonjs/Cameras/camera";
  74230. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74231. import { Engine } from "babylonjs/Engines/engine";
  74232. import "babylonjs/Shaders/extractHighlights.fragment";
  74233. /**
  74234. * 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.
  74235. */
  74236. export class ExtractHighlightsPostProcess extends PostProcess {
  74237. /**
  74238. * The luminance threshold, pixels below this value will be set to black.
  74239. */
  74240. threshold: number;
  74241. /** @hidden */
  74242. _exposure: number;
  74243. /**
  74244. * Post process which has the input texture to be used when performing highlight extraction
  74245. * @hidden
  74246. */
  74247. _inputPostProcess: Nullable<PostProcess>;
  74248. /**
  74249. * Gets a string identifying the name of the class
  74250. * @returns "ExtractHighlightsPostProcess" string
  74251. */
  74252. getClassName(): string;
  74253. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74254. }
  74255. }
  74256. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  74257. /** @hidden */
  74258. export var bloomMergePixelShader: {
  74259. name: string;
  74260. shader: string;
  74261. };
  74262. }
  74263. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  74264. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74265. import { Nullable } from "babylonjs/types";
  74266. import { Engine } from "babylonjs/Engines/engine";
  74267. import { Camera } from "babylonjs/Cameras/camera";
  74268. import "babylonjs/Shaders/bloomMerge.fragment";
  74269. /**
  74270. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74271. */
  74272. export class BloomMergePostProcess extends PostProcess {
  74273. /** Weight of the bloom to be added to the original input. */
  74274. weight: number;
  74275. /**
  74276. * Gets a string identifying the name of the class
  74277. * @returns "BloomMergePostProcess" string
  74278. */
  74279. getClassName(): string;
  74280. /**
  74281. * Creates a new instance of @see BloomMergePostProcess
  74282. * @param name The name of the effect.
  74283. * @param originalFromInput Post process which's input will be used for the merge.
  74284. * @param blurred Blurred highlights post process which's output will be used.
  74285. * @param weight Weight of the bloom to be added to the original input.
  74286. * @param options The required width/height ratio to downsize to before computing the render pass.
  74287. * @param camera The camera to apply the render pass to.
  74288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74289. * @param engine The engine which the post process will be applied. (default: current engine)
  74290. * @param reusable If the post process can be reused on the same frame. (default: false)
  74291. * @param textureType Type of textures used when performing the post process. (default: 0)
  74292. * @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)
  74293. */
  74294. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  74295. /** Weight of the bloom to be added to the original input. */
  74296. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74297. }
  74298. }
  74299. declare module "babylonjs/PostProcesses/bloomEffect" {
  74300. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74301. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74302. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74303. import { Camera } from "babylonjs/Cameras/camera";
  74304. import { Scene } from "babylonjs/scene";
  74305. /**
  74306. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  74307. */
  74308. export class BloomEffect extends PostProcessRenderEffect {
  74309. private bloomScale;
  74310. /**
  74311. * @hidden Internal
  74312. */
  74313. _effects: Array<PostProcess>;
  74314. /**
  74315. * @hidden Internal
  74316. */
  74317. _downscale: ExtractHighlightsPostProcess;
  74318. private _blurX;
  74319. private _blurY;
  74320. private _merge;
  74321. /**
  74322. * The luminance threshold to find bright areas of the image to bloom.
  74323. */
  74324. get threshold(): number;
  74325. set threshold(value: number);
  74326. /**
  74327. * The strength of the bloom.
  74328. */
  74329. get weight(): number;
  74330. set weight(value: number);
  74331. /**
  74332. * Specifies the size of the bloom blur kernel, relative to the final output size
  74333. */
  74334. get kernel(): number;
  74335. set kernel(value: number);
  74336. /**
  74337. * Creates a new instance of @see BloomEffect
  74338. * @param scene The scene the effect belongs to.
  74339. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  74340. * @param bloomKernel The size of the kernel to be used when applying the blur.
  74341. * @param bloomWeight The the strength of bloom.
  74342. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74343. * @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)
  74344. */
  74345. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  74346. /**
  74347. * Disposes each of the internal effects for a given camera.
  74348. * @param camera The camera to dispose the effect on.
  74349. */
  74350. disposeEffects(camera: Camera): void;
  74351. /**
  74352. * @hidden Internal
  74353. */
  74354. _updateEffects(): void;
  74355. /**
  74356. * Internal
  74357. * @returns if all the contained post processes are ready.
  74358. * @hidden
  74359. */
  74360. _isReady(): boolean;
  74361. }
  74362. }
  74363. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  74364. /** @hidden */
  74365. export var chromaticAberrationPixelShader: {
  74366. name: string;
  74367. shader: string;
  74368. };
  74369. }
  74370. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  74371. import { Vector2 } from "babylonjs/Maths/math.vector";
  74372. import { Nullable } from "babylonjs/types";
  74373. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74374. import { Camera } from "babylonjs/Cameras/camera";
  74375. import { Engine } from "babylonjs/Engines/engine";
  74376. import "babylonjs/Shaders/chromaticAberration.fragment";
  74377. import { Scene } from "babylonjs/scene";
  74378. /**
  74379. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74380. */
  74381. export class ChromaticAberrationPostProcess extends PostProcess {
  74382. /**
  74383. * The amount of seperation of rgb channels (default: 30)
  74384. */
  74385. aberrationAmount: number;
  74386. /**
  74387. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74388. */
  74389. radialIntensity: number;
  74390. /**
  74391. * 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))
  74392. */
  74393. direction: Vector2;
  74394. /**
  74395. * 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))
  74396. */
  74397. centerPosition: Vector2;
  74398. /** The width of the screen to apply the effect on */
  74399. screenWidth: number;
  74400. /** The height of the screen to apply the effect on */
  74401. screenHeight: number;
  74402. /**
  74403. * Gets a string identifying the name of the class
  74404. * @returns "ChromaticAberrationPostProcess" string
  74405. */
  74406. getClassName(): string;
  74407. /**
  74408. * Creates a new instance ChromaticAberrationPostProcess
  74409. * @param name The name of the effect.
  74410. * @param screenWidth The width of the screen to apply the effect on.
  74411. * @param screenHeight The height of the screen to apply the effect on.
  74412. * @param options The required width/height ratio to downsize to before computing the render pass.
  74413. * @param camera The camera to apply the render pass to.
  74414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74415. * @param engine The engine which the post process will be applied. (default: current engine)
  74416. * @param reusable If the post process can be reused on the same frame. (default: false)
  74417. * @param textureType Type of textures used when performing the post process. (default: 0)
  74418. * @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)
  74419. */
  74420. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74421. /** @hidden */
  74422. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74423. }
  74424. }
  74425. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  74426. /** @hidden */
  74427. export var circleOfConfusionPixelShader: {
  74428. name: string;
  74429. shader: string;
  74430. };
  74431. }
  74432. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  74433. import { Nullable } from "babylonjs/types";
  74434. import { Engine } from "babylonjs/Engines/engine";
  74435. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74436. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74437. import { Camera } from "babylonjs/Cameras/camera";
  74438. import "babylonjs/Shaders/circleOfConfusion.fragment";
  74439. /**
  74440. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74441. */
  74442. export class CircleOfConfusionPostProcess extends PostProcess {
  74443. /**
  74444. * 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.
  74445. */
  74446. lensSize: number;
  74447. /**
  74448. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74449. */
  74450. fStop: number;
  74451. /**
  74452. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74453. */
  74454. focusDistance: number;
  74455. /**
  74456. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74457. */
  74458. focalLength: number;
  74459. /**
  74460. * Gets a string identifying the name of the class
  74461. * @returns "CircleOfConfusionPostProcess" string
  74462. */
  74463. getClassName(): string;
  74464. private _depthTexture;
  74465. /**
  74466. * Creates a new instance CircleOfConfusionPostProcess
  74467. * @param name The name of the effect.
  74468. * @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.
  74469. * @param options The required width/height ratio to downsize to before computing the render pass.
  74470. * @param camera The camera to apply the render pass to.
  74471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74472. * @param engine The engine which the post process will be applied. (default: current engine)
  74473. * @param reusable If the post process can be reused on the same frame. (default: false)
  74474. * @param textureType Type of textures used when performing the post process. (default: 0)
  74475. * @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)
  74476. */
  74477. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74478. /**
  74479. * 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.
  74480. */
  74481. set depthTexture(value: RenderTargetTexture);
  74482. }
  74483. }
  74484. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  74485. /** @hidden */
  74486. export var colorCorrectionPixelShader: {
  74487. name: string;
  74488. shader: string;
  74489. };
  74490. }
  74491. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  74492. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74493. import { Engine } from "babylonjs/Engines/engine";
  74494. import { Camera } from "babylonjs/Cameras/camera";
  74495. import "babylonjs/Shaders/colorCorrection.fragment";
  74496. import { Nullable } from "babylonjs/types";
  74497. import { Scene } from "babylonjs/scene";
  74498. /**
  74499. *
  74500. * This post-process allows the modification of rendered colors by using
  74501. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74502. *
  74503. * The object needs to be provided an url to a texture containing the color
  74504. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74505. * Use an image editing software to tweak the LUT to match your needs.
  74506. *
  74507. * For an example of a color LUT, see here:
  74508. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74509. * For explanations on color grading, see here:
  74510. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74511. *
  74512. */
  74513. export class ColorCorrectionPostProcess extends PostProcess {
  74514. private _colorTableTexture;
  74515. /**
  74516. * Gets the color table url used to create the LUT texture
  74517. */
  74518. colorTableUrl: string;
  74519. /**
  74520. * Gets a string identifying the name of the class
  74521. * @returns "ColorCorrectionPostProcess" string
  74522. */
  74523. getClassName(): string;
  74524. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74525. /** @hidden */
  74526. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74527. }
  74528. }
  74529. declare module "babylonjs/Shaders/convolution.fragment" {
  74530. /** @hidden */
  74531. export var convolutionPixelShader: {
  74532. name: string;
  74533. shader: string;
  74534. };
  74535. }
  74536. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  74537. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74538. import { Nullable } from "babylonjs/types";
  74539. import { Camera } from "babylonjs/Cameras/camera";
  74540. import { Engine } from "babylonjs/Engines/engine";
  74541. import "babylonjs/Shaders/convolution.fragment";
  74542. import { Scene } from "babylonjs/scene";
  74543. /**
  74544. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74545. * input texture to perform effects such as edge detection or sharpening
  74546. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74547. */
  74548. export class ConvolutionPostProcess extends PostProcess {
  74549. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74550. kernel: number[];
  74551. /**
  74552. * Gets a string identifying the name of the class
  74553. * @returns "ConvolutionPostProcess" string
  74554. */
  74555. getClassName(): string;
  74556. /**
  74557. * Creates a new instance ConvolutionPostProcess
  74558. * @param name The name of the effect.
  74559. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74560. * @param options The required width/height ratio to downsize to before computing the render pass.
  74561. * @param camera The camera to apply the render pass to.
  74562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74563. * @param engine The engine which the post process will be applied. (default: current engine)
  74564. * @param reusable If the post process can be reused on the same frame. (default: false)
  74565. * @param textureType Type of textures used when performing the post process. (default: 0)
  74566. */
  74567. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74568. /** @hidden */
  74569. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74570. /**
  74571. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74572. */
  74573. static EdgeDetect0Kernel: number[];
  74574. /**
  74575. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74576. */
  74577. static EdgeDetect1Kernel: number[];
  74578. /**
  74579. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74580. */
  74581. static EdgeDetect2Kernel: number[];
  74582. /**
  74583. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74584. */
  74585. static SharpenKernel: number[];
  74586. /**
  74587. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74588. */
  74589. static EmbossKernel: number[];
  74590. /**
  74591. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74592. */
  74593. static GaussianKernel: number[];
  74594. }
  74595. }
  74596. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  74597. import { Nullable } from "babylonjs/types";
  74598. import { Vector2 } from "babylonjs/Maths/math.vector";
  74599. import { Camera } from "babylonjs/Cameras/camera";
  74600. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74601. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74602. import { Engine } from "babylonjs/Engines/engine";
  74603. import { Scene } from "babylonjs/scene";
  74604. /**
  74605. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74606. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74607. * based on samples that have a large difference in distance than the center pixel.
  74608. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74609. */
  74610. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74611. /**
  74612. * The direction the blur should be applied
  74613. */
  74614. direction: Vector2;
  74615. /**
  74616. * Gets a string identifying the name of the class
  74617. * @returns "DepthOfFieldBlurPostProcess" string
  74618. */
  74619. getClassName(): string;
  74620. /**
  74621. * Creates a new instance CircleOfConfusionPostProcess
  74622. * @param name The name of the effect.
  74623. * @param scene The scene the effect belongs to.
  74624. * @param direction The direction the blur should be applied.
  74625. * @param kernel The size of the kernel used to blur.
  74626. * @param options The required width/height ratio to downsize to before computing the render pass.
  74627. * @param camera The camera to apply the render pass to.
  74628. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  74629. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74631. * @param engine The engine which the post process will be applied. (default: current engine)
  74632. * @param reusable If the post process can be reused on the same frame. (default: false)
  74633. * @param textureType Type of textures used when performing the post process. (default: 0)
  74634. * @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)
  74635. */
  74636. 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);
  74637. }
  74638. }
  74639. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  74640. /** @hidden */
  74641. export var depthOfFieldMergePixelShader: {
  74642. name: string;
  74643. shader: string;
  74644. };
  74645. }
  74646. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  74647. import { Nullable } from "babylonjs/types";
  74648. import { Camera } from "babylonjs/Cameras/camera";
  74649. import { Effect } from "babylonjs/Materials/effect";
  74650. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74651. import { Engine } from "babylonjs/Engines/engine";
  74652. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  74653. /**
  74654. * Options to be set when merging outputs from the default pipeline.
  74655. */
  74656. export class DepthOfFieldMergePostProcessOptions {
  74657. /**
  74658. * The original image to merge on top of
  74659. */
  74660. originalFromInput: PostProcess;
  74661. /**
  74662. * Parameters to perform the merge of the depth of field effect
  74663. */
  74664. depthOfField?: {
  74665. circleOfConfusion: PostProcess;
  74666. blurSteps: Array<PostProcess>;
  74667. };
  74668. /**
  74669. * Parameters to perform the merge of bloom effect
  74670. */
  74671. bloom?: {
  74672. blurred: PostProcess;
  74673. weight: number;
  74674. };
  74675. }
  74676. /**
  74677. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74678. */
  74679. export class DepthOfFieldMergePostProcess extends PostProcess {
  74680. private blurSteps;
  74681. /**
  74682. * Gets a string identifying the name of the class
  74683. * @returns "DepthOfFieldMergePostProcess" string
  74684. */
  74685. getClassName(): string;
  74686. /**
  74687. * Creates a new instance of DepthOfFieldMergePostProcess
  74688. * @param name The name of the effect.
  74689. * @param originalFromInput Post process which's input will be used for the merge.
  74690. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74691. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74692. * @param options The required width/height ratio to downsize to before computing the render pass.
  74693. * @param camera The camera to apply the render pass to.
  74694. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74695. * @param engine The engine which the post process will be applied. (default: current engine)
  74696. * @param reusable If the post process can be reused on the same frame. (default: false)
  74697. * @param textureType Type of textures used when performing the post process. (default: 0)
  74698. * @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)
  74699. */
  74700. 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);
  74701. /**
  74702. * Updates the effect with the current post process compile time values and recompiles the shader.
  74703. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74704. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74705. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74706. * @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
  74707. * @param onCompiled Called when the shader has been compiled.
  74708. * @param onError Called if there is an error when compiling a shader.
  74709. */
  74710. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74711. }
  74712. }
  74713. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  74714. import { Nullable } from "babylonjs/types";
  74715. import { Camera } from "babylonjs/Cameras/camera";
  74716. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74717. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74718. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74719. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74720. import { Scene } from "babylonjs/scene";
  74721. /**
  74722. * Specifies the level of max blur that should be applied when using the depth of field effect
  74723. */
  74724. export enum DepthOfFieldEffectBlurLevel {
  74725. /**
  74726. * Subtle blur
  74727. */
  74728. Low = 0,
  74729. /**
  74730. * Medium blur
  74731. */
  74732. Medium = 1,
  74733. /**
  74734. * Large blur
  74735. */
  74736. High = 2
  74737. }
  74738. /**
  74739. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74740. */
  74741. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74742. private _circleOfConfusion;
  74743. /**
  74744. * @hidden Internal, blurs from high to low
  74745. */
  74746. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74747. private _depthOfFieldBlurY;
  74748. private _dofMerge;
  74749. /**
  74750. * @hidden Internal post processes in depth of field effect
  74751. */
  74752. _effects: Array<PostProcess>;
  74753. /**
  74754. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74755. */
  74756. set focalLength(value: number);
  74757. get focalLength(): number;
  74758. /**
  74759. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74760. */
  74761. set fStop(value: number);
  74762. get fStop(): number;
  74763. /**
  74764. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74765. */
  74766. set focusDistance(value: number);
  74767. get focusDistance(): number;
  74768. /**
  74769. * 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.
  74770. */
  74771. set lensSize(value: number);
  74772. get lensSize(): number;
  74773. /**
  74774. * Creates a new instance DepthOfFieldEffect
  74775. * @param scene The scene the effect belongs to.
  74776. * @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.
  74777. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74778. * @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)
  74779. */
  74780. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74781. /**
  74782. * Get the current class name of the current effet
  74783. * @returns "DepthOfFieldEffect"
  74784. */
  74785. getClassName(): string;
  74786. /**
  74787. * 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.
  74788. */
  74789. set depthTexture(value: RenderTargetTexture);
  74790. /**
  74791. * Disposes each of the internal effects for a given camera.
  74792. * @param camera The camera to dispose the effect on.
  74793. */
  74794. disposeEffects(camera: Camera): void;
  74795. /**
  74796. * @hidden Internal
  74797. */
  74798. _updateEffects(): void;
  74799. /**
  74800. * Internal
  74801. * @returns if all the contained post processes are ready.
  74802. * @hidden
  74803. */
  74804. _isReady(): boolean;
  74805. }
  74806. }
  74807. declare module "babylonjs/Shaders/displayPass.fragment" {
  74808. /** @hidden */
  74809. export var displayPassPixelShader: {
  74810. name: string;
  74811. shader: string;
  74812. };
  74813. }
  74814. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  74815. import { Nullable } from "babylonjs/types";
  74816. import { Camera } from "babylonjs/Cameras/camera";
  74817. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74818. import { Engine } from "babylonjs/Engines/engine";
  74819. import "babylonjs/Shaders/displayPass.fragment";
  74820. import { Scene } from "babylonjs/scene";
  74821. /**
  74822. * DisplayPassPostProcess which produces an output the same as it's input
  74823. */
  74824. export class DisplayPassPostProcess extends PostProcess {
  74825. /**
  74826. * Gets a string identifying the name of the class
  74827. * @returns "DisplayPassPostProcess" string
  74828. */
  74829. getClassName(): string;
  74830. /**
  74831. * Creates the DisplayPassPostProcess
  74832. * @param name The name of the effect.
  74833. * @param options The required width/height ratio to downsize to before computing the render pass.
  74834. * @param camera The camera to apply the render pass to.
  74835. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74836. * @param engine The engine which the post process will be applied. (default: current engine)
  74837. * @param reusable If the post process can be reused on the same frame. (default: false)
  74838. */
  74839. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74840. /** @hidden */
  74841. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74842. }
  74843. }
  74844. declare module "babylonjs/Shaders/filter.fragment" {
  74845. /** @hidden */
  74846. export var filterPixelShader: {
  74847. name: string;
  74848. shader: string;
  74849. };
  74850. }
  74851. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74852. import { Nullable } from "babylonjs/types";
  74853. import { Matrix } from "babylonjs/Maths/math.vector";
  74854. import { Camera } from "babylonjs/Cameras/camera";
  74855. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74856. import { Engine } from "babylonjs/Engines/engine";
  74857. import "babylonjs/Shaders/filter.fragment";
  74858. import { Scene } from "babylonjs/scene";
  74859. /**
  74860. * Applies a kernel filter to the image
  74861. */
  74862. export class FilterPostProcess extends PostProcess {
  74863. /** The matrix to be applied to the image */
  74864. kernelMatrix: Matrix;
  74865. /**
  74866. * Gets a string identifying the name of the class
  74867. * @returns "FilterPostProcess" string
  74868. */
  74869. getClassName(): string;
  74870. /**
  74871. *
  74872. * @param name The name of the effect.
  74873. * @param kernelMatrix The matrix to be applied to the image
  74874. * @param options The required width/height ratio to downsize to before computing the render pass.
  74875. * @param camera The camera to apply the render pass to.
  74876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74877. * @param engine The engine which the post process will be applied. (default: current engine)
  74878. * @param reusable If the post process can be reused on the same frame. (default: false)
  74879. */
  74880. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74881. /** @hidden */
  74882. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74883. }
  74884. }
  74885. declare module "babylonjs/Shaders/fxaa.fragment" {
  74886. /** @hidden */
  74887. export var fxaaPixelShader: {
  74888. name: string;
  74889. shader: string;
  74890. };
  74891. }
  74892. declare module "babylonjs/Shaders/fxaa.vertex" {
  74893. /** @hidden */
  74894. export var fxaaVertexShader: {
  74895. name: string;
  74896. shader: string;
  74897. };
  74898. }
  74899. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74900. import { Nullable } from "babylonjs/types";
  74901. import { Camera } from "babylonjs/Cameras/camera";
  74902. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74903. import { Engine } from "babylonjs/Engines/engine";
  74904. import "babylonjs/Shaders/fxaa.fragment";
  74905. import "babylonjs/Shaders/fxaa.vertex";
  74906. import { Scene } from "babylonjs/scene";
  74907. /**
  74908. * Fxaa post process
  74909. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74910. */
  74911. export class FxaaPostProcess extends PostProcess {
  74912. /**
  74913. * Gets a string identifying the name of the class
  74914. * @returns "FxaaPostProcess" string
  74915. */
  74916. getClassName(): string;
  74917. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74918. private _getDefines;
  74919. /** @hidden */
  74920. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74921. }
  74922. }
  74923. declare module "babylonjs/Shaders/grain.fragment" {
  74924. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74925. /** @hidden */
  74926. export var grainPixelShader: {
  74927. name: string;
  74928. shader: string;
  74929. };
  74930. }
  74931. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74932. import { Nullable } from "babylonjs/types";
  74933. import { Camera } from "babylonjs/Cameras/camera";
  74934. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74935. import { Engine } from "babylonjs/Engines/engine";
  74936. import "babylonjs/Shaders/grain.fragment";
  74937. import { Scene } from "babylonjs/scene";
  74938. /**
  74939. * The GrainPostProcess adds noise to the image at mid luminance levels
  74940. */
  74941. export class GrainPostProcess extends PostProcess {
  74942. /**
  74943. * The intensity of the grain added (default: 30)
  74944. */
  74945. intensity: number;
  74946. /**
  74947. * If the grain should be randomized on every frame
  74948. */
  74949. animated: boolean;
  74950. /**
  74951. * Gets a string identifying the name of the class
  74952. * @returns "GrainPostProcess" string
  74953. */
  74954. getClassName(): string;
  74955. /**
  74956. * Creates a new instance of @see GrainPostProcess
  74957. * @param name The name of the effect.
  74958. * @param options The required width/height ratio to downsize to before computing the render pass.
  74959. * @param camera The camera to apply the render pass to.
  74960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74961. * @param engine The engine which the post process will be applied. (default: current engine)
  74962. * @param reusable If the post process can be reused on the same frame. (default: false)
  74963. * @param textureType Type of textures used when performing the post process. (default: 0)
  74964. * @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)
  74965. */
  74966. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74967. /** @hidden */
  74968. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74969. }
  74970. }
  74971. declare module "babylonjs/Shaders/highlights.fragment" {
  74972. /** @hidden */
  74973. export var highlightsPixelShader: {
  74974. name: string;
  74975. shader: string;
  74976. };
  74977. }
  74978. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74979. import { Nullable } from "babylonjs/types";
  74980. import { Camera } from "babylonjs/Cameras/camera";
  74981. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74982. import { Engine } from "babylonjs/Engines/engine";
  74983. import "babylonjs/Shaders/highlights.fragment";
  74984. /**
  74985. * Extracts highlights from the image
  74986. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74987. */
  74988. export class HighlightsPostProcess extends PostProcess {
  74989. /**
  74990. * Gets a string identifying the name of the class
  74991. * @returns "HighlightsPostProcess" string
  74992. */
  74993. getClassName(): string;
  74994. /**
  74995. * Extracts highlights from the image
  74996. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74997. * @param name The name of the effect.
  74998. * @param options The required width/height ratio to downsize to before computing the render pass.
  74999. * @param camera The camera to apply the render pass to.
  75000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75001. * @param engine The engine which the post process will be applied. (default: current engine)
  75002. * @param reusable If the post process can be reused on the same frame. (default: false)
  75003. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  75004. */
  75005. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  75006. }
  75007. }
  75008. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  75009. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75010. /**
  75011. * Contains all parameters needed for the prepass to perform
  75012. * motion blur
  75013. */
  75014. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  75015. /**
  75016. * Is motion blur enabled
  75017. */
  75018. enabled: boolean;
  75019. /**
  75020. * Name of the configuration
  75021. */
  75022. name: string;
  75023. /**
  75024. * Textures that should be present in the MRT for this effect to work
  75025. */
  75026. readonly texturesRequired: number[];
  75027. }
  75028. }
  75029. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  75030. import { Nullable } from "babylonjs/types";
  75031. import { Scene } from "babylonjs/scene";
  75032. import { ISceneComponent } from "babylonjs/sceneComponent";
  75033. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  75034. module "babylonjs/scene" {
  75035. interface Scene {
  75036. /** @hidden (Backing field) */
  75037. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  75038. /**
  75039. * Gets or Sets the current geometry buffer associated to the scene.
  75040. */
  75041. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  75042. /**
  75043. * Enables a GeometryBufferRender and associates it with the scene
  75044. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  75045. * @returns the GeometryBufferRenderer
  75046. */
  75047. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  75048. /**
  75049. * Disables the GeometryBufferRender associated with the scene
  75050. */
  75051. disableGeometryBufferRenderer(): void;
  75052. }
  75053. }
  75054. /**
  75055. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75056. * in several rendering techniques.
  75057. */
  75058. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  75059. /**
  75060. * The component name helpful to identify the component in the list of scene components.
  75061. */
  75062. readonly name: string;
  75063. /**
  75064. * The scene the component belongs to.
  75065. */
  75066. scene: Scene;
  75067. /**
  75068. * Creates a new instance of the component for the given scene
  75069. * @param scene Defines the scene to register the component in
  75070. */
  75071. constructor(scene: Scene);
  75072. /**
  75073. * Registers the component in a given scene
  75074. */
  75075. register(): void;
  75076. /**
  75077. * Rebuilds the elements related to this component in case of
  75078. * context lost for instance.
  75079. */
  75080. rebuild(): void;
  75081. /**
  75082. * Disposes the component and the associated ressources
  75083. */
  75084. dispose(): void;
  75085. private _gatherRenderTargets;
  75086. }
  75087. }
  75088. declare module "babylonjs/Shaders/motionBlur.fragment" {
  75089. /** @hidden */
  75090. export var motionBlurPixelShader: {
  75091. name: string;
  75092. shader: string;
  75093. };
  75094. }
  75095. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  75096. import { Nullable } from "babylonjs/types";
  75097. import { Camera } from "babylonjs/Cameras/camera";
  75098. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75100. import "babylonjs/Animations/animatable";
  75101. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75102. import "babylonjs/Shaders/motionBlur.fragment";
  75103. import { Engine } from "babylonjs/Engines/engine";
  75104. import { Scene } from "babylonjs/scene";
  75105. /**
  75106. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  75107. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  75108. * As an example, all you have to do is to create the post-process:
  75109. * var mb = new BABYLON.MotionBlurPostProcess(
  75110. * 'mb', // The name of the effect.
  75111. * scene, // The scene containing the objects to blur according to their velocity.
  75112. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  75113. * camera // The camera to apply the render pass to.
  75114. * );
  75115. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  75116. */
  75117. export class MotionBlurPostProcess extends PostProcess {
  75118. /**
  75119. * Defines how much the image is blurred by the movement. Default value is equal to 1
  75120. */
  75121. motionStrength: number;
  75122. /**
  75123. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  75124. */
  75125. get motionBlurSamples(): number;
  75126. /**
  75127. * Sets the number of iterations to be used for motion blur quality
  75128. */
  75129. set motionBlurSamples(samples: number);
  75130. private _motionBlurSamples;
  75131. private _forceGeometryBuffer;
  75132. private _geometryBufferRenderer;
  75133. private _prePassRenderer;
  75134. /**
  75135. * Gets a string identifying the name of the class
  75136. * @returns "MotionBlurPostProcess" string
  75137. */
  75138. getClassName(): string;
  75139. /**
  75140. * Creates a new instance MotionBlurPostProcess
  75141. * @param name The name of the effect.
  75142. * @param scene The scene containing the objects to blur according to their velocity.
  75143. * @param options The required width/height ratio to downsize to before computing the render pass.
  75144. * @param camera The camera to apply the render pass to.
  75145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75146. * @param engine The engine which the post process will be applied. (default: current engine)
  75147. * @param reusable If the post process can be reused on the same frame. (default: false)
  75148. * @param textureType Type of textures used when performing the post process. (default: 0)
  75149. * @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)
  75150. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75151. */
  75152. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75153. /**
  75154. * Excludes the given skinned mesh from computing bones velocities.
  75155. * 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.
  75156. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  75157. */
  75158. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75159. /**
  75160. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  75161. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  75162. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  75163. */
  75164. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75165. /**
  75166. * Disposes the post process.
  75167. * @param camera The camera to dispose the post process on.
  75168. */
  75169. dispose(camera?: Camera): void;
  75170. /** @hidden */
  75171. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  75172. }
  75173. }
  75174. declare module "babylonjs/Shaders/refraction.fragment" {
  75175. /** @hidden */
  75176. export var refractionPixelShader: {
  75177. name: string;
  75178. shader: string;
  75179. };
  75180. }
  75181. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  75182. import { Color3 } from "babylonjs/Maths/math.color";
  75183. import { Camera } from "babylonjs/Cameras/camera";
  75184. import { Texture } from "babylonjs/Materials/Textures/texture";
  75185. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75186. import { Engine } from "babylonjs/Engines/engine";
  75187. import "babylonjs/Shaders/refraction.fragment";
  75188. import { Scene } from "babylonjs/scene";
  75189. /**
  75190. * Post process which applies a refractin texture
  75191. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75192. */
  75193. export class RefractionPostProcess extends PostProcess {
  75194. private _refTexture;
  75195. private _ownRefractionTexture;
  75196. /** the base color of the refraction (used to taint the rendering) */
  75197. color: Color3;
  75198. /** simulated refraction depth */
  75199. depth: number;
  75200. /** the coefficient of the base color (0 to remove base color tainting) */
  75201. colorLevel: number;
  75202. /** Gets the url used to load the refraction texture */
  75203. refractionTextureUrl: string;
  75204. /**
  75205. * Gets or sets the refraction texture
  75206. * Please note that you are responsible for disposing the texture if you set it manually
  75207. */
  75208. get refractionTexture(): Texture;
  75209. set refractionTexture(value: Texture);
  75210. /**
  75211. * Gets a string identifying the name of the class
  75212. * @returns "RefractionPostProcess" string
  75213. */
  75214. getClassName(): string;
  75215. /**
  75216. * Initializes the RefractionPostProcess
  75217. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75218. * @param name The name of the effect.
  75219. * @param refractionTextureUrl Url of the refraction texture to use
  75220. * @param color the base color of the refraction (used to taint the rendering)
  75221. * @param depth simulated refraction depth
  75222. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  75223. * @param camera The camera to apply the render pass to.
  75224. * @param options The required width/height ratio to downsize to before computing the render pass.
  75225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75226. * @param engine The engine which the post process will be applied. (default: current engine)
  75227. * @param reusable If the post process can be reused on the same frame. (default: false)
  75228. */
  75229. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75230. /**
  75231. * Disposes of the post process
  75232. * @param camera Camera to dispose post process on
  75233. */
  75234. dispose(camera: Camera): void;
  75235. /** @hidden */
  75236. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  75237. }
  75238. }
  75239. declare module "babylonjs/Shaders/sharpen.fragment" {
  75240. /** @hidden */
  75241. export var sharpenPixelShader: {
  75242. name: string;
  75243. shader: string;
  75244. };
  75245. }
  75246. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  75247. import { Nullable } from "babylonjs/types";
  75248. import { Camera } from "babylonjs/Cameras/camera";
  75249. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75250. import "babylonjs/Shaders/sharpen.fragment";
  75251. import { Engine } from "babylonjs/Engines/engine";
  75252. import { Scene } from "babylonjs/scene";
  75253. /**
  75254. * The SharpenPostProcess applies a sharpen kernel to every pixel
  75255. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  75256. */
  75257. export class SharpenPostProcess extends PostProcess {
  75258. /**
  75259. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  75260. */
  75261. colorAmount: number;
  75262. /**
  75263. * How much sharpness should be applied (default: 0.3)
  75264. */
  75265. edgeAmount: number;
  75266. /**
  75267. * Gets a string identifying the name of the class
  75268. * @returns "SharpenPostProcess" string
  75269. */
  75270. getClassName(): string;
  75271. /**
  75272. * Creates a new instance ConvolutionPostProcess
  75273. * @param name The name of the effect.
  75274. * @param options The required width/height ratio to downsize to before computing the render pass.
  75275. * @param camera The camera to apply the render pass to.
  75276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75277. * @param engine The engine which the post process will be applied. (default: current engine)
  75278. * @param reusable If the post process can be reused on the same frame. (default: false)
  75279. * @param textureType Type of textures used when performing the post process. (default: 0)
  75280. * @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)
  75281. */
  75282. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75283. /** @hidden */
  75284. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  75285. }
  75286. }
  75287. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  75288. import { Nullable } from "babylonjs/types";
  75289. import { Camera } from "babylonjs/Cameras/camera";
  75290. import { Engine } from "babylonjs/Engines/engine";
  75291. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75292. import { IInspectable } from "babylonjs/Misc/iInspectable";
  75293. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75294. /**
  75295. * PostProcessRenderPipeline
  75296. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75297. */
  75298. export class PostProcessRenderPipeline {
  75299. private engine;
  75300. private _renderEffects;
  75301. private _renderEffectsForIsolatedPass;
  75302. /**
  75303. * List of inspectable custom properties (used by the Inspector)
  75304. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75305. */
  75306. inspectableCustomProperties: IInspectable[];
  75307. /**
  75308. * @hidden
  75309. */
  75310. protected _cameras: Camera[];
  75311. /** @hidden */
  75312. _name: string;
  75313. /**
  75314. * Gets pipeline name
  75315. */
  75316. get name(): string;
  75317. /** Gets the list of attached cameras */
  75318. get cameras(): Camera[];
  75319. /**
  75320. * Initializes a PostProcessRenderPipeline
  75321. * @param engine engine to add the pipeline to
  75322. * @param name name of the pipeline
  75323. */
  75324. constructor(engine: Engine, name: string);
  75325. /**
  75326. * Gets the class name
  75327. * @returns "PostProcessRenderPipeline"
  75328. */
  75329. getClassName(): string;
  75330. /**
  75331. * If all the render effects in the pipeline are supported
  75332. */
  75333. get isSupported(): boolean;
  75334. /**
  75335. * Adds an effect to the pipeline
  75336. * @param renderEffect the effect to add
  75337. */
  75338. addEffect(renderEffect: PostProcessRenderEffect): void;
  75339. /** @hidden */
  75340. _rebuild(): void;
  75341. /** @hidden */
  75342. _enableEffect(renderEffectName: string, cameras: Camera): void;
  75343. /** @hidden */
  75344. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  75345. /** @hidden */
  75346. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75347. /** @hidden */
  75348. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75349. /** @hidden */
  75350. _attachCameras(cameras: Camera, unique: boolean): void;
  75351. /** @hidden */
  75352. _attachCameras(cameras: Camera[], unique: boolean): void;
  75353. /** @hidden */
  75354. _detachCameras(cameras: Camera): void;
  75355. /** @hidden */
  75356. _detachCameras(cameras: Nullable<Camera[]>): void;
  75357. /** @hidden */
  75358. _update(): void;
  75359. /** @hidden */
  75360. _reset(): void;
  75361. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75362. /**
  75363. * Sets the required values to the prepass renderer.
  75364. * @param prePassRenderer defines the prepass renderer to setup.
  75365. * @returns true if the pre pass is needed.
  75366. */
  75367. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75368. /**
  75369. * Disposes of the pipeline
  75370. */
  75371. dispose(): void;
  75372. }
  75373. }
  75374. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  75375. import { Camera } from "babylonjs/Cameras/camera";
  75376. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75377. /**
  75378. * PostProcessRenderPipelineManager class
  75379. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75380. */
  75381. export class PostProcessRenderPipelineManager {
  75382. private _renderPipelines;
  75383. /**
  75384. * Initializes a PostProcessRenderPipelineManager
  75385. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75386. */
  75387. constructor();
  75388. /**
  75389. * Gets the list of supported render pipelines
  75390. */
  75391. get supportedPipelines(): PostProcessRenderPipeline[];
  75392. /**
  75393. * Adds a pipeline to the manager
  75394. * @param renderPipeline The pipeline to add
  75395. */
  75396. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75397. /**
  75398. * Attaches a camera to the pipeline
  75399. * @param renderPipelineName The name of the pipeline to attach to
  75400. * @param cameras the camera to attach
  75401. * @param unique if the camera can be attached multiple times to the pipeline
  75402. */
  75403. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75404. /**
  75405. * Detaches a camera from the pipeline
  75406. * @param renderPipelineName The name of the pipeline to detach from
  75407. * @param cameras the camera to detach
  75408. */
  75409. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75410. /**
  75411. * Enables an effect by name on a pipeline
  75412. * @param renderPipelineName the name of the pipeline to enable the effect in
  75413. * @param renderEffectName the name of the effect to enable
  75414. * @param cameras the cameras that the effect should be enabled on
  75415. */
  75416. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75417. /**
  75418. * Disables an effect by name on a pipeline
  75419. * @param renderPipelineName the name of the pipeline to disable the effect in
  75420. * @param renderEffectName the name of the effect to disable
  75421. * @param cameras the cameras that the effect should be disabled on
  75422. */
  75423. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75424. /**
  75425. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75426. */
  75427. update(): void;
  75428. /** @hidden */
  75429. _rebuild(): void;
  75430. /**
  75431. * Disposes of the manager and pipelines
  75432. */
  75433. dispose(): void;
  75434. }
  75435. }
  75436. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  75437. import { ISceneComponent } from "babylonjs/sceneComponent";
  75438. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75439. import { Scene } from "babylonjs/scene";
  75440. module "babylonjs/scene" {
  75441. interface Scene {
  75442. /** @hidden (Backing field) */
  75443. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75444. /**
  75445. * Gets the postprocess render pipeline manager
  75446. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75447. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75448. */
  75449. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75450. }
  75451. }
  75452. /**
  75453. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75454. */
  75455. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75456. /**
  75457. * The component name helpfull to identify the component in the list of scene components.
  75458. */
  75459. readonly name: string;
  75460. /**
  75461. * The scene the component belongs to.
  75462. */
  75463. scene: Scene;
  75464. /**
  75465. * Creates a new instance of the component for the given scene
  75466. * @param scene Defines the scene to register the component in
  75467. */
  75468. constructor(scene: Scene);
  75469. /**
  75470. * Registers the component in a given scene
  75471. */
  75472. register(): void;
  75473. /**
  75474. * Rebuilds the elements related to this component in case of
  75475. * context lost for instance.
  75476. */
  75477. rebuild(): void;
  75478. /**
  75479. * Disposes the component and the associated ressources
  75480. */
  75481. dispose(): void;
  75482. private _gatherRenderTargets;
  75483. }
  75484. }
  75485. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  75486. import { Nullable } from "babylonjs/types";
  75487. import { Observable } from "babylonjs/Misc/observable";
  75488. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75489. import { Camera } from "babylonjs/Cameras/camera";
  75490. import { IDisposable } from "babylonjs/scene";
  75491. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  75492. import { Scene } from "babylonjs/scene";
  75493. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  75494. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75495. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75496. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  75497. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75498. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75499. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  75500. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75501. import { Animation } from "babylonjs/Animations/animation";
  75502. /**
  75503. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75504. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75505. */
  75506. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75507. private _scene;
  75508. private _camerasToBeAttached;
  75509. /**
  75510. * ID of the sharpen post process,
  75511. */
  75512. private readonly SharpenPostProcessId;
  75513. /**
  75514. * @ignore
  75515. * ID of the image processing post process;
  75516. */
  75517. readonly ImageProcessingPostProcessId: string;
  75518. /**
  75519. * @ignore
  75520. * ID of the Fast Approximate Anti-Aliasing post process;
  75521. */
  75522. readonly FxaaPostProcessId: string;
  75523. /**
  75524. * ID of the chromatic aberration post process,
  75525. */
  75526. private readonly ChromaticAberrationPostProcessId;
  75527. /**
  75528. * ID of the grain post process
  75529. */
  75530. private readonly GrainPostProcessId;
  75531. /**
  75532. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75533. */
  75534. sharpen: SharpenPostProcess;
  75535. private _sharpenEffect;
  75536. private bloom;
  75537. /**
  75538. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75539. */
  75540. depthOfField: DepthOfFieldEffect;
  75541. /**
  75542. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75543. */
  75544. fxaa: FxaaPostProcess;
  75545. /**
  75546. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75547. */
  75548. imageProcessing: ImageProcessingPostProcess;
  75549. /**
  75550. * Chromatic aberration post process which will shift rgb colors in the image
  75551. */
  75552. chromaticAberration: ChromaticAberrationPostProcess;
  75553. private _chromaticAberrationEffect;
  75554. /**
  75555. * Grain post process which add noise to the image
  75556. */
  75557. grain: GrainPostProcess;
  75558. private _grainEffect;
  75559. /**
  75560. * Glow post process which adds a glow to emissive areas of the image
  75561. */
  75562. private _glowLayer;
  75563. /**
  75564. * Animations which can be used to tweak settings over a period of time
  75565. */
  75566. animations: Animation[];
  75567. private _imageProcessingConfigurationObserver;
  75568. private _sharpenEnabled;
  75569. private _bloomEnabled;
  75570. private _depthOfFieldEnabled;
  75571. private _depthOfFieldBlurLevel;
  75572. private _fxaaEnabled;
  75573. private _imageProcessingEnabled;
  75574. private _defaultPipelineTextureType;
  75575. private _bloomScale;
  75576. private _chromaticAberrationEnabled;
  75577. private _grainEnabled;
  75578. private _buildAllowed;
  75579. /**
  75580. * This is triggered each time the pipeline has been built.
  75581. */
  75582. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75583. /**
  75584. * Gets active scene
  75585. */
  75586. get scene(): Scene;
  75587. /**
  75588. * Enable or disable the sharpen process from the pipeline
  75589. */
  75590. set sharpenEnabled(enabled: boolean);
  75591. get sharpenEnabled(): boolean;
  75592. private _resizeObserver;
  75593. private _hardwareScaleLevel;
  75594. private _bloomKernel;
  75595. /**
  75596. * Specifies the size of the bloom blur kernel, relative to the final output size
  75597. */
  75598. get bloomKernel(): number;
  75599. set bloomKernel(value: number);
  75600. /**
  75601. * Specifies the weight of the bloom in the final rendering
  75602. */
  75603. private _bloomWeight;
  75604. /**
  75605. * Specifies the luma threshold for the area that will be blurred by the bloom
  75606. */
  75607. private _bloomThreshold;
  75608. private _hdr;
  75609. /**
  75610. * The strength of the bloom.
  75611. */
  75612. set bloomWeight(value: number);
  75613. get bloomWeight(): number;
  75614. /**
  75615. * The strength of the bloom.
  75616. */
  75617. set bloomThreshold(value: number);
  75618. get bloomThreshold(): number;
  75619. /**
  75620. * The scale of the bloom, lower value will provide better performance.
  75621. */
  75622. set bloomScale(value: number);
  75623. get bloomScale(): number;
  75624. /**
  75625. * Enable or disable the bloom from the pipeline
  75626. */
  75627. set bloomEnabled(enabled: boolean);
  75628. get bloomEnabled(): boolean;
  75629. private _rebuildBloom;
  75630. /**
  75631. * If the depth of field is enabled.
  75632. */
  75633. get depthOfFieldEnabled(): boolean;
  75634. set depthOfFieldEnabled(enabled: boolean);
  75635. /**
  75636. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75637. */
  75638. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75639. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75640. /**
  75641. * If the anti aliasing is enabled.
  75642. */
  75643. set fxaaEnabled(enabled: boolean);
  75644. get fxaaEnabled(): boolean;
  75645. private _samples;
  75646. /**
  75647. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75648. */
  75649. set samples(sampleCount: number);
  75650. get samples(): number;
  75651. /**
  75652. * If image processing is enabled.
  75653. */
  75654. set imageProcessingEnabled(enabled: boolean);
  75655. get imageProcessingEnabled(): boolean;
  75656. /**
  75657. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75658. */
  75659. set glowLayerEnabled(enabled: boolean);
  75660. get glowLayerEnabled(): boolean;
  75661. /**
  75662. * Gets the glow layer (or null if not defined)
  75663. */
  75664. get glowLayer(): Nullable<GlowLayer>;
  75665. /**
  75666. * Enable or disable the chromaticAberration process from the pipeline
  75667. */
  75668. set chromaticAberrationEnabled(enabled: boolean);
  75669. get chromaticAberrationEnabled(): boolean;
  75670. /**
  75671. * Enable or disable the grain process from the pipeline
  75672. */
  75673. set grainEnabled(enabled: boolean);
  75674. get grainEnabled(): boolean;
  75675. /**
  75676. * @constructor
  75677. * @param name - The rendering pipeline name (default: "")
  75678. * @param hdr - If high dynamic range textures should be used (default: true)
  75679. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75680. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75681. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75682. */
  75683. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75684. /**
  75685. * Get the class name
  75686. * @returns "DefaultRenderingPipeline"
  75687. */
  75688. getClassName(): string;
  75689. /**
  75690. * Force the compilation of the entire pipeline.
  75691. */
  75692. prepare(): void;
  75693. private _hasCleared;
  75694. private _prevPostProcess;
  75695. private _prevPrevPostProcess;
  75696. private _setAutoClearAndTextureSharing;
  75697. private _depthOfFieldSceneObserver;
  75698. private _buildPipeline;
  75699. private _disposePostProcesses;
  75700. /**
  75701. * Adds a camera to the pipeline
  75702. * @param camera the camera to be added
  75703. */
  75704. addCamera(camera: Camera): void;
  75705. /**
  75706. * Removes a camera from the pipeline
  75707. * @param camera the camera to remove
  75708. */
  75709. removeCamera(camera: Camera): void;
  75710. /**
  75711. * Dispose of the pipeline and stop all post processes
  75712. */
  75713. dispose(): void;
  75714. /**
  75715. * Serialize the rendering pipeline (Used when exporting)
  75716. * @returns the serialized object
  75717. */
  75718. serialize(): any;
  75719. /**
  75720. * Parse the serialized pipeline
  75721. * @param source Source pipeline.
  75722. * @param scene The scene to load the pipeline to.
  75723. * @param rootUrl The URL of the serialized pipeline.
  75724. * @returns An instantiated pipeline from the serialized object.
  75725. */
  75726. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75727. }
  75728. }
  75729. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  75730. /** @hidden */
  75731. export var lensHighlightsPixelShader: {
  75732. name: string;
  75733. shader: string;
  75734. };
  75735. }
  75736. declare module "babylonjs/Shaders/depthOfField.fragment" {
  75737. /** @hidden */
  75738. export var depthOfFieldPixelShader: {
  75739. name: string;
  75740. shader: string;
  75741. };
  75742. }
  75743. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  75744. import { Camera } from "babylonjs/Cameras/camera";
  75745. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75746. import { Scene } from "babylonjs/scene";
  75747. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75748. import "babylonjs/Shaders/chromaticAberration.fragment";
  75749. import "babylonjs/Shaders/lensHighlights.fragment";
  75750. import "babylonjs/Shaders/depthOfField.fragment";
  75751. /**
  75752. * BABYLON.JS Chromatic Aberration GLSL Shader
  75753. * Author: Olivier Guyot
  75754. * Separates very slightly R, G and B colors on the edges of the screen
  75755. * Inspired by Francois Tarlier & Martins Upitis
  75756. */
  75757. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75758. /**
  75759. * @ignore
  75760. * The chromatic aberration PostProcess id in the pipeline
  75761. */
  75762. LensChromaticAberrationEffect: string;
  75763. /**
  75764. * @ignore
  75765. * The highlights enhancing PostProcess id in the pipeline
  75766. */
  75767. HighlightsEnhancingEffect: string;
  75768. /**
  75769. * @ignore
  75770. * The depth-of-field PostProcess id in the pipeline
  75771. */
  75772. LensDepthOfFieldEffect: string;
  75773. private _scene;
  75774. private _depthTexture;
  75775. private _grainTexture;
  75776. private _chromaticAberrationPostProcess;
  75777. private _highlightsPostProcess;
  75778. private _depthOfFieldPostProcess;
  75779. private _edgeBlur;
  75780. private _grainAmount;
  75781. private _chromaticAberration;
  75782. private _distortion;
  75783. private _highlightsGain;
  75784. private _highlightsThreshold;
  75785. private _dofDistance;
  75786. private _dofAperture;
  75787. private _dofDarken;
  75788. private _dofPentagon;
  75789. private _blurNoise;
  75790. /**
  75791. * @constructor
  75792. *
  75793. * Effect parameters are as follow:
  75794. * {
  75795. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75796. * edge_blur: number; // from 0 to x (1 for realism)
  75797. * distortion: number; // from 0 to x (1 for realism)
  75798. * grain_amount: number; // from 0 to 1
  75799. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75800. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75801. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75802. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75803. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75804. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75805. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75806. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75807. * }
  75808. * Note: if an effect parameter is unset, effect is disabled
  75809. *
  75810. * @param name The rendering pipeline name
  75811. * @param parameters - An object containing all parameters (see above)
  75812. * @param scene The scene linked to this pipeline
  75813. * @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)
  75814. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75815. */
  75816. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75817. /**
  75818. * Get the class name
  75819. * @returns "LensRenderingPipeline"
  75820. */
  75821. getClassName(): string;
  75822. /**
  75823. * Gets associated scene
  75824. */
  75825. get scene(): Scene;
  75826. /**
  75827. * Gets or sets the edge blur
  75828. */
  75829. get edgeBlur(): number;
  75830. set edgeBlur(value: number);
  75831. /**
  75832. * Gets or sets the grain amount
  75833. */
  75834. get grainAmount(): number;
  75835. set grainAmount(value: number);
  75836. /**
  75837. * Gets or sets the chromatic aberration amount
  75838. */
  75839. get chromaticAberration(): number;
  75840. set chromaticAberration(value: number);
  75841. /**
  75842. * Gets or sets the depth of field aperture
  75843. */
  75844. get dofAperture(): number;
  75845. set dofAperture(value: number);
  75846. /**
  75847. * Gets or sets the edge distortion
  75848. */
  75849. get edgeDistortion(): number;
  75850. set edgeDistortion(value: number);
  75851. /**
  75852. * Gets or sets the depth of field distortion
  75853. */
  75854. get dofDistortion(): number;
  75855. set dofDistortion(value: number);
  75856. /**
  75857. * Gets or sets the darken out of focus amount
  75858. */
  75859. get darkenOutOfFocus(): number;
  75860. set darkenOutOfFocus(value: number);
  75861. /**
  75862. * Gets or sets a boolean indicating if blur noise is enabled
  75863. */
  75864. get blurNoise(): boolean;
  75865. set blurNoise(value: boolean);
  75866. /**
  75867. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75868. */
  75869. get pentagonBokeh(): boolean;
  75870. set pentagonBokeh(value: boolean);
  75871. /**
  75872. * Gets or sets the highlight grain amount
  75873. */
  75874. get highlightsGain(): number;
  75875. set highlightsGain(value: number);
  75876. /**
  75877. * Gets or sets the highlight threshold
  75878. */
  75879. get highlightsThreshold(): number;
  75880. set highlightsThreshold(value: number);
  75881. /**
  75882. * Sets the amount of blur at the edges
  75883. * @param amount blur amount
  75884. */
  75885. setEdgeBlur(amount: number): void;
  75886. /**
  75887. * Sets edge blur to 0
  75888. */
  75889. disableEdgeBlur(): void;
  75890. /**
  75891. * Sets the amout of grain
  75892. * @param amount Amount of grain
  75893. */
  75894. setGrainAmount(amount: number): void;
  75895. /**
  75896. * Set grain amount to 0
  75897. */
  75898. disableGrain(): void;
  75899. /**
  75900. * Sets the chromatic aberration amount
  75901. * @param amount amount of chromatic aberration
  75902. */
  75903. setChromaticAberration(amount: number): void;
  75904. /**
  75905. * Sets chromatic aberration amount to 0
  75906. */
  75907. disableChromaticAberration(): void;
  75908. /**
  75909. * Sets the EdgeDistortion amount
  75910. * @param amount amount of EdgeDistortion
  75911. */
  75912. setEdgeDistortion(amount: number): void;
  75913. /**
  75914. * Sets edge distortion to 0
  75915. */
  75916. disableEdgeDistortion(): void;
  75917. /**
  75918. * Sets the FocusDistance amount
  75919. * @param amount amount of FocusDistance
  75920. */
  75921. setFocusDistance(amount: number): void;
  75922. /**
  75923. * Disables depth of field
  75924. */
  75925. disableDepthOfField(): void;
  75926. /**
  75927. * Sets the Aperture amount
  75928. * @param amount amount of Aperture
  75929. */
  75930. setAperture(amount: number): void;
  75931. /**
  75932. * Sets the DarkenOutOfFocus amount
  75933. * @param amount amount of DarkenOutOfFocus
  75934. */
  75935. setDarkenOutOfFocus(amount: number): void;
  75936. private _pentagonBokehIsEnabled;
  75937. /**
  75938. * Creates a pentagon bokeh effect
  75939. */
  75940. enablePentagonBokeh(): void;
  75941. /**
  75942. * Disables the pentagon bokeh effect
  75943. */
  75944. disablePentagonBokeh(): void;
  75945. /**
  75946. * Enables noise blur
  75947. */
  75948. enableNoiseBlur(): void;
  75949. /**
  75950. * Disables noise blur
  75951. */
  75952. disableNoiseBlur(): void;
  75953. /**
  75954. * Sets the HighlightsGain amount
  75955. * @param amount amount of HighlightsGain
  75956. */
  75957. setHighlightsGain(amount: number): void;
  75958. /**
  75959. * Sets the HighlightsThreshold amount
  75960. * @param amount amount of HighlightsThreshold
  75961. */
  75962. setHighlightsThreshold(amount: number): void;
  75963. /**
  75964. * Disables highlights
  75965. */
  75966. disableHighlights(): void;
  75967. /**
  75968. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75969. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75970. */
  75971. dispose(disableDepthRender?: boolean): void;
  75972. private _createChromaticAberrationPostProcess;
  75973. private _createHighlightsPostProcess;
  75974. private _createDepthOfFieldPostProcess;
  75975. private _createGrainTexture;
  75976. }
  75977. }
  75978. declare module "babylonjs/Rendering/ssao2Configuration" {
  75979. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75980. /**
  75981. * Contains all parameters needed for the prepass to perform
  75982. * screen space subsurface scattering
  75983. */
  75984. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75985. /**
  75986. * Is subsurface enabled
  75987. */
  75988. enabled: boolean;
  75989. /**
  75990. * Name of the configuration
  75991. */
  75992. name: string;
  75993. /**
  75994. * Textures that should be present in the MRT for this effect to work
  75995. */
  75996. readonly texturesRequired: number[];
  75997. }
  75998. }
  75999. declare module "babylonjs/Shaders/ssao2.fragment" {
  76000. /** @hidden */
  76001. export var ssao2PixelShader: {
  76002. name: string;
  76003. shader: string;
  76004. };
  76005. }
  76006. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  76007. /** @hidden */
  76008. export var ssaoCombinePixelShader: {
  76009. name: string;
  76010. shader: string;
  76011. };
  76012. }
  76013. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  76014. import { Camera } from "babylonjs/Cameras/camera";
  76015. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76016. import { Scene } from "babylonjs/scene";
  76017. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76018. import "babylonjs/Shaders/ssao2.fragment";
  76019. import "babylonjs/Shaders/ssaoCombine.fragment";
  76020. /**
  76021. * Render pipeline to produce ssao effect
  76022. */
  76023. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  76024. /**
  76025. * @ignore
  76026. * The PassPostProcess id in the pipeline that contains the original scene color
  76027. */
  76028. SSAOOriginalSceneColorEffect: string;
  76029. /**
  76030. * @ignore
  76031. * The SSAO PostProcess id in the pipeline
  76032. */
  76033. SSAORenderEffect: string;
  76034. /**
  76035. * @ignore
  76036. * The horizontal blur PostProcess id in the pipeline
  76037. */
  76038. SSAOBlurHRenderEffect: string;
  76039. /**
  76040. * @ignore
  76041. * The vertical blur PostProcess id in the pipeline
  76042. */
  76043. SSAOBlurVRenderEffect: string;
  76044. /**
  76045. * @ignore
  76046. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76047. */
  76048. SSAOCombineRenderEffect: string;
  76049. /**
  76050. * The output strength of the SSAO post-process. Default value is 1.0.
  76051. */
  76052. totalStrength: number;
  76053. /**
  76054. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  76055. */
  76056. maxZ: number;
  76057. /**
  76058. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  76059. */
  76060. minZAspect: number;
  76061. private _samples;
  76062. /**
  76063. * Number of samples used for the SSAO calculations. Default value is 8
  76064. */
  76065. set samples(n: number);
  76066. get samples(): number;
  76067. private _textureSamples;
  76068. /**
  76069. * Number of samples to use for antialiasing
  76070. */
  76071. set textureSamples(n: number);
  76072. get textureSamples(): number;
  76073. /**
  76074. * Force rendering the geometry through geometry buffer
  76075. */
  76076. private _forceGeometryBuffer;
  76077. /**
  76078. * Ratio object used for SSAO ratio and blur ratio
  76079. */
  76080. private _ratio;
  76081. /**
  76082. * Dynamically generated sphere sampler.
  76083. */
  76084. private _sampleSphere;
  76085. /**
  76086. * Blur filter offsets
  76087. */
  76088. private _samplerOffsets;
  76089. private _expensiveBlur;
  76090. /**
  76091. * If bilateral blur should be used
  76092. */
  76093. set expensiveBlur(b: boolean);
  76094. get expensiveBlur(): boolean;
  76095. /**
  76096. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  76097. */
  76098. radius: number;
  76099. /**
  76100. * The base color of the SSAO post-process
  76101. * The final result is "base + ssao" between [0, 1]
  76102. */
  76103. base: number;
  76104. /**
  76105. * Support test.
  76106. */
  76107. static get IsSupported(): boolean;
  76108. private _scene;
  76109. private _randomTexture;
  76110. private _originalColorPostProcess;
  76111. private _ssaoPostProcess;
  76112. private _blurHPostProcess;
  76113. private _blurVPostProcess;
  76114. private _ssaoCombinePostProcess;
  76115. private _prePassRenderer;
  76116. /**
  76117. * Gets active scene
  76118. */
  76119. get scene(): Scene;
  76120. /**
  76121. * @constructor
  76122. * @param name The rendering pipeline name
  76123. * @param scene The scene linked to this pipeline
  76124. * @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 }
  76125. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76126. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  76127. */
  76128. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  76129. /**
  76130. * Get the class name
  76131. * @returns "SSAO2RenderingPipeline"
  76132. */
  76133. getClassName(): string;
  76134. /**
  76135. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  76136. */
  76137. dispose(disableGeometryBufferRenderer?: boolean): void;
  76138. private _createBlurPostProcess;
  76139. /** @hidden */
  76140. _rebuild(): void;
  76141. private _bits;
  76142. private _radicalInverse_VdC;
  76143. private _hammersley;
  76144. private _hemisphereSample_uniform;
  76145. private _generateHemisphere;
  76146. private _getDefinesForSSAO;
  76147. private _createSSAOPostProcess;
  76148. private _createSSAOCombinePostProcess;
  76149. private _createRandomTexture;
  76150. /**
  76151. * Serialize the rendering pipeline (Used when exporting)
  76152. * @returns the serialized object
  76153. */
  76154. serialize(): any;
  76155. /**
  76156. * Parse the serialized pipeline
  76157. * @param source Source pipeline.
  76158. * @param scene The scene to load the pipeline to.
  76159. * @param rootUrl The URL of the serialized pipeline.
  76160. * @returns An instantiated pipeline from the serialized object.
  76161. */
  76162. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  76163. }
  76164. }
  76165. declare module "babylonjs/Shaders/ssao.fragment" {
  76166. /** @hidden */
  76167. export var ssaoPixelShader: {
  76168. name: string;
  76169. shader: string;
  76170. };
  76171. }
  76172. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  76173. import { Camera } from "babylonjs/Cameras/camera";
  76174. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76175. import { Scene } from "babylonjs/scene";
  76176. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76177. import "babylonjs/Shaders/ssao.fragment";
  76178. import "babylonjs/Shaders/ssaoCombine.fragment";
  76179. /**
  76180. * Render pipeline to produce ssao effect
  76181. */
  76182. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  76183. /**
  76184. * @ignore
  76185. * The PassPostProcess id in the pipeline that contains the original scene color
  76186. */
  76187. SSAOOriginalSceneColorEffect: string;
  76188. /**
  76189. * @ignore
  76190. * The SSAO PostProcess id in the pipeline
  76191. */
  76192. SSAORenderEffect: string;
  76193. /**
  76194. * @ignore
  76195. * The horizontal blur PostProcess id in the pipeline
  76196. */
  76197. SSAOBlurHRenderEffect: string;
  76198. /**
  76199. * @ignore
  76200. * The vertical blur PostProcess id in the pipeline
  76201. */
  76202. SSAOBlurVRenderEffect: string;
  76203. /**
  76204. * @ignore
  76205. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76206. */
  76207. SSAOCombineRenderEffect: string;
  76208. /**
  76209. * The output strength of the SSAO post-process. Default value is 1.0.
  76210. */
  76211. totalStrength: number;
  76212. /**
  76213. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  76214. */
  76215. radius: number;
  76216. /**
  76217. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  76218. * Must not be equal to fallOff and superior to fallOff.
  76219. * Default value is 0.0075
  76220. */
  76221. area: number;
  76222. /**
  76223. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  76224. * Must not be equal to area and inferior to area.
  76225. * Default value is 0.000001
  76226. */
  76227. fallOff: number;
  76228. /**
  76229. * The base color of the SSAO post-process
  76230. * The final result is "base + ssao" between [0, 1]
  76231. */
  76232. base: number;
  76233. private _scene;
  76234. private _depthTexture;
  76235. private _randomTexture;
  76236. private _originalColorPostProcess;
  76237. private _ssaoPostProcess;
  76238. private _blurHPostProcess;
  76239. private _blurVPostProcess;
  76240. private _ssaoCombinePostProcess;
  76241. private _firstUpdate;
  76242. /**
  76243. * Gets active scene
  76244. */
  76245. get scene(): Scene;
  76246. /**
  76247. * @constructor
  76248. * @param name - The rendering pipeline name
  76249. * @param scene - The scene linked to this pipeline
  76250. * @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 }
  76251. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  76252. */
  76253. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  76254. /**
  76255. * Get the class name
  76256. * @returns "SSAORenderingPipeline"
  76257. */
  76258. getClassName(): string;
  76259. /**
  76260. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  76261. */
  76262. dispose(disableDepthRender?: boolean): void;
  76263. private _createBlurPostProcess;
  76264. /** @hidden */
  76265. _rebuild(): void;
  76266. private _createSSAOPostProcess;
  76267. private _createSSAOCombinePostProcess;
  76268. private _createRandomTexture;
  76269. }
  76270. }
  76271. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  76272. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76273. /**
  76274. * Contains all parameters needed for the prepass to perform
  76275. * screen space reflections
  76276. */
  76277. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  76278. /**
  76279. * Is ssr enabled
  76280. */
  76281. enabled: boolean;
  76282. /**
  76283. * Name of the configuration
  76284. */
  76285. name: string;
  76286. /**
  76287. * Textures that should be present in the MRT for this effect to work
  76288. */
  76289. readonly texturesRequired: number[];
  76290. }
  76291. }
  76292. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  76293. /** @hidden */
  76294. export var screenSpaceReflectionPixelShader: {
  76295. name: string;
  76296. shader: string;
  76297. };
  76298. }
  76299. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  76300. import { Nullable } from "babylonjs/types";
  76301. import { Camera } from "babylonjs/Cameras/camera";
  76302. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76303. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  76304. import { Engine } from "babylonjs/Engines/engine";
  76305. import { Scene } from "babylonjs/scene";
  76306. /**
  76307. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  76308. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  76309. */
  76310. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  76311. /**
  76312. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  76313. */
  76314. threshold: number;
  76315. /**
  76316. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  76317. */
  76318. strength: number;
  76319. /**
  76320. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  76321. */
  76322. reflectionSpecularFalloffExponent: number;
  76323. /**
  76324. * 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]
  76325. */
  76326. step: number;
  76327. /**
  76328. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  76329. */
  76330. roughnessFactor: number;
  76331. private _forceGeometryBuffer;
  76332. private _geometryBufferRenderer;
  76333. private _prePassRenderer;
  76334. private _enableSmoothReflections;
  76335. private _reflectionSamples;
  76336. private _smoothSteps;
  76337. /**
  76338. * Gets a string identifying the name of the class
  76339. * @returns "ScreenSpaceReflectionPostProcess" string
  76340. */
  76341. getClassName(): string;
  76342. /**
  76343. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  76344. * @param name The name of the effect.
  76345. * @param scene The scene containing the objects to calculate reflections.
  76346. * @param options The required width/height ratio to downsize to before computing the render pass.
  76347. * @param camera The camera to apply the render pass to.
  76348. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76349. * @param engine The engine which the post process will be applied. (default: current engine)
  76350. * @param reusable If the post process can be reused on the same frame. (default: false)
  76351. * @param textureType Type of textures used when performing the post process. (default: 0)
  76352. * @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)
  76353. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  76354. */
  76355. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  76356. /**
  76357. * Gets wether or not smoothing reflections is enabled.
  76358. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76359. */
  76360. get enableSmoothReflections(): boolean;
  76361. /**
  76362. * Sets wether or not smoothing reflections is enabled.
  76363. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76364. */
  76365. set enableSmoothReflections(enabled: boolean);
  76366. /**
  76367. * Gets the number of samples taken while computing reflections. More samples count is high,
  76368. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76369. */
  76370. get reflectionSamples(): number;
  76371. /**
  76372. * Sets the number of samples taken while computing reflections. More samples count is high,
  76373. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76374. */
  76375. set reflectionSamples(samples: number);
  76376. /**
  76377. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76378. * more the post-process will require GPU power and can generate a drop in FPS.
  76379. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76380. */
  76381. get smoothSteps(): number;
  76382. set smoothSteps(steps: number);
  76383. private _updateEffectDefines;
  76384. /** @hidden */
  76385. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76386. }
  76387. }
  76388. declare module "babylonjs/Shaders/standard.fragment" {
  76389. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  76390. /** @hidden */
  76391. export var standardPixelShader: {
  76392. name: string;
  76393. shader: string;
  76394. };
  76395. }
  76396. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  76397. import { Nullable } from "babylonjs/types";
  76398. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  76399. import { Camera } from "babylonjs/Cameras/camera";
  76400. import { Texture } from "babylonjs/Materials/Textures/texture";
  76401. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76402. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76403. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  76404. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  76405. import { IDisposable } from "babylonjs/scene";
  76406. import { SpotLight } from "babylonjs/Lights/spotLight";
  76407. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  76408. import { Scene } from "babylonjs/scene";
  76409. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76410. import { Animation } from "babylonjs/Animations/animation";
  76411. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76412. import "babylonjs/Shaders/standard.fragment";
  76413. /**
  76414. * Standard rendering pipeline
  76415. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76416. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76417. */
  76418. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76419. /**
  76420. * Public members
  76421. */
  76422. /**
  76423. * Post-process which contains the original scene color before the pipeline applies all the effects
  76424. */
  76425. originalPostProcess: Nullable<PostProcess>;
  76426. /**
  76427. * Post-process used to down scale an image x4
  76428. */
  76429. downSampleX4PostProcess: Nullable<PostProcess>;
  76430. /**
  76431. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76432. */
  76433. brightPassPostProcess: Nullable<PostProcess>;
  76434. /**
  76435. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76436. */
  76437. blurHPostProcesses: PostProcess[];
  76438. /**
  76439. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76440. */
  76441. blurVPostProcesses: PostProcess[];
  76442. /**
  76443. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76444. */
  76445. textureAdderPostProcess: Nullable<PostProcess>;
  76446. /**
  76447. * Post-process used to create volumetric lighting effect
  76448. */
  76449. volumetricLightPostProcess: Nullable<PostProcess>;
  76450. /**
  76451. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76452. */
  76453. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76454. /**
  76455. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76456. */
  76457. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76458. /**
  76459. * Post-process used to merge the volumetric light effect and the real scene color
  76460. */
  76461. volumetricLightMergePostProces: Nullable<PostProcess>;
  76462. /**
  76463. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76464. */
  76465. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76466. /**
  76467. * Base post-process used to calculate the average luminance of the final image for HDR
  76468. */
  76469. luminancePostProcess: Nullable<PostProcess>;
  76470. /**
  76471. * Post-processes used to create down sample post-processes in order to get
  76472. * the average luminance of the final image for HDR
  76473. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76474. */
  76475. luminanceDownSamplePostProcesses: PostProcess[];
  76476. /**
  76477. * Post-process used to create a HDR effect (light adaptation)
  76478. */
  76479. hdrPostProcess: Nullable<PostProcess>;
  76480. /**
  76481. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76482. */
  76483. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76484. /**
  76485. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76486. */
  76487. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76488. /**
  76489. * Post-process used to merge the final HDR post-process and the real scene color
  76490. */
  76491. hdrFinalPostProcess: Nullable<PostProcess>;
  76492. /**
  76493. * Post-process used to create a lens flare effect
  76494. */
  76495. lensFlarePostProcess: Nullable<PostProcess>;
  76496. /**
  76497. * Post-process that merges the result of the lens flare post-process and the real scene color
  76498. */
  76499. lensFlareComposePostProcess: Nullable<PostProcess>;
  76500. /**
  76501. * Post-process used to create a motion blur effect
  76502. */
  76503. motionBlurPostProcess: Nullable<PostProcess>;
  76504. /**
  76505. * Post-process used to create a depth of field effect
  76506. */
  76507. depthOfFieldPostProcess: Nullable<PostProcess>;
  76508. /**
  76509. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  76510. */
  76511. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76512. /**
  76513. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76514. */
  76515. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76516. /**
  76517. * Represents the brightness threshold in order to configure the illuminated surfaces
  76518. */
  76519. brightThreshold: number;
  76520. /**
  76521. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76522. */
  76523. blurWidth: number;
  76524. /**
  76525. * Sets if the blur for highlighted surfaces must be only horizontal
  76526. */
  76527. horizontalBlur: boolean;
  76528. /**
  76529. * Gets the overall exposure used by the pipeline
  76530. */
  76531. get exposure(): number;
  76532. /**
  76533. * Sets the overall exposure used by the pipeline
  76534. */
  76535. set exposure(value: number);
  76536. /**
  76537. * Texture used typically to simulate "dirty" on camera lens
  76538. */
  76539. lensTexture: Nullable<Texture>;
  76540. /**
  76541. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76542. */
  76543. volumetricLightCoefficient: number;
  76544. /**
  76545. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76546. */
  76547. volumetricLightPower: number;
  76548. /**
  76549. * Used the set the blur intensity to smooth the volumetric lights
  76550. */
  76551. volumetricLightBlurScale: number;
  76552. /**
  76553. * Light (spot or directional) used to generate the volumetric lights rays
  76554. * The source light must have a shadow generate so the pipeline can get its
  76555. * depth map
  76556. */
  76557. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76558. /**
  76559. * For eye adaptation, represents the minimum luminance the eye can see
  76560. */
  76561. hdrMinimumLuminance: number;
  76562. /**
  76563. * For eye adaptation, represents the decrease luminance speed
  76564. */
  76565. hdrDecreaseRate: number;
  76566. /**
  76567. * For eye adaptation, represents the increase luminance speed
  76568. */
  76569. hdrIncreaseRate: number;
  76570. /**
  76571. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76572. */
  76573. get hdrAutoExposure(): boolean;
  76574. /**
  76575. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76576. */
  76577. set hdrAutoExposure(value: boolean);
  76578. /**
  76579. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76580. */
  76581. lensColorTexture: Nullable<Texture>;
  76582. /**
  76583. * The overall strengh for the lens flare effect
  76584. */
  76585. lensFlareStrength: number;
  76586. /**
  76587. * Dispersion coefficient for lens flare ghosts
  76588. */
  76589. lensFlareGhostDispersal: number;
  76590. /**
  76591. * Main lens flare halo width
  76592. */
  76593. lensFlareHaloWidth: number;
  76594. /**
  76595. * Based on the lens distortion effect, defines how much the lens flare result
  76596. * is distorted
  76597. */
  76598. lensFlareDistortionStrength: number;
  76599. /**
  76600. * Configures the blur intensity used for for lens flare (halo)
  76601. */
  76602. lensFlareBlurWidth: number;
  76603. /**
  76604. * Lens star texture must be used to simulate rays on the flares and is available
  76605. * in the documentation
  76606. */
  76607. lensStarTexture: Nullable<Texture>;
  76608. /**
  76609. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76610. * flare effect by taking account of the dirt texture
  76611. */
  76612. lensFlareDirtTexture: Nullable<Texture>;
  76613. /**
  76614. * Represents the focal length for the depth of field effect
  76615. */
  76616. depthOfFieldDistance: number;
  76617. /**
  76618. * Represents the blur intensity for the blurred part of the depth of field effect
  76619. */
  76620. depthOfFieldBlurWidth: number;
  76621. /**
  76622. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76623. */
  76624. get motionStrength(): number;
  76625. /**
  76626. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76627. */
  76628. set motionStrength(strength: number);
  76629. /**
  76630. * Gets wether or not the motion blur post-process is object based or screen based.
  76631. */
  76632. get objectBasedMotionBlur(): boolean;
  76633. /**
  76634. * Sets wether or not the motion blur post-process should be object based or screen based
  76635. */
  76636. set objectBasedMotionBlur(value: boolean);
  76637. /**
  76638. * List of animations for the pipeline (IAnimatable implementation)
  76639. */
  76640. animations: Animation[];
  76641. /**
  76642. * Private members
  76643. */
  76644. private _scene;
  76645. private _currentDepthOfFieldSource;
  76646. private _basePostProcess;
  76647. private _fixedExposure;
  76648. private _currentExposure;
  76649. private _hdrAutoExposure;
  76650. private _hdrCurrentLuminance;
  76651. private _motionStrength;
  76652. private _isObjectBasedMotionBlur;
  76653. private _floatTextureType;
  76654. private _camerasToBeAttached;
  76655. private _ratio;
  76656. private _bloomEnabled;
  76657. private _depthOfFieldEnabled;
  76658. private _vlsEnabled;
  76659. private _lensFlareEnabled;
  76660. private _hdrEnabled;
  76661. private _motionBlurEnabled;
  76662. private _fxaaEnabled;
  76663. private _screenSpaceReflectionsEnabled;
  76664. private _motionBlurSamples;
  76665. private _volumetricLightStepsCount;
  76666. private _samples;
  76667. /**
  76668. * @ignore
  76669. * Specifies if the bloom pipeline is enabled
  76670. */
  76671. get BloomEnabled(): boolean;
  76672. set BloomEnabled(enabled: boolean);
  76673. /**
  76674. * @ignore
  76675. * Specifies if the depth of field pipeline is enabed
  76676. */
  76677. get DepthOfFieldEnabled(): boolean;
  76678. set DepthOfFieldEnabled(enabled: boolean);
  76679. /**
  76680. * @ignore
  76681. * Specifies if the lens flare pipeline is enabed
  76682. */
  76683. get LensFlareEnabled(): boolean;
  76684. set LensFlareEnabled(enabled: boolean);
  76685. /**
  76686. * @ignore
  76687. * Specifies if the HDR pipeline is enabled
  76688. */
  76689. get HDREnabled(): boolean;
  76690. set HDREnabled(enabled: boolean);
  76691. /**
  76692. * @ignore
  76693. * Specifies if the volumetric lights scattering effect is enabled
  76694. */
  76695. get VLSEnabled(): boolean;
  76696. set VLSEnabled(enabled: boolean);
  76697. /**
  76698. * @ignore
  76699. * Specifies if the motion blur effect is enabled
  76700. */
  76701. get MotionBlurEnabled(): boolean;
  76702. set MotionBlurEnabled(enabled: boolean);
  76703. /**
  76704. * Specifies if anti-aliasing is enabled
  76705. */
  76706. get fxaaEnabled(): boolean;
  76707. set fxaaEnabled(enabled: boolean);
  76708. /**
  76709. * Specifies if screen space reflections are enabled.
  76710. */
  76711. get screenSpaceReflectionsEnabled(): boolean;
  76712. set screenSpaceReflectionsEnabled(enabled: boolean);
  76713. /**
  76714. * Specifies the number of steps used to calculate the volumetric lights
  76715. * Typically in interval [50, 200]
  76716. */
  76717. get volumetricLightStepsCount(): number;
  76718. set volumetricLightStepsCount(count: number);
  76719. /**
  76720. * Specifies the number of samples used for the motion blur effect
  76721. * Typically in interval [16, 64]
  76722. */
  76723. get motionBlurSamples(): number;
  76724. set motionBlurSamples(samples: number);
  76725. /**
  76726. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76727. */
  76728. get samples(): number;
  76729. set samples(sampleCount: number);
  76730. /**
  76731. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76732. * @constructor
  76733. * @param name The rendering pipeline name
  76734. * @param scene The scene linked to this pipeline
  76735. * @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)
  76736. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76737. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76738. */
  76739. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76740. private _buildPipeline;
  76741. private _createDownSampleX4PostProcess;
  76742. private _createBrightPassPostProcess;
  76743. private _createBlurPostProcesses;
  76744. private _createTextureAdderPostProcess;
  76745. private _createVolumetricLightPostProcess;
  76746. private _createLuminancePostProcesses;
  76747. private _createHdrPostProcess;
  76748. private _createLensFlarePostProcess;
  76749. private _createDepthOfFieldPostProcess;
  76750. private _createMotionBlurPostProcess;
  76751. private _getDepthTexture;
  76752. private _disposePostProcesses;
  76753. /**
  76754. * Dispose of the pipeline and stop all post processes
  76755. */
  76756. dispose(): void;
  76757. /**
  76758. * Serialize the rendering pipeline (Used when exporting)
  76759. * @returns the serialized object
  76760. */
  76761. serialize(): any;
  76762. /**
  76763. * Parse the serialized pipeline
  76764. * @param source Source pipeline.
  76765. * @param scene The scene to load the pipeline to.
  76766. * @param rootUrl The URL of the serialized pipeline.
  76767. * @returns An instantiated pipeline from the serialized object.
  76768. */
  76769. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76770. /**
  76771. * Luminance steps
  76772. */
  76773. static LuminanceSteps: number;
  76774. }
  76775. }
  76776. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  76777. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  76778. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  76779. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  76780. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  76781. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  76782. }
  76783. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  76784. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  76785. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  76786. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76787. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  76788. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76789. }
  76790. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  76791. /** @hidden */
  76792. export var stereoscopicInterlacePixelShader: {
  76793. name: string;
  76794. shader: string;
  76795. };
  76796. }
  76797. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76798. import { Camera } from "babylonjs/Cameras/camera";
  76799. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76800. import { Engine } from "babylonjs/Engines/engine";
  76801. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76802. /**
  76803. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76804. */
  76805. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76806. private _stepSize;
  76807. private _passedProcess;
  76808. /**
  76809. * Gets a string identifying the name of the class
  76810. * @returns "StereoscopicInterlacePostProcessI" string
  76811. */
  76812. getClassName(): string;
  76813. /**
  76814. * Initializes a StereoscopicInterlacePostProcessI
  76815. * @param name The name of the effect.
  76816. * @param rigCameras The rig cameras to be appled to the post process
  76817. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76818. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76819. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76820. * @param engine The engine which the post process will be applied. (default: current engine)
  76821. * @param reusable If the post process can be reused on the same frame. (default: false)
  76822. */
  76823. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76824. }
  76825. /**
  76826. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76827. */
  76828. export class StereoscopicInterlacePostProcess extends PostProcess {
  76829. private _stepSize;
  76830. private _passedProcess;
  76831. /**
  76832. * Gets a string identifying the name of the class
  76833. * @returns "StereoscopicInterlacePostProcess" string
  76834. */
  76835. getClassName(): string;
  76836. /**
  76837. * Initializes a StereoscopicInterlacePostProcess
  76838. * @param name The name of the effect.
  76839. * @param rigCameras The rig cameras to be appled to the post process
  76840. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76842. * @param engine The engine which the post process will be applied. (default: current engine)
  76843. * @param reusable If the post process can be reused on the same frame. (default: false)
  76844. */
  76845. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76846. }
  76847. }
  76848. declare module "babylonjs/Shaders/tonemap.fragment" {
  76849. /** @hidden */
  76850. export var tonemapPixelShader: {
  76851. name: string;
  76852. shader: string;
  76853. };
  76854. }
  76855. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76856. import { Camera } from "babylonjs/Cameras/camera";
  76857. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76858. import "babylonjs/Shaders/tonemap.fragment";
  76859. import { Engine } from "babylonjs/Engines/engine";
  76860. /** Defines operator used for tonemapping */
  76861. export enum TonemappingOperator {
  76862. /** Hable */
  76863. Hable = 0,
  76864. /** Reinhard */
  76865. Reinhard = 1,
  76866. /** HejiDawson */
  76867. HejiDawson = 2,
  76868. /** Photographic */
  76869. Photographic = 3
  76870. }
  76871. /**
  76872. * Defines a post process to apply tone mapping
  76873. */
  76874. export class TonemapPostProcess extends PostProcess {
  76875. private _operator;
  76876. /** Defines the required exposure adjustement */
  76877. exposureAdjustment: number;
  76878. /**
  76879. * Gets a string identifying the name of the class
  76880. * @returns "TonemapPostProcess" string
  76881. */
  76882. getClassName(): string;
  76883. /**
  76884. * Creates a new TonemapPostProcess
  76885. * @param name defines the name of the postprocess
  76886. * @param _operator defines the operator to use
  76887. * @param exposureAdjustment defines the required exposure adjustement
  76888. * @param camera defines the camera to use (can be null)
  76889. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76890. * @param engine defines the hosting engine (can be ignore if camera is set)
  76891. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76892. */
  76893. constructor(name: string, _operator: TonemappingOperator,
  76894. /** Defines the required exposure adjustement */
  76895. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76896. }
  76897. }
  76898. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76899. /** @hidden */
  76900. export var volumetricLightScatteringPixelShader: {
  76901. name: string;
  76902. shader: string;
  76903. };
  76904. }
  76905. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76906. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76907. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76908. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76909. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76910. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76911. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76912. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76913. /** @hidden */
  76914. export var volumetricLightScatteringPassVertexShader: {
  76915. name: string;
  76916. shader: string;
  76917. };
  76918. }
  76919. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76920. /** @hidden */
  76921. export var volumetricLightScatteringPassPixelShader: {
  76922. name: string;
  76923. shader: string;
  76924. };
  76925. }
  76926. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76927. import { Vector3 } from "babylonjs/Maths/math.vector";
  76928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76929. import { Mesh } from "babylonjs/Meshes/mesh";
  76930. import { Camera } from "babylonjs/Cameras/camera";
  76931. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76933. import { Scene } from "babylonjs/scene";
  76934. import "babylonjs/Meshes/Builders/planeBuilder";
  76935. import "babylonjs/Shaders/depth.vertex";
  76936. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76937. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76938. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76939. import { Engine } from "babylonjs/Engines/engine";
  76940. /**
  76941. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76942. */
  76943. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76944. private _volumetricLightScatteringPass;
  76945. private _volumetricLightScatteringRTT;
  76946. private _viewPort;
  76947. private _screenCoordinates;
  76948. private _cachedDefines;
  76949. /**
  76950. * If not undefined, the mesh position is computed from the attached node position
  76951. */
  76952. attachedNode: {
  76953. position: Vector3;
  76954. };
  76955. /**
  76956. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76957. */
  76958. customMeshPosition: Vector3;
  76959. /**
  76960. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76961. */
  76962. useCustomMeshPosition: boolean;
  76963. /**
  76964. * If the post-process should inverse the light scattering direction
  76965. */
  76966. invert: boolean;
  76967. /**
  76968. * The internal mesh used by the post-process
  76969. */
  76970. mesh: Mesh;
  76971. /**
  76972. * @hidden
  76973. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76974. */
  76975. get useDiffuseColor(): boolean;
  76976. set useDiffuseColor(useDiffuseColor: boolean);
  76977. /**
  76978. * Array containing the excluded meshes not rendered in the internal pass
  76979. */
  76980. excludedMeshes: AbstractMesh[];
  76981. /**
  76982. * Controls the overall intensity of the post-process
  76983. */
  76984. exposure: number;
  76985. /**
  76986. * Dissipates each sample's contribution in range [0, 1]
  76987. */
  76988. decay: number;
  76989. /**
  76990. * Controls the overall intensity of each sample
  76991. */
  76992. weight: number;
  76993. /**
  76994. * Controls the density of each sample
  76995. */
  76996. density: number;
  76997. /**
  76998. * @constructor
  76999. * @param name The post-process name
  77000. * @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)
  77001. * @param camera The camera that the post-process will be attached to
  77002. * @param mesh The mesh used to create the light scattering
  77003. * @param samples The post-process quality, default 100
  77004. * @param samplingModeThe post-process filtering mode
  77005. * @param engine The babylon engine
  77006. * @param reusable If the post-process is reusable
  77007. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  77008. */
  77009. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  77010. /**
  77011. * Returns the string "VolumetricLightScatteringPostProcess"
  77012. * @returns "VolumetricLightScatteringPostProcess"
  77013. */
  77014. getClassName(): string;
  77015. private _isReady;
  77016. /**
  77017. * Sets the new light position for light scattering effect
  77018. * @param position The new custom light position
  77019. */
  77020. setCustomMeshPosition(position: Vector3): void;
  77021. /**
  77022. * Returns the light position for light scattering effect
  77023. * @return Vector3 The custom light position
  77024. */
  77025. getCustomMeshPosition(): Vector3;
  77026. /**
  77027. * Disposes the internal assets and detaches the post-process from the camera
  77028. */
  77029. dispose(camera: Camera): void;
  77030. /**
  77031. * Returns the render target texture used by the post-process
  77032. * @return the render target texture used by the post-process
  77033. */
  77034. getPass(): RenderTargetTexture;
  77035. private _meshExcluded;
  77036. private _createPass;
  77037. private _updateMeshScreenCoordinates;
  77038. /**
  77039. * Creates a default mesh for the Volumeric Light Scattering post-process
  77040. * @param name The mesh name
  77041. * @param scene The scene where to create the mesh
  77042. * @return the default mesh
  77043. */
  77044. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  77045. }
  77046. }
  77047. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  77048. /** @hidden */
  77049. export var screenSpaceCurvaturePixelShader: {
  77050. name: string;
  77051. shader: string;
  77052. };
  77053. }
  77054. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  77055. import { Nullable } from "babylonjs/types";
  77056. import { Camera } from "babylonjs/Cameras/camera";
  77057. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77058. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77059. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  77060. import { Engine } from "babylonjs/Engines/engine";
  77061. import { Scene } from "babylonjs/scene";
  77062. /**
  77063. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  77064. */
  77065. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  77066. /**
  77067. * Defines how much ridge the curvature effect displays.
  77068. */
  77069. ridge: number;
  77070. /**
  77071. * Defines how much valley the curvature effect displays.
  77072. */
  77073. valley: number;
  77074. private _geometryBufferRenderer;
  77075. /**
  77076. * Gets a string identifying the name of the class
  77077. * @returns "ScreenSpaceCurvaturePostProcess" string
  77078. */
  77079. getClassName(): string;
  77080. /**
  77081. * Creates a new instance ScreenSpaceCurvaturePostProcess
  77082. * @param name The name of the effect.
  77083. * @param scene The scene containing the objects to blur according to their velocity.
  77084. * @param options The required width/height ratio to downsize to before computing the render pass.
  77085. * @param camera The camera to apply the render pass to.
  77086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77087. * @param engine The engine which the post process will be applied. (default: current engine)
  77088. * @param reusable If the post process can be reused on the same frame. (default: false)
  77089. * @param textureType Type of textures used when performing the post process. (default: 0)
  77090. * @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)
  77091. */
  77092. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77093. /**
  77094. * Support test.
  77095. */
  77096. static get IsSupported(): boolean;
  77097. /** @hidden */
  77098. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  77099. }
  77100. }
  77101. declare module "babylonjs/PostProcesses/index" {
  77102. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  77103. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  77104. export * from "babylonjs/PostProcesses/bloomEffect";
  77105. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  77106. export * from "babylonjs/PostProcesses/blurPostProcess";
  77107. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  77108. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  77109. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  77110. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  77111. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  77112. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  77113. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  77114. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  77115. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  77116. export * from "babylonjs/PostProcesses/filterPostProcess";
  77117. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  77118. export * from "babylonjs/PostProcesses/grainPostProcess";
  77119. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  77120. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  77121. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  77122. export * from "babylonjs/PostProcesses/passPostProcess";
  77123. export * from "babylonjs/PostProcesses/postProcess";
  77124. export * from "babylonjs/PostProcesses/postProcessManager";
  77125. export * from "babylonjs/PostProcesses/refractionPostProcess";
  77126. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  77127. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  77128. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  77129. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  77130. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  77131. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  77132. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  77133. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  77134. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  77135. }
  77136. declare module "babylonjs/Probes/index" {
  77137. export * from "babylonjs/Probes/reflectionProbe";
  77138. }
  77139. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  77140. import { Scene } from "babylonjs/scene";
  77141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77142. import { SmartArray } from "babylonjs/Misc/smartArray";
  77143. import { ISceneComponent } from "babylonjs/sceneComponent";
  77144. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  77145. import "babylonjs/Meshes/Builders/boxBuilder";
  77146. import "babylonjs/Shaders/color.fragment";
  77147. import "babylonjs/Shaders/color.vertex";
  77148. import { Color3 } from "babylonjs/Maths/math.color";
  77149. import { Observable } from "babylonjs/Misc/observable";
  77150. module "babylonjs/scene" {
  77151. interface Scene {
  77152. /** @hidden (Backing field) */
  77153. _boundingBoxRenderer: BoundingBoxRenderer;
  77154. /** @hidden (Backing field) */
  77155. _forceShowBoundingBoxes: boolean;
  77156. /**
  77157. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  77158. */
  77159. forceShowBoundingBoxes: boolean;
  77160. /**
  77161. * Gets the bounding box renderer associated with the scene
  77162. * @returns a BoundingBoxRenderer
  77163. */
  77164. getBoundingBoxRenderer(): BoundingBoxRenderer;
  77165. }
  77166. }
  77167. module "babylonjs/Meshes/abstractMesh" {
  77168. interface AbstractMesh {
  77169. /** @hidden (Backing field) */
  77170. _showBoundingBox: boolean;
  77171. /**
  77172. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  77173. */
  77174. showBoundingBox: boolean;
  77175. }
  77176. }
  77177. /**
  77178. * Component responsible of rendering the bounding box of the meshes in a scene.
  77179. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  77180. */
  77181. export class BoundingBoxRenderer implements ISceneComponent {
  77182. /**
  77183. * The component name helpfull to identify the component in the list of scene components.
  77184. */
  77185. readonly name: string;
  77186. /**
  77187. * The scene the component belongs to.
  77188. */
  77189. scene: Scene;
  77190. /**
  77191. * Color of the bounding box lines placed in front of an object
  77192. */
  77193. frontColor: Color3;
  77194. /**
  77195. * Color of the bounding box lines placed behind an object
  77196. */
  77197. backColor: Color3;
  77198. /**
  77199. * Defines if the renderer should show the back lines or not
  77200. */
  77201. showBackLines: boolean;
  77202. /**
  77203. * Observable raised before rendering a bounding box
  77204. */
  77205. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  77206. /**
  77207. * Observable raised after rendering a bounding box
  77208. */
  77209. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  77210. /**
  77211. * Observable raised after resources are created
  77212. */
  77213. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  77214. /**
  77215. * When false, no bounding boxes will be rendered
  77216. */
  77217. enabled: boolean;
  77218. /**
  77219. * @hidden
  77220. */
  77221. renderList: SmartArray<BoundingBox>;
  77222. private _colorShader;
  77223. private _vertexBuffers;
  77224. private _indexBuffer;
  77225. private _fillIndexBuffer;
  77226. private _fillIndexData;
  77227. /**
  77228. * Instantiates a new bounding box renderer in a scene.
  77229. * @param scene the scene the renderer renders in
  77230. */
  77231. constructor(scene: Scene);
  77232. /**
  77233. * Registers the component in a given scene
  77234. */
  77235. register(): void;
  77236. private _evaluateSubMesh;
  77237. private _preActiveMesh;
  77238. private _prepareResources;
  77239. private _createIndexBuffer;
  77240. /**
  77241. * Rebuilds the elements related to this component in case of
  77242. * context lost for instance.
  77243. */
  77244. rebuild(): void;
  77245. /**
  77246. * @hidden
  77247. */
  77248. reset(): void;
  77249. /**
  77250. * Render the bounding boxes of a specific rendering group
  77251. * @param renderingGroupId defines the rendering group to render
  77252. */
  77253. render(renderingGroupId: number): void;
  77254. /**
  77255. * In case of occlusion queries, we can render the occlusion bounding box through this method
  77256. * @param mesh Define the mesh to render the occlusion bounding box for
  77257. */
  77258. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  77259. /**
  77260. * Dispose and release the resources attached to this renderer.
  77261. */
  77262. dispose(): void;
  77263. }
  77264. }
  77265. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  77266. import { Nullable } from "babylonjs/types";
  77267. import { Scene } from "babylonjs/scene";
  77268. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  77269. import { Camera } from "babylonjs/Cameras/camera";
  77270. import { ISceneComponent } from "babylonjs/sceneComponent";
  77271. module "babylonjs/scene" {
  77272. interface Scene {
  77273. /** @hidden (Backing field) */
  77274. _depthRenderer: {
  77275. [id: string]: DepthRenderer;
  77276. };
  77277. /**
  77278. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  77279. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  77280. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  77281. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  77282. * @returns the created depth renderer
  77283. */
  77284. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  77285. /**
  77286. * Disables a depth renderer for a given camera
  77287. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  77288. */
  77289. disableDepthRenderer(camera?: Nullable<Camera>): void;
  77290. }
  77291. }
  77292. /**
  77293. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  77294. * in several rendering techniques.
  77295. */
  77296. export class DepthRendererSceneComponent implements ISceneComponent {
  77297. /**
  77298. * The component name helpfull to identify the component in the list of scene components.
  77299. */
  77300. readonly name: string;
  77301. /**
  77302. * The scene the component belongs to.
  77303. */
  77304. scene: Scene;
  77305. /**
  77306. * Creates a new instance of the component for the given scene
  77307. * @param scene Defines the scene to register the component in
  77308. */
  77309. constructor(scene: Scene);
  77310. /**
  77311. * Registers the component in a given scene
  77312. */
  77313. register(): void;
  77314. /**
  77315. * Rebuilds the elements related to this component in case of
  77316. * context lost for instance.
  77317. */
  77318. rebuild(): void;
  77319. /**
  77320. * Disposes the component and the associated ressources
  77321. */
  77322. dispose(): void;
  77323. private _gatherRenderTargets;
  77324. private _gatherActiveCameraRenderTargets;
  77325. }
  77326. }
  77327. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  77328. import { Nullable } from "babylonjs/types";
  77329. import { Scene } from "babylonjs/scene";
  77330. import { ISceneComponent } from "babylonjs/sceneComponent";
  77331. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  77332. module "babylonjs/abstractScene" {
  77333. interface AbstractScene {
  77334. /** @hidden (Backing field) */
  77335. _prePassRenderer: Nullable<PrePassRenderer>;
  77336. /**
  77337. * Gets or Sets the current prepass renderer associated to the scene.
  77338. */
  77339. prePassRenderer: Nullable<PrePassRenderer>;
  77340. /**
  77341. * Enables the prepass and associates it with the scene
  77342. * @returns the PrePassRenderer
  77343. */
  77344. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  77345. /**
  77346. * Disables the prepass associated with the scene
  77347. */
  77348. disablePrePassRenderer(): void;
  77349. }
  77350. }
  77351. /**
  77352. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77353. * in several rendering techniques.
  77354. */
  77355. export class PrePassRendererSceneComponent implements ISceneComponent {
  77356. /**
  77357. * The component name helpful to identify the component in the list of scene components.
  77358. */
  77359. readonly name: string;
  77360. /**
  77361. * The scene the component belongs to.
  77362. */
  77363. scene: Scene;
  77364. /**
  77365. * Creates a new instance of the component for the given scene
  77366. * @param scene Defines the scene to register the component in
  77367. */
  77368. constructor(scene: Scene);
  77369. /**
  77370. * Registers the component in a given scene
  77371. */
  77372. register(): void;
  77373. private _beforeCameraDraw;
  77374. private _afterCameraDraw;
  77375. private _beforeClearStage;
  77376. /**
  77377. * Rebuilds the elements related to this component in case of
  77378. * context lost for instance.
  77379. */
  77380. rebuild(): void;
  77381. /**
  77382. * Disposes the component and the associated ressources
  77383. */
  77384. dispose(): void;
  77385. }
  77386. }
  77387. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  77388. /** @hidden */
  77389. export var fibonacci: {
  77390. name: string;
  77391. shader: string;
  77392. };
  77393. }
  77394. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  77395. /** @hidden */
  77396. export var diffusionProfile: {
  77397. name: string;
  77398. shader: string;
  77399. };
  77400. }
  77401. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  77402. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  77403. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77404. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  77405. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  77406. /** @hidden */
  77407. export var subSurfaceScatteringPixelShader: {
  77408. name: string;
  77409. shader: string;
  77410. };
  77411. }
  77412. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  77413. import { Nullable } from "babylonjs/types";
  77414. import { Camera } from "babylonjs/Cameras/camera";
  77415. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77416. import { Engine } from "babylonjs/Engines/engine";
  77417. import { Scene } from "babylonjs/scene";
  77418. import "babylonjs/Shaders/imageProcessing.fragment";
  77419. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  77420. import "babylonjs/Shaders/postprocess.vertex";
  77421. /**
  77422. * Sub surface scattering post process
  77423. */
  77424. export class SubSurfaceScatteringPostProcess extends PostProcess {
  77425. /**
  77426. * Gets a string identifying the name of the class
  77427. * @returns "SubSurfaceScatteringPostProcess" string
  77428. */
  77429. getClassName(): string;
  77430. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77431. }
  77432. }
  77433. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  77434. import { Scene } from "babylonjs/scene";
  77435. import { Color3 } from "babylonjs/Maths/math.color";
  77436. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  77437. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  77438. /**
  77439. * Contains all parameters needed for the prepass to perform
  77440. * screen space subsurface scattering
  77441. */
  77442. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  77443. /** @hidden */
  77444. static _SceneComponentInitialization: (scene: Scene) => void;
  77445. private _ssDiffusionS;
  77446. private _ssFilterRadii;
  77447. private _ssDiffusionD;
  77448. /**
  77449. * Post process to attach for screen space subsurface scattering
  77450. */
  77451. postProcess: SubSurfaceScatteringPostProcess;
  77452. /**
  77453. * Diffusion profile color for subsurface scattering
  77454. */
  77455. get ssDiffusionS(): number[];
  77456. /**
  77457. * Diffusion profile max color channel value for subsurface scattering
  77458. */
  77459. get ssDiffusionD(): number[];
  77460. /**
  77461. * Diffusion profile filter radius for subsurface scattering
  77462. */
  77463. get ssFilterRadii(): number[];
  77464. /**
  77465. * Is subsurface enabled
  77466. */
  77467. enabled: boolean;
  77468. /**
  77469. * Name of the configuration
  77470. */
  77471. name: string;
  77472. /**
  77473. * Diffusion profile colors for subsurface scattering
  77474. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  77475. * See ...
  77476. * Note that you can only store up to 5 of them
  77477. */
  77478. ssDiffusionProfileColors: Color3[];
  77479. /**
  77480. * Defines the ratio real world => scene units.
  77481. * Used for subsurface scattering
  77482. */
  77483. metersPerUnit: number;
  77484. /**
  77485. * Textures that should be present in the MRT for this effect to work
  77486. */
  77487. readonly texturesRequired: number[];
  77488. private _scene;
  77489. /**
  77490. * Builds a subsurface configuration object
  77491. * @param scene The scene
  77492. */
  77493. constructor(scene: Scene);
  77494. /**
  77495. * Adds a new diffusion profile.
  77496. * Useful for more realistic subsurface scattering on diverse materials.
  77497. * @param color The color of the diffusion profile. Should be the average color of the material.
  77498. * @return The index of the diffusion profile for the material subsurface configuration
  77499. */
  77500. addDiffusionProfile(color: Color3): number;
  77501. /**
  77502. * Creates the sss post process
  77503. * @return The created post process
  77504. */
  77505. createPostProcess(): SubSurfaceScatteringPostProcess;
  77506. /**
  77507. * Deletes all diffusion profiles.
  77508. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  77509. */
  77510. clearAllDiffusionProfiles(): void;
  77511. /**
  77512. * Disposes this object
  77513. */
  77514. dispose(): void;
  77515. /**
  77516. * @hidden
  77517. * https://zero-radiance.github.io/post/sampling-diffusion/
  77518. *
  77519. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  77520. * ------------------------------------------------------------------------------------
  77521. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  77522. * PDF[r, phi, s] = r * R[r, phi, s]
  77523. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  77524. * ------------------------------------------------------------------------------------
  77525. * We importance sample the color channel with the widest scattering distance.
  77526. */
  77527. getDiffusionProfileParameters(color: Color3): number;
  77528. /**
  77529. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  77530. * 'u' is the random number (the value of the CDF): [0, 1).
  77531. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  77532. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  77533. */
  77534. private _sampleBurleyDiffusionProfile;
  77535. }
  77536. }
  77537. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  77538. import { Nullable } from "babylonjs/types";
  77539. import { Scene } from "babylonjs/scene";
  77540. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  77541. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  77542. import { AbstractScene } from "babylonjs/abstractScene";
  77543. module "babylonjs/abstractScene" {
  77544. interface AbstractScene {
  77545. /** @hidden (Backing field) */
  77546. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77547. /**
  77548. * Gets or Sets the current prepass renderer associated to the scene.
  77549. */
  77550. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77551. /**
  77552. * Enables the subsurface effect for prepass
  77553. * @returns the SubSurfaceConfiguration
  77554. */
  77555. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  77556. /**
  77557. * Disables the subsurface effect for prepass
  77558. */
  77559. disableSubSurfaceForPrePass(): void;
  77560. }
  77561. }
  77562. /**
  77563. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77564. * in several rendering techniques.
  77565. */
  77566. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77567. /**
  77568. * The component name helpful to identify the component in the list of scene components.
  77569. */
  77570. readonly name: string;
  77571. /**
  77572. * The scene the component belongs to.
  77573. */
  77574. scene: Scene;
  77575. /**
  77576. * Creates a new instance of the component for the given scene
  77577. * @param scene Defines the scene to register the component in
  77578. */
  77579. constructor(scene: Scene);
  77580. /**
  77581. * Registers the component in a given scene
  77582. */
  77583. register(): void;
  77584. /**
  77585. * Serializes the component data to the specified json object
  77586. * @param serializationObject The object to serialize to
  77587. */
  77588. serialize(serializationObject: any): void;
  77589. /**
  77590. * Adds all the elements from the container to the scene
  77591. * @param container the container holding the elements
  77592. */
  77593. addFromContainer(container: AbstractScene): void;
  77594. /**
  77595. * Removes all the elements in the container from the scene
  77596. * @param container contains the elements to remove
  77597. * @param dispose if the removed element should be disposed (default: false)
  77598. */
  77599. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77600. /**
  77601. * Rebuilds the elements related to this component in case of
  77602. * context lost for instance.
  77603. */
  77604. rebuild(): void;
  77605. /**
  77606. * Disposes the component and the associated ressources
  77607. */
  77608. dispose(): void;
  77609. }
  77610. }
  77611. declare module "babylonjs/Shaders/outline.fragment" {
  77612. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77613. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  77614. /** @hidden */
  77615. export var outlinePixelShader: {
  77616. name: string;
  77617. shader: string;
  77618. };
  77619. }
  77620. declare module "babylonjs/Shaders/outline.vertex" {
  77621. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  77622. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  77623. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  77624. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  77625. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77626. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  77627. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  77628. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  77629. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  77630. /** @hidden */
  77631. export var outlineVertexShader: {
  77632. name: string;
  77633. shader: string;
  77634. };
  77635. }
  77636. declare module "babylonjs/Rendering/outlineRenderer" {
  77637. import { SubMesh } from "babylonjs/Meshes/subMesh";
  77638. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  77639. import { Scene } from "babylonjs/scene";
  77640. import { ISceneComponent } from "babylonjs/sceneComponent";
  77641. import "babylonjs/Shaders/outline.fragment";
  77642. import "babylonjs/Shaders/outline.vertex";
  77643. module "babylonjs/scene" {
  77644. interface Scene {
  77645. /** @hidden */
  77646. _outlineRenderer: OutlineRenderer;
  77647. /**
  77648. * Gets the outline renderer associated with the scene
  77649. * @returns a OutlineRenderer
  77650. */
  77651. getOutlineRenderer(): OutlineRenderer;
  77652. }
  77653. }
  77654. module "babylonjs/Meshes/abstractMesh" {
  77655. interface AbstractMesh {
  77656. /** @hidden (Backing field) */
  77657. _renderOutline: boolean;
  77658. /**
  77659. * Gets or sets a boolean indicating if the outline must be rendered as well
  77660. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77661. */
  77662. renderOutline: boolean;
  77663. /** @hidden (Backing field) */
  77664. _renderOverlay: boolean;
  77665. /**
  77666. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77667. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77668. */
  77669. renderOverlay: boolean;
  77670. }
  77671. }
  77672. /**
  77673. * This class is responsible to draw bothe outline/overlay of meshes.
  77674. * It should not be used directly but through the available method on mesh.
  77675. */
  77676. export class OutlineRenderer implements ISceneComponent {
  77677. /**
  77678. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77679. */
  77680. private static _StencilReference;
  77681. /**
  77682. * The name of the component. Each component must have a unique name.
  77683. */
  77684. name: string;
  77685. /**
  77686. * The scene the component belongs to.
  77687. */
  77688. scene: Scene;
  77689. /**
  77690. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77691. */
  77692. zOffset: number;
  77693. private _engine;
  77694. private _effect;
  77695. private _cachedDefines;
  77696. private _savedDepthWrite;
  77697. /**
  77698. * Instantiates a new outline renderer. (There could be only one per scene).
  77699. * @param scene Defines the scene it belongs to
  77700. */
  77701. constructor(scene: Scene);
  77702. /**
  77703. * Register the component to one instance of a scene.
  77704. */
  77705. register(): void;
  77706. /**
  77707. * Rebuilds the elements related to this component in case of
  77708. * context lost for instance.
  77709. */
  77710. rebuild(): void;
  77711. /**
  77712. * Disposes the component and the associated ressources.
  77713. */
  77714. dispose(): void;
  77715. /**
  77716. * Renders the outline in the canvas.
  77717. * @param subMesh Defines the sumesh to render
  77718. * @param batch Defines the batch of meshes in case of instances
  77719. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77720. */
  77721. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77722. /**
  77723. * Returns whether or not the outline renderer is ready for a given submesh.
  77724. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77725. * @param subMesh Defines the submesh to check readyness for
  77726. * @param useInstances Defines wheter wee are trying to render instances or not
  77727. * @returns true if ready otherwise false
  77728. */
  77729. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77730. private _beforeRenderingMesh;
  77731. private _afterRenderingMesh;
  77732. }
  77733. }
  77734. declare module "babylonjs/Rendering/index" {
  77735. export * from "babylonjs/Rendering/boundingBoxRenderer";
  77736. export * from "babylonjs/Rendering/depthRenderer";
  77737. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  77738. export * from "babylonjs/Rendering/edgesRenderer";
  77739. export * from "babylonjs/Rendering/geometryBufferRenderer";
  77740. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77741. export * from "babylonjs/Rendering/prePassRenderer";
  77742. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  77743. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  77744. export * from "babylonjs/Rendering/outlineRenderer";
  77745. export * from "babylonjs/Rendering/renderingGroup";
  77746. export * from "babylonjs/Rendering/renderingManager";
  77747. export * from "babylonjs/Rendering/utilityLayerRenderer";
  77748. }
  77749. declare module "babylonjs/Sprites/ISprites" {
  77750. /**
  77751. * Defines the basic options interface of a Sprite Frame Source Size.
  77752. */
  77753. export interface ISpriteJSONSpriteSourceSize {
  77754. /**
  77755. * number of the original width of the Frame
  77756. */
  77757. w: number;
  77758. /**
  77759. * number of the original height of the Frame
  77760. */
  77761. h: number;
  77762. }
  77763. /**
  77764. * Defines the basic options interface of a Sprite Frame Data.
  77765. */
  77766. export interface ISpriteJSONSpriteFrameData {
  77767. /**
  77768. * number of the x offset of the Frame
  77769. */
  77770. x: number;
  77771. /**
  77772. * number of the y offset of the Frame
  77773. */
  77774. y: number;
  77775. /**
  77776. * number of the width of the Frame
  77777. */
  77778. w: number;
  77779. /**
  77780. * number of the height of the Frame
  77781. */
  77782. h: number;
  77783. }
  77784. /**
  77785. * Defines the basic options interface of a JSON Sprite.
  77786. */
  77787. export interface ISpriteJSONSprite {
  77788. /**
  77789. * string name of the Frame
  77790. */
  77791. filename: string;
  77792. /**
  77793. * ISpriteJSONSpriteFrame basic object of the frame data
  77794. */
  77795. frame: ISpriteJSONSpriteFrameData;
  77796. /**
  77797. * boolean to flag is the frame was rotated.
  77798. */
  77799. rotated: boolean;
  77800. /**
  77801. * boolean to flag is the frame was trimmed.
  77802. */
  77803. trimmed: boolean;
  77804. /**
  77805. * ISpriteJSONSpriteFrame basic object of the source data
  77806. */
  77807. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77808. /**
  77809. * ISpriteJSONSpriteFrame basic object of the source data
  77810. */
  77811. sourceSize: ISpriteJSONSpriteSourceSize;
  77812. }
  77813. /**
  77814. * Defines the basic options interface of a JSON atlas.
  77815. */
  77816. export interface ISpriteJSONAtlas {
  77817. /**
  77818. * Array of objects that contain the frame data.
  77819. */
  77820. frames: Array<ISpriteJSONSprite>;
  77821. /**
  77822. * object basic object containing the sprite meta data.
  77823. */
  77824. meta?: object;
  77825. }
  77826. }
  77827. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77828. /** @hidden */
  77829. export var spriteMapPixelShader: {
  77830. name: string;
  77831. shader: string;
  77832. };
  77833. }
  77834. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77835. /** @hidden */
  77836. export var spriteMapVertexShader: {
  77837. name: string;
  77838. shader: string;
  77839. };
  77840. }
  77841. declare module "babylonjs/Sprites/spriteMap" {
  77842. import { IDisposable, Scene } from "babylonjs/scene";
  77843. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77844. import { Texture } from "babylonjs/Materials/Textures/texture";
  77845. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77846. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77847. import "babylonjs/Meshes/Builders/planeBuilder";
  77848. import "babylonjs/Shaders/spriteMap.fragment";
  77849. import "babylonjs/Shaders/spriteMap.vertex";
  77850. /**
  77851. * Defines the basic options interface of a SpriteMap
  77852. */
  77853. export interface ISpriteMapOptions {
  77854. /**
  77855. * Vector2 of the number of cells in the grid.
  77856. */
  77857. stageSize?: Vector2;
  77858. /**
  77859. * Vector2 of the size of the output plane in World Units.
  77860. */
  77861. outputSize?: Vector2;
  77862. /**
  77863. * Vector3 of the position of the output plane in World Units.
  77864. */
  77865. outputPosition?: Vector3;
  77866. /**
  77867. * Vector3 of the rotation of the output plane.
  77868. */
  77869. outputRotation?: Vector3;
  77870. /**
  77871. * number of layers that the system will reserve in resources.
  77872. */
  77873. layerCount?: number;
  77874. /**
  77875. * number of max animation frames a single cell will reserve in resources.
  77876. */
  77877. maxAnimationFrames?: number;
  77878. /**
  77879. * number cell index of the base tile when the system compiles.
  77880. */
  77881. baseTile?: number;
  77882. /**
  77883. * boolean flip the sprite after its been repositioned by the framing data.
  77884. */
  77885. flipU?: boolean;
  77886. /**
  77887. * Vector3 scalar of the global RGB values of the SpriteMap.
  77888. */
  77889. colorMultiply?: Vector3;
  77890. }
  77891. /**
  77892. * Defines the IDisposable interface in order to be cleanable from resources.
  77893. */
  77894. export interface ISpriteMap extends IDisposable {
  77895. /**
  77896. * String name of the SpriteMap.
  77897. */
  77898. name: string;
  77899. /**
  77900. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77901. */
  77902. atlasJSON: ISpriteJSONAtlas;
  77903. /**
  77904. * Texture of the SpriteMap.
  77905. */
  77906. spriteSheet: Texture;
  77907. /**
  77908. * The parameters to initialize the SpriteMap with.
  77909. */
  77910. options: ISpriteMapOptions;
  77911. }
  77912. /**
  77913. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77914. */
  77915. export class SpriteMap implements ISpriteMap {
  77916. /** The Name of the spriteMap */
  77917. name: string;
  77918. /** The JSON file with the frame and meta data */
  77919. atlasJSON: ISpriteJSONAtlas;
  77920. /** The systems Sprite Sheet Texture */
  77921. spriteSheet: Texture;
  77922. /** Arguments passed with the Constructor */
  77923. options: ISpriteMapOptions;
  77924. /** Public Sprite Storage array, parsed from atlasJSON */
  77925. sprites: Array<ISpriteJSONSprite>;
  77926. /** Returns the Number of Sprites in the System */
  77927. get spriteCount(): number;
  77928. /** Returns the Position of Output Plane*/
  77929. get position(): Vector3;
  77930. /** Returns the Position of Output Plane*/
  77931. set position(v: Vector3);
  77932. /** Returns the Rotation of Output Plane*/
  77933. get rotation(): Vector3;
  77934. /** Returns the Rotation of Output Plane*/
  77935. set rotation(v: Vector3);
  77936. /** Sets the AnimationMap*/
  77937. get animationMap(): RawTexture;
  77938. /** Sets the AnimationMap*/
  77939. set animationMap(v: RawTexture);
  77940. /** Scene that the SpriteMap was created in */
  77941. private _scene;
  77942. /** Texture Buffer of Float32 that holds tile frame data*/
  77943. private _frameMap;
  77944. /** Texture Buffers of Float32 that holds tileMap data*/
  77945. private _tileMaps;
  77946. /** Texture Buffer of Float32 that holds Animation Data*/
  77947. private _animationMap;
  77948. /** Custom ShaderMaterial Central to the System*/
  77949. private _material;
  77950. /** Custom ShaderMaterial Central to the System*/
  77951. private _output;
  77952. /** Systems Time Ticker*/
  77953. private _time;
  77954. /**
  77955. * Creates a new SpriteMap
  77956. * @param name defines the SpriteMaps Name
  77957. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77958. * @param spriteSheet is the Texture that the Sprites are on.
  77959. * @param options a basic deployment configuration
  77960. * @param scene The Scene that the map is deployed on
  77961. */
  77962. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77963. /**
  77964. * Returns tileID location
  77965. * @returns Vector2 the cell position ID
  77966. */
  77967. getTileID(): Vector2;
  77968. /**
  77969. * Gets the UV location of the mouse over the SpriteMap.
  77970. * @returns Vector2 the UV position of the mouse interaction
  77971. */
  77972. getMousePosition(): Vector2;
  77973. /**
  77974. * Creates the "frame" texture Buffer
  77975. * -------------------------------------
  77976. * Structure of frames
  77977. * "filename": "Falling-Water-2.png",
  77978. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77979. * "rotated": true,
  77980. * "trimmed": true,
  77981. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77982. * "sourceSize": {"w":32,"h":32}
  77983. * @returns RawTexture of the frameMap
  77984. */
  77985. private _createFrameBuffer;
  77986. /**
  77987. * Creates the tileMap texture Buffer
  77988. * @param buffer normally and array of numbers, or a false to generate from scratch
  77989. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77990. * @returns RawTexture of the tileMap
  77991. */
  77992. private _createTileBuffer;
  77993. /**
  77994. * Modifies the data of the tileMaps
  77995. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77996. * @param pos is the iVector2 Coordinates of the Tile
  77997. * @param tile The SpriteIndex of the new Tile
  77998. */
  77999. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  78000. /**
  78001. * Creates the animationMap texture Buffer
  78002. * @param buffer normally and array of numbers, or a false to generate from scratch
  78003. * @returns RawTexture of the animationMap
  78004. */
  78005. private _createTileAnimationBuffer;
  78006. /**
  78007. * Modifies the data of the animationMap
  78008. * @param cellID is the Index of the Sprite
  78009. * @param _frame is the target Animation frame
  78010. * @param toCell is the Target Index of the next frame of the animation
  78011. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  78012. * @param speed is a global scalar of the time variable on the map.
  78013. */
  78014. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  78015. /**
  78016. * Exports the .tilemaps file
  78017. */
  78018. saveTileMaps(): void;
  78019. /**
  78020. * Imports the .tilemaps file
  78021. * @param url of the .tilemaps file
  78022. */
  78023. loadTileMaps(url: string): void;
  78024. /**
  78025. * Release associated resources
  78026. */
  78027. dispose(): void;
  78028. }
  78029. }
  78030. declare module "babylonjs/Sprites/spritePackedManager" {
  78031. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  78032. import { Scene } from "babylonjs/scene";
  78033. /**
  78034. * Class used to manage multiple sprites of different sizes on the same spritesheet
  78035. * @see https://doc.babylonjs.com/babylon101/sprites
  78036. */
  78037. export class SpritePackedManager extends SpriteManager {
  78038. /** defines the packed manager's name */
  78039. name: string;
  78040. /**
  78041. * Creates a new sprite manager from a packed sprite sheet
  78042. * @param name defines the manager's name
  78043. * @param imgUrl defines the sprite sheet url
  78044. * @param capacity defines the maximum allowed number of sprites
  78045. * @param scene defines the hosting scene
  78046. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  78047. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78048. * @param samplingMode defines the smapling mode to use with spritesheet
  78049. * @param fromPacked set to true; do not alter
  78050. */
  78051. constructor(
  78052. /** defines the packed manager's name */
  78053. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  78054. }
  78055. }
  78056. declare module "babylonjs/Sprites/index" {
  78057. export * from "babylonjs/Sprites/sprite";
  78058. export * from "babylonjs/Sprites/ISprites";
  78059. export * from "babylonjs/Sprites/spriteManager";
  78060. export * from "babylonjs/Sprites/spriteMap";
  78061. export * from "babylonjs/Sprites/spritePackedManager";
  78062. export * from "babylonjs/Sprites/spriteSceneComponent";
  78063. }
  78064. declare module "babylonjs/States/index" {
  78065. export * from "babylonjs/States/alphaCullingState";
  78066. export * from "babylonjs/States/depthCullingState";
  78067. export * from "babylonjs/States/stencilState";
  78068. }
  78069. declare module "babylonjs/Misc/assetsManager" {
  78070. import { Scene } from "babylonjs/scene";
  78071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78072. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  78073. import { Skeleton } from "babylonjs/Bones/skeleton";
  78074. import { Observable } from "babylonjs/Misc/observable";
  78075. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  78076. import { Texture } from "babylonjs/Materials/Textures/texture";
  78077. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  78078. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  78079. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  78080. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  78081. import { AssetContainer } from "babylonjs/assetContainer";
  78082. /**
  78083. * Defines the list of states available for a task inside a AssetsManager
  78084. */
  78085. export enum AssetTaskState {
  78086. /**
  78087. * Initialization
  78088. */
  78089. INIT = 0,
  78090. /**
  78091. * Running
  78092. */
  78093. RUNNING = 1,
  78094. /**
  78095. * Done
  78096. */
  78097. DONE = 2,
  78098. /**
  78099. * Error
  78100. */
  78101. ERROR = 3
  78102. }
  78103. /**
  78104. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  78105. */
  78106. export abstract class AbstractAssetTask {
  78107. /**
  78108. * Task name
  78109. */ name: string;
  78110. /**
  78111. * Callback called when the task is successful
  78112. */
  78113. onSuccess: (task: any) => void;
  78114. /**
  78115. * Callback called when the task is not successful
  78116. */
  78117. onError: (task: any, message?: string, exception?: any) => void;
  78118. /**
  78119. * Creates a new AssetsManager
  78120. * @param name defines the name of the task
  78121. */
  78122. constructor(
  78123. /**
  78124. * Task name
  78125. */ name: string);
  78126. private _isCompleted;
  78127. private _taskState;
  78128. private _errorObject;
  78129. /**
  78130. * Get if the task is completed
  78131. */
  78132. get isCompleted(): boolean;
  78133. /**
  78134. * Gets the current state of the task
  78135. */
  78136. get taskState(): AssetTaskState;
  78137. /**
  78138. * Gets the current error object (if task is in error)
  78139. */
  78140. get errorObject(): {
  78141. message?: string;
  78142. exception?: any;
  78143. };
  78144. /**
  78145. * Internal only
  78146. * @hidden
  78147. */
  78148. _setErrorObject(message?: string, exception?: any): void;
  78149. /**
  78150. * Execute the current task
  78151. * @param scene defines the scene where you want your assets to be loaded
  78152. * @param onSuccess is a callback called when the task is successfully executed
  78153. * @param onError is a callback called if an error occurs
  78154. */
  78155. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78156. /**
  78157. * Execute the current task
  78158. * @param scene defines the scene where you want your assets to be loaded
  78159. * @param onSuccess is a callback called when the task is successfully executed
  78160. * @param onError is a callback called if an error occurs
  78161. */
  78162. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78163. /**
  78164. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  78165. * This can be used with failed tasks that have the reason for failure fixed.
  78166. */
  78167. reset(): void;
  78168. private onErrorCallback;
  78169. private onDoneCallback;
  78170. }
  78171. /**
  78172. * Define the interface used by progress events raised during assets loading
  78173. */
  78174. export interface IAssetsProgressEvent {
  78175. /**
  78176. * Defines the number of remaining tasks to process
  78177. */
  78178. remainingCount: number;
  78179. /**
  78180. * Defines the total number of tasks
  78181. */
  78182. totalCount: number;
  78183. /**
  78184. * Defines the task that was just processed
  78185. */
  78186. task: AbstractAssetTask;
  78187. }
  78188. /**
  78189. * Class used to share progress information about assets loading
  78190. */
  78191. export class AssetsProgressEvent implements IAssetsProgressEvent {
  78192. /**
  78193. * Defines the number of remaining tasks to process
  78194. */
  78195. remainingCount: number;
  78196. /**
  78197. * Defines the total number of tasks
  78198. */
  78199. totalCount: number;
  78200. /**
  78201. * Defines the task that was just processed
  78202. */
  78203. task: AbstractAssetTask;
  78204. /**
  78205. * Creates a AssetsProgressEvent
  78206. * @param remainingCount defines the number of remaining tasks to process
  78207. * @param totalCount defines the total number of tasks
  78208. * @param task defines the task that was just processed
  78209. */
  78210. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  78211. }
  78212. /**
  78213. * Define a task used by AssetsManager to load assets into a container
  78214. */
  78215. export class ContainerAssetTask extends AbstractAssetTask {
  78216. /**
  78217. * Defines the name of the task
  78218. */
  78219. name: string;
  78220. /**
  78221. * Defines the list of mesh's names you want to load
  78222. */
  78223. meshesNames: any;
  78224. /**
  78225. * Defines the root url to use as a base to load your meshes and associated resources
  78226. */
  78227. rootUrl: string;
  78228. /**
  78229. * Defines the filename or File of the scene to load from
  78230. */
  78231. sceneFilename: string | File;
  78232. /**
  78233. * Get the loaded asset container
  78234. */
  78235. loadedContainer: AssetContainer;
  78236. /**
  78237. * Gets the list of loaded meshes
  78238. */
  78239. loadedMeshes: Array<AbstractMesh>;
  78240. /**
  78241. * Gets the list of loaded particle systems
  78242. */
  78243. loadedParticleSystems: Array<IParticleSystem>;
  78244. /**
  78245. * Gets the list of loaded skeletons
  78246. */
  78247. loadedSkeletons: Array<Skeleton>;
  78248. /**
  78249. * Gets the list of loaded animation groups
  78250. */
  78251. loadedAnimationGroups: Array<AnimationGroup>;
  78252. /**
  78253. * Callback called when the task is successful
  78254. */
  78255. onSuccess: (task: ContainerAssetTask) => void;
  78256. /**
  78257. * Callback called when the task is successful
  78258. */
  78259. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  78260. /**
  78261. * Creates a new ContainerAssetTask
  78262. * @param name defines the name of the task
  78263. * @param meshesNames defines the list of mesh's names you want to load
  78264. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78265. * @param sceneFilename defines the filename or File of the scene to load from
  78266. */
  78267. constructor(
  78268. /**
  78269. * Defines the name of the task
  78270. */
  78271. name: string,
  78272. /**
  78273. * Defines the list of mesh's names you want to load
  78274. */
  78275. meshesNames: any,
  78276. /**
  78277. * Defines the root url to use as a base to load your meshes and associated resources
  78278. */
  78279. rootUrl: string,
  78280. /**
  78281. * Defines the filename or File of the scene to load from
  78282. */
  78283. sceneFilename: string | File);
  78284. /**
  78285. * Execute the current task
  78286. * @param scene defines the scene where you want your assets to be loaded
  78287. * @param onSuccess is a callback called when the task is successfully executed
  78288. * @param onError is a callback called if an error occurs
  78289. */
  78290. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78291. }
  78292. /**
  78293. * Define a task used by AssetsManager to load meshes
  78294. */
  78295. export class MeshAssetTask extends AbstractAssetTask {
  78296. /**
  78297. * Defines the name of the task
  78298. */
  78299. name: string;
  78300. /**
  78301. * Defines the list of mesh's names you want to load
  78302. */
  78303. meshesNames: any;
  78304. /**
  78305. * Defines the root url to use as a base to load your meshes and associated resources
  78306. */
  78307. rootUrl: string;
  78308. /**
  78309. * Defines the filename or File of the scene to load from
  78310. */
  78311. sceneFilename: string | File;
  78312. /**
  78313. * Gets the list of loaded meshes
  78314. */
  78315. loadedMeshes: Array<AbstractMesh>;
  78316. /**
  78317. * Gets the list of loaded particle systems
  78318. */
  78319. loadedParticleSystems: Array<IParticleSystem>;
  78320. /**
  78321. * Gets the list of loaded skeletons
  78322. */
  78323. loadedSkeletons: Array<Skeleton>;
  78324. /**
  78325. * Gets the list of loaded animation groups
  78326. */
  78327. loadedAnimationGroups: Array<AnimationGroup>;
  78328. /**
  78329. * Callback called when the task is successful
  78330. */
  78331. onSuccess: (task: MeshAssetTask) => void;
  78332. /**
  78333. * Callback called when the task is successful
  78334. */
  78335. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  78336. /**
  78337. * Creates a new MeshAssetTask
  78338. * @param name defines the name of the task
  78339. * @param meshesNames defines the list of mesh's names you want to load
  78340. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78341. * @param sceneFilename defines the filename or File of the scene to load from
  78342. */
  78343. constructor(
  78344. /**
  78345. * Defines the name of the task
  78346. */
  78347. name: string,
  78348. /**
  78349. * Defines the list of mesh's names you want to load
  78350. */
  78351. meshesNames: any,
  78352. /**
  78353. * Defines the root url to use as a base to load your meshes and associated resources
  78354. */
  78355. rootUrl: string,
  78356. /**
  78357. * Defines the filename or File of the scene to load from
  78358. */
  78359. sceneFilename: string | File);
  78360. /**
  78361. * Execute the current task
  78362. * @param scene defines the scene where you want your assets to be loaded
  78363. * @param onSuccess is a callback called when the task is successfully executed
  78364. * @param onError is a callback called if an error occurs
  78365. */
  78366. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78367. }
  78368. /**
  78369. * Define a task used by AssetsManager to load text content
  78370. */
  78371. export class TextFileAssetTask extends AbstractAssetTask {
  78372. /**
  78373. * Defines the name of the task
  78374. */
  78375. name: string;
  78376. /**
  78377. * Defines the location of the file to load
  78378. */
  78379. url: string;
  78380. /**
  78381. * Gets the loaded text string
  78382. */
  78383. text: string;
  78384. /**
  78385. * Callback called when the task is successful
  78386. */
  78387. onSuccess: (task: TextFileAssetTask) => void;
  78388. /**
  78389. * Callback called when the task is successful
  78390. */
  78391. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  78392. /**
  78393. * Creates a new TextFileAssetTask object
  78394. * @param name defines the name of the task
  78395. * @param url defines the location of the file to load
  78396. */
  78397. constructor(
  78398. /**
  78399. * Defines the name of the task
  78400. */
  78401. name: string,
  78402. /**
  78403. * Defines the location of the file to load
  78404. */
  78405. url: string);
  78406. /**
  78407. * Execute the current task
  78408. * @param scene defines the scene where you want your assets to be loaded
  78409. * @param onSuccess is a callback called when the task is successfully executed
  78410. * @param onError is a callback called if an error occurs
  78411. */
  78412. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78413. }
  78414. /**
  78415. * Define a task used by AssetsManager to load binary data
  78416. */
  78417. export class BinaryFileAssetTask extends AbstractAssetTask {
  78418. /**
  78419. * Defines the name of the task
  78420. */
  78421. name: string;
  78422. /**
  78423. * Defines the location of the file to load
  78424. */
  78425. url: string;
  78426. /**
  78427. * Gets the lodaded data (as an array buffer)
  78428. */
  78429. data: ArrayBuffer;
  78430. /**
  78431. * Callback called when the task is successful
  78432. */
  78433. onSuccess: (task: BinaryFileAssetTask) => void;
  78434. /**
  78435. * Callback called when the task is successful
  78436. */
  78437. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  78438. /**
  78439. * Creates a new BinaryFileAssetTask object
  78440. * @param name defines the name of the new task
  78441. * @param url defines the location of the file to load
  78442. */
  78443. constructor(
  78444. /**
  78445. * Defines the name of the task
  78446. */
  78447. name: string,
  78448. /**
  78449. * Defines the location of the file to load
  78450. */
  78451. url: string);
  78452. /**
  78453. * Execute the current task
  78454. * @param scene defines the scene where you want your assets to be loaded
  78455. * @param onSuccess is a callback called when the task is successfully executed
  78456. * @param onError is a callback called if an error occurs
  78457. */
  78458. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78459. }
  78460. /**
  78461. * Define a task used by AssetsManager to load images
  78462. */
  78463. export class ImageAssetTask extends AbstractAssetTask {
  78464. /**
  78465. * Defines the name of the task
  78466. */
  78467. name: string;
  78468. /**
  78469. * Defines the location of the image to load
  78470. */
  78471. url: string;
  78472. /**
  78473. * Gets the loaded images
  78474. */
  78475. image: HTMLImageElement;
  78476. /**
  78477. * Callback called when the task is successful
  78478. */
  78479. onSuccess: (task: ImageAssetTask) => void;
  78480. /**
  78481. * Callback called when the task is successful
  78482. */
  78483. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  78484. /**
  78485. * Creates a new ImageAssetTask
  78486. * @param name defines the name of the task
  78487. * @param url defines the location of the image to load
  78488. */
  78489. constructor(
  78490. /**
  78491. * Defines the name of the task
  78492. */
  78493. name: string,
  78494. /**
  78495. * Defines the location of the image to load
  78496. */
  78497. url: string);
  78498. /**
  78499. * Execute the current task
  78500. * @param scene defines the scene where you want your assets to be loaded
  78501. * @param onSuccess is a callback called when the task is successfully executed
  78502. * @param onError is a callback called if an error occurs
  78503. */
  78504. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78505. }
  78506. /**
  78507. * Defines the interface used by texture loading tasks
  78508. */
  78509. export interface ITextureAssetTask<TEX extends BaseTexture> {
  78510. /**
  78511. * Gets the loaded texture
  78512. */
  78513. texture: TEX;
  78514. }
  78515. /**
  78516. * Define a task used by AssetsManager to load 2D textures
  78517. */
  78518. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  78519. /**
  78520. * Defines the name of the task
  78521. */
  78522. name: string;
  78523. /**
  78524. * Defines the location of the file to load
  78525. */
  78526. url: string;
  78527. /**
  78528. * Defines if mipmap should not be generated (default is false)
  78529. */
  78530. noMipmap?: boolean | undefined;
  78531. /**
  78532. * Defines if texture must be inverted on Y axis (default is true)
  78533. */
  78534. invertY: boolean;
  78535. /**
  78536. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78537. */
  78538. samplingMode: number;
  78539. /**
  78540. * Gets the loaded texture
  78541. */
  78542. texture: Texture;
  78543. /**
  78544. * Callback called when the task is successful
  78545. */
  78546. onSuccess: (task: TextureAssetTask) => void;
  78547. /**
  78548. * Callback called when the task is successful
  78549. */
  78550. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  78551. /**
  78552. * Creates a new TextureAssetTask object
  78553. * @param name defines the name of the task
  78554. * @param url defines the location of the file to load
  78555. * @param noMipmap defines if mipmap should not be generated (default is false)
  78556. * @param invertY defines if texture must be inverted on Y axis (default is true)
  78557. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78558. */
  78559. constructor(
  78560. /**
  78561. * Defines the name of the task
  78562. */
  78563. name: string,
  78564. /**
  78565. * Defines the location of the file to load
  78566. */
  78567. url: string,
  78568. /**
  78569. * Defines if mipmap should not be generated (default is false)
  78570. */
  78571. noMipmap?: boolean | undefined,
  78572. /**
  78573. * Defines if texture must be inverted on Y axis (default is true)
  78574. */
  78575. invertY?: boolean,
  78576. /**
  78577. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78578. */
  78579. samplingMode?: number);
  78580. /**
  78581. * Execute the current task
  78582. * @param scene defines the scene where you want your assets to be loaded
  78583. * @param onSuccess is a callback called when the task is successfully executed
  78584. * @param onError is a callback called if an error occurs
  78585. */
  78586. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78587. }
  78588. /**
  78589. * Define a task used by AssetsManager to load cube textures
  78590. */
  78591. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  78592. /**
  78593. * Defines the name of the task
  78594. */
  78595. name: string;
  78596. /**
  78597. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78598. */
  78599. url: string;
  78600. /**
  78601. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78602. */
  78603. extensions?: string[] | undefined;
  78604. /**
  78605. * Defines if mipmaps should not be generated (default is false)
  78606. */
  78607. noMipmap?: boolean | undefined;
  78608. /**
  78609. * Defines the explicit list of files (undefined by default)
  78610. */
  78611. files?: string[] | undefined;
  78612. /**
  78613. * Gets the loaded texture
  78614. */
  78615. texture: CubeTexture;
  78616. /**
  78617. * Callback called when the task is successful
  78618. */
  78619. onSuccess: (task: CubeTextureAssetTask) => void;
  78620. /**
  78621. * Callback called when the task is successful
  78622. */
  78623. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  78624. /**
  78625. * Creates a new CubeTextureAssetTask
  78626. * @param name defines the name of the task
  78627. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78628. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78629. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78630. * @param files defines the explicit list of files (undefined by default)
  78631. */
  78632. constructor(
  78633. /**
  78634. * Defines the name of the task
  78635. */
  78636. name: string,
  78637. /**
  78638. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78639. */
  78640. url: string,
  78641. /**
  78642. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78643. */
  78644. extensions?: string[] | undefined,
  78645. /**
  78646. * Defines if mipmaps should not be generated (default is false)
  78647. */
  78648. noMipmap?: boolean | undefined,
  78649. /**
  78650. * Defines the explicit list of files (undefined by default)
  78651. */
  78652. files?: string[] | undefined);
  78653. /**
  78654. * Execute the current task
  78655. * @param scene defines the scene where you want your assets to be loaded
  78656. * @param onSuccess is a callback called when the task is successfully executed
  78657. * @param onError is a callback called if an error occurs
  78658. */
  78659. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78660. }
  78661. /**
  78662. * Define a task used by AssetsManager to load HDR cube textures
  78663. */
  78664. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78665. /**
  78666. * Defines the name of the task
  78667. */
  78668. name: string;
  78669. /**
  78670. * Defines the location of the file to load
  78671. */
  78672. url: string;
  78673. /**
  78674. * Defines the desired size (the more it increases the longer the generation will be)
  78675. */
  78676. size: number;
  78677. /**
  78678. * Defines if mipmaps should not be generated (default is false)
  78679. */
  78680. noMipmap: boolean;
  78681. /**
  78682. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78683. */
  78684. generateHarmonics: boolean;
  78685. /**
  78686. * 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)
  78687. */
  78688. gammaSpace: boolean;
  78689. /**
  78690. * Internal Use Only
  78691. */
  78692. reserved: boolean;
  78693. /**
  78694. * Gets the loaded texture
  78695. */
  78696. texture: HDRCubeTexture;
  78697. /**
  78698. * Callback called when the task is successful
  78699. */
  78700. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78701. /**
  78702. * Callback called when the task is successful
  78703. */
  78704. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78705. /**
  78706. * Creates a new HDRCubeTextureAssetTask object
  78707. * @param name defines the name of the task
  78708. * @param url defines the location of the file to load
  78709. * @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.
  78710. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78711. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78712. * @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)
  78713. * @param reserved Internal use only
  78714. */
  78715. constructor(
  78716. /**
  78717. * Defines the name of the task
  78718. */
  78719. name: string,
  78720. /**
  78721. * Defines the location of the file to load
  78722. */
  78723. url: string,
  78724. /**
  78725. * Defines the desired size (the more it increases the longer the generation will be)
  78726. */
  78727. size: number,
  78728. /**
  78729. * Defines if mipmaps should not be generated (default is false)
  78730. */
  78731. noMipmap?: boolean,
  78732. /**
  78733. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78734. */
  78735. generateHarmonics?: boolean,
  78736. /**
  78737. * 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)
  78738. */
  78739. gammaSpace?: boolean,
  78740. /**
  78741. * Internal Use Only
  78742. */
  78743. reserved?: boolean);
  78744. /**
  78745. * Execute the current task
  78746. * @param scene defines the scene where you want your assets to be loaded
  78747. * @param onSuccess is a callback called when the task is successfully executed
  78748. * @param onError is a callback called if an error occurs
  78749. */
  78750. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78751. }
  78752. /**
  78753. * Define a task used by AssetsManager to load Equirectangular cube textures
  78754. */
  78755. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78756. /**
  78757. * Defines the name of the task
  78758. */
  78759. name: string;
  78760. /**
  78761. * Defines the location of the file to load
  78762. */
  78763. url: string;
  78764. /**
  78765. * Defines the desired size (the more it increases the longer the generation will be)
  78766. */
  78767. size: number;
  78768. /**
  78769. * Defines if mipmaps should not be generated (default is false)
  78770. */
  78771. noMipmap: boolean;
  78772. /**
  78773. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78774. * but the standard material would require them in Gamma space) (default is true)
  78775. */
  78776. gammaSpace: boolean;
  78777. /**
  78778. * Gets the loaded texture
  78779. */
  78780. texture: EquiRectangularCubeTexture;
  78781. /**
  78782. * Callback called when the task is successful
  78783. */
  78784. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78785. /**
  78786. * Callback called when the task is successful
  78787. */
  78788. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78789. /**
  78790. * Creates a new EquiRectangularCubeTextureAssetTask object
  78791. * @param name defines the name of the task
  78792. * @param url defines the location of the file to load
  78793. * @param size defines the desired size (the more it increases the longer the generation will be)
  78794. * If the size is omitted this implies you are using a preprocessed cubemap.
  78795. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78796. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78797. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78798. * (default is true)
  78799. */
  78800. constructor(
  78801. /**
  78802. * Defines the name of the task
  78803. */
  78804. name: string,
  78805. /**
  78806. * Defines the location of the file to load
  78807. */
  78808. url: string,
  78809. /**
  78810. * Defines the desired size (the more it increases the longer the generation will be)
  78811. */
  78812. size: number,
  78813. /**
  78814. * Defines if mipmaps should not be generated (default is false)
  78815. */
  78816. noMipmap?: boolean,
  78817. /**
  78818. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78819. * but the standard material would require them in Gamma space) (default is true)
  78820. */
  78821. gammaSpace?: boolean);
  78822. /**
  78823. * Execute the current task
  78824. * @param scene defines the scene where you want your assets to be loaded
  78825. * @param onSuccess is a callback called when the task is successfully executed
  78826. * @param onError is a callback called if an error occurs
  78827. */
  78828. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78829. }
  78830. /**
  78831. * This class can be used to easily import assets into a scene
  78832. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78833. */
  78834. export class AssetsManager {
  78835. private _scene;
  78836. private _isLoading;
  78837. protected _tasks: AbstractAssetTask[];
  78838. protected _waitingTasksCount: number;
  78839. protected _totalTasksCount: number;
  78840. /**
  78841. * Callback called when all tasks are processed
  78842. */
  78843. onFinish: (tasks: AbstractAssetTask[]) => void;
  78844. /**
  78845. * Callback called when a task is successful
  78846. */
  78847. onTaskSuccess: (task: AbstractAssetTask) => void;
  78848. /**
  78849. * Callback called when a task had an error
  78850. */
  78851. onTaskError: (task: AbstractAssetTask) => void;
  78852. /**
  78853. * Callback called when a task is done (whatever the result is)
  78854. */
  78855. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78856. /**
  78857. * Observable called when all tasks are processed
  78858. */
  78859. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78860. /**
  78861. * Observable called when a task had an error
  78862. */
  78863. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78864. /**
  78865. * Observable called when all tasks were executed
  78866. */
  78867. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78868. /**
  78869. * Observable called when a task is done (whatever the result is)
  78870. */
  78871. onProgressObservable: Observable<IAssetsProgressEvent>;
  78872. /**
  78873. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78874. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78875. */
  78876. useDefaultLoadingScreen: boolean;
  78877. /**
  78878. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78879. * when all assets have been downloaded.
  78880. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78881. */
  78882. autoHideLoadingUI: boolean;
  78883. /**
  78884. * Creates a new AssetsManager
  78885. * @param scene defines the scene to work on
  78886. */
  78887. constructor(scene: Scene);
  78888. /**
  78889. * Add a ContainerAssetTask to the list of active tasks
  78890. * @param taskName defines the name of the new task
  78891. * @param meshesNames defines the name of meshes to load
  78892. * @param rootUrl defines the root url to use to locate files
  78893. * @param sceneFilename defines the filename of the scene file
  78894. * @returns a new ContainerAssetTask object
  78895. */
  78896. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78897. /**
  78898. * Add a MeshAssetTask to the list of active tasks
  78899. * @param taskName defines the name of the new task
  78900. * @param meshesNames defines the name of meshes to load
  78901. * @param rootUrl defines the root url to use to locate files
  78902. * @param sceneFilename defines the filename of the scene file
  78903. * @returns a new MeshAssetTask object
  78904. */
  78905. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78906. /**
  78907. * Add a TextFileAssetTask to the list of active tasks
  78908. * @param taskName defines the name of the new task
  78909. * @param url defines the url of the file to load
  78910. * @returns a new TextFileAssetTask object
  78911. */
  78912. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78913. /**
  78914. * Add a BinaryFileAssetTask to the list of active tasks
  78915. * @param taskName defines the name of the new task
  78916. * @param url defines the url of the file to load
  78917. * @returns a new BinaryFileAssetTask object
  78918. */
  78919. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78920. /**
  78921. * Add a ImageAssetTask to the list of active tasks
  78922. * @param taskName defines the name of the new task
  78923. * @param url defines the url of the file to load
  78924. * @returns a new ImageAssetTask object
  78925. */
  78926. addImageTask(taskName: string, url: string): ImageAssetTask;
  78927. /**
  78928. * Add a TextureAssetTask to the list of active tasks
  78929. * @param taskName defines the name of the new task
  78930. * @param url defines the url of the file to load
  78931. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78932. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78933. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78934. * @returns a new TextureAssetTask object
  78935. */
  78936. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78937. /**
  78938. * Add a CubeTextureAssetTask to the list of active tasks
  78939. * @param taskName defines the name of the new task
  78940. * @param url defines the url of the file to load
  78941. * @param extensions defines the extension to use to load the cube map (can be null)
  78942. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78943. * @param files defines the list of files to load (can be null)
  78944. * @returns a new CubeTextureAssetTask object
  78945. */
  78946. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78947. /**
  78948. *
  78949. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78950. * @param taskName defines the name of the new task
  78951. * @param url defines the url of the file to load
  78952. * @param size defines the size you want for the cubemap (can be null)
  78953. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78954. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78955. * @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)
  78956. * @param reserved Internal use only
  78957. * @returns a new HDRCubeTextureAssetTask object
  78958. */
  78959. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78960. /**
  78961. *
  78962. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78963. * @param taskName defines the name of the new task
  78964. * @param url defines the url of the file to load
  78965. * @param size defines the size you want for the cubemap (can be null)
  78966. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78967. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78968. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78969. * @returns a new EquiRectangularCubeTextureAssetTask object
  78970. */
  78971. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78972. /**
  78973. * Remove a task from the assets manager.
  78974. * @param task the task to remove
  78975. */
  78976. removeTask(task: AbstractAssetTask): void;
  78977. private _decreaseWaitingTasksCount;
  78978. private _runTask;
  78979. /**
  78980. * Reset the AssetsManager and remove all tasks
  78981. * @return the current instance of the AssetsManager
  78982. */
  78983. reset(): AssetsManager;
  78984. /**
  78985. * Start the loading process
  78986. * @return the current instance of the AssetsManager
  78987. */
  78988. load(): AssetsManager;
  78989. /**
  78990. * Start the loading process as an async operation
  78991. * @return a promise returning the list of failed tasks
  78992. */
  78993. loadAsync(): Promise<void>;
  78994. }
  78995. }
  78996. declare module "babylonjs/Misc/deferred" {
  78997. /**
  78998. * Wrapper class for promise with external resolve and reject.
  78999. */
  79000. export class Deferred<T> {
  79001. /**
  79002. * The promise associated with this deferred object.
  79003. */
  79004. readonly promise: Promise<T>;
  79005. private _resolve;
  79006. private _reject;
  79007. /**
  79008. * The resolve method of the promise associated with this deferred object.
  79009. */
  79010. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  79011. /**
  79012. * The reject method of the promise associated with this deferred object.
  79013. */
  79014. get reject(): (reason?: any) => void;
  79015. /**
  79016. * Constructor for this deferred object.
  79017. */
  79018. constructor();
  79019. }
  79020. }
  79021. declare module "babylonjs/Misc/meshExploder" {
  79022. import { Mesh } from "babylonjs/Meshes/mesh";
  79023. /**
  79024. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  79025. */
  79026. export class MeshExploder {
  79027. private _centerMesh;
  79028. private _meshes;
  79029. private _meshesOrigins;
  79030. private _toCenterVectors;
  79031. private _scaledDirection;
  79032. private _newPosition;
  79033. private _centerPosition;
  79034. /**
  79035. * Explodes meshes from a center mesh.
  79036. * @param meshes The meshes to explode.
  79037. * @param centerMesh The mesh to be center of explosion.
  79038. */
  79039. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  79040. private _setCenterMesh;
  79041. /**
  79042. * Get class name
  79043. * @returns "MeshExploder"
  79044. */
  79045. getClassName(): string;
  79046. /**
  79047. * "Exploded meshes"
  79048. * @returns Array of meshes with the centerMesh at index 0.
  79049. */
  79050. getMeshes(): Array<Mesh>;
  79051. /**
  79052. * Explodes meshes giving a specific direction
  79053. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  79054. */
  79055. explode(direction?: number): void;
  79056. }
  79057. }
  79058. declare module "babylonjs/Misc/filesInput" {
  79059. import { Engine } from "babylonjs/Engines/engine";
  79060. import { Scene } from "babylonjs/scene";
  79061. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  79062. import { Nullable } from "babylonjs/types";
  79063. /**
  79064. * Class used to help managing file picking and drag'n'drop
  79065. */
  79066. export class FilesInput {
  79067. /**
  79068. * List of files ready to be loaded
  79069. */
  79070. static get FilesToLoad(): {
  79071. [key: string]: File;
  79072. };
  79073. /**
  79074. * Callback called when a file is processed
  79075. */
  79076. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  79077. private _engine;
  79078. private _currentScene;
  79079. private _sceneLoadedCallback;
  79080. private _progressCallback;
  79081. private _additionalRenderLoopLogicCallback;
  79082. private _textureLoadingCallback;
  79083. private _startingProcessingFilesCallback;
  79084. private _onReloadCallback;
  79085. private _errorCallback;
  79086. private _elementToMonitor;
  79087. private _sceneFileToLoad;
  79088. private _filesToLoad;
  79089. /**
  79090. * Creates a new FilesInput
  79091. * @param engine defines the rendering engine
  79092. * @param scene defines the hosting scene
  79093. * @param sceneLoadedCallback callback called when scene is loaded
  79094. * @param progressCallback callback called to track progress
  79095. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  79096. * @param textureLoadingCallback callback called when a texture is loading
  79097. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  79098. * @param onReloadCallback callback called when a reload is requested
  79099. * @param errorCallback callback call if an error occurs
  79100. */
  79101. 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>);
  79102. private _dragEnterHandler;
  79103. private _dragOverHandler;
  79104. private _dropHandler;
  79105. /**
  79106. * Calls this function to listen to drag'n'drop events on a specific DOM element
  79107. * @param elementToMonitor defines the DOM element to track
  79108. */
  79109. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  79110. /** Gets the current list of files to load */
  79111. get filesToLoad(): File[];
  79112. /**
  79113. * Release all associated resources
  79114. */
  79115. dispose(): void;
  79116. private renderFunction;
  79117. private drag;
  79118. private drop;
  79119. private _traverseFolder;
  79120. private _processFiles;
  79121. /**
  79122. * Load files from a drop event
  79123. * @param event defines the drop event to use as source
  79124. */
  79125. loadFiles(event: any): void;
  79126. private _processReload;
  79127. /**
  79128. * Reload the current scene from the loaded files
  79129. */
  79130. reload(): void;
  79131. }
  79132. }
  79133. declare module "babylonjs/Misc/HighDynamicRange/index" {
  79134. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  79135. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  79136. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  79137. }
  79138. declare module "babylonjs/Misc/sceneOptimizer" {
  79139. import { Scene, IDisposable } from "babylonjs/scene";
  79140. import { Observable } from "babylonjs/Misc/observable";
  79141. /**
  79142. * Defines the root class used to create scene optimization to use with SceneOptimizer
  79143. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79144. */
  79145. export class SceneOptimization {
  79146. /**
  79147. * Defines the priority of this optimization (0 by default which means first in the list)
  79148. */
  79149. priority: number;
  79150. /**
  79151. * Gets a string describing the action executed by the current optimization
  79152. * @returns description string
  79153. */
  79154. getDescription(): string;
  79155. /**
  79156. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79157. * @param scene defines the current scene where to apply this optimization
  79158. * @param optimizer defines the current optimizer
  79159. * @returns true if everything that can be done was applied
  79160. */
  79161. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79162. /**
  79163. * Creates the SceneOptimization object
  79164. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79165. * @param desc defines the description associated with the optimization
  79166. */
  79167. constructor(
  79168. /**
  79169. * Defines the priority of this optimization (0 by default which means first in the list)
  79170. */
  79171. priority?: number);
  79172. }
  79173. /**
  79174. * Defines an optimization used to reduce the size of render target textures
  79175. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79176. */
  79177. export class TextureOptimization extends SceneOptimization {
  79178. /**
  79179. * Defines the priority of this optimization (0 by default which means first in the list)
  79180. */
  79181. priority: number;
  79182. /**
  79183. * 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
  79184. */
  79185. maximumSize: number;
  79186. /**
  79187. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79188. */
  79189. step: number;
  79190. /**
  79191. * Gets a string describing the action executed by the current optimization
  79192. * @returns description string
  79193. */
  79194. getDescription(): string;
  79195. /**
  79196. * Creates the TextureOptimization object
  79197. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79198. * @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
  79199. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79200. */
  79201. constructor(
  79202. /**
  79203. * Defines the priority of this optimization (0 by default which means first in the list)
  79204. */
  79205. priority?: number,
  79206. /**
  79207. * 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
  79208. */
  79209. maximumSize?: number,
  79210. /**
  79211. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79212. */
  79213. step?: number);
  79214. /**
  79215. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79216. * @param scene defines the current scene where to apply this optimization
  79217. * @param optimizer defines the current optimizer
  79218. * @returns true if everything that can be done was applied
  79219. */
  79220. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79221. }
  79222. /**
  79223. * Defines an optimization used to increase or decrease the rendering resolution
  79224. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79225. */
  79226. export class HardwareScalingOptimization extends SceneOptimization {
  79227. /**
  79228. * Defines the priority of this optimization (0 by default which means first in the list)
  79229. */
  79230. priority: number;
  79231. /**
  79232. * Defines the maximum scale to use (2 by default)
  79233. */
  79234. maximumScale: number;
  79235. /**
  79236. * Defines the step to use between two passes (0.5 by default)
  79237. */
  79238. step: number;
  79239. private _currentScale;
  79240. private _directionOffset;
  79241. /**
  79242. * Gets a string describing the action executed by the current optimization
  79243. * @return description string
  79244. */
  79245. getDescription(): string;
  79246. /**
  79247. * Creates the HardwareScalingOptimization object
  79248. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79249. * @param maximumScale defines the maximum scale to use (2 by default)
  79250. * @param step defines the step to use between two passes (0.5 by default)
  79251. */
  79252. constructor(
  79253. /**
  79254. * Defines the priority of this optimization (0 by default which means first in the list)
  79255. */
  79256. priority?: number,
  79257. /**
  79258. * Defines the maximum scale to use (2 by default)
  79259. */
  79260. maximumScale?: number,
  79261. /**
  79262. * Defines the step to use between two passes (0.5 by default)
  79263. */
  79264. step?: number);
  79265. /**
  79266. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79267. * @param scene defines the current scene where to apply this optimization
  79268. * @param optimizer defines the current optimizer
  79269. * @returns true if everything that can be done was applied
  79270. */
  79271. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79272. }
  79273. /**
  79274. * Defines an optimization used to remove shadows
  79275. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79276. */
  79277. export class ShadowsOptimization extends SceneOptimization {
  79278. /**
  79279. * Gets a string describing the action executed by the current optimization
  79280. * @return description string
  79281. */
  79282. getDescription(): string;
  79283. /**
  79284. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79285. * @param scene defines the current scene where to apply this optimization
  79286. * @param optimizer defines the current optimizer
  79287. * @returns true if everything that can be done was applied
  79288. */
  79289. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79290. }
  79291. /**
  79292. * Defines an optimization used to turn post-processes off
  79293. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79294. */
  79295. export class PostProcessesOptimization extends SceneOptimization {
  79296. /**
  79297. * Gets a string describing the action executed by the current optimization
  79298. * @return description string
  79299. */
  79300. getDescription(): string;
  79301. /**
  79302. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79303. * @param scene defines the current scene where to apply this optimization
  79304. * @param optimizer defines the current optimizer
  79305. * @returns true if everything that can be done was applied
  79306. */
  79307. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79308. }
  79309. /**
  79310. * Defines an optimization used to turn lens flares off
  79311. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79312. */
  79313. export class LensFlaresOptimization extends SceneOptimization {
  79314. /**
  79315. * Gets a string describing the action executed by the current optimization
  79316. * @return description string
  79317. */
  79318. getDescription(): string;
  79319. /**
  79320. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79321. * @param scene defines the current scene where to apply this optimization
  79322. * @param optimizer defines the current optimizer
  79323. * @returns true if everything that can be done was applied
  79324. */
  79325. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79326. }
  79327. /**
  79328. * Defines an optimization based on user defined callback.
  79329. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79330. */
  79331. export class CustomOptimization extends SceneOptimization {
  79332. /**
  79333. * Callback called to apply the custom optimization.
  79334. */
  79335. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  79336. /**
  79337. * Callback called to get custom description
  79338. */
  79339. onGetDescription: () => string;
  79340. /**
  79341. * Gets a string describing the action executed by the current optimization
  79342. * @returns description string
  79343. */
  79344. getDescription(): string;
  79345. /**
  79346. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79347. * @param scene defines the current scene where to apply this optimization
  79348. * @param optimizer defines the current optimizer
  79349. * @returns true if everything that can be done was applied
  79350. */
  79351. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79352. }
  79353. /**
  79354. * Defines an optimization used to turn particles off
  79355. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79356. */
  79357. export class ParticlesOptimization extends SceneOptimization {
  79358. /**
  79359. * Gets a string describing the action executed by the current optimization
  79360. * @return description string
  79361. */
  79362. getDescription(): string;
  79363. /**
  79364. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79365. * @param scene defines the current scene where to apply this optimization
  79366. * @param optimizer defines the current optimizer
  79367. * @returns true if everything that can be done was applied
  79368. */
  79369. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79370. }
  79371. /**
  79372. * Defines an optimization used to turn render targets off
  79373. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79374. */
  79375. export class RenderTargetsOptimization extends SceneOptimization {
  79376. /**
  79377. * Gets a string describing the action executed by the current optimization
  79378. * @return description string
  79379. */
  79380. getDescription(): string;
  79381. /**
  79382. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79383. * @param scene defines the current scene where to apply this optimization
  79384. * @param optimizer defines the current optimizer
  79385. * @returns true if everything that can be done was applied
  79386. */
  79387. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79388. }
  79389. /**
  79390. * Defines an optimization used to merge meshes with compatible materials
  79391. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79392. */
  79393. export class MergeMeshesOptimization extends SceneOptimization {
  79394. private static _UpdateSelectionTree;
  79395. /**
  79396. * Gets or sets a boolean which defines if optimization octree has to be updated
  79397. */
  79398. static get UpdateSelectionTree(): boolean;
  79399. /**
  79400. * Gets or sets a boolean which defines if optimization octree has to be updated
  79401. */
  79402. static set UpdateSelectionTree(value: boolean);
  79403. /**
  79404. * Gets a string describing the action executed by the current optimization
  79405. * @return description string
  79406. */
  79407. getDescription(): string;
  79408. private _canBeMerged;
  79409. /**
  79410. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79411. * @param scene defines the current scene where to apply this optimization
  79412. * @param optimizer defines the current optimizer
  79413. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  79414. * @returns true if everything that can be done was applied
  79415. */
  79416. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  79417. }
  79418. /**
  79419. * Defines a list of options used by SceneOptimizer
  79420. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79421. */
  79422. export class SceneOptimizerOptions {
  79423. /**
  79424. * Defines the target frame rate to reach (60 by default)
  79425. */
  79426. targetFrameRate: number;
  79427. /**
  79428. * Defines the interval between two checkes (2000ms by default)
  79429. */
  79430. trackerDuration: number;
  79431. /**
  79432. * Gets the list of optimizations to apply
  79433. */
  79434. optimizations: SceneOptimization[];
  79435. /**
  79436. * Creates a new list of options used by SceneOptimizer
  79437. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  79438. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  79439. */
  79440. constructor(
  79441. /**
  79442. * Defines the target frame rate to reach (60 by default)
  79443. */
  79444. targetFrameRate?: number,
  79445. /**
  79446. * Defines the interval between two checkes (2000ms by default)
  79447. */
  79448. trackerDuration?: number);
  79449. /**
  79450. * Add a new optimization
  79451. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  79452. * @returns the current SceneOptimizerOptions
  79453. */
  79454. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  79455. /**
  79456. * Add a new custom optimization
  79457. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  79458. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  79459. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79460. * @returns the current SceneOptimizerOptions
  79461. */
  79462. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  79463. /**
  79464. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  79465. * @param targetFrameRate defines the target frame rate (60 by default)
  79466. * @returns a SceneOptimizerOptions object
  79467. */
  79468. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79469. /**
  79470. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  79471. * @param targetFrameRate defines the target frame rate (60 by default)
  79472. * @returns a SceneOptimizerOptions object
  79473. */
  79474. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79475. /**
  79476. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  79477. * @param targetFrameRate defines the target frame rate (60 by default)
  79478. * @returns a SceneOptimizerOptions object
  79479. */
  79480. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79481. }
  79482. /**
  79483. * Class used to run optimizations in order to reach a target frame rate
  79484. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79485. */
  79486. export class SceneOptimizer implements IDisposable {
  79487. private _isRunning;
  79488. private _options;
  79489. private _scene;
  79490. private _currentPriorityLevel;
  79491. private _targetFrameRate;
  79492. private _trackerDuration;
  79493. private _currentFrameRate;
  79494. private _sceneDisposeObserver;
  79495. private _improvementMode;
  79496. /**
  79497. * Defines an observable called when the optimizer reaches the target frame rate
  79498. */
  79499. onSuccessObservable: Observable<SceneOptimizer>;
  79500. /**
  79501. * Defines an observable called when the optimizer enables an optimization
  79502. */
  79503. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  79504. /**
  79505. * Defines an observable called when the optimizer is not able to reach the target frame rate
  79506. */
  79507. onFailureObservable: Observable<SceneOptimizer>;
  79508. /**
  79509. * Gets a boolean indicating if the optimizer is in improvement mode
  79510. */
  79511. get isInImprovementMode(): boolean;
  79512. /**
  79513. * Gets the current priority level (0 at start)
  79514. */
  79515. get currentPriorityLevel(): number;
  79516. /**
  79517. * Gets the current frame rate checked by the SceneOptimizer
  79518. */
  79519. get currentFrameRate(): number;
  79520. /**
  79521. * Gets or sets the current target frame rate (60 by default)
  79522. */
  79523. get targetFrameRate(): number;
  79524. /**
  79525. * Gets or sets the current target frame rate (60 by default)
  79526. */
  79527. set targetFrameRate(value: number);
  79528. /**
  79529. * Gets or sets the current interval between two checks (every 2000ms by default)
  79530. */
  79531. get trackerDuration(): number;
  79532. /**
  79533. * Gets or sets the current interval between two checks (every 2000ms by default)
  79534. */
  79535. set trackerDuration(value: number);
  79536. /**
  79537. * Gets the list of active optimizations
  79538. */
  79539. get optimizations(): SceneOptimization[];
  79540. /**
  79541. * Creates a new SceneOptimizer
  79542. * @param scene defines the scene to work on
  79543. * @param options defines the options to use with the SceneOptimizer
  79544. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  79545. * @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)
  79546. */
  79547. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  79548. /**
  79549. * Stops the current optimizer
  79550. */
  79551. stop(): void;
  79552. /**
  79553. * Reset the optimizer to initial step (current priority level = 0)
  79554. */
  79555. reset(): void;
  79556. /**
  79557. * Start the optimizer. By default it will try to reach a specific framerate
  79558. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  79559. */
  79560. start(): void;
  79561. private _checkCurrentState;
  79562. /**
  79563. * Release all resources
  79564. */
  79565. dispose(): void;
  79566. /**
  79567. * Helper function to create a SceneOptimizer with one single line of code
  79568. * @param scene defines the scene to work on
  79569. * @param options defines the options to use with the SceneOptimizer
  79570. * @param onSuccess defines a callback to call on success
  79571. * @param onFailure defines a callback to call on failure
  79572. * @returns the new SceneOptimizer object
  79573. */
  79574. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  79575. }
  79576. }
  79577. declare module "babylonjs/Misc/sceneSerializer" {
  79578. import { Scene } from "babylonjs/scene";
  79579. /**
  79580. * Class used to serialize a scene into a string
  79581. */
  79582. export class SceneSerializer {
  79583. /**
  79584. * Clear cache used by a previous serialization
  79585. */
  79586. static ClearCache(): void;
  79587. /**
  79588. * Serialize a scene into a JSON compatible object
  79589. * @param scene defines the scene to serialize
  79590. * @returns a JSON compatible object
  79591. */
  79592. static Serialize(scene: Scene): any;
  79593. /**
  79594. * Serialize a mesh into a JSON compatible object
  79595. * @param toSerialize defines the mesh to serialize
  79596. * @param withParents defines if parents must be serialized as well
  79597. * @param withChildren defines if children must be serialized as well
  79598. * @returns a JSON compatible object
  79599. */
  79600. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  79601. }
  79602. }
  79603. declare module "babylonjs/Misc/textureTools" {
  79604. import { Texture } from "babylonjs/Materials/Textures/texture";
  79605. /**
  79606. * Class used to host texture specific utilities
  79607. */
  79608. export class TextureTools {
  79609. /**
  79610. * Uses the GPU to create a copy texture rescaled at a given size
  79611. * @param texture Texture to copy from
  79612. * @param width defines the desired width
  79613. * @param height defines the desired height
  79614. * @param useBilinearMode defines if bilinear mode has to be used
  79615. * @return the generated texture
  79616. */
  79617. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  79618. }
  79619. }
  79620. declare module "babylonjs/Misc/videoRecorder" {
  79621. import { Nullable } from "babylonjs/types";
  79622. import { Engine } from "babylonjs/Engines/engine";
  79623. /**
  79624. * This represents the different options available for the video capture.
  79625. */
  79626. export interface VideoRecorderOptions {
  79627. /** Defines the mime type of the video. */
  79628. mimeType: string;
  79629. /** Defines the FPS the video should be recorded at. */
  79630. fps: number;
  79631. /** Defines the chunk size for the recording data. */
  79632. recordChunckSize: number;
  79633. /** The audio tracks to attach to the recording. */
  79634. audioTracks?: MediaStreamTrack[];
  79635. }
  79636. /**
  79637. * This can help with recording videos from BabylonJS.
  79638. * This is based on the available WebRTC functionalities of the browser.
  79639. *
  79640. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  79641. */
  79642. export class VideoRecorder {
  79643. private static readonly _defaultOptions;
  79644. /**
  79645. * Returns whether or not the VideoRecorder is available in your browser.
  79646. * @param engine Defines the Babylon Engine.
  79647. * @returns true if supported otherwise false.
  79648. */
  79649. static IsSupported(engine: Engine): boolean;
  79650. private readonly _options;
  79651. private _canvas;
  79652. private _mediaRecorder;
  79653. private _recordedChunks;
  79654. private _fileName;
  79655. private _resolve;
  79656. private _reject;
  79657. /**
  79658. * True when a recording is already in progress.
  79659. */
  79660. get isRecording(): boolean;
  79661. /**
  79662. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79663. * @param engine Defines the BabylonJS Engine you wish to record.
  79664. * @param options Defines options that can be used to customize the capture.
  79665. */
  79666. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79667. /**
  79668. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79669. */
  79670. stopRecording(): void;
  79671. /**
  79672. * Starts recording the canvas for a max duration specified in parameters.
  79673. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79674. * If null no automatic download will start and you can rely on the promise to get the data back.
  79675. * @param maxDuration Defines the maximum recording time in seconds.
  79676. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79677. * @return A promise callback at the end of the recording with the video data in Blob.
  79678. */
  79679. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79680. /**
  79681. * Releases internal resources used during the recording.
  79682. */
  79683. dispose(): void;
  79684. private _handleDataAvailable;
  79685. private _handleError;
  79686. private _handleStop;
  79687. }
  79688. }
  79689. declare module "babylonjs/Misc/screenshotTools" {
  79690. import { Camera } from "babylonjs/Cameras/camera";
  79691. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  79692. import { Engine } from "babylonjs/Engines/engine";
  79693. /**
  79694. * Class containing a set of static utilities functions for screenshots
  79695. */
  79696. export class ScreenshotTools {
  79697. /**
  79698. * Captures a screenshot of the current rendering
  79699. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79700. * @param engine defines the rendering engine
  79701. * @param camera defines the source camera
  79702. * @param size This parameter can be set to a single number or to an object with the
  79703. * following (optional) properties: precision, width, height. If a single number is passed,
  79704. * it will be used for both width and height. If an object is passed, the screenshot size
  79705. * will be derived from the parameters. The precision property is a multiplier allowing
  79706. * rendering at a higher or lower resolution
  79707. * @param successCallback defines the callback receives a single parameter which contains the
  79708. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79709. * src parameter of an <img> to display it
  79710. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79711. * Check your browser for supported MIME types
  79712. */
  79713. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  79714. /**
  79715. * Captures a screenshot of the current rendering
  79716. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79717. * @param engine defines the rendering engine
  79718. * @param camera defines the source camera
  79719. * @param size This parameter can be set to a single number or to an object with the
  79720. * following (optional) properties: precision, width, height. If a single number is passed,
  79721. * it will be used for both width and height. If an object is passed, the screenshot size
  79722. * will be derived from the parameters. The precision property is a multiplier allowing
  79723. * rendering at a higher or lower resolution
  79724. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79725. * Check your browser for supported MIME types
  79726. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79727. * to the src parameter of an <img> to display it
  79728. */
  79729. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79730. /**
  79731. * Generates an image screenshot from the specified camera.
  79732. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79733. * @param engine The engine to use for rendering
  79734. * @param camera The camera to use for rendering
  79735. * @param size This parameter can be set to a single number or to an object with the
  79736. * following (optional) properties: precision, width, height. If a single number is passed,
  79737. * it will be used for both width and height. If an object is passed, the screenshot size
  79738. * will be derived from the parameters. The precision property is a multiplier allowing
  79739. * rendering at a higher or lower resolution
  79740. * @param successCallback The callback receives a single parameter which contains the
  79741. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79742. * src parameter of an <img> to display it
  79743. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79744. * Check your browser for supported MIME types
  79745. * @param samples Texture samples (default: 1)
  79746. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79747. * @param fileName A name for for the downloaded file.
  79748. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79749. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79750. */
  79751. 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;
  79752. /**
  79753. * Generates an image screenshot from the specified camera.
  79754. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79755. * @param engine The engine to use for rendering
  79756. * @param camera The camera to use for rendering
  79757. * @param size This parameter can be set to a single number or to an object with the
  79758. * following (optional) properties: precision, width, height. If a single number is passed,
  79759. * it will be used for both width and height. If an object is passed, the screenshot size
  79760. * will be derived from the parameters. The precision property is a multiplier allowing
  79761. * rendering at a higher or lower resolution
  79762. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79763. * Check your browser for supported MIME types
  79764. * @param samples Texture samples (default: 1)
  79765. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79766. * @param fileName A name for for the downloaded file.
  79767. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79768. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79769. * to the src parameter of an <img> to display it
  79770. */
  79771. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79772. /**
  79773. * Gets height and width for screenshot size
  79774. * @private
  79775. */
  79776. private static _getScreenshotSize;
  79777. }
  79778. }
  79779. declare module "babylonjs/Misc/dataReader" {
  79780. /**
  79781. * Interface for a data buffer
  79782. */
  79783. export interface IDataBuffer {
  79784. /**
  79785. * Reads bytes from the data buffer.
  79786. * @param byteOffset The byte offset to read
  79787. * @param byteLength The byte length to read
  79788. * @returns A promise that resolves when the bytes are read
  79789. */
  79790. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79791. /**
  79792. * The byte length of the buffer.
  79793. */
  79794. readonly byteLength: number;
  79795. }
  79796. /**
  79797. * Utility class for reading from a data buffer
  79798. */
  79799. export class DataReader {
  79800. /**
  79801. * The data buffer associated with this data reader.
  79802. */
  79803. readonly buffer: IDataBuffer;
  79804. /**
  79805. * The current byte offset from the beginning of the data buffer.
  79806. */
  79807. byteOffset: number;
  79808. private _dataView;
  79809. private _dataByteOffset;
  79810. /**
  79811. * Constructor
  79812. * @param buffer The buffer to read
  79813. */
  79814. constructor(buffer: IDataBuffer);
  79815. /**
  79816. * Loads the given byte length.
  79817. * @param byteLength The byte length to load
  79818. * @returns A promise that resolves when the load is complete
  79819. */
  79820. loadAsync(byteLength: number): Promise<void>;
  79821. /**
  79822. * Read a unsigned 32-bit integer from the currently loaded data range.
  79823. * @returns The 32-bit integer read
  79824. */
  79825. readUint32(): number;
  79826. /**
  79827. * Read a byte array from the currently loaded data range.
  79828. * @param byteLength The byte length to read
  79829. * @returns The byte array read
  79830. */
  79831. readUint8Array(byteLength: number): Uint8Array;
  79832. /**
  79833. * Read a string from the currently loaded data range.
  79834. * @param byteLength The byte length to read
  79835. * @returns The string read
  79836. */
  79837. readString(byteLength: number): string;
  79838. /**
  79839. * Skips the given byte length the currently loaded data range.
  79840. * @param byteLength The byte length to skip
  79841. */
  79842. skipBytes(byteLength: number): void;
  79843. }
  79844. }
  79845. declare module "babylonjs/Misc/dataStorage" {
  79846. /**
  79847. * Class for storing data to local storage if available or in-memory storage otherwise
  79848. */
  79849. export class DataStorage {
  79850. private static _Storage;
  79851. private static _GetStorage;
  79852. /**
  79853. * Reads a string from the data storage
  79854. * @param key The key to read
  79855. * @param defaultValue The value if the key doesn't exist
  79856. * @returns The string value
  79857. */
  79858. static ReadString(key: string, defaultValue: string): string;
  79859. /**
  79860. * Writes a string to the data storage
  79861. * @param key The key to write
  79862. * @param value The value to write
  79863. */
  79864. static WriteString(key: string, value: string): void;
  79865. /**
  79866. * Reads a boolean from the data storage
  79867. * @param key The key to read
  79868. * @param defaultValue The value if the key doesn't exist
  79869. * @returns The boolean value
  79870. */
  79871. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79872. /**
  79873. * Writes a boolean to the data storage
  79874. * @param key The key to write
  79875. * @param value The value to write
  79876. */
  79877. static WriteBoolean(key: string, value: boolean): void;
  79878. /**
  79879. * Reads a number from the data storage
  79880. * @param key The key to read
  79881. * @param defaultValue The value if the key doesn't exist
  79882. * @returns The number value
  79883. */
  79884. static ReadNumber(key: string, defaultValue: number): number;
  79885. /**
  79886. * Writes a number to the data storage
  79887. * @param key The key to write
  79888. * @param value The value to write
  79889. */
  79890. static WriteNumber(key: string, value: number): void;
  79891. }
  79892. }
  79893. declare module "babylonjs/Misc/sceneRecorder" {
  79894. import { Scene } from "babylonjs/scene";
  79895. /**
  79896. * Class used to record delta files between 2 scene states
  79897. */
  79898. export class SceneRecorder {
  79899. private _trackedScene;
  79900. private _savedJSON;
  79901. /**
  79902. * Track a given scene. This means the current scene state will be considered the original state
  79903. * @param scene defines the scene to track
  79904. */
  79905. track(scene: Scene): void;
  79906. /**
  79907. * Get the delta between current state and original state
  79908. * @returns a string containing the delta
  79909. */
  79910. getDelta(): any;
  79911. private _compareArray;
  79912. private _compareObjects;
  79913. private _compareCollections;
  79914. private static GetShadowGeneratorById;
  79915. /**
  79916. * Apply a given delta to a given scene
  79917. * @param deltaJSON defines the JSON containing the delta
  79918. * @param scene defines the scene to apply the delta to
  79919. */
  79920. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79921. private static _ApplyPropertiesToEntity;
  79922. private static _ApplyDeltaForEntity;
  79923. }
  79924. }
  79925. declare module "babylonjs/Misc/trajectoryClassifier" {
  79926. import { DeepImmutable, Nullable } from "babylonjs/types";
  79927. import { Vector3 } from "babylonjs/Maths/math.vector";
  79928. /**
  79929. * A 3D trajectory consisting of an order list of vectors describing a
  79930. * path of motion through 3D space.
  79931. */
  79932. export class Trajectory {
  79933. private _points;
  79934. private readonly _segmentLength;
  79935. /**
  79936. * Serialize to JSON.
  79937. * @returns serialized JSON string
  79938. */
  79939. serialize(): string;
  79940. /**
  79941. * Deserialize from JSON.
  79942. * @param json serialized JSON string
  79943. * @returns deserialized Trajectory
  79944. */
  79945. static Deserialize(json: string): Trajectory;
  79946. /**
  79947. * Create a new empty Trajectory.
  79948. * @param segmentLength radius of discretization for Trajectory points
  79949. */
  79950. constructor(segmentLength?: number);
  79951. /**
  79952. * Get the length of the Trajectory.
  79953. * @returns length of the Trajectory
  79954. */
  79955. getLength(): number;
  79956. /**
  79957. * Append a new point to the Trajectory.
  79958. * NOTE: This implementation has many allocations.
  79959. * @param point point to append to the Trajectory
  79960. */
  79961. add(point: DeepImmutable<Vector3>): void;
  79962. /**
  79963. * Create a new Trajectory with a segment length chosen to make it
  79964. * probable that the new Trajectory will have a specified number of
  79965. * segments. This operation is imprecise.
  79966. * @param targetResolution number of segments desired
  79967. * @returns new Trajectory with approximately the requested number of segments
  79968. */
  79969. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79970. /**
  79971. * Convert Trajectory segments into tokenized representation. This
  79972. * representation is an array of numbers where each nth number is the
  79973. * index of the token which is most similar to the nth segment of the
  79974. * Trajectory.
  79975. * @param tokens list of vectors which serve as discrete tokens
  79976. * @returns list of indices of most similar token per segment
  79977. */
  79978. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79979. private static _forwardDir;
  79980. private static _inverseFromVec;
  79981. private static _upDir;
  79982. private static _fromToVec;
  79983. private static _lookMatrix;
  79984. /**
  79985. * Transform the rotation (i.e., direction) of a segment to isolate
  79986. * the relative transformation represented by the segment. This operation
  79987. * may or may not succeed due to singularities in the equations that define
  79988. * motion relativity in this context.
  79989. * @param priorVec the origin of the prior segment
  79990. * @param fromVec the origin of the current segment
  79991. * @param toVec the destination of the current segment
  79992. * @param result reference to output variable
  79993. * @returns whether or not transformation was successful
  79994. */
  79995. private static _transformSegmentDirToRef;
  79996. private static _bestMatch;
  79997. private static _score;
  79998. private static _bestScore;
  79999. /**
  80000. * Determine which token vector is most similar to the
  80001. * segment vector.
  80002. * @param segment segment vector
  80003. * @param tokens token vector list
  80004. * @returns index of the most similar token to the segment
  80005. */
  80006. private static _tokenizeSegment;
  80007. }
  80008. /**
  80009. * Class representing a set of known, named trajectories to which Trajectories can be
  80010. * added and using which Trajectories can be recognized.
  80011. */
  80012. export class TrajectoryClassifier {
  80013. private _maximumAllowableMatchCost;
  80014. private _vector3Alphabet;
  80015. private _levenshteinAlphabet;
  80016. private _nameToDescribedTrajectory;
  80017. /**
  80018. * Serialize to JSON.
  80019. * @returns JSON serialization
  80020. */
  80021. serialize(): string;
  80022. /**
  80023. * Deserialize from JSON.
  80024. * @param json JSON serialization
  80025. * @returns deserialized TrajectorySet
  80026. */
  80027. static Deserialize(json: string): TrajectoryClassifier;
  80028. /**
  80029. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  80030. * VERY naive, need to be generating these things from known
  80031. * sets. Better version later, probably eliminating this one.
  80032. * @returns auto-generated TrajectorySet
  80033. */
  80034. static Generate(): TrajectoryClassifier;
  80035. private constructor();
  80036. /**
  80037. * Add a new Trajectory to the set with a given name.
  80038. * @param trajectory new Trajectory to be added
  80039. * @param classification name to which to add the Trajectory
  80040. */
  80041. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  80042. /**
  80043. * Remove a known named trajectory and all Trajectories associated with it.
  80044. * @param classification name to remove
  80045. * @returns whether anything was removed
  80046. */
  80047. deleteClassification(classification: string): boolean;
  80048. /**
  80049. * Attempt to recognize a Trajectory from among all the classifications
  80050. * already known to the classifier.
  80051. * @param trajectory Trajectory to be recognized
  80052. * @returns classification of Trajectory if recognized, null otherwise
  80053. */
  80054. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  80055. }
  80056. }
  80057. declare module "babylonjs/Misc/index" {
  80058. export * from "babylonjs/Misc/andOrNotEvaluator";
  80059. export * from "babylonjs/Misc/assetsManager";
  80060. export * from "babylonjs/Misc/basis";
  80061. export * from "babylonjs/Misc/dds";
  80062. export * from "babylonjs/Misc/decorators";
  80063. export * from "babylonjs/Misc/deferred";
  80064. export * from "babylonjs/Misc/environmentTextureTools";
  80065. export * from "babylonjs/Misc/meshExploder";
  80066. export * from "babylonjs/Misc/filesInput";
  80067. export * from "babylonjs/Misc/HighDynamicRange/index";
  80068. export * from "babylonjs/Misc/khronosTextureContainer";
  80069. export * from "babylonjs/Misc/observable";
  80070. export * from "babylonjs/Misc/performanceMonitor";
  80071. export * from "babylonjs/Misc/promise";
  80072. export * from "babylonjs/Misc/sceneOptimizer";
  80073. export * from "babylonjs/Misc/sceneSerializer";
  80074. export * from "babylonjs/Misc/smartArray";
  80075. export * from "babylonjs/Misc/stringDictionary";
  80076. export * from "babylonjs/Misc/tags";
  80077. export * from "babylonjs/Misc/textureTools";
  80078. export * from "babylonjs/Misc/tga";
  80079. export * from "babylonjs/Misc/tools";
  80080. export * from "babylonjs/Misc/videoRecorder";
  80081. export * from "babylonjs/Misc/virtualJoystick";
  80082. export * from "babylonjs/Misc/workerPool";
  80083. export * from "babylonjs/Misc/logger";
  80084. export * from "babylonjs/Misc/typeStore";
  80085. export * from "babylonjs/Misc/filesInputStore";
  80086. export * from "babylonjs/Misc/deepCopier";
  80087. export * from "babylonjs/Misc/pivotTools";
  80088. export * from "babylonjs/Misc/precisionDate";
  80089. export * from "babylonjs/Misc/screenshotTools";
  80090. export * from "babylonjs/Misc/typeStore";
  80091. export * from "babylonjs/Misc/webRequest";
  80092. export * from "babylonjs/Misc/iInspectable";
  80093. export * from "babylonjs/Misc/brdfTextureTools";
  80094. export * from "babylonjs/Misc/rgbdTextureTools";
  80095. export * from "babylonjs/Misc/gradients";
  80096. export * from "babylonjs/Misc/perfCounter";
  80097. export * from "babylonjs/Misc/fileRequest";
  80098. export * from "babylonjs/Misc/customAnimationFrameRequester";
  80099. export * from "babylonjs/Misc/retryStrategy";
  80100. export * from "babylonjs/Misc/interfaces/screenshotSize";
  80101. export * from "babylonjs/Misc/canvasGenerator";
  80102. export * from "babylonjs/Misc/fileTools";
  80103. export * from "babylonjs/Misc/stringTools";
  80104. export * from "babylonjs/Misc/dataReader";
  80105. export * from "babylonjs/Misc/minMaxReducer";
  80106. export * from "babylonjs/Misc/depthReducer";
  80107. export * from "babylonjs/Misc/dataStorage";
  80108. export * from "babylonjs/Misc/sceneRecorder";
  80109. export * from "babylonjs/Misc/khronosTextureContainer2";
  80110. export * from "babylonjs/Misc/trajectoryClassifier";
  80111. export * from "babylonjs/Misc/timer";
  80112. export * from "babylonjs/Misc/copyTools";
  80113. }
  80114. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  80115. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  80116. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80117. import { Observable } from "babylonjs/Misc/observable";
  80118. import { Matrix } from "babylonjs/Maths/math.vector";
  80119. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80120. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80121. /**
  80122. * An interface for all Hit test features
  80123. */
  80124. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  80125. /**
  80126. * Triggered when new babylon (transformed) hit test results are available
  80127. */
  80128. onHitTestResultObservable: Observable<T[]>;
  80129. }
  80130. /**
  80131. * Options used for hit testing
  80132. */
  80133. export interface IWebXRLegacyHitTestOptions {
  80134. /**
  80135. * Only test when user interacted with the scene. Default - hit test every frame
  80136. */
  80137. testOnPointerDownOnly?: boolean;
  80138. /**
  80139. * The node to use to transform the local results to world coordinates
  80140. */
  80141. worldParentNode?: TransformNode;
  80142. }
  80143. /**
  80144. * Interface defining the babylon result of raycasting/hit-test
  80145. */
  80146. export interface IWebXRLegacyHitResult {
  80147. /**
  80148. * Transformation matrix that can be applied to a node that will put it in the hit point location
  80149. */
  80150. transformationMatrix: Matrix;
  80151. /**
  80152. * The native hit test result
  80153. */
  80154. xrHitResult: XRHitResult | XRHitTestResult;
  80155. }
  80156. /**
  80157. * The currently-working hit-test module.
  80158. * Hit test (or Ray-casting) is used to interact with the real world.
  80159. * For further information read here - https://github.com/immersive-web/hit-test
  80160. */
  80161. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  80162. /**
  80163. * options to use when constructing this feature
  80164. */
  80165. readonly options: IWebXRLegacyHitTestOptions;
  80166. private _direction;
  80167. private _mat;
  80168. private _onSelectEnabled;
  80169. private _origin;
  80170. /**
  80171. * The module's name
  80172. */
  80173. static readonly Name: string;
  80174. /**
  80175. * The (Babylon) version of this module.
  80176. * This is an integer representing the implementation version.
  80177. * This number does not correspond to the WebXR specs version
  80178. */
  80179. static readonly Version: number;
  80180. /**
  80181. * Populated with the last native XR Hit Results
  80182. */
  80183. lastNativeXRHitResults: XRHitResult[];
  80184. /**
  80185. * Triggered when new babylon (transformed) hit test results are available
  80186. */
  80187. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  80188. /**
  80189. * Creates a new instance of the (legacy version) hit test feature
  80190. * @param _xrSessionManager an instance of WebXRSessionManager
  80191. * @param options options to use when constructing this feature
  80192. */
  80193. constructor(_xrSessionManager: WebXRSessionManager,
  80194. /**
  80195. * options to use when constructing this feature
  80196. */
  80197. options?: IWebXRLegacyHitTestOptions);
  80198. /**
  80199. * execute a hit test with an XR Ray
  80200. *
  80201. * @param xrSession a native xrSession that will execute this hit test
  80202. * @param xrRay the ray (position and direction) to use for ray-casting
  80203. * @param referenceSpace native XR reference space to use for the hit-test
  80204. * @param filter filter function that will filter the results
  80205. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  80206. */
  80207. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  80208. /**
  80209. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  80210. * @param event the (select) event to use to select with
  80211. * @param referenceSpace the reference space to use for this hit test
  80212. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  80213. */
  80214. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  80215. /**
  80216. * attach this feature
  80217. * Will usually be called by the features manager
  80218. *
  80219. * @returns true if successful.
  80220. */
  80221. attach(): boolean;
  80222. /**
  80223. * detach this feature.
  80224. * Will usually be called by the features manager
  80225. *
  80226. * @returns true if successful.
  80227. */
  80228. detach(): boolean;
  80229. /**
  80230. * Dispose this feature and all of the resources attached
  80231. */
  80232. dispose(): void;
  80233. protected _onXRFrame(frame: XRFrame): void;
  80234. private _onHitTestResults;
  80235. private _onSelect;
  80236. }
  80237. }
  80238. declare module "babylonjs/XR/features/WebXRHitTest" {
  80239. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80240. import { Observable } from "babylonjs/Misc/observable";
  80241. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80242. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80243. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  80244. /**
  80245. * Options used for hit testing (version 2)
  80246. */
  80247. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  80248. /**
  80249. * Do not create a permanent hit test. Will usually be used when only
  80250. * transient inputs are needed.
  80251. */
  80252. disablePermanentHitTest?: boolean;
  80253. /**
  80254. * Enable transient (for example touch-based) hit test inspections
  80255. */
  80256. enableTransientHitTest?: boolean;
  80257. /**
  80258. * Offset ray for the permanent hit test
  80259. */
  80260. offsetRay?: Vector3;
  80261. /**
  80262. * Offset ray for the transient hit test
  80263. */
  80264. transientOffsetRay?: Vector3;
  80265. /**
  80266. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  80267. */
  80268. useReferenceSpace?: boolean;
  80269. /**
  80270. * Override the default entity type(s) of the hit-test result
  80271. */
  80272. entityTypes?: XRHitTestTrackableType[];
  80273. }
  80274. /**
  80275. * Interface defining the babylon result of hit-test
  80276. */
  80277. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  80278. /**
  80279. * The input source that generated this hit test (if transient)
  80280. */
  80281. inputSource?: XRInputSource;
  80282. /**
  80283. * Is this a transient hit test
  80284. */
  80285. isTransient?: boolean;
  80286. /**
  80287. * Position of the hit test result
  80288. */
  80289. position: Vector3;
  80290. /**
  80291. * Rotation of the hit test result
  80292. */
  80293. rotationQuaternion: Quaternion;
  80294. /**
  80295. * The native hit test result
  80296. */
  80297. xrHitResult: XRHitTestResult;
  80298. }
  80299. /**
  80300. * The currently-working hit-test module.
  80301. * Hit test (or Ray-casting) is used to interact with the real world.
  80302. * For further information read here - https://github.com/immersive-web/hit-test
  80303. *
  80304. * Tested on chrome (mobile) 80.
  80305. */
  80306. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  80307. /**
  80308. * options to use when constructing this feature
  80309. */
  80310. readonly options: IWebXRHitTestOptions;
  80311. private _tmpMat;
  80312. private _tmpPos;
  80313. private _tmpQuat;
  80314. private _transientXrHitTestSource;
  80315. private _xrHitTestSource;
  80316. private initHitTestSource;
  80317. /**
  80318. * The module's name
  80319. */
  80320. static readonly Name: string;
  80321. /**
  80322. * The (Babylon) version of this module.
  80323. * This is an integer representing the implementation version.
  80324. * This number does not correspond to the WebXR specs version
  80325. */
  80326. static readonly Version: number;
  80327. /**
  80328. * When set to true, each hit test will have its own position/rotation objects
  80329. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  80330. * the developers will clone them or copy them as they see fit.
  80331. */
  80332. autoCloneTransformation: boolean;
  80333. /**
  80334. * Triggered when new babylon (transformed) hit test results are available
  80335. * Note - this will be called when results come back from the device. It can be an empty array!!
  80336. */
  80337. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  80338. /**
  80339. * Use this to temporarily pause hit test checks.
  80340. */
  80341. paused: boolean;
  80342. /**
  80343. * Creates a new instance of the hit test feature
  80344. * @param _xrSessionManager an instance of WebXRSessionManager
  80345. * @param options options to use when constructing this feature
  80346. */
  80347. constructor(_xrSessionManager: WebXRSessionManager,
  80348. /**
  80349. * options to use when constructing this feature
  80350. */
  80351. options?: IWebXRHitTestOptions);
  80352. /**
  80353. * attach this feature
  80354. * Will usually be called by the features manager
  80355. *
  80356. * @returns true if successful.
  80357. */
  80358. attach(): boolean;
  80359. /**
  80360. * detach this feature.
  80361. * Will usually be called by the features manager
  80362. *
  80363. * @returns true if successful.
  80364. */
  80365. detach(): boolean;
  80366. /**
  80367. * Dispose this feature and all of the resources attached
  80368. */
  80369. dispose(): void;
  80370. protected _onXRFrame(frame: XRFrame): void;
  80371. private _processWebXRHitTestResult;
  80372. }
  80373. }
  80374. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  80375. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80376. import { Observable } from "babylonjs/Misc/observable";
  80377. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80378. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80379. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80380. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  80381. /**
  80382. * Configuration options of the anchor system
  80383. */
  80384. export interface IWebXRAnchorSystemOptions {
  80385. /**
  80386. * a node that will be used to convert local to world coordinates
  80387. */
  80388. worldParentNode?: TransformNode;
  80389. /**
  80390. * If set to true a reference of the created anchors will be kept until the next session starts
  80391. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  80392. */
  80393. doNotRemoveAnchorsOnSessionEnded?: boolean;
  80394. }
  80395. /**
  80396. * A babylon container for an XR Anchor
  80397. */
  80398. export interface IWebXRAnchor {
  80399. /**
  80400. * A babylon-assigned ID for this anchor
  80401. */
  80402. id: number;
  80403. /**
  80404. * Transformation matrix to apply to an object attached to this anchor
  80405. */
  80406. transformationMatrix: Matrix;
  80407. /**
  80408. * The native anchor object
  80409. */
  80410. xrAnchor: XRAnchor;
  80411. /**
  80412. * if defined, this object will be constantly updated by the anchor's position and rotation
  80413. */
  80414. attachedNode?: TransformNode;
  80415. /**
  80416. * Remove this anchor from the scene
  80417. */
  80418. remove(): void;
  80419. }
  80420. /**
  80421. * An implementation of the anchor system for WebXR.
  80422. * For further information see https://github.com/immersive-web/anchors/
  80423. */
  80424. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  80425. private _options;
  80426. private _lastFrameDetected;
  80427. private _trackedAnchors;
  80428. private _referenceSpaceForFrameAnchors;
  80429. private _futureAnchors;
  80430. /**
  80431. * The module's name
  80432. */
  80433. static readonly Name: string;
  80434. /**
  80435. * The (Babylon) version of this module.
  80436. * This is an integer representing the implementation version.
  80437. * This number does not correspond to the WebXR specs version
  80438. */
  80439. static readonly Version: number;
  80440. /**
  80441. * Observers registered here will be executed when a new anchor was added to the session
  80442. */
  80443. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  80444. /**
  80445. * Observers registered here will be executed when an anchor was removed from the session
  80446. */
  80447. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  80448. /**
  80449. * Observers registered here will be executed when an existing anchor updates
  80450. * This can execute N times every frame
  80451. */
  80452. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  80453. /**
  80454. * Set the reference space to use for anchor creation, when not using a hit test.
  80455. * Will default to the session's reference space if not defined
  80456. */
  80457. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  80458. /**
  80459. * constructs a new anchor system
  80460. * @param _xrSessionManager an instance of WebXRSessionManager
  80461. * @param _options configuration object for this feature
  80462. */
  80463. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  80464. private _tmpVector;
  80465. private _tmpQuaternion;
  80466. private _populateTmpTransformation;
  80467. /**
  80468. * Create a new anchor point using a hit test result at a specific point in the scene
  80469. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80470. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80471. *
  80472. * @param hitTestResult The hit test result to use for this anchor creation
  80473. * @param position an optional position offset for this anchor
  80474. * @param rotationQuaternion an optional rotation offset for this anchor
  80475. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80476. */
  80477. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  80478. /**
  80479. * Add a new anchor at a specific position and rotation
  80480. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  80481. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  80482. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80483. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80484. *
  80485. * @param position the position in which to add an anchor
  80486. * @param rotationQuaternion an optional rotation for the anchor transformation
  80487. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  80488. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80489. */
  80490. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  80491. /**
  80492. * Get the list of anchors currently being tracked by the system
  80493. */
  80494. get anchors(): IWebXRAnchor[];
  80495. /**
  80496. * detach this feature.
  80497. * Will usually be called by the features manager
  80498. *
  80499. * @returns true if successful.
  80500. */
  80501. detach(): boolean;
  80502. /**
  80503. * Dispose this feature and all of the resources attached
  80504. */
  80505. dispose(): void;
  80506. protected _onXRFrame(frame: XRFrame): void;
  80507. /**
  80508. * avoiding using Array.find for global support.
  80509. * @param xrAnchor the plane to find in the array
  80510. */
  80511. private _findIndexInAnchorArray;
  80512. private _updateAnchorWithXRFrame;
  80513. private _createAnchorAtTransformation;
  80514. }
  80515. }
  80516. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  80517. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80518. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80519. import { Observable } from "babylonjs/Misc/observable";
  80520. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  80521. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80522. /**
  80523. * Options used in the plane detector module
  80524. */
  80525. export interface IWebXRPlaneDetectorOptions {
  80526. /**
  80527. * The node to use to transform the local results to world coordinates
  80528. */
  80529. worldParentNode?: TransformNode;
  80530. /**
  80531. * If set to true a reference of the created planes will be kept until the next session starts
  80532. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  80533. */
  80534. doNotRemovePlanesOnSessionEnded?: boolean;
  80535. }
  80536. /**
  80537. * A babylon interface for a WebXR plane.
  80538. * A Plane is actually a polygon, built from N points in space
  80539. *
  80540. * Supported in chrome 79, not supported in canary 81 ATM
  80541. */
  80542. export interface IWebXRPlane {
  80543. /**
  80544. * a babylon-assigned ID for this polygon
  80545. */
  80546. id: number;
  80547. /**
  80548. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  80549. */
  80550. polygonDefinition: Array<Vector3>;
  80551. /**
  80552. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  80553. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  80554. */
  80555. transformationMatrix: Matrix;
  80556. /**
  80557. * the native xr-plane object
  80558. */
  80559. xrPlane: XRPlane;
  80560. }
  80561. /**
  80562. * The plane detector is used to detect planes in the real world when in AR
  80563. * For more information see https://github.com/immersive-web/real-world-geometry/
  80564. */
  80565. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  80566. private _options;
  80567. private _detectedPlanes;
  80568. private _enabled;
  80569. private _lastFrameDetected;
  80570. /**
  80571. * The module's name
  80572. */
  80573. static readonly Name: string;
  80574. /**
  80575. * The (Babylon) version of this module.
  80576. * This is an integer representing the implementation version.
  80577. * This number does not correspond to the WebXR specs version
  80578. */
  80579. static readonly Version: number;
  80580. /**
  80581. * Observers registered here will be executed when a new plane was added to the session
  80582. */
  80583. onPlaneAddedObservable: Observable<IWebXRPlane>;
  80584. /**
  80585. * Observers registered here will be executed when a plane is no longer detected in the session
  80586. */
  80587. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  80588. /**
  80589. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  80590. * This can execute N times every frame
  80591. */
  80592. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  80593. /**
  80594. * construct a new Plane Detector
  80595. * @param _xrSessionManager an instance of xr Session manager
  80596. * @param _options configuration to use when constructing this feature
  80597. */
  80598. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  80599. /**
  80600. * detach this feature.
  80601. * Will usually be called by the features manager
  80602. *
  80603. * @returns true if successful.
  80604. */
  80605. detach(): boolean;
  80606. /**
  80607. * Dispose this feature and all of the resources attached
  80608. */
  80609. dispose(): void;
  80610. /**
  80611. * Check if the needed objects are defined.
  80612. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80613. */
  80614. isCompatible(): boolean;
  80615. protected _onXRFrame(frame: XRFrame): void;
  80616. private _init;
  80617. private _updatePlaneWithXRPlane;
  80618. /**
  80619. * avoiding using Array.find for global support.
  80620. * @param xrPlane the plane to find in the array
  80621. */
  80622. private findIndexInPlaneArray;
  80623. }
  80624. }
  80625. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  80626. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80628. import { Observable } from "babylonjs/Misc/observable";
  80629. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80630. /**
  80631. * Options interface for the background remover plugin
  80632. */
  80633. export interface IWebXRBackgroundRemoverOptions {
  80634. /**
  80635. * Further background meshes to disable when entering AR
  80636. */
  80637. backgroundMeshes?: AbstractMesh[];
  80638. /**
  80639. * flags to configure the removal of the environment helper.
  80640. * If not set, the entire background will be removed. If set, flags should be set as well.
  80641. */
  80642. environmentHelperRemovalFlags?: {
  80643. /**
  80644. * Should the skybox be removed (default false)
  80645. */
  80646. skyBox?: boolean;
  80647. /**
  80648. * Should the ground be removed (default false)
  80649. */
  80650. ground?: boolean;
  80651. };
  80652. /**
  80653. * don't disable the environment helper
  80654. */
  80655. ignoreEnvironmentHelper?: boolean;
  80656. }
  80657. /**
  80658. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  80659. */
  80660. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  80661. /**
  80662. * read-only options to be used in this module
  80663. */
  80664. readonly options: IWebXRBackgroundRemoverOptions;
  80665. /**
  80666. * The module's name
  80667. */
  80668. static readonly Name: string;
  80669. /**
  80670. * The (Babylon) version of this module.
  80671. * This is an integer representing the implementation version.
  80672. * This number does not correspond to the WebXR specs version
  80673. */
  80674. static readonly Version: number;
  80675. /**
  80676. * registered observers will be triggered when the background state changes
  80677. */
  80678. onBackgroundStateChangedObservable: Observable<boolean>;
  80679. /**
  80680. * constructs a new background remover module
  80681. * @param _xrSessionManager the session manager for this module
  80682. * @param options read-only options to be used in this module
  80683. */
  80684. constructor(_xrSessionManager: WebXRSessionManager,
  80685. /**
  80686. * read-only options to be used in this module
  80687. */
  80688. options?: IWebXRBackgroundRemoverOptions);
  80689. /**
  80690. * attach this feature
  80691. * Will usually be called by the features manager
  80692. *
  80693. * @returns true if successful.
  80694. */
  80695. attach(): boolean;
  80696. /**
  80697. * detach this feature.
  80698. * Will usually be called by the features manager
  80699. *
  80700. * @returns true if successful.
  80701. */
  80702. detach(): boolean;
  80703. /**
  80704. * Dispose this feature and all of the resources attached
  80705. */
  80706. dispose(): void;
  80707. protected _onXRFrame(_xrFrame: XRFrame): void;
  80708. private _setBackgroundState;
  80709. }
  80710. }
  80711. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  80712. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80713. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80714. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  80715. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80716. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80717. import { Nullable } from "babylonjs/types";
  80718. /**
  80719. * Options for the controller physics feature
  80720. */
  80721. export class IWebXRControllerPhysicsOptions {
  80722. /**
  80723. * Should the headset get its own impostor
  80724. */
  80725. enableHeadsetImpostor?: boolean;
  80726. /**
  80727. * Optional parameters for the headset impostor
  80728. */
  80729. headsetImpostorParams?: {
  80730. /**
  80731. * The type of impostor to create. Default is sphere
  80732. */
  80733. impostorType: number;
  80734. /**
  80735. * the size of the impostor. Defaults to 10cm
  80736. */
  80737. impostorSize?: number | {
  80738. width: number;
  80739. height: number;
  80740. depth: number;
  80741. };
  80742. /**
  80743. * Friction definitions
  80744. */
  80745. friction?: number;
  80746. /**
  80747. * Restitution
  80748. */
  80749. restitution?: number;
  80750. };
  80751. /**
  80752. * The physics properties of the future impostors
  80753. */
  80754. physicsProperties?: {
  80755. /**
  80756. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80757. * Note that this requires a physics engine that supports mesh impostors!
  80758. */
  80759. useControllerMesh?: boolean;
  80760. /**
  80761. * The type of impostor to create. Default is sphere
  80762. */
  80763. impostorType?: number;
  80764. /**
  80765. * the size of the impostor. Defaults to 10cm
  80766. */
  80767. impostorSize?: number | {
  80768. width: number;
  80769. height: number;
  80770. depth: number;
  80771. };
  80772. /**
  80773. * Friction definitions
  80774. */
  80775. friction?: number;
  80776. /**
  80777. * Restitution
  80778. */
  80779. restitution?: number;
  80780. };
  80781. /**
  80782. * the xr input to use with this pointer selection
  80783. */
  80784. xrInput: WebXRInput;
  80785. }
  80786. /**
  80787. * Add physics impostor to your webxr controllers,
  80788. * including naive calculation of their linear and angular velocity
  80789. */
  80790. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80791. private readonly _options;
  80792. private _attachController;
  80793. private _controllers;
  80794. private _debugMode;
  80795. private _delta;
  80796. private _headsetImpostor?;
  80797. private _headsetMesh?;
  80798. private _lastTimestamp;
  80799. private _tmpQuaternion;
  80800. private _tmpVector;
  80801. /**
  80802. * The module's name
  80803. */
  80804. static readonly Name: string;
  80805. /**
  80806. * The (Babylon) version of this module.
  80807. * This is an integer representing the implementation version.
  80808. * This number does not correspond to the webxr specs version
  80809. */
  80810. static readonly Version: number;
  80811. /**
  80812. * Construct a new Controller Physics Feature
  80813. * @param _xrSessionManager the corresponding xr session manager
  80814. * @param _options options to create this feature with
  80815. */
  80816. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80817. /**
  80818. * @hidden
  80819. * enable debugging - will show console outputs and the impostor mesh
  80820. */
  80821. _enablePhysicsDebug(): void;
  80822. /**
  80823. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80824. * @param xrController the controller to add
  80825. */
  80826. addController(xrController: WebXRInputSource): void;
  80827. /**
  80828. * attach this feature
  80829. * Will usually be called by the features manager
  80830. *
  80831. * @returns true if successful.
  80832. */
  80833. attach(): boolean;
  80834. /**
  80835. * detach this feature.
  80836. * Will usually be called by the features manager
  80837. *
  80838. * @returns true if successful.
  80839. */
  80840. detach(): boolean;
  80841. /**
  80842. * Get the headset impostor, if enabled
  80843. * @returns the impostor
  80844. */
  80845. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80846. /**
  80847. * Get the physics impostor of a specific controller.
  80848. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80849. * @param controller the controller or the controller id of which to get the impostor
  80850. * @returns the impostor or null
  80851. */
  80852. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80853. /**
  80854. * Update the physics properties provided in the constructor
  80855. * @param newProperties the new properties object
  80856. */
  80857. setPhysicsProperties(newProperties: {
  80858. impostorType?: number;
  80859. impostorSize?: number | {
  80860. width: number;
  80861. height: number;
  80862. depth: number;
  80863. };
  80864. friction?: number;
  80865. restitution?: number;
  80866. }): void;
  80867. protected _onXRFrame(_xrFrame: any): void;
  80868. private _detachController;
  80869. }
  80870. }
  80871. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  80872. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80873. import { Observable } from "babylonjs/Misc/observable";
  80874. import { Vector3 } from "babylonjs/Maths/math.vector";
  80875. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80876. /**
  80877. * A babylon interface for a "WebXR" feature point.
  80878. * Represents the position and confidence value of a given feature point.
  80879. */
  80880. export interface IWebXRFeaturePoint {
  80881. /**
  80882. * Represents the position of the feature point in world space.
  80883. */
  80884. position: Vector3;
  80885. /**
  80886. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80887. */
  80888. confidenceValue: number;
  80889. }
  80890. /**
  80891. * The feature point system is used to detect feature points from real world geometry.
  80892. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80893. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80894. */
  80895. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80896. private _enabled;
  80897. private _featurePointCloud;
  80898. /**
  80899. * The module's name
  80900. */
  80901. static readonly Name: string;
  80902. /**
  80903. * The (Babylon) version of this module.
  80904. * This is an integer representing the implementation version.
  80905. * This number does not correspond to the WebXR specs version
  80906. */
  80907. static readonly Version: number;
  80908. /**
  80909. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80910. * Will notify the observers about which feature points have been added.
  80911. */
  80912. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80913. /**
  80914. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80915. * Will notify the observers about which feature points have been updated.
  80916. */
  80917. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80918. /**
  80919. * The current feature point cloud maintained across frames.
  80920. */
  80921. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80922. /**
  80923. * construct the feature point system
  80924. * @param _xrSessionManager an instance of xr Session manager
  80925. */
  80926. constructor(_xrSessionManager: WebXRSessionManager);
  80927. /**
  80928. * Detach this feature.
  80929. * Will usually be called by the features manager
  80930. *
  80931. * @returns true if successful.
  80932. */
  80933. detach(): boolean;
  80934. /**
  80935. * Dispose this feature and all of the resources attached
  80936. */
  80937. dispose(): void;
  80938. /**
  80939. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80940. */
  80941. protected _onXRFrame(frame: XRFrame): void;
  80942. /**
  80943. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80944. */
  80945. private _init;
  80946. }
  80947. }
  80948. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80949. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80950. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80952. import { Mesh } from "babylonjs/Meshes/mesh";
  80953. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80954. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80955. import { Nullable } from "babylonjs/types";
  80956. import { IDisposable } from "babylonjs/scene";
  80957. import { Observable } from "babylonjs/Misc/observable";
  80958. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80959. /**
  80960. * Configuration interface for the hand tracking feature
  80961. */
  80962. export interface IWebXRHandTrackingOptions {
  80963. /**
  80964. * The xrInput that will be used as source for new hands
  80965. */
  80966. xrInput: WebXRInput;
  80967. /**
  80968. * Configuration object for the joint meshes
  80969. */
  80970. jointMeshes?: {
  80971. /**
  80972. * Should the meshes created be invisible (defaults to false)
  80973. */
  80974. invisible?: boolean;
  80975. /**
  80976. * A source mesh to be used to create instances. Defaults to a sphere.
  80977. * This mesh will be the source for all other (25) meshes.
  80978. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80979. */
  80980. sourceMesh?: Mesh;
  80981. /**
  80982. * This function will be called after a mesh was created for a specific joint.
  80983. * Using this function you can either manipulate the instance or return a new mesh.
  80984. * When returning a new mesh the instance created before will be disposed
  80985. */
  80986. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80987. /**
  80988. * Should the source mesh stay visible. Defaults to false
  80989. */
  80990. keepOriginalVisible?: boolean;
  80991. /**
  80992. * Scale factor for all instances (defaults to 2)
  80993. */
  80994. scaleFactor?: number;
  80995. /**
  80996. * Should each instance have its own physics impostor
  80997. */
  80998. enablePhysics?: boolean;
  80999. /**
  81000. * If enabled, override default physics properties
  81001. */
  81002. physicsProps?: {
  81003. friction?: number;
  81004. restitution?: number;
  81005. impostorType?: number;
  81006. };
  81007. /**
  81008. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  81009. */
  81010. handMesh?: AbstractMesh;
  81011. };
  81012. }
  81013. /**
  81014. * Parts of the hands divided to writs and finger names
  81015. */
  81016. export const enum HandPart {
  81017. /**
  81018. * HandPart - Wrist
  81019. */
  81020. WRIST = "wrist",
  81021. /**
  81022. * HandPart - The THumb
  81023. */
  81024. THUMB = "thumb",
  81025. /**
  81026. * HandPart - Index finger
  81027. */
  81028. INDEX = "index",
  81029. /**
  81030. * HandPart - Middle finger
  81031. */
  81032. MIDDLE = "middle",
  81033. /**
  81034. * HandPart - Ring finger
  81035. */
  81036. RING = "ring",
  81037. /**
  81038. * HandPart - Little finger
  81039. */
  81040. LITTLE = "little"
  81041. }
  81042. /**
  81043. * Representing a single hand (with its corresponding native XRHand object)
  81044. */
  81045. export class WebXRHand implements IDisposable {
  81046. /** the controller to which the hand correlates */
  81047. readonly xrController: WebXRInputSource;
  81048. /** the meshes to be used to track the hand joints */
  81049. readonly trackedMeshes: AbstractMesh[];
  81050. /**
  81051. * Hand-parts definition (key is HandPart)
  81052. */
  81053. handPartsDefinition: {
  81054. [key: string]: number[];
  81055. };
  81056. /**
  81057. * Populate the HandPartsDefinition object.
  81058. * This is called as a side effect since certain browsers don't have XRHand defined.
  81059. */
  81060. private generateHandPartsDefinition;
  81061. /**
  81062. * Construct a new hand object
  81063. * @param xrController the controller to which the hand correlates
  81064. * @param trackedMeshes the meshes to be used to track the hand joints
  81065. */
  81066. constructor(
  81067. /** the controller to which the hand correlates */
  81068. xrController: WebXRInputSource,
  81069. /** the meshes to be used to track the hand joints */
  81070. trackedMeshes: AbstractMesh[]);
  81071. /**
  81072. * Update this hand from the latest xr frame
  81073. * @param xrFrame xrFrame to update from
  81074. * @param referenceSpace The current viewer reference space
  81075. * @param scaleFactor optional scale factor for the meshes
  81076. */
  81077. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  81078. /**
  81079. * Get meshes of part of the hand
  81080. * @param part the part of hand to get
  81081. * @returns An array of meshes that correlate to the hand part requested
  81082. */
  81083. getHandPartMeshes(part: HandPart): AbstractMesh[];
  81084. /**
  81085. * Dispose this Hand object
  81086. */
  81087. dispose(): void;
  81088. }
  81089. /**
  81090. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  81091. */
  81092. export class WebXRHandTracking extends WebXRAbstractFeature {
  81093. /**
  81094. * options to use when constructing this feature
  81095. */
  81096. readonly options: IWebXRHandTrackingOptions;
  81097. private static _idCounter;
  81098. /**
  81099. * The module's name
  81100. */
  81101. static readonly Name: string;
  81102. /**
  81103. * The (Babylon) version of this module.
  81104. * This is an integer representing the implementation version.
  81105. * This number does not correspond to the WebXR specs version
  81106. */
  81107. static readonly Version: number;
  81108. /**
  81109. * This observable will notify registered observers when a new hand object was added and initialized
  81110. */
  81111. onHandAddedObservable: Observable<WebXRHand>;
  81112. /**
  81113. * This observable will notify its observers right before the hand object is disposed
  81114. */
  81115. onHandRemovedObservable: Observable<WebXRHand>;
  81116. private _hands;
  81117. /**
  81118. * Creates a new instance of the hit test feature
  81119. * @param _xrSessionManager an instance of WebXRSessionManager
  81120. * @param options options to use when constructing this feature
  81121. */
  81122. constructor(_xrSessionManager: WebXRSessionManager,
  81123. /**
  81124. * options to use when constructing this feature
  81125. */
  81126. options: IWebXRHandTrackingOptions);
  81127. /**
  81128. * Check if the needed objects are defined.
  81129. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  81130. */
  81131. isCompatible(): boolean;
  81132. /**
  81133. * attach this feature
  81134. * Will usually be called by the features manager
  81135. *
  81136. * @returns true if successful.
  81137. */
  81138. attach(): boolean;
  81139. /**
  81140. * detach this feature.
  81141. * Will usually be called by the features manager
  81142. *
  81143. * @returns true if successful.
  81144. */
  81145. detach(): boolean;
  81146. /**
  81147. * Dispose this feature and all of the resources attached
  81148. */
  81149. dispose(): void;
  81150. /**
  81151. * Get the hand object according to the controller id
  81152. * @param controllerId the controller id to which we want to get the hand
  81153. * @returns null if not found or the WebXRHand object if found
  81154. */
  81155. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  81156. /**
  81157. * Get a hand object according to the requested handedness
  81158. * @param handedness the handedness to request
  81159. * @returns null if not found or the WebXRHand object if found
  81160. */
  81161. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  81162. protected _onXRFrame(_xrFrame: XRFrame): void;
  81163. private _attachHand;
  81164. private _detachHand;
  81165. }
  81166. }
  81167. declare module "babylonjs/XR/features/index" {
  81168. export * from "babylonjs/XR/features/WebXRAbstractFeature";
  81169. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  81170. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  81171. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  81172. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  81173. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  81174. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  81175. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  81176. export * from "babylonjs/XR/features/WebXRHitTest";
  81177. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  81178. export * from "babylonjs/XR/features/WebXRHandTracking";
  81179. }
  81180. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  81181. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81183. import { Scene } from "babylonjs/scene";
  81184. /**
  81185. * The motion controller class for all microsoft mixed reality controllers
  81186. */
  81187. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  81188. protected readonly _mapping: {
  81189. defaultButton: {
  81190. valueNodeName: string;
  81191. unpressedNodeName: string;
  81192. pressedNodeName: string;
  81193. };
  81194. defaultAxis: {
  81195. valueNodeName: string;
  81196. minNodeName: string;
  81197. maxNodeName: string;
  81198. };
  81199. buttons: {
  81200. "xr-standard-trigger": {
  81201. rootNodeName: string;
  81202. componentProperty: string;
  81203. states: string[];
  81204. };
  81205. "xr-standard-squeeze": {
  81206. rootNodeName: string;
  81207. componentProperty: string;
  81208. states: string[];
  81209. };
  81210. "xr-standard-touchpad": {
  81211. rootNodeName: string;
  81212. labelAnchorNodeName: string;
  81213. touchPointNodeName: string;
  81214. };
  81215. "xr-standard-thumbstick": {
  81216. rootNodeName: string;
  81217. componentProperty: string;
  81218. states: string[];
  81219. };
  81220. };
  81221. axes: {
  81222. "xr-standard-touchpad": {
  81223. "x-axis": {
  81224. rootNodeName: string;
  81225. };
  81226. "y-axis": {
  81227. rootNodeName: string;
  81228. };
  81229. };
  81230. "xr-standard-thumbstick": {
  81231. "x-axis": {
  81232. rootNodeName: string;
  81233. };
  81234. "y-axis": {
  81235. rootNodeName: string;
  81236. };
  81237. };
  81238. };
  81239. };
  81240. /**
  81241. * The base url used to load the left and right controller models
  81242. */
  81243. static MODEL_BASE_URL: string;
  81244. /**
  81245. * The name of the left controller model file
  81246. */
  81247. static MODEL_LEFT_FILENAME: string;
  81248. /**
  81249. * The name of the right controller model file
  81250. */
  81251. static MODEL_RIGHT_FILENAME: string;
  81252. profileId: string;
  81253. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81254. protected _getFilenameAndPath(): {
  81255. filename: string;
  81256. path: string;
  81257. };
  81258. protected _getModelLoadingConstraints(): boolean;
  81259. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81260. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81261. protected _updateModel(): void;
  81262. }
  81263. }
  81264. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  81265. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81267. import { Scene } from "babylonjs/scene";
  81268. /**
  81269. * The motion controller class for oculus touch (quest, rift).
  81270. * This class supports legacy mapping as well the standard xr mapping
  81271. */
  81272. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  81273. private _forceLegacyControllers;
  81274. private _modelRootNode;
  81275. /**
  81276. * The base url used to load the left and right controller models
  81277. */
  81278. static MODEL_BASE_URL: string;
  81279. /**
  81280. * The name of the left controller model file
  81281. */
  81282. static MODEL_LEFT_FILENAME: string;
  81283. /**
  81284. * The name of the right controller model file
  81285. */
  81286. static MODEL_RIGHT_FILENAME: string;
  81287. /**
  81288. * Base Url for the Quest controller model.
  81289. */
  81290. static QUEST_MODEL_BASE_URL: string;
  81291. profileId: string;
  81292. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  81293. protected _getFilenameAndPath(): {
  81294. filename: string;
  81295. path: string;
  81296. };
  81297. protected _getModelLoadingConstraints(): boolean;
  81298. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81299. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81300. protected _updateModel(): void;
  81301. /**
  81302. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  81303. * between the touch and touch 2.
  81304. */
  81305. private _isQuest;
  81306. }
  81307. }
  81308. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  81309. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81310. import { Scene } from "babylonjs/scene";
  81311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81312. /**
  81313. * The motion controller class for the standard HTC-Vive controllers
  81314. */
  81315. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  81316. private _modelRootNode;
  81317. /**
  81318. * The base url used to load the left and right controller models
  81319. */
  81320. static MODEL_BASE_URL: string;
  81321. /**
  81322. * File name for the controller model.
  81323. */
  81324. static MODEL_FILENAME: string;
  81325. profileId: string;
  81326. /**
  81327. * Create a new Vive motion controller object
  81328. * @param scene the scene to use to create this controller
  81329. * @param gamepadObject the corresponding gamepad object
  81330. * @param handedness the handedness of the controller
  81331. */
  81332. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81333. protected _getFilenameAndPath(): {
  81334. filename: string;
  81335. path: string;
  81336. };
  81337. protected _getModelLoadingConstraints(): boolean;
  81338. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81339. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81340. protected _updateModel(): void;
  81341. }
  81342. }
  81343. declare module "babylonjs/XR/motionController/index" {
  81344. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81345. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  81346. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  81347. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  81348. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  81349. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  81350. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  81351. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  81352. }
  81353. declare module "babylonjs/XR/index" {
  81354. export * from "babylonjs/XR/webXRCamera";
  81355. export * from "babylonjs/XR/webXREnterExitUI";
  81356. export * from "babylonjs/XR/webXRExperienceHelper";
  81357. export * from "babylonjs/XR/webXRInput";
  81358. export * from "babylonjs/XR/webXRInputSource";
  81359. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  81360. export * from "babylonjs/XR/webXRTypes";
  81361. export * from "babylonjs/XR/webXRSessionManager";
  81362. export * from "babylonjs/XR/webXRDefaultExperience";
  81363. export * from "babylonjs/XR/webXRFeaturesManager";
  81364. export * from "babylonjs/XR/features/index";
  81365. export * from "babylonjs/XR/motionController/index";
  81366. }
  81367. declare module "babylonjs/index" {
  81368. export * from "babylonjs/abstractScene";
  81369. export * from "babylonjs/Actions/index";
  81370. export * from "babylonjs/Animations/index";
  81371. export * from "babylonjs/assetContainer";
  81372. export * from "babylonjs/Audio/index";
  81373. export * from "babylonjs/Behaviors/index";
  81374. export * from "babylonjs/Bones/index";
  81375. export * from "babylonjs/Cameras/index";
  81376. export * from "babylonjs/Collisions/index";
  81377. export * from "babylonjs/Culling/index";
  81378. export * from "babylonjs/Debug/index";
  81379. export * from "babylonjs/DeviceInput/index";
  81380. export * from "babylonjs/Engines/index";
  81381. export * from "babylonjs/Events/index";
  81382. export * from "babylonjs/Gamepads/index";
  81383. export * from "babylonjs/Gizmos/index";
  81384. export * from "babylonjs/Helpers/index";
  81385. export * from "babylonjs/Instrumentation/index";
  81386. export * from "babylonjs/Layers/index";
  81387. export * from "babylonjs/LensFlares/index";
  81388. export * from "babylonjs/Lights/index";
  81389. export * from "babylonjs/Loading/index";
  81390. export * from "babylonjs/Materials/index";
  81391. export * from "babylonjs/Maths/index";
  81392. export * from "babylonjs/Meshes/index";
  81393. export * from "babylonjs/Morph/index";
  81394. export * from "babylonjs/Navigation/index";
  81395. export * from "babylonjs/node";
  81396. export * from "babylonjs/Offline/index";
  81397. export * from "babylonjs/Particles/index";
  81398. export * from "babylonjs/Physics/index";
  81399. export * from "babylonjs/PostProcesses/index";
  81400. export * from "babylonjs/Probes/index";
  81401. export * from "babylonjs/Rendering/index";
  81402. export * from "babylonjs/scene";
  81403. export * from "babylonjs/sceneComponent";
  81404. export * from "babylonjs/Sprites/index";
  81405. export * from "babylonjs/States/index";
  81406. export * from "babylonjs/Misc/index";
  81407. export * from "babylonjs/XR/index";
  81408. export * from "babylonjs/types";
  81409. }
  81410. declare module "babylonjs/Animations/pathCursor" {
  81411. import { Vector3 } from "babylonjs/Maths/math.vector";
  81412. import { Path2 } from "babylonjs/Maths/math.path";
  81413. /**
  81414. * A cursor which tracks a point on a path
  81415. */
  81416. export class PathCursor {
  81417. private path;
  81418. /**
  81419. * Stores path cursor callbacks for when an onchange event is triggered
  81420. */
  81421. private _onchange;
  81422. /**
  81423. * The value of the path cursor
  81424. */
  81425. value: number;
  81426. /**
  81427. * The animation array of the path cursor
  81428. */
  81429. animations: Animation[];
  81430. /**
  81431. * Initializes the path cursor
  81432. * @param path The path to track
  81433. */
  81434. constructor(path: Path2);
  81435. /**
  81436. * Gets the cursor point on the path
  81437. * @returns A point on the path cursor at the cursor location
  81438. */
  81439. getPoint(): Vector3;
  81440. /**
  81441. * Moves the cursor ahead by the step amount
  81442. * @param step The amount to move the cursor forward
  81443. * @returns This path cursor
  81444. */
  81445. moveAhead(step?: number): PathCursor;
  81446. /**
  81447. * Moves the cursor behind by the step amount
  81448. * @param step The amount to move the cursor back
  81449. * @returns This path cursor
  81450. */
  81451. moveBack(step?: number): PathCursor;
  81452. /**
  81453. * Moves the cursor by the step amount
  81454. * If the step amount is greater than one, an exception is thrown
  81455. * @param step The amount to move the cursor
  81456. * @returns This path cursor
  81457. */
  81458. move(step: number): PathCursor;
  81459. /**
  81460. * Ensures that the value is limited between zero and one
  81461. * @returns This path cursor
  81462. */
  81463. private ensureLimits;
  81464. /**
  81465. * Runs onchange callbacks on change (used by the animation engine)
  81466. * @returns This path cursor
  81467. */
  81468. private raiseOnChange;
  81469. /**
  81470. * Executes a function on change
  81471. * @param f A path cursor onchange callback
  81472. * @returns This path cursor
  81473. */
  81474. onchange(f: (cursor: PathCursor) => void): PathCursor;
  81475. }
  81476. }
  81477. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  81478. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  81479. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  81480. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  81481. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  81482. }
  81483. declare module "babylonjs/Engines/Processors/Expressions/index" {
  81484. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  81485. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  81486. }
  81487. declare module "babylonjs/Engines/Processors/index" {
  81488. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  81489. export * from "babylonjs/Engines/Processors/Expressions/index";
  81490. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  81491. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  81492. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  81493. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  81494. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  81495. export * from "babylonjs/Engines/Processors/shaderProcessor";
  81496. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  81497. }
  81498. declare module "babylonjs/Legacy/legacy" {
  81499. import * as Babylon from "babylonjs/index";
  81500. export * from "babylonjs/index";
  81501. }
  81502. declare module "babylonjs/Shaders/blur.fragment" {
  81503. /** @hidden */
  81504. export var blurPixelShader: {
  81505. name: string;
  81506. shader: string;
  81507. };
  81508. }
  81509. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  81510. /** @hidden */
  81511. export var pointCloudVertexDeclaration: {
  81512. name: string;
  81513. shader: string;
  81514. };
  81515. }
  81516. declare module "babylonjs" {
  81517. export * from "babylonjs/Legacy/legacy";
  81518. }
  81519. declare module BABYLON {
  81520. /** Alias type for value that can be null */
  81521. export type Nullable<T> = T | null;
  81522. /**
  81523. * Alias type for number that are floats
  81524. * @ignorenaming
  81525. */
  81526. export type float = number;
  81527. /**
  81528. * Alias type for number that are doubles.
  81529. * @ignorenaming
  81530. */
  81531. export type double = number;
  81532. /**
  81533. * Alias type for number that are integer
  81534. * @ignorenaming
  81535. */
  81536. export type int = number;
  81537. /** Alias type for number array or Float32Array */
  81538. export type FloatArray = number[] | Float32Array;
  81539. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  81540. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  81541. /**
  81542. * Alias for types that can be used by a Buffer or VertexBuffer.
  81543. */
  81544. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  81545. /**
  81546. * Alias type for primitive types
  81547. * @ignorenaming
  81548. */
  81549. type Primitive = undefined | null | boolean | string | number | Function;
  81550. /**
  81551. * Type modifier to make all the properties of an object Readonly
  81552. */
  81553. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  81554. /**
  81555. * Type modifier to make all the properties of an object Readonly recursively
  81556. */
  81557. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  81558. /**
  81559. * Type modifier to make object properties readonly.
  81560. */
  81561. export type DeepImmutableObject<T> = {
  81562. readonly [K in keyof T]: DeepImmutable<T[K]>;
  81563. };
  81564. /** @hidden */
  81565. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  81566. }
  81567. }
  81568. declare module BABYLON {
  81569. /**
  81570. * A class serves as a medium between the observable and its observers
  81571. */
  81572. export class EventState {
  81573. /**
  81574. * Create a new EventState
  81575. * @param mask defines the mask associated with this state
  81576. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81577. * @param target defines the original target of the state
  81578. * @param currentTarget defines the current target of the state
  81579. */
  81580. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  81581. /**
  81582. * Initialize the current event state
  81583. * @param mask defines the mask associated with this state
  81584. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81585. * @param target defines the original target of the state
  81586. * @param currentTarget defines the current target of the state
  81587. * @returns the current event state
  81588. */
  81589. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  81590. /**
  81591. * An Observer can set this property to true to prevent subsequent observers of being notified
  81592. */
  81593. skipNextObservers: boolean;
  81594. /**
  81595. * Get the mask value that were used to trigger the event corresponding to this EventState object
  81596. */
  81597. mask: number;
  81598. /**
  81599. * The object that originally notified the event
  81600. */
  81601. target?: any;
  81602. /**
  81603. * The current object in the bubbling phase
  81604. */
  81605. currentTarget?: any;
  81606. /**
  81607. * This will be populated with the return value of the last function that was executed.
  81608. * If it is the first function in the callback chain it will be the event data.
  81609. */
  81610. lastReturnValue?: any;
  81611. /**
  81612. * User defined information that will be sent to observers
  81613. */
  81614. userInfo?: any;
  81615. }
  81616. /**
  81617. * Represent an Observer registered to a given Observable object.
  81618. */
  81619. export class Observer<T> {
  81620. /**
  81621. * Defines the callback to call when the observer is notified
  81622. */
  81623. callback: (eventData: T, eventState: EventState) => void;
  81624. /**
  81625. * Defines the mask of the observer (used to filter notifications)
  81626. */
  81627. mask: number;
  81628. /**
  81629. * Defines the current scope used to restore the JS context
  81630. */
  81631. scope: any;
  81632. /** @hidden */
  81633. _willBeUnregistered: boolean;
  81634. /**
  81635. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  81636. */
  81637. unregisterOnNextCall: boolean;
  81638. /**
  81639. * Creates a new observer
  81640. * @param callback defines the callback to call when the observer is notified
  81641. * @param mask defines the mask of the observer (used to filter notifications)
  81642. * @param scope defines the current scope used to restore the JS context
  81643. */
  81644. constructor(
  81645. /**
  81646. * Defines the callback to call when the observer is notified
  81647. */
  81648. callback: (eventData: T, eventState: EventState) => void,
  81649. /**
  81650. * Defines the mask of the observer (used to filter notifications)
  81651. */
  81652. mask: number,
  81653. /**
  81654. * Defines the current scope used to restore the JS context
  81655. */
  81656. scope?: any);
  81657. }
  81658. /**
  81659. * Represent a list of observers registered to multiple Observables object.
  81660. */
  81661. export class MultiObserver<T> {
  81662. private _observers;
  81663. private _observables;
  81664. /**
  81665. * Release associated resources
  81666. */
  81667. dispose(): void;
  81668. /**
  81669. * Raise a callback when one of the observable will notify
  81670. * @param observables defines a list of observables to watch
  81671. * @param callback defines the callback to call on notification
  81672. * @param mask defines the mask used to filter notifications
  81673. * @param scope defines the current scope used to restore the JS context
  81674. * @returns the new MultiObserver
  81675. */
  81676. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  81677. }
  81678. /**
  81679. * The Observable class is a simple implementation of the Observable pattern.
  81680. *
  81681. * 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.
  81682. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  81683. * 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).
  81684. * 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.
  81685. */
  81686. export class Observable<T> {
  81687. private _observers;
  81688. private _eventState;
  81689. private _onObserverAdded;
  81690. /**
  81691. * Gets the list of observers
  81692. */
  81693. get observers(): Array<Observer<T>>;
  81694. /**
  81695. * Creates a new observable
  81696. * @param onObserverAdded defines a callback to call when a new observer is added
  81697. */
  81698. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  81699. /**
  81700. * Create a new Observer with the specified callback
  81701. * @param callback the callback that will be executed for that Observer
  81702. * @param mask the mask used to filter observers
  81703. * @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.
  81704. * @param scope optional scope for the callback to be called from
  81705. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  81706. * @returns the new observer created for the callback
  81707. */
  81708. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  81709. /**
  81710. * Create a new Observer with the specified callback and unregisters after the next notification
  81711. * @param callback the callback that will be executed for that Observer
  81712. * @returns the new observer created for the callback
  81713. */
  81714. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  81715. /**
  81716. * Remove an Observer from the Observable object
  81717. * @param observer the instance of the Observer to remove
  81718. * @returns false if it doesn't belong to this Observable
  81719. */
  81720. remove(observer: Nullable<Observer<T>>): boolean;
  81721. /**
  81722. * Remove a callback from the Observable object
  81723. * @param callback the callback to remove
  81724. * @param scope optional scope. If used only the callbacks with this scope will be removed
  81725. * @returns false if it doesn't belong to this Observable
  81726. */
  81727. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  81728. private _deferUnregister;
  81729. private _remove;
  81730. /**
  81731. * Moves the observable to the top of the observer list making it get called first when notified
  81732. * @param observer the observer to move
  81733. */
  81734. makeObserverTopPriority(observer: Observer<T>): void;
  81735. /**
  81736. * Moves the observable to the bottom of the observer list making it get called last when notified
  81737. * @param observer the observer to move
  81738. */
  81739. makeObserverBottomPriority(observer: Observer<T>): void;
  81740. /**
  81741. * Notify all Observers by calling their respective callback with the given data
  81742. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  81743. * @param eventData defines the data to send to all observers
  81744. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  81745. * @param target defines the original target of the state
  81746. * @param currentTarget defines the current target of the state
  81747. * @param userInfo defines any user info to send to observers
  81748. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  81749. */
  81750. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  81751. /**
  81752. * Calling this will execute each callback, expecting it to be a promise or return a value.
  81753. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  81754. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  81755. * and it is crucial that all callbacks will be executed.
  81756. * The order of the callbacks is kept, callbacks are not executed parallel.
  81757. *
  81758. * @param eventData The data to be sent to each callback
  81759. * @param mask is used to filter observers defaults to -1
  81760. * @param target defines the callback target (see EventState)
  81761. * @param currentTarget defines he current object in the bubbling phase
  81762. * @param userInfo defines any user info to send to observers
  81763. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  81764. */
  81765. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  81766. /**
  81767. * Notify a specific observer
  81768. * @param observer defines the observer to notify
  81769. * @param eventData defines the data to be sent to each callback
  81770. * @param mask is used to filter observers defaults to -1
  81771. */
  81772. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  81773. /**
  81774. * Gets a boolean indicating if the observable has at least one observer
  81775. * @returns true is the Observable has at least one Observer registered
  81776. */
  81777. hasObservers(): boolean;
  81778. /**
  81779. * Clear the list of observers
  81780. */
  81781. clear(): void;
  81782. /**
  81783. * Clone the current observable
  81784. * @returns a new observable
  81785. */
  81786. clone(): Observable<T>;
  81787. /**
  81788. * Does this observable handles observer registered with a given mask
  81789. * @param mask defines the mask to be tested
  81790. * @return whether or not one observer registered with the given mask is handeled
  81791. **/
  81792. hasSpecificMask(mask?: number): boolean;
  81793. }
  81794. }
  81795. declare module BABYLON {
  81796. /**
  81797. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  81798. * Babylon.js
  81799. */
  81800. export class DomManagement {
  81801. /**
  81802. * Checks if the window object exists
  81803. * @returns true if the window object exists
  81804. */
  81805. static IsWindowObjectExist(): boolean;
  81806. /**
  81807. * Checks if the navigator object exists
  81808. * @returns true if the navigator object exists
  81809. */
  81810. static IsNavigatorAvailable(): boolean;
  81811. /**
  81812. * Check if the document object exists
  81813. * @returns true if the document object exists
  81814. */
  81815. static IsDocumentAvailable(): boolean;
  81816. /**
  81817. * Extracts text content from a DOM element hierarchy
  81818. * @param element defines the root element
  81819. * @returns a string
  81820. */
  81821. static GetDOMTextContent(element: HTMLElement): string;
  81822. }
  81823. }
  81824. declare module BABYLON {
  81825. /**
  81826. * Logger used througouht the application to allow configuration of
  81827. * the log level required for the messages.
  81828. */
  81829. export class Logger {
  81830. /**
  81831. * No log
  81832. */
  81833. static readonly NoneLogLevel: number;
  81834. /**
  81835. * Only message logs
  81836. */
  81837. static readonly MessageLogLevel: number;
  81838. /**
  81839. * Only warning logs
  81840. */
  81841. static readonly WarningLogLevel: number;
  81842. /**
  81843. * Only error logs
  81844. */
  81845. static readonly ErrorLogLevel: number;
  81846. /**
  81847. * All logs
  81848. */
  81849. static readonly AllLogLevel: number;
  81850. private static _LogCache;
  81851. /**
  81852. * Gets a value indicating the number of loading errors
  81853. * @ignorenaming
  81854. */
  81855. static errorsCount: number;
  81856. /**
  81857. * Callback called when a new log is added
  81858. */
  81859. static OnNewCacheEntry: (entry: string) => void;
  81860. private static _AddLogEntry;
  81861. private static _FormatMessage;
  81862. private static _LogDisabled;
  81863. private static _LogEnabled;
  81864. private static _WarnDisabled;
  81865. private static _WarnEnabled;
  81866. private static _ErrorDisabled;
  81867. private static _ErrorEnabled;
  81868. /**
  81869. * Log a message to the console
  81870. */
  81871. static Log: (message: string) => void;
  81872. /**
  81873. * Write a warning message to the console
  81874. */
  81875. static Warn: (message: string) => void;
  81876. /**
  81877. * Write an error message to the console
  81878. */
  81879. static Error: (message: string) => void;
  81880. /**
  81881. * Gets current log cache (list of logs)
  81882. */
  81883. static get LogCache(): string;
  81884. /**
  81885. * Clears the log cache
  81886. */
  81887. static ClearLogCache(): void;
  81888. /**
  81889. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  81890. */
  81891. static set LogLevels(level: number);
  81892. }
  81893. }
  81894. declare module BABYLON {
  81895. /** @hidden */
  81896. export class _TypeStore {
  81897. /** @hidden */
  81898. static RegisteredTypes: {
  81899. [key: string]: Object;
  81900. };
  81901. /** @hidden */
  81902. static GetClass(fqdn: string): any;
  81903. }
  81904. }
  81905. declare module BABYLON {
  81906. /**
  81907. * Helper to manipulate strings
  81908. */
  81909. export class StringTools {
  81910. /**
  81911. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81912. * @param str Source string
  81913. * @param suffix Suffix to search for in the source string
  81914. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81915. */
  81916. static EndsWith(str: string, suffix: string): boolean;
  81917. /**
  81918. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81919. * @param str Source string
  81920. * @param suffix Suffix to search for in the source string
  81921. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81922. */
  81923. static StartsWith(str: string, suffix: string): boolean;
  81924. /**
  81925. * Decodes a buffer into a string
  81926. * @param buffer The buffer to decode
  81927. * @returns The decoded string
  81928. */
  81929. static Decode(buffer: Uint8Array | Uint16Array): string;
  81930. /**
  81931. * Encode a buffer to a base64 string
  81932. * @param buffer defines the buffer to encode
  81933. * @returns the encoded string
  81934. */
  81935. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81936. /**
  81937. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81938. * @param num the number to convert and pad
  81939. * @param length the expected length of the string
  81940. * @returns the padded string
  81941. */
  81942. static PadNumber(num: number, length: number): string;
  81943. }
  81944. }
  81945. declare module BABYLON {
  81946. /**
  81947. * Class containing a set of static utilities functions for deep copy.
  81948. */
  81949. export class DeepCopier {
  81950. /**
  81951. * Tries to copy an object by duplicating every property
  81952. * @param source defines the source object
  81953. * @param destination defines the target object
  81954. * @param doNotCopyList defines a list of properties to avoid
  81955. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81956. */
  81957. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81958. }
  81959. }
  81960. declare module BABYLON {
  81961. /**
  81962. * Class containing a set of static utilities functions for precision date
  81963. */
  81964. export class PrecisionDate {
  81965. /**
  81966. * Gets either window.performance.now() if supported or Date.now() else
  81967. */
  81968. static get Now(): number;
  81969. }
  81970. }
  81971. declare module BABYLON {
  81972. /** @hidden */
  81973. export class _DevTools {
  81974. static WarnImport(name: string): string;
  81975. }
  81976. }
  81977. declare module BABYLON {
  81978. /**
  81979. * Interface used to define the mechanism to get data from the network
  81980. */
  81981. export interface IWebRequest {
  81982. /**
  81983. * Returns client's response url
  81984. */
  81985. responseURL: string;
  81986. /**
  81987. * Returns client's status
  81988. */
  81989. status: number;
  81990. /**
  81991. * Returns client's status as a text
  81992. */
  81993. statusText: string;
  81994. }
  81995. }
  81996. declare module BABYLON {
  81997. /**
  81998. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81999. */
  82000. export class WebRequest implements IWebRequest {
  82001. private readonly _xhr;
  82002. /**
  82003. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  82004. * i.e. when loading files, where the server/service expects an Authorization header
  82005. */
  82006. static CustomRequestHeaders: {
  82007. [key: string]: string;
  82008. };
  82009. /**
  82010. * Add callback functions in this array to update all the requests before they get sent to the network
  82011. */
  82012. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  82013. private _injectCustomRequestHeaders;
  82014. /**
  82015. * Gets or sets a function to be called when loading progress changes
  82016. */
  82017. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  82018. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  82019. /**
  82020. * Returns client's state
  82021. */
  82022. get readyState(): number;
  82023. /**
  82024. * Returns client's status
  82025. */
  82026. get status(): number;
  82027. /**
  82028. * Returns client's status as a text
  82029. */
  82030. get statusText(): string;
  82031. /**
  82032. * Returns client's response
  82033. */
  82034. get response(): any;
  82035. /**
  82036. * Returns client's response url
  82037. */
  82038. get responseURL(): string;
  82039. /**
  82040. * Returns client's response as text
  82041. */
  82042. get responseText(): string;
  82043. /**
  82044. * Gets or sets the expected response type
  82045. */
  82046. get responseType(): XMLHttpRequestResponseType;
  82047. set responseType(value: XMLHttpRequestResponseType);
  82048. /** @hidden */
  82049. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  82050. /** @hidden */
  82051. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  82052. /**
  82053. * Cancels any network activity
  82054. */
  82055. abort(): void;
  82056. /**
  82057. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  82058. * @param body defines an optional request body
  82059. */
  82060. send(body?: Document | BodyInit | null): void;
  82061. /**
  82062. * Sets the request method, request URL
  82063. * @param method defines the method to use (GET, POST, etc..)
  82064. * @param url defines the url to connect with
  82065. */
  82066. open(method: string, url: string): void;
  82067. /**
  82068. * Sets the value of a request header.
  82069. * @param name The name of the header whose value is to be set
  82070. * @param value The value to set as the body of the header
  82071. */
  82072. setRequestHeader(name: string, value: string): void;
  82073. /**
  82074. * Get the string containing the text of a particular header's value.
  82075. * @param name The name of the header
  82076. * @returns The string containing the text of the given header name
  82077. */
  82078. getResponseHeader(name: string): Nullable<string>;
  82079. }
  82080. }
  82081. declare module BABYLON {
  82082. /**
  82083. * File request interface
  82084. */
  82085. export interface IFileRequest {
  82086. /**
  82087. * Raised when the request is complete (success or error).
  82088. */
  82089. onCompleteObservable: Observable<IFileRequest>;
  82090. /**
  82091. * Aborts the request for a file.
  82092. */
  82093. abort: () => void;
  82094. }
  82095. }
  82096. declare module BABYLON {
  82097. /**
  82098. * Define options used to create a render target texture
  82099. */
  82100. export class RenderTargetCreationOptions {
  82101. /**
  82102. * Specifies is mipmaps must be generated
  82103. */
  82104. generateMipMaps?: boolean;
  82105. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  82106. generateDepthBuffer?: boolean;
  82107. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  82108. generateStencilBuffer?: boolean;
  82109. /** Defines texture type (int by default) */
  82110. type?: number;
  82111. /** Defines sampling mode (trilinear by default) */
  82112. samplingMode?: number;
  82113. /** Defines format (RGBA by default) */
  82114. format?: number;
  82115. }
  82116. }
  82117. declare module BABYLON {
  82118. /** Defines the cross module used constants to avoid circular dependncies */
  82119. export class Constants {
  82120. /** Defines that alpha blending is disabled */
  82121. static readonly ALPHA_DISABLE: number;
  82122. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  82123. static readonly ALPHA_ADD: number;
  82124. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  82125. static readonly ALPHA_COMBINE: number;
  82126. /** Defines that alpha blending is DEST - SRC * DEST */
  82127. static readonly ALPHA_SUBTRACT: number;
  82128. /** Defines that alpha blending is SRC * DEST */
  82129. static readonly ALPHA_MULTIPLY: number;
  82130. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  82131. static readonly ALPHA_MAXIMIZED: number;
  82132. /** Defines that alpha blending is SRC + DEST */
  82133. static readonly ALPHA_ONEONE: number;
  82134. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  82135. static readonly ALPHA_PREMULTIPLIED: number;
  82136. /**
  82137. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  82138. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  82139. */
  82140. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  82141. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  82142. static readonly ALPHA_INTERPOLATE: number;
  82143. /**
  82144. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  82145. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  82146. */
  82147. static readonly ALPHA_SCREENMODE: number;
  82148. /**
  82149. * Defines that alpha blending is SRC + DST
  82150. * Alpha will be set to SRC ALPHA + DST ALPHA
  82151. */
  82152. static readonly ALPHA_ONEONE_ONEONE: number;
  82153. /**
  82154. * Defines that alpha blending is SRC * DST ALPHA + DST
  82155. * Alpha will be set to 0
  82156. */
  82157. static readonly ALPHA_ALPHATOCOLOR: number;
  82158. /**
  82159. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  82160. */
  82161. static readonly ALPHA_REVERSEONEMINUS: number;
  82162. /**
  82163. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  82164. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  82165. */
  82166. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  82167. /**
  82168. * Defines that alpha blending is SRC + DST
  82169. * Alpha will be set to SRC ALPHA
  82170. */
  82171. static readonly ALPHA_ONEONE_ONEZERO: number;
  82172. /**
  82173. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  82174. * Alpha will be set to DST ALPHA
  82175. */
  82176. static readonly ALPHA_EXCLUSION: number;
  82177. /** Defines that alpha blending equation a SUM */
  82178. static readonly ALPHA_EQUATION_ADD: number;
  82179. /** Defines that alpha blending equation a SUBSTRACTION */
  82180. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  82181. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  82182. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  82183. /** Defines that alpha blending equation a MAX operation */
  82184. static readonly ALPHA_EQUATION_MAX: number;
  82185. /** Defines that alpha blending equation a MIN operation */
  82186. static readonly ALPHA_EQUATION_MIN: number;
  82187. /**
  82188. * Defines that alpha blending equation a DARKEN operation:
  82189. * It takes the min of the src and sums the alpha channels.
  82190. */
  82191. static readonly ALPHA_EQUATION_DARKEN: number;
  82192. /** Defines that the ressource is not delayed*/
  82193. static readonly DELAYLOADSTATE_NONE: number;
  82194. /** Defines that the ressource was successfully delay loaded */
  82195. static readonly DELAYLOADSTATE_LOADED: number;
  82196. /** Defines that the ressource is currently delay loading */
  82197. static readonly DELAYLOADSTATE_LOADING: number;
  82198. /** Defines that the ressource is delayed and has not started loading */
  82199. static readonly DELAYLOADSTATE_NOTLOADED: number;
  82200. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  82201. static readonly NEVER: number;
  82202. /** 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 */
  82203. static readonly ALWAYS: number;
  82204. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  82205. static readonly LESS: number;
  82206. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  82207. static readonly EQUAL: number;
  82208. /** 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 */
  82209. static readonly LEQUAL: number;
  82210. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  82211. static readonly GREATER: number;
  82212. /** 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 */
  82213. static readonly GEQUAL: number;
  82214. /** 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 */
  82215. static readonly NOTEQUAL: number;
  82216. /** Passed to stencilOperation to specify that stencil value must be kept */
  82217. static readonly KEEP: number;
  82218. /** Passed to stencilOperation to specify that stencil value must be replaced */
  82219. static readonly REPLACE: number;
  82220. /** Passed to stencilOperation to specify that stencil value must be incremented */
  82221. static readonly INCR: number;
  82222. /** Passed to stencilOperation to specify that stencil value must be decremented */
  82223. static readonly DECR: number;
  82224. /** Passed to stencilOperation to specify that stencil value must be inverted */
  82225. static readonly INVERT: number;
  82226. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  82227. static readonly INCR_WRAP: number;
  82228. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  82229. static readonly DECR_WRAP: number;
  82230. /** Texture is not repeating outside of 0..1 UVs */
  82231. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  82232. /** Texture is repeating outside of 0..1 UVs */
  82233. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  82234. /** Texture is repeating and mirrored */
  82235. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  82236. /** ALPHA */
  82237. static readonly TEXTUREFORMAT_ALPHA: number;
  82238. /** LUMINANCE */
  82239. static readonly TEXTUREFORMAT_LUMINANCE: number;
  82240. /** LUMINANCE_ALPHA */
  82241. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  82242. /** RGB */
  82243. static readonly TEXTUREFORMAT_RGB: number;
  82244. /** RGBA */
  82245. static readonly TEXTUREFORMAT_RGBA: number;
  82246. /** RED */
  82247. static readonly TEXTUREFORMAT_RED: number;
  82248. /** RED (2nd reference) */
  82249. static readonly TEXTUREFORMAT_R: number;
  82250. /** RG */
  82251. static readonly TEXTUREFORMAT_RG: number;
  82252. /** RED_INTEGER */
  82253. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  82254. /** RED_INTEGER (2nd reference) */
  82255. static readonly TEXTUREFORMAT_R_INTEGER: number;
  82256. /** RG_INTEGER */
  82257. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  82258. /** RGB_INTEGER */
  82259. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  82260. /** RGBA_INTEGER */
  82261. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  82262. /** UNSIGNED_BYTE */
  82263. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  82264. /** UNSIGNED_BYTE (2nd reference) */
  82265. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  82266. /** FLOAT */
  82267. static readonly TEXTURETYPE_FLOAT: number;
  82268. /** HALF_FLOAT */
  82269. static readonly TEXTURETYPE_HALF_FLOAT: number;
  82270. /** BYTE */
  82271. static readonly TEXTURETYPE_BYTE: number;
  82272. /** SHORT */
  82273. static readonly TEXTURETYPE_SHORT: number;
  82274. /** UNSIGNED_SHORT */
  82275. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  82276. /** INT */
  82277. static readonly TEXTURETYPE_INT: number;
  82278. /** UNSIGNED_INT */
  82279. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  82280. /** UNSIGNED_SHORT_4_4_4_4 */
  82281. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  82282. /** UNSIGNED_SHORT_5_5_5_1 */
  82283. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  82284. /** UNSIGNED_SHORT_5_6_5 */
  82285. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  82286. /** UNSIGNED_INT_2_10_10_10_REV */
  82287. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  82288. /** UNSIGNED_INT_24_8 */
  82289. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  82290. /** UNSIGNED_INT_10F_11F_11F_REV */
  82291. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  82292. /** UNSIGNED_INT_5_9_9_9_REV */
  82293. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  82294. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  82295. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  82296. /** nearest is mag = nearest and min = nearest and no mip */
  82297. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  82298. /** mag = nearest and min = nearest and mip = none */
  82299. static readonly TEXTURE_NEAREST_NEAREST: number;
  82300. /** Bilinear is mag = linear and min = linear and no mip */
  82301. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  82302. /** mag = linear and min = linear and mip = none */
  82303. static readonly TEXTURE_LINEAR_LINEAR: number;
  82304. /** Trilinear is mag = linear and min = linear and mip = linear */
  82305. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  82306. /** Trilinear is mag = linear and min = linear and mip = linear */
  82307. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  82308. /** mag = nearest and min = nearest and mip = nearest */
  82309. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  82310. /** mag = nearest and min = linear and mip = nearest */
  82311. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  82312. /** mag = nearest and min = linear and mip = linear */
  82313. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  82314. /** mag = nearest and min = linear and mip = none */
  82315. static readonly TEXTURE_NEAREST_LINEAR: number;
  82316. /** nearest is mag = nearest and min = nearest and mip = linear */
  82317. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  82318. /** mag = linear and min = nearest and mip = nearest */
  82319. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  82320. /** mag = linear and min = nearest and mip = linear */
  82321. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  82322. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82323. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  82324. /** mag = linear and min = nearest and mip = none */
  82325. static readonly TEXTURE_LINEAR_NEAREST: number;
  82326. /** Explicit coordinates mode */
  82327. static readonly TEXTURE_EXPLICIT_MODE: number;
  82328. /** Spherical coordinates mode */
  82329. static readonly TEXTURE_SPHERICAL_MODE: number;
  82330. /** Planar coordinates mode */
  82331. static readonly TEXTURE_PLANAR_MODE: number;
  82332. /** Cubic coordinates mode */
  82333. static readonly TEXTURE_CUBIC_MODE: number;
  82334. /** Projection coordinates mode */
  82335. static readonly TEXTURE_PROJECTION_MODE: number;
  82336. /** Skybox coordinates mode */
  82337. static readonly TEXTURE_SKYBOX_MODE: number;
  82338. /** Inverse Cubic coordinates mode */
  82339. static readonly TEXTURE_INVCUBIC_MODE: number;
  82340. /** Equirectangular coordinates mode */
  82341. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  82342. /** Equirectangular Fixed coordinates mode */
  82343. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  82344. /** Equirectangular Fixed Mirrored coordinates mode */
  82345. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82346. /** Offline (baking) quality for texture filtering */
  82347. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  82348. /** High quality for texture filtering */
  82349. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  82350. /** Medium quality for texture filtering */
  82351. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  82352. /** Low quality for texture filtering */
  82353. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  82354. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  82355. static readonly SCALEMODE_FLOOR: number;
  82356. /** Defines that texture rescaling will look for the nearest power of 2 size */
  82357. static readonly SCALEMODE_NEAREST: number;
  82358. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  82359. static readonly SCALEMODE_CEILING: number;
  82360. /**
  82361. * The dirty texture flag value
  82362. */
  82363. static readonly MATERIAL_TextureDirtyFlag: number;
  82364. /**
  82365. * The dirty light flag value
  82366. */
  82367. static readonly MATERIAL_LightDirtyFlag: number;
  82368. /**
  82369. * The dirty fresnel flag value
  82370. */
  82371. static readonly MATERIAL_FresnelDirtyFlag: number;
  82372. /**
  82373. * The dirty attribute flag value
  82374. */
  82375. static readonly MATERIAL_AttributesDirtyFlag: number;
  82376. /**
  82377. * The dirty misc flag value
  82378. */
  82379. static readonly MATERIAL_MiscDirtyFlag: number;
  82380. /**
  82381. * The dirty prepass flag value
  82382. */
  82383. static readonly MATERIAL_PrePassDirtyFlag: number;
  82384. /**
  82385. * The all dirty flag value
  82386. */
  82387. static readonly MATERIAL_AllDirtyFlag: number;
  82388. /**
  82389. * Returns the triangle fill mode
  82390. */
  82391. static readonly MATERIAL_TriangleFillMode: number;
  82392. /**
  82393. * Returns the wireframe mode
  82394. */
  82395. static readonly MATERIAL_WireFrameFillMode: number;
  82396. /**
  82397. * Returns the point fill mode
  82398. */
  82399. static readonly MATERIAL_PointFillMode: number;
  82400. /**
  82401. * Returns the point list draw mode
  82402. */
  82403. static readonly MATERIAL_PointListDrawMode: number;
  82404. /**
  82405. * Returns the line list draw mode
  82406. */
  82407. static readonly MATERIAL_LineListDrawMode: number;
  82408. /**
  82409. * Returns the line loop draw mode
  82410. */
  82411. static readonly MATERIAL_LineLoopDrawMode: number;
  82412. /**
  82413. * Returns the line strip draw mode
  82414. */
  82415. static readonly MATERIAL_LineStripDrawMode: number;
  82416. /**
  82417. * Returns the triangle strip draw mode
  82418. */
  82419. static readonly MATERIAL_TriangleStripDrawMode: number;
  82420. /**
  82421. * Returns the triangle fan draw mode
  82422. */
  82423. static readonly MATERIAL_TriangleFanDrawMode: number;
  82424. /**
  82425. * Stores the clock-wise side orientation
  82426. */
  82427. static readonly MATERIAL_ClockWiseSideOrientation: number;
  82428. /**
  82429. * Stores the counter clock-wise side orientation
  82430. */
  82431. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  82432. /**
  82433. * Nothing
  82434. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82435. */
  82436. static readonly ACTION_NothingTrigger: number;
  82437. /**
  82438. * On pick
  82439. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82440. */
  82441. static readonly ACTION_OnPickTrigger: number;
  82442. /**
  82443. * On left pick
  82444. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82445. */
  82446. static readonly ACTION_OnLeftPickTrigger: number;
  82447. /**
  82448. * On right pick
  82449. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82450. */
  82451. static readonly ACTION_OnRightPickTrigger: number;
  82452. /**
  82453. * On center pick
  82454. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82455. */
  82456. static readonly ACTION_OnCenterPickTrigger: number;
  82457. /**
  82458. * On pick down
  82459. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82460. */
  82461. static readonly ACTION_OnPickDownTrigger: number;
  82462. /**
  82463. * On double pick
  82464. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82465. */
  82466. static readonly ACTION_OnDoublePickTrigger: number;
  82467. /**
  82468. * On pick up
  82469. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82470. */
  82471. static readonly ACTION_OnPickUpTrigger: number;
  82472. /**
  82473. * On pick out.
  82474. * This trigger will only be raised if you also declared a OnPickDown
  82475. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82476. */
  82477. static readonly ACTION_OnPickOutTrigger: number;
  82478. /**
  82479. * On long press
  82480. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82481. */
  82482. static readonly ACTION_OnLongPressTrigger: number;
  82483. /**
  82484. * On pointer over
  82485. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82486. */
  82487. static readonly ACTION_OnPointerOverTrigger: number;
  82488. /**
  82489. * On pointer out
  82490. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82491. */
  82492. static readonly ACTION_OnPointerOutTrigger: number;
  82493. /**
  82494. * On every frame
  82495. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82496. */
  82497. static readonly ACTION_OnEveryFrameTrigger: number;
  82498. /**
  82499. * On intersection enter
  82500. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82501. */
  82502. static readonly ACTION_OnIntersectionEnterTrigger: number;
  82503. /**
  82504. * On intersection exit
  82505. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82506. */
  82507. static readonly ACTION_OnIntersectionExitTrigger: number;
  82508. /**
  82509. * On key down
  82510. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82511. */
  82512. static readonly ACTION_OnKeyDownTrigger: number;
  82513. /**
  82514. * On key up
  82515. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82516. */
  82517. static readonly ACTION_OnKeyUpTrigger: number;
  82518. /**
  82519. * Billboard mode will only apply to Y axis
  82520. */
  82521. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  82522. /**
  82523. * Billboard mode will apply to all axes
  82524. */
  82525. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  82526. /**
  82527. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82528. */
  82529. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  82530. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82531. * Test order :
  82532. * Is the bounding sphere outside the frustum ?
  82533. * If not, are the bounding box vertices outside the frustum ?
  82534. * It not, then the cullable object is in the frustum.
  82535. */
  82536. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  82537. /** Culling strategy : Bounding Sphere Only.
  82538. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82539. * It's also less accurate than the standard because some not visible objects can still be selected.
  82540. * Test : is the bounding sphere outside the frustum ?
  82541. * If not, then the cullable object is in the frustum.
  82542. */
  82543. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82544. /** Culling strategy : Optimistic Inclusion.
  82545. * This in an inclusion test first, then the standard exclusion test.
  82546. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82547. * 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.
  82548. * Anyway, it's as accurate as the standard strategy.
  82549. * Test :
  82550. * Is the cullable object bounding sphere center in the frustum ?
  82551. * If not, apply the default culling strategy.
  82552. */
  82553. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82554. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82555. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82556. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82557. * 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.
  82558. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82559. * Test :
  82560. * Is the cullable object bounding sphere center in the frustum ?
  82561. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82562. */
  82563. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82564. /**
  82565. * No logging while loading
  82566. */
  82567. static readonly SCENELOADER_NO_LOGGING: number;
  82568. /**
  82569. * Minimal logging while loading
  82570. */
  82571. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  82572. /**
  82573. * Summary logging while loading
  82574. */
  82575. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  82576. /**
  82577. * Detailled logging while loading
  82578. */
  82579. static readonly SCENELOADER_DETAILED_LOGGING: number;
  82580. /**
  82581. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  82582. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  82583. */
  82584. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  82585. /**
  82586. * Constant used to retrieve the position texture index in the textures array in the prepass
  82587. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  82588. */
  82589. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  82590. /**
  82591. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  82592. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  82593. */
  82594. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  82595. /**
  82596. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  82597. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  82598. */
  82599. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  82600. /**
  82601. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  82602. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  82603. */
  82604. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  82605. /**
  82606. * Constant used to retrieve depth + normal index in the textures array in the prepass
  82607. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  82608. */
  82609. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  82610. /**
  82611. * Constant used to retrieve albedo index in the textures array in the prepass
  82612. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  82613. */
  82614. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  82615. }
  82616. }
  82617. declare module BABYLON {
  82618. /**
  82619. * This represents the required contract to create a new type of texture loader.
  82620. */
  82621. export interface IInternalTextureLoader {
  82622. /**
  82623. * Defines wether the loader supports cascade loading the different faces.
  82624. */
  82625. supportCascades: boolean;
  82626. /**
  82627. * This returns if the loader support the current file information.
  82628. * @param extension defines the file extension of the file being loaded
  82629. * @param mimeType defines the optional mime type of the file being loaded
  82630. * @returns true if the loader can load the specified file
  82631. */
  82632. canLoad(extension: string, mimeType?: string): boolean;
  82633. /**
  82634. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  82635. * @param data contains the texture data
  82636. * @param texture defines the BabylonJS internal texture
  82637. * @param createPolynomials will be true if polynomials have been requested
  82638. * @param onLoad defines the callback to trigger once the texture is ready
  82639. * @param onError defines the callback to trigger in case of error
  82640. * @param options options to be passed to the loader
  82641. */
  82642. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  82643. /**
  82644. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  82645. * @param data contains the texture data
  82646. * @param texture defines the BabylonJS internal texture
  82647. * @param callback defines the method to call once ready to upload
  82648. * @param options options to be passed to the loader
  82649. */
  82650. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  82651. }
  82652. }
  82653. declare module BABYLON {
  82654. /**
  82655. * Class used to store and describe the pipeline context associated with an effect
  82656. */
  82657. export interface IPipelineContext {
  82658. /**
  82659. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  82660. */
  82661. isAsync: boolean;
  82662. /**
  82663. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  82664. */
  82665. isReady: boolean;
  82666. /** @hidden */
  82667. _getVertexShaderCode(): string | null;
  82668. /** @hidden */
  82669. _getFragmentShaderCode(): string | null;
  82670. /** @hidden */
  82671. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  82672. }
  82673. }
  82674. declare module BABYLON {
  82675. /**
  82676. * Class used to store gfx data (like WebGLBuffer)
  82677. */
  82678. export class DataBuffer {
  82679. /**
  82680. * Gets or sets the number of objects referencing this buffer
  82681. */
  82682. references: number;
  82683. /** Gets or sets the size of the underlying buffer */
  82684. capacity: number;
  82685. /**
  82686. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  82687. */
  82688. is32Bits: boolean;
  82689. /**
  82690. * Gets the underlying buffer
  82691. */
  82692. get underlyingResource(): any;
  82693. }
  82694. }
  82695. declare module BABYLON {
  82696. /** @hidden */
  82697. export interface IShaderProcessor {
  82698. attributeProcessor?: (attribute: string) => string;
  82699. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  82700. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  82701. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  82702. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  82703. lineProcessor?: (line: string, isFragment: boolean) => string;
  82704. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  82705. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  82706. }
  82707. }
  82708. declare module BABYLON {
  82709. /** @hidden */
  82710. export interface ProcessingOptions {
  82711. defines: string[];
  82712. indexParameters: any;
  82713. isFragment: boolean;
  82714. shouldUseHighPrecisionShader: boolean;
  82715. supportsUniformBuffers: boolean;
  82716. shadersRepository: string;
  82717. includesShadersStore: {
  82718. [key: string]: string;
  82719. };
  82720. processor?: IShaderProcessor;
  82721. version: string;
  82722. platformName: string;
  82723. lookForClosingBracketForUniformBuffer?: boolean;
  82724. }
  82725. }
  82726. declare module BABYLON {
  82727. /** @hidden */
  82728. export class ShaderCodeNode {
  82729. line: string;
  82730. children: ShaderCodeNode[];
  82731. additionalDefineKey?: string;
  82732. additionalDefineValue?: string;
  82733. isValid(preprocessors: {
  82734. [key: string]: string;
  82735. }): boolean;
  82736. process(preprocessors: {
  82737. [key: string]: string;
  82738. }, options: ProcessingOptions): string;
  82739. }
  82740. }
  82741. declare module BABYLON {
  82742. /** @hidden */
  82743. export class ShaderCodeCursor {
  82744. private _lines;
  82745. lineIndex: number;
  82746. get currentLine(): string;
  82747. get canRead(): boolean;
  82748. set lines(value: string[]);
  82749. }
  82750. }
  82751. declare module BABYLON {
  82752. /** @hidden */
  82753. export class ShaderCodeConditionNode extends ShaderCodeNode {
  82754. process(preprocessors: {
  82755. [key: string]: string;
  82756. }, options: ProcessingOptions): string;
  82757. }
  82758. }
  82759. declare module BABYLON {
  82760. /** @hidden */
  82761. export class ShaderDefineExpression {
  82762. isTrue(preprocessors: {
  82763. [key: string]: string;
  82764. }): boolean;
  82765. private static _OperatorPriority;
  82766. private static _Stack;
  82767. static postfixToInfix(postfix: string[]): string;
  82768. static infixToPostfix(infix: string): string[];
  82769. }
  82770. }
  82771. declare module BABYLON {
  82772. /** @hidden */
  82773. export class ShaderCodeTestNode extends ShaderCodeNode {
  82774. testExpression: ShaderDefineExpression;
  82775. isValid(preprocessors: {
  82776. [key: string]: string;
  82777. }): boolean;
  82778. }
  82779. }
  82780. declare module BABYLON {
  82781. /** @hidden */
  82782. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  82783. define: string;
  82784. not: boolean;
  82785. constructor(define: string, not?: boolean);
  82786. isTrue(preprocessors: {
  82787. [key: string]: string;
  82788. }): boolean;
  82789. }
  82790. }
  82791. declare module BABYLON {
  82792. /** @hidden */
  82793. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  82794. leftOperand: ShaderDefineExpression;
  82795. rightOperand: ShaderDefineExpression;
  82796. isTrue(preprocessors: {
  82797. [key: string]: string;
  82798. }): boolean;
  82799. }
  82800. }
  82801. declare module BABYLON {
  82802. /** @hidden */
  82803. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  82804. leftOperand: ShaderDefineExpression;
  82805. rightOperand: ShaderDefineExpression;
  82806. isTrue(preprocessors: {
  82807. [key: string]: string;
  82808. }): boolean;
  82809. }
  82810. }
  82811. declare module BABYLON {
  82812. /** @hidden */
  82813. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  82814. define: string;
  82815. operand: string;
  82816. testValue: string;
  82817. constructor(define: string, operand: string, testValue: string);
  82818. isTrue(preprocessors: {
  82819. [key: string]: string;
  82820. }): boolean;
  82821. }
  82822. }
  82823. declare module BABYLON {
  82824. /**
  82825. * Class used to enable access to offline support
  82826. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82827. */
  82828. export interface IOfflineProvider {
  82829. /**
  82830. * Gets a boolean indicating if scene must be saved in the database
  82831. */
  82832. enableSceneOffline: boolean;
  82833. /**
  82834. * Gets a boolean indicating if textures must be saved in the database
  82835. */
  82836. enableTexturesOffline: boolean;
  82837. /**
  82838. * Open the offline support and make it available
  82839. * @param successCallback defines the callback to call on success
  82840. * @param errorCallback defines the callback to call on error
  82841. */
  82842. open(successCallback: () => void, errorCallback: () => void): void;
  82843. /**
  82844. * Loads an image from the offline support
  82845. * @param url defines the url to load from
  82846. * @param image defines the target DOM image
  82847. */
  82848. loadImage(url: string, image: HTMLImageElement): void;
  82849. /**
  82850. * Loads a file from offline support
  82851. * @param url defines the URL to load from
  82852. * @param sceneLoaded defines a callback to call on success
  82853. * @param progressCallBack defines a callback to call when progress changed
  82854. * @param errorCallback defines a callback to call on error
  82855. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  82856. */
  82857. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  82858. }
  82859. }
  82860. declare module BABYLON {
  82861. /**
  82862. * Class used to help managing file picking and drag'n'drop
  82863. * File Storage
  82864. */
  82865. export class FilesInputStore {
  82866. /**
  82867. * List of files ready to be loaded
  82868. */
  82869. static FilesToLoad: {
  82870. [key: string]: File;
  82871. };
  82872. }
  82873. }
  82874. declare module BABYLON {
  82875. /**
  82876. * Class used to define a retry strategy when error happens while loading assets
  82877. */
  82878. export class RetryStrategy {
  82879. /**
  82880. * Function used to defines an exponential back off strategy
  82881. * @param maxRetries defines the maximum number of retries (3 by default)
  82882. * @param baseInterval defines the interval between retries
  82883. * @returns the strategy function to use
  82884. */
  82885. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  82886. }
  82887. }
  82888. declare module BABYLON {
  82889. /**
  82890. * @ignore
  82891. * Application error to support additional information when loading a file
  82892. */
  82893. export abstract class BaseError extends Error {
  82894. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  82895. }
  82896. }
  82897. declare module BABYLON {
  82898. /** @ignore */
  82899. export class LoadFileError extends BaseError {
  82900. request?: WebRequest;
  82901. file?: File;
  82902. /**
  82903. * Creates a new LoadFileError
  82904. * @param message defines the message of the error
  82905. * @param request defines the optional web request
  82906. * @param file defines the optional file
  82907. */
  82908. constructor(message: string, object?: WebRequest | File);
  82909. }
  82910. /** @ignore */
  82911. export class RequestFileError extends BaseError {
  82912. request: WebRequest;
  82913. /**
  82914. * Creates a new LoadFileError
  82915. * @param message defines the message of the error
  82916. * @param request defines the optional web request
  82917. */
  82918. constructor(message: string, request: WebRequest);
  82919. }
  82920. /** @ignore */
  82921. export class ReadFileError extends BaseError {
  82922. file: File;
  82923. /**
  82924. * Creates a new ReadFileError
  82925. * @param message defines the message of the error
  82926. * @param file defines the optional file
  82927. */
  82928. constructor(message: string, file: File);
  82929. }
  82930. /**
  82931. * @hidden
  82932. */
  82933. export class FileTools {
  82934. /**
  82935. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82936. */
  82937. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82938. /**
  82939. * Gets or sets the base URL to use to load assets
  82940. */
  82941. static BaseUrl: string;
  82942. /**
  82943. * Default behaviour for cors in the application.
  82944. * It can be a string if the expected behavior is identical in the entire app.
  82945. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82946. */
  82947. static CorsBehavior: string | ((url: string | string[]) => string);
  82948. /**
  82949. * Gets or sets a function used to pre-process url before using them to load assets
  82950. */
  82951. static PreprocessUrl: (url: string) => string;
  82952. /**
  82953. * Removes unwanted characters from an url
  82954. * @param url defines the url to clean
  82955. * @returns the cleaned url
  82956. */
  82957. private static _CleanUrl;
  82958. /**
  82959. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82960. * @param url define the url we are trying
  82961. * @param element define the dom element where to configure the cors policy
  82962. */
  82963. static SetCorsBehavior(url: string | string[], element: {
  82964. crossOrigin: string | null;
  82965. }): void;
  82966. /**
  82967. * Loads an image as an HTMLImageElement.
  82968. * @param input url string, ArrayBuffer, or Blob to load
  82969. * @param onLoad callback called when the image successfully loads
  82970. * @param onError callback called when the image fails to load
  82971. * @param offlineProvider offline provider for caching
  82972. * @param mimeType optional mime type
  82973. * @returns the HTMLImageElement of the loaded image
  82974. */
  82975. 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>;
  82976. /**
  82977. * Reads a file from a File object
  82978. * @param file defines the file to load
  82979. * @param onSuccess defines the callback to call when data is loaded
  82980. * @param onProgress defines the callback to call during loading process
  82981. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82982. * @param onError defines the callback to call when an error occurs
  82983. * @returns a file request object
  82984. */
  82985. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82986. /**
  82987. * Loads a file from a url
  82988. * @param url url to load
  82989. * @param onSuccess callback called when the file successfully loads
  82990. * @param onProgress callback called while file is loading (if the server supports this mode)
  82991. * @param offlineProvider defines the offline provider for caching
  82992. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82993. * @param onError callback called when the file fails to load
  82994. * @returns a file request object
  82995. */
  82996. 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;
  82997. /**
  82998. * Loads a file
  82999. * @param url url to load
  83000. * @param onSuccess callback called when the file successfully loads
  83001. * @param onProgress callback called while file is loading (if the server supports this mode)
  83002. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  83003. * @param onError callback called when the file fails to load
  83004. * @param onOpened callback called when the web request is opened
  83005. * @returns a file request object
  83006. */
  83007. 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;
  83008. /**
  83009. * Checks if the loaded document was accessed via `file:`-Protocol.
  83010. * @returns boolean
  83011. */
  83012. static IsFileURL(): boolean;
  83013. }
  83014. }
  83015. declare module BABYLON {
  83016. /** @hidden */
  83017. export class ShaderProcessor {
  83018. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  83019. private static _ProcessPrecision;
  83020. private static _ExtractOperation;
  83021. private static _BuildSubExpression;
  83022. private static _BuildExpression;
  83023. private static _MoveCursorWithinIf;
  83024. private static _MoveCursor;
  83025. private static _EvaluatePreProcessors;
  83026. private static _PreparePreProcessors;
  83027. private static _ProcessShaderConversion;
  83028. private static _ProcessIncludes;
  83029. /**
  83030. * Loads a file from a url
  83031. * @param url url to load
  83032. * @param onSuccess callback called when the file successfully loads
  83033. * @param onProgress callback called while file is loading (if the server supports this mode)
  83034. * @param offlineProvider defines the offline provider for caching
  83035. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  83036. * @param onError callback called when the file fails to load
  83037. * @returns a file request object
  83038. * @hidden
  83039. */
  83040. 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;
  83041. }
  83042. }
  83043. declare module BABYLON {
  83044. /**
  83045. * @hidden
  83046. */
  83047. export interface IColor4Like {
  83048. r: float;
  83049. g: float;
  83050. b: float;
  83051. a: float;
  83052. }
  83053. /**
  83054. * @hidden
  83055. */
  83056. export interface IColor3Like {
  83057. r: float;
  83058. g: float;
  83059. b: float;
  83060. }
  83061. /**
  83062. * @hidden
  83063. */
  83064. export interface IVector4Like {
  83065. x: float;
  83066. y: float;
  83067. z: float;
  83068. w: float;
  83069. }
  83070. /**
  83071. * @hidden
  83072. */
  83073. export interface IVector3Like {
  83074. x: float;
  83075. y: float;
  83076. z: float;
  83077. }
  83078. /**
  83079. * @hidden
  83080. */
  83081. export interface IVector2Like {
  83082. x: float;
  83083. y: float;
  83084. }
  83085. /**
  83086. * @hidden
  83087. */
  83088. export interface IMatrixLike {
  83089. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83090. updateFlag: int;
  83091. }
  83092. /**
  83093. * @hidden
  83094. */
  83095. export interface IViewportLike {
  83096. x: float;
  83097. y: float;
  83098. width: float;
  83099. height: float;
  83100. }
  83101. /**
  83102. * @hidden
  83103. */
  83104. export interface IPlaneLike {
  83105. normal: IVector3Like;
  83106. d: float;
  83107. normalize(): void;
  83108. }
  83109. }
  83110. declare module BABYLON {
  83111. /**
  83112. * Interface used to define common properties for effect fallbacks
  83113. */
  83114. export interface IEffectFallbacks {
  83115. /**
  83116. * Removes the defines that should be removed when falling back.
  83117. * @param currentDefines defines the current define statements for the shader.
  83118. * @param effect defines the current effect we try to compile
  83119. * @returns The resulting defines with defines of the current rank removed.
  83120. */
  83121. reduce(currentDefines: string, effect: Effect): string;
  83122. /**
  83123. * Removes the fallback from the bound mesh.
  83124. */
  83125. unBindMesh(): void;
  83126. /**
  83127. * Checks to see if more fallbacks are still availible.
  83128. */
  83129. hasMoreFallbacks: boolean;
  83130. }
  83131. }
  83132. declare module BABYLON {
  83133. /**
  83134. * Interface for the size containing width and height
  83135. */
  83136. export interface ISize {
  83137. /**
  83138. * Width
  83139. */
  83140. width: number;
  83141. /**
  83142. * Heighht
  83143. */
  83144. height: number;
  83145. }
  83146. /**
  83147. * Size containing widht and height
  83148. */
  83149. export class Size implements ISize {
  83150. /**
  83151. * Width
  83152. */
  83153. width: number;
  83154. /**
  83155. * Height
  83156. */
  83157. height: number;
  83158. /**
  83159. * Creates a Size object from the given width and height (floats).
  83160. * @param width width of the new size
  83161. * @param height height of the new size
  83162. */
  83163. constructor(width: number, height: number);
  83164. /**
  83165. * Returns a string with the Size width and height
  83166. * @returns a string with the Size width and height
  83167. */
  83168. toString(): string;
  83169. /**
  83170. * "Size"
  83171. * @returns the string "Size"
  83172. */
  83173. getClassName(): string;
  83174. /**
  83175. * Returns the Size hash code.
  83176. * @returns a hash code for a unique width and height
  83177. */
  83178. getHashCode(): number;
  83179. /**
  83180. * Updates the current size from the given one.
  83181. * @param src the given size
  83182. */
  83183. copyFrom(src: Size): void;
  83184. /**
  83185. * Updates in place the current Size from the given floats.
  83186. * @param width width of the new size
  83187. * @param height height of the new size
  83188. * @returns the updated Size.
  83189. */
  83190. copyFromFloats(width: number, height: number): Size;
  83191. /**
  83192. * Updates in place the current Size from the given floats.
  83193. * @param width width to set
  83194. * @param height height to set
  83195. * @returns the updated Size.
  83196. */
  83197. set(width: number, height: number): Size;
  83198. /**
  83199. * Multiplies the width and height by numbers
  83200. * @param w factor to multiple the width by
  83201. * @param h factor to multiple the height by
  83202. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83203. */
  83204. multiplyByFloats(w: number, h: number): Size;
  83205. /**
  83206. * Clones the size
  83207. * @returns a new Size copied from the given one.
  83208. */
  83209. clone(): Size;
  83210. /**
  83211. * True if the current Size and the given one width and height are strictly equal.
  83212. * @param other the other size to compare against
  83213. * @returns True if the current Size and the given one width and height are strictly equal.
  83214. */
  83215. equals(other: Size): boolean;
  83216. /**
  83217. * The surface of the Size : width * height (float).
  83218. */
  83219. get surface(): number;
  83220. /**
  83221. * Create a new size of zero
  83222. * @returns a new Size set to (0.0, 0.0)
  83223. */
  83224. static Zero(): Size;
  83225. /**
  83226. * Sums the width and height of two sizes
  83227. * @param otherSize size to add to this size
  83228. * @returns a new Size set as the addition result of the current Size and the given one.
  83229. */
  83230. add(otherSize: Size): Size;
  83231. /**
  83232. * Subtracts the width and height of two
  83233. * @param otherSize size to subtract to this size
  83234. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83235. */
  83236. subtract(otherSize: Size): Size;
  83237. /**
  83238. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83239. * @param start starting size to lerp between
  83240. * @param end end size to lerp between
  83241. * @param amount amount to lerp between the start and end values
  83242. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83243. */
  83244. static Lerp(start: Size, end: Size, amount: number): Size;
  83245. }
  83246. }
  83247. declare module BABYLON {
  83248. /**
  83249. * Base class of all the textures in babylon.
  83250. * It groups all the common properties required to work with Thin Engine.
  83251. */
  83252. export class ThinTexture {
  83253. protected _wrapU: number;
  83254. /**
  83255. * | Value | Type | Description |
  83256. * | ----- | ------------------ | ----------- |
  83257. * | 0 | CLAMP_ADDRESSMODE | |
  83258. * | 1 | WRAP_ADDRESSMODE | |
  83259. * | 2 | MIRROR_ADDRESSMODE | |
  83260. */
  83261. get wrapU(): number;
  83262. set wrapU(value: number);
  83263. protected _wrapV: number;
  83264. /**
  83265. * | Value | Type | Description |
  83266. * | ----- | ------------------ | ----------- |
  83267. * | 0 | CLAMP_ADDRESSMODE | |
  83268. * | 1 | WRAP_ADDRESSMODE | |
  83269. * | 2 | MIRROR_ADDRESSMODE | |
  83270. */
  83271. get wrapV(): number;
  83272. set wrapV(value: number);
  83273. /**
  83274. * | Value | Type | Description |
  83275. * | ----- | ------------------ | ----------- |
  83276. * | 0 | CLAMP_ADDRESSMODE | |
  83277. * | 1 | WRAP_ADDRESSMODE | |
  83278. * | 2 | MIRROR_ADDRESSMODE | |
  83279. */
  83280. wrapR: number;
  83281. /**
  83282. * With compliant hardware and browser (supporting anisotropic filtering)
  83283. * this defines the level of anisotropic filtering in the texture.
  83284. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  83285. */
  83286. anisotropicFilteringLevel: number;
  83287. /**
  83288. * Define the current state of the loading sequence when in delayed load mode.
  83289. */
  83290. delayLoadState: number;
  83291. /**
  83292. * How a texture is mapped.
  83293. * Unused in thin texture mode.
  83294. */
  83295. get coordinatesMode(): number;
  83296. /**
  83297. * Define if the texture is a cube texture or if false a 2d texture.
  83298. */
  83299. get isCube(): boolean;
  83300. set isCube(value: boolean);
  83301. /**
  83302. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  83303. */
  83304. get is3D(): boolean;
  83305. set is3D(value: boolean);
  83306. /**
  83307. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  83308. */
  83309. get is2DArray(): boolean;
  83310. set is2DArray(value: boolean);
  83311. /**
  83312. * Get the class name of the texture.
  83313. * @returns "ThinTexture"
  83314. */
  83315. getClassName(): string;
  83316. /** @hidden */
  83317. _texture: Nullable<InternalTexture>;
  83318. protected _engine: Nullable<ThinEngine>;
  83319. private _cachedSize;
  83320. private _cachedBaseSize;
  83321. /**
  83322. * Instantiates a new ThinTexture.
  83323. * Base class of all the textures in babylon.
  83324. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  83325. * @param internalTexture Define the internalTexture to wrap
  83326. */
  83327. constructor(internalTexture: Nullable<InternalTexture>);
  83328. /**
  83329. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  83330. * @returns true if fully ready
  83331. */
  83332. isReady(): boolean;
  83333. /**
  83334. * Triggers the load sequence in delayed load mode.
  83335. */
  83336. delayLoad(): void;
  83337. /**
  83338. * Get the underlying lower level texture from Babylon.
  83339. * @returns the insternal texture
  83340. */
  83341. getInternalTexture(): Nullable<InternalTexture>;
  83342. /**
  83343. * Get the size of the texture.
  83344. * @returns the texture size.
  83345. */
  83346. getSize(): ISize;
  83347. /**
  83348. * Get the base size of the texture.
  83349. * It can be different from the size if the texture has been resized for POT for instance
  83350. * @returns the base size
  83351. */
  83352. getBaseSize(): ISize;
  83353. /**
  83354. * Update the sampling mode of the texture.
  83355. * Default is Trilinear mode.
  83356. *
  83357. * | Value | Type | Description |
  83358. * | ----- | ------------------ | ----------- |
  83359. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  83360. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  83361. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  83362. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  83363. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  83364. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  83365. * | 7 | NEAREST_LINEAR | |
  83366. * | 8 | NEAREST_NEAREST | |
  83367. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  83368. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  83369. * | 11 | LINEAR_LINEAR | |
  83370. * | 12 | LINEAR_NEAREST | |
  83371. *
  83372. * > _mag_: magnification filter (close to the viewer)
  83373. * > _min_: minification filter (far from the viewer)
  83374. * > _mip_: filter used between mip map levels
  83375. *@param samplingMode Define the new sampling mode of the texture
  83376. */
  83377. updateSamplingMode(samplingMode: number): void;
  83378. /**
  83379. * Release and destroy the underlying lower level texture aka internalTexture.
  83380. */
  83381. releaseInternalTexture(): void;
  83382. /**
  83383. * Dispose the texture and release its associated resources.
  83384. */
  83385. dispose(): void;
  83386. }
  83387. }
  83388. declare module BABYLON {
  83389. /**
  83390. * Defines an array and its length.
  83391. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83392. */
  83393. export interface ISmartArrayLike<T> {
  83394. /**
  83395. * The data of the array.
  83396. */
  83397. data: Array<T>;
  83398. /**
  83399. * The active length of the array.
  83400. */
  83401. length: number;
  83402. }
  83403. /**
  83404. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83405. */
  83406. export class SmartArray<T> implements ISmartArrayLike<T> {
  83407. /**
  83408. * The full set of data from the array.
  83409. */
  83410. data: Array<T>;
  83411. /**
  83412. * The active length of the array.
  83413. */
  83414. length: number;
  83415. protected _id: number;
  83416. /**
  83417. * Instantiates a Smart Array.
  83418. * @param capacity defines the default capacity of the array.
  83419. */
  83420. constructor(capacity: number);
  83421. /**
  83422. * Pushes a value at the end of the active data.
  83423. * @param value defines the object to push in the array.
  83424. */
  83425. push(value: T): void;
  83426. /**
  83427. * Iterates over the active data and apply the lambda to them.
  83428. * @param func defines the action to apply on each value.
  83429. */
  83430. forEach(func: (content: T) => void): void;
  83431. /**
  83432. * Sorts the full sets of data.
  83433. * @param compareFn defines the comparison function to apply.
  83434. */
  83435. sort(compareFn: (a: T, b: T) => number): void;
  83436. /**
  83437. * Resets the active data to an empty array.
  83438. */
  83439. reset(): void;
  83440. /**
  83441. * Releases all the data from the array as well as the array.
  83442. */
  83443. dispose(): void;
  83444. /**
  83445. * Concats the active data with a given array.
  83446. * @param array defines the data to concatenate with.
  83447. */
  83448. concat(array: any): void;
  83449. /**
  83450. * Returns the position of a value in the active data.
  83451. * @param value defines the value to find the index for
  83452. * @returns the index if found in the active data otherwise -1
  83453. */
  83454. indexOf(value: T): number;
  83455. /**
  83456. * Returns whether an element is part of the active data.
  83457. * @param value defines the value to look for
  83458. * @returns true if found in the active data otherwise false
  83459. */
  83460. contains(value: T): boolean;
  83461. private static _GlobalId;
  83462. }
  83463. /**
  83464. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83465. * The data in this array can only be present once
  83466. */
  83467. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83468. private _duplicateId;
  83469. /**
  83470. * Pushes a value at the end of the active data.
  83471. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83472. * @param value defines the object to push in the array.
  83473. */
  83474. push(value: T): void;
  83475. /**
  83476. * Pushes a value at the end of the active data.
  83477. * If the data is already present, it won t be added again
  83478. * @param value defines the object to push in the array.
  83479. * @returns true if added false if it was already present
  83480. */
  83481. pushNoDuplicate(value: T): boolean;
  83482. /**
  83483. * Resets the active data to an empty array.
  83484. */
  83485. reset(): void;
  83486. /**
  83487. * Concats the active data with a given array.
  83488. * This ensures no dupplicate will be present in the result.
  83489. * @param array defines the data to concatenate with.
  83490. */
  83491. concatWithNoDuplicate(array: any): void;
  83492. }
  83493. }
  83494. declare module BABYLON {
  83495. /**
  83496. * Class used to evalaute queries containing `and` and `or` operators
  83497. */
  83498. export class AndOrNotEvaluator {
  83499. /**
  83500. * Evaluate a query
  83501. * @param query defines the query to evaluate
  83502. * @param evaluateCallback defines the callback used to filter result
  83503. * @returns true if the query matches
  83504. */
  83505. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  83506. private static _HandleParenthesisContent;
  83507. private static _SimplifyNegation;
  83508. }
  83509. }
  83510. declare module BABYLON {
  83511. /**
  83512. * Class used to store custom tags
  83513. */
  83514. export class Tags {
  83515. /**
  83516. * Adds support for tags on the given object
  83517. * @param obj defines the object to use
  83518. */
  83519. static EnableFor(obj: any): void;
  83520. /**
  83521. * Removes tags support
  83522. * @param obj defines the object to use
  83523. */
  83524. static DisableFor(obj: any): void;
  83525. /**
  83526. * Gets a boolean indicating if the given object has tags
  83527. * @param obj defines the object to use
  83528. * @returns a boolean
  83529. */
  83530. static HasTags(obj: any): boolean;
  83531. /**
  83532. * Gets the tags available on a given object
  83533. * @param obj defines the object to use
  83534. * @param asString defines if the tags must be returned as a string instead of an array of strings
  83535. * @returns the tags
  83536. */
  83537. static GetTags(obj: any, asString?: boolean): any;
  83538. /**
  83539. * Adds tags to an object
  83540. * @param obj defines the object to use
  83541. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  83542. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  83543. */
  83544. static AddTagsTo(obj: any, tagsString: string): void;
  83545. /**
  83546. * @hidden
  83547. */
  83548. static _AddTagTo(obj: any, tag: string): void;
  83549. /**
  83550. * Removes specific tags from a specific object
  83551. * @param obj defines the object to use
  83552. * @param tagsString defines the tags to remove
  83553. */
  83554. static RemoveTagsFrom(obj: any, tagsString: string): void;
  83555. /**
  83556. * @hidden
  83557. */
  83558. static _RemoveTagFrom(obj: any, tag: string): void;
  83559. /**
  83560. * Defines if tags hosted on an object match a given query
  83561. * @param obj defines the object to use
  83562. * @param tagsQuery defines the tag query
  83563. * @returns a boolean
  83564. */
  83565. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  83566. }
  83567. }
  83568. declare module BABYLON {
  83569. /**
  83570. * Scalar computation library
  83571. */
  83572. export class Scalar {
  83573. /**
  83574. * Two pi constants convenient for computation.
  83575. */
  83576. static TwoPi: number;
  83577. /**
  83578. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  83579. * @param a number
  83580. * @param b number
  83581. * @param epsilon (default = 1.401298E-45)
  83582. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  83583. */
  83584. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  83585. /**
  83586. * Returns a string : the upper case translation of the number i to hexadecimal.
  83587. * @param i number
  83588. * @returns the upper case translation of the number i to hexadecimal.
  83589. */
  83590. static ToHex(i: number): string;
  83591. /**
  83592. * Returns -1 if value is negative and +1 is value is positive.
  83593. * @param value the value
  83594. * @returns the value itself if it's equal to zero.
  83595. */
  83596. static Sign(value: number): number;
  83597. /**
  83598. * Returns the value itself if it's between min and max.
  83599. * Returns min if the value is lower than min.
  83600. * Returns max if the value is greater than max.
  83601. * @param value the value to clmap
  83602. * @param min the min value to clamp to (default: 0)
  83603. * @param max the max value to clamp to (default: 1)
  83604. * @returns the clamped value
  83605. */
  83606. static Clamp(value: number, min?: number, max?: number): number;
  83607. /**
  83608. * the log2 of value.
  83609. * @param value the value to compute log2 of
  83610. * @returns the log2 of value.
  83611. */
  83612. static Log2(value: number): number;
  83613. /**
  83614. * Loops the value, so that it is never larger than length and never smaller than 0.
  83615. *
  83616. * This is similar to the modulo operator but it works with floating point numbers.
  83617. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  83618. * With t = 5 and length = 2.5, the result would be 0.0.
  83619. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  83620. * @param value the value
  83621. * @param length the length
  83622. * @returns the looped value
  83623. */
  83624. static Repeat(value: number, length: number): number;
  83625. /**
  83626. * Normalize the value between 0.0 and 1.0 using min and max values
  83627. * @param value value to normalize
  83628. * @param min max to normalize between
  83629. * @param max min to normalize between
  83630. * @returns the normalized value
  83631. */
  83632. static Normalize(value: number, min: number, max: number): number;
  83633. /**
  83634. * Denormalize the value from 0.0 and 1.0 using min and max values
  83635. * @param normalized value to denormalize
  83636. * @param min max to denormalize between
  83637. * @param max min to denormalize between
  83638. * @returns the denormalized value
  83639. */
  83640. static Denormalize(normalized: number, min: number, max: number): number;
  83641. /**
  83642. * Calculates the shortest difference between two given angles given in degrees.
  83643. * @param current current angle in degrees
  83644. * @param target target angle in degrees
  83645. * @returns the delta
  83646. */
  83647. static DeltaAngle(current: number, target: number): number;
  83648. /**
  83649. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  83650. * @param tx value
  83651. * @param length length
  83652. * @returns The returned value will move back and forth between 0 and length
  83653. */
  83654. static PingPong(tx: number, length: number): number;
  83655. /**
  83656. * Interpolates between min and max with smoothing at the limits.
  83657. *
  83658. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  83659. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  83660. * @param from from
  83661. * @param to to
  83662. * @param tx value
  83663. * @returns the smooth stepped value
  83664. */
  83665. static SmoothStep(from: number, to: number, tx: number): number;
  83666. /**
  83667. * Moves a value current towards target.
  83668. *
  83669. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  83670. * Negative values of maxDelta pushes the value away from target.
  83671. * @param current current value
  83672. * @param target target value
  83673. * @param maxDelta max distance to move
  83674. * @returns resulting value
  83675. */
  83676. static MoveTowards(current: number, target: number, maxDelta: number): number;
  83677. /**
  83678. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83679. *
  83680. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  83681. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  83682. * @param current current value
  83683. * @param target target value
  83684. * @param maxDelta max distance to move
  83685. * @returns resulting angle
  83686. */
  83687. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  83688. /**
  83689. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  83690. * @param start start value
  83691. * @param end target value
  83692. * @param amount amount to lerp between
  83693. * @returns the lerped value
  83694. */
  83695. static Lerp(start: number, end: number, amount: number): number;
  83696. /**
  83697. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83698. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  83699. * @param start start value
  83700. * @param end target value
  83701. * @param amount amount to lerp between
  83702. * @returns the lerped value
  83703. */
  83704. static LerpAngle(start: number, end: number, amount: number): number;
  83705. /**
  83706. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  83707. * @param a start value
  83708. * @param b target value
  83709. * @param value value between a and b
  83710. * @returns the inverseLerp value
  83711. */
  83712. static InverseLerp(a: number, b: number, value: number): number;
  83713. /**
  83714. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  83715. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  83716. * @param value1 spline value
  83717. * @param tangent1 spline value
  83718. * @param value2 spline value
  83719. * @param tangent2 spline value
  83720. * @param amount input value
  83721. * @returns hermite result
  83722. */
  83723. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  83724. /**
  83725. * Returns a random float number between and min and max values
  83726. * @param min min value of random
  83727. * @param max max value of random
  83728. * @returns random value
  83729. */
  83730. static RandomRange(min: number, max: number): number;
  83731. /**
  83732. * This function returns percentage of a number in a given range.
  83733. *
  83734. * RangeToPercent(40,20,60) will return 0.5 (50%)
  83735. * RangeToPercent(34,0,100) will return 0.34 (34%)
  83736. * @param number to convert to percentage
  83737. * @param min min range
  83738. * @param max max range
  83739. * @returns the percentage
  83740. */
  83741. static RangeToPercent(number: number, min: number, max: number): number;
  83742. /**
  83743. * This function returns number that corresponds to the percentage in a given range.
  83744. *
  83745. * PercentToRange(0.34,0,100) will return 34.
  83746. * @param percent to convert to number
  83747. * @param min min range
  83748. * @param max max range
  83749. * @returns the number
  83750. */
  83751. static PercentToRange(percent: number, min: number, max: number): number;
  83752. /**
  83753. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  83754. * @param angle The angle to normalize in radian.
  83755. * @return The converted angle.
  83756. */
  83757. static NormalizeRadians(angle: number): number;
  83758. }
  83759. }
  83760. declare module BABYLON {
  83761. /**
  83762. * Constant used to convert a value to gamma space
  83763. * @ignorenaming
  83764. */
  83765. export const ToGammaSpace: number;
  83766. /**
  83767. * Constant used to convert a value to linear space
  83768. * @ignorenaming
  83769. */
  83770. export const ToLinearSpace = 2.2;
  83771. /**
  83772. * Constant used to define the minimal number value in Babylon.js
  83773. * @ignorenaming
  83774. */
  83775. let Epsilon: number;
  83776. }
  83777. declare module BABYLON {
  83778. /**
  83779. * Class used to represent a viewport on screen
  83780. */
  83781. export class Viewport {
  83782. /** viewport left coordinate */
  83783. x: number;
  83784. /** viewport top coordinate */
  83785. y: number;
  83786. /**viewport width */
  83787. width: number;
  83788. /** viewport height */
  83789. height: number;
  83790. /**
  83791. * Creates a Viewport object located at (x, y) and sized (width, height)
  83792. * @param x defines viewport left coordinate
  83793. * @param y defines viewport top coordinate
  83794. * @param width defines the viewport width
  83795. * @param height defines the viewport height
  83796. */
  83797. constructor(
  83798. /** viewport left coordinate */
  83799. x: number,
  83800. /** viewport top coordinate */
  83801. y: number,
  83802. /**viewport width */
  83803. width: number,
  83804. /** viewport height */
  83805. height: number);
  83806. /**
  83807. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  83808. * @param renderWidth defines the rendering width
  83809. * @param renderHeight defines the rendering height
  83810. * @returns a new Viewport
  83811. */
  83812. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  83813. /**
  83814. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  83815. * @param renderWidth defines the rendering width
  83816. * @param renderHeight defines the rendering height
  83817. * @param ref defines the target viewport
  83818. * @returns the current viewport
  83819. */
  83820. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  83821. /**
  83822. * Returns a new Viewport copied from the current one
  83823. * @returns a new Viewport
  83824. */
  83825. clone(): Viewport;
  83826. }
  83827. }
  83828. declare module BABYLON {
  83829. /**
  83830. * Class containing a set of static utilities functions for arrays.
  83831. */
  83832. export class ArrayTools {
  83833. /**
  83834. * Returns an array of the given size filled with element built from the given constructor and the paramters
  83835. * @param size the number of element to construct and put in the array
  83836. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  83837. * @returns a new array filled with new objects
  83838. */
  83839. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  83840. }
  83841. }
  83842. declare module BABYLON {
  83843. /**
  83844. * Represents a plane by the equation ax + by + cz + d = 0
  83845. */
  83846. export class Plane {
  83847. private static _TmpMatrix;
  83848. /**
  83849. * Normal of the plane (a,b,c)
  83850. */
  83851. normal: Vector3;
  83852. /**
  83853. * d component of the plane
  83854. */
  83855. d: number;
  83856. /**
  83857. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  83858. * @param a a component of the plane
  83859. * @param b b component of the plane
  83860. * @param c c component of the plane
  83861. * @param d d component of the plane
  83862. */
  83863. constructor(a: number, b: number, c: number, d: number);
  83864. /**
  83865. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  83866. */
  83867. asArray(): number[];
  83868. /**
  83869. * @returns a new plane copied from the current Plane.
  83870. */
  83871. clone(): Plane;
  83872. /**
  83873. * @returns the string "Plane".
  83874. */
  83875. getClassName(): string;
  83876. /**
  83877. * @returns the Plane hash code.
  83878. */
  83879. getHashCode(): number;
  83880. /**
  83881. * Normalize the current Plane in place.
  83882. * @returns the updated Plane.
  83883. */
  83884. normalize(): Plane;
  83885. /**
  83886. * Applies a transformation the plane and returns the result
  83887. * @param transformation the transformation matrix to be applied to the plane
  83888. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  83889. */
  83890. transform(transformation: DeepImmutable<Matrix>): Plane;
  83891. /**
  83892. * Compute the dot product between the point and the plane normal
  83893. * @param point point to calculate the dot product with
  83894. * @returns the dot product (float) of the point coordinates and the plane normal.
  83895. */
  83896. dotCoordinate(point: DeepImmutable<Vector3>): number;
  83897. /**
  83898. * Updates the current Plane from the plane defined by the three given points.
  83899. * @param point1 one of the points used to contruct the plane
  83900. * @param point2 one of the points used to contruct the plane
  83901. * @param point3 one of the points used to contruct the plane
  83902. * @returns the updated Plane.
  83903. */
  83904. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  83905. /**
  83906. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  83907. * Note that for this function to work as expected you should make sure that:
  83908. * - direction and the plane normal are normalized
  83909. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  83910. * @param direction the direction to check if the plane is facing
  83911. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  83912. * @returns True if the plane is facing the given direction
  83913. */
  83914. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  83915. /**
  83916. * Calculates the distance to a point
  83917. * @param point point to calculate distance to
  83918. * @returns the signed distance (float) from the given point to the Plane.
  83919. */
  83920. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  83921. /**
  83922. * Creates a plane from an array
  83923. * @param array the array to create a plane from
  83924. * @returns a new Plane from the given array.
  83925. */
  83926. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  83927. /**
  83928. * Creates a plane from three points
  83929. * @param point1 point used to create the plane
  83930. * @param point2 point used to create the plane
  83931. * @param point3 point used to create the plane
  83932. * @returns a new Plane defined by the three given points.
  83933. */
  83934. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  83935. /**
  83936. * Creates a plane from an origin point and a normal
  83937. * @param origin origin of the plane to be constructed
  83938. * @param normal normal of the plane to be constructed
  83939. * @returns a new Plane the normal vector to this plane at the given origin point.
  83940. * Note : the vector "normal" is updated because normalized.
  83941. */
  83942. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  83943. /**
  83944. * Calculates the distance from a plane and a point
  83945. * @param origin origin of the plane to be constructed
  83946. * @param normal normal of the plane to be constructed
  83947. * @param point point to calculate distance to
  83948. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  83949. */
  83950. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  83951. }
  83952. }
  83953. declare module BABYLON {
  83954. /** @hidden */
  83955. export class PerformanceConfigurator {
  83956. /** @hidden */
  83957. static MatrixUse64Bits: boolean;
  83958. /** @hidden */
  83959. static MatrixTrackPrecisionChange: boolean;
  83960. /** @hidden */
  83961. static MatrixCurrentType: any;
  83962. /** @hidden */
  83963. static MatrixTrackedMatrices: Array<any> | null;
  83964. /** @hidden */
  83965. static SetMatrixPrecision(use64bits: boolean): void;
  83966. }
  83967. }
  83968. declare module BABYLON {
  83969. /**
  83970. * Class representing a vector containing 2 coordinates
  83971. */
  83972. export class Vector2 {
  83973. /** defines the first coordinate */
  83974. x: number;
  83975. /** defines the second coordinate */
  83976. y: number;
  83977. /**
  83978. * Creates a new Vector2 from the given x and y coordinates
  83979. * @param x defines the first coordinate
  83980. * @param y defines the second coordinate
  83981. */
  83982. constructor(
  83983. /** defines the first coordinate */
  83984. x?: number,
  83985. /** defines the second coordinate */
  83986. y?: number);
  83987. /**
  83988. * Gets a string with the Vector2 coordinates
  83989. * @returns a string with the Vector2 coordinates
  83990. */
  83991. toString(): string;
  83992. /**
  83993. * Gets class name
  83994. * @returns the string "Vector2"
  83995. */
  83996. getClassName(): string;
  83997. /**
  83998. * Gets current vector hash code
  83999. * @returns the Vector2 hash code as a number
  84000. */
  84001. getHashCode(): number;
  84002. /**
  84003. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  84004. * @param array defines the source array
  84005. * @param index defines the offset in source array
  84006. * @returns the current Vector2
  84007. */
  84008. toArray(array: FloatArray, index?: number): Vector2;
  84009. /**
  84010. * Update the current vector from an array
  84011. * @param array defines the destination array
  84012. * @param index defines the offset in the destination array
  84013. * @returns the current Vector3
  84014. */
  84015. fromArray(array: FloatArray, index?: number): Vector2;
  84016. /**
  84017. * Copy the current vector to an array
  84018. * @returns a new array with 2 elements: the Vector2 coordinates.
  84019. */
  84020. asArray(): number[];
  84021. /**
  84022. * Sets the Vector2 coordinates with the given Vector2 coordinates
  84023. * @param source defines the source Vector2
  84024. * @returns the current updated Vector2
  84025. */
  84026. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  84027. /**
  84028. * Sets the Vector2 coordinates with the given floats
  84029. * @param x defines the first coordinate
  84030. * @param y defines the second coordinate
  84031. * @returns the current updated Vector2
  84032. */
  84033. copyFromFloats(x: number, y: number): Vector2;
  84034. /**
  84035. * Sets the Vector2 coordinates with the given floats
  84036. * @param x defines the first coordinate
  84037. * @param y defines the second coordinate
  84038. * @returns the current updated Vector2
  84039. */
  84040. set(x: number, y: number): Vector2;
  84041. /**
  84042. * Add another vector with the current one
  84043. * @param otherVector defines the other vector
  84044. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  84045. */
  84046. add(otherVector: DeepImmutable<Vector2>): Vector2;
  84047. /**
  84048. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  84049. * @param otherVector defines the other vector
  84050. * @param result defines the target vector
  84051. * @returns the unmodified current Vector2
  84052. */
  84053. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84054. /**
  84055. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  84056. * @param otherVector defines the other vector
  84057. * @returns the current updated Vector2
  84058. */
  84059. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84060. /**
  84061. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  84062. * @param otherVector defines the other vector
  84063. * @returns a new Vector2
  84064. */
  84065. addVector3(otherVector: Vector3): Vector2;
  84066. /**
  84067. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  84068. * @param otherVector defines the other vector
  84069. * @returns a new Vector2
  84070. */
  84071. subtract(otherVector: Vector2): Vector2;
  84072. /**
  84073. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  84074. * @param otherVector defines the other vector
  84075. * @param result defines the target vector
  84076. * @returns the unmodified current Vector2
  84077. */
  84078. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84079. /**
  84080. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  84081. * @param otherVector defines the other vector
  84082. * @returns the current updated Vector2
  84083. */
  84084. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84085. /**
  84086. * Multiplies in place the current Vector2 coordinates by the given ones
  84087. * @param otherVector defines the other vector
  84088. * @returns the current updated Vector2
  84089. */
  84090. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84091. /**
  84092. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  84093. * @param otherVector defines the other vector
  84094. * @returns a new Vector2
  84095. */
  84096. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  84097. /**
  84098. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  84099. * @param otherVector defines the other vector
  84100. * @param result defines the target vector
  84101. * @returns the unmodified current Vector2
  84102. */
  84103. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84104. /**
  84105. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  84106. * @param x defines the first coordinate
  84107. * @param y defines the second coordinate
  84108. * @returns a new Vector2
  84109. */
  84110. multiplyByFloats(x: number, y: number): Vector2;
  84111. /**
  84112. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  84113. * @param otherVector defines the other vector
  84114. * @returns a new Vector2
  84115. */
  84116. divide(otherVector: Vector2): Vector2;
  84117. /**
  84118. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  84119. * @param otherVector defines the other vector
  84120. * @param result defines the target vector
  84121. * @returns the unmodified current Vector2
  84122. */
  84123. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84124. /**
  84125. * Divides the current Vector2 coordinates by the given ones
  84126. * @param otherVector defines the other vector
  84127. * @returns the current updated Vector2
  84128. */
  84129. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84130. /**
  84131. * Gets a new Vector2 with current Vector2 negated coordinates
  84132. * @returns a new Vector2
  84133. */
  84134. negate(): Vector2;
  84135. /**
  84136. * Negate this vector in place
  84137. * @returns this
  84138. */
  84139. negateInPlace(): Vector2;
  84140. /**
  84141. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  84142. * @param result defines the Vector3 object where to store the result
  84143. * @returns the current Vector2
  84144. */
  84145. negateToRef(result: Vector2): Vector2;
  84146. /**
  84147. * Multiply the Vector2 coordinates by scale
  84148. * @param scale defines the scaling factor
  84149. * @returns the current updated Vector2
  84150. */
  84151. scaleInPlace(scale: number): Vector2;
  84152. /**
  84153. * Returns a new Vector2 scaled by "scale" from the current Vector2
  84154. * @param scale defines the scaling factor
  84155. * @returns a new Vector2
  84156. */
  84157. scale(scale: number): Vector2;
  84158. /**
  84159. * Scale the current Vector2 values by a factor to a given Vector2
  84160. * @param scale defines the scale factor
  84161. * @param result defines the Vector2 object where to store the result
  84162. * @returns the unmodified current Vector2
  84163. */
  84164. scaleToRef(scale: number, result: Vector2): Vector2;
  84165. /**
  84166. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  84167. * @param scale defines the scale factor
  84168. * @param result defines the Vector2 object where to store the result
  84169. * @returns the unmodified current Vector2
  84170. */
  84171. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  84172. /**
  84173. * Gets a boolean if two vectors are equals
  84174. * @param otherVector defines the other vector
  84175. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  84176. */
  84177. equals(otherVector: DeepImmutable<Vector2>): boolean;
  84178. /**
  84179. * Gets a boolean if two vectors are equals (using an epsilon value)
  84180. * @param otherVector defines the other vector
  84181. * @param epsilon defines the minimal distance to consider equality
  84182. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  84183. */
  84184. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  84185. /**
  84186. * Gets a new Vector2 from current Vector2 floored values
  84187. * @returns a new Vector2
  84188. */
  84189. floor(): Vector2;
  84190. /**
  84191. * Gets a new Vector2 from current Vector2 floored values
  84192. * @returns a new Vector2
  84193. */
  84194. fract(): Vector2;
  84195. /**
  84196. * Gets the length of the vector
  84197. * @returns the vector length (float)
  84198. */
  84199. length(): number;
  84200. /**
  84201. * Gets the vector squared length
  84202. * @returns the vector squared length (float)
  84203. */
  84204. lengthSquared(): number;
  84205. /**
  84206. * Normalize the vector
  84207. * @returns the current updated Vector2
  84208. */
  84209. normalize(): Vector2;
  84210. /**
  84211. * Gets a new Vector2 copied from the Vector2
  84212. * @returns a new Vector2
  84213. */
  84214. clone(): Vector2;
  84215. /**
  84216. * Gets a new Vector2(0, 0)
  84217. * @returns a new Vector2
  84218. */
  84219. static Zero(): Vector2;
  84220. /**
  84221. * Gets a new Vector2(1, 1)
  84222. * @returns a new Vector2
  84223. */
  84224. static One(): Vector2;
  84225. /**
  84226. * Gets a new Vector2 set from the given index element of the given array
  84227. * @param array defines the data source
  84228. * @param offset defines the offset in the data source
  84229. * @returns a new Vector2
  84230. */
  84231. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  84232. /**
  84233. * Sets "result" from the given index element of the given array
  84234. * @param array defines the data source
  84235. * @param offset defines the offset in the data source
  84236. * @param result defines the target vector
  84237. */
  84238. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  84239. /**
  84240. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  84241. * @param value1 defines 1st point of control
  84242. * @param value2 defines 2nd point of control
  84243. * @param value3 defines 3rd point of control
  84244. * @param value4 defines 4th point of control
  84245. * @param amount defines the interpolation factor
  84246. * @returns a new Vector2
  84247. */
  84248. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  84249. /**
  84250. * 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".
  84251. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  84252. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  84253. * @param value defines the value to clamp
  84254. * @param min defines the lower limit
  84255. * @param max defines the upper limit
  84256. * @returns a new Vector2
  84257. */
  84258. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  84259. /**
  84260. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  84261. * @param value1 defines the 1st control point
  84262. * @param tangent1 defines the outgoing tangent
  84263. * @param value2 defines the 2nd control point
  84264. * @param tangent2 defines the incoming tangent
  84265. * @param amount defines the interpolation factor
  84266. * @returns a new Vector2
  84267. */
  84268. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  84269. /**
  84270. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  84271. * @param start defines the start vector
  84272. * @param end defines the end vector
  84273. * @param amount defines the interpolation factor
  84274. * @returns a new Vector2
  84275. */
  84276. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  84277. /**
  84278. * Gets the dot product of the vector "left" and the vector "right"
  84279. * @param left defines first vector
  84280. * @param right defines second vector
  84281. * @returns the dot product (float)
  84282. */
  84283. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  84284. /**
  84285. * Returns a new Vector2 equal to the normalized given vector
  84286. * @param vector defines the vector to normalize
  84287. * @returns a new Vector2
  84288. */
  84289. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  84290. /**
  84291. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  84292. * @param left defines 1st vector
  84293. * @param right defines 2nd vector
  84294. * @returns a new Vector2
  84295. */
  84296. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  84297. /**
  84298. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  84299. * @param left defines 1st vector
  84300. * @param right defines 2nd vector
  84301. * @returns a new Vector2
  84302. */
  84303. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  84304. /**
  84305. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  84306. * @param vector defines the vector to transform
  84307. * @param transformation defines the matrix to apply
  84308. * @returns a new Vector2
  84309. */
  84310. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  84311. /**
  84312. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  84313. * @param vector defines the vector to transform
  84314. * @param transformation defines the matrix to apply
  84315. * @param result defines the target vector
  84316. */
  84317. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  84318. /**
  84319. * Determines if a given vector is included in a triangle
  84320. * @param p defines the vector to test
  84321. * @param p0 defines 1st triangle point
  84322. * @param p1 defines 2nd triangle point
  84323. * @param p2 defines 3rd triangle point
  84324. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  84325. */
  84326. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  84327. /**
  84328. * Gets the distance between the vectors "value1" and "value2"
  84329. * @param value1 defines first vector
  84330. * @param value2 defines second vector
  84331. * @returns the distance between vectors
  84332. */
  84333. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  84334. /**
  84335. * Returns the squared distance between the vectors "value1" and "value2"
  84336. * @param value1 defines first vector
  84337. * @param value2 defines second vector
  84338. * @returns the squared distance between vectors
  84339. */
  84340. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  84341. /**
  84342. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  84343. * @param value1 defines first vector
  84344. * @param value2 defines second vector
  84345. * @returns a new Vector2
  84346. */
  84347. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  84348. /**
  84349. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  84350. * @param p defines the middle point
  84351. * @param segA defines one point of the segment
  84352. * @param segB defines the other point of the segment
  84353. * @returns the shortest distance
  84354. */
  84355. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  84356. }
  84357. /**
  84358. * Class used to store (x,y,z) vector representation
  84359. * A Vector3 is the main object used in 3D geometry
  84360. * It can represent etiher the coordinates of a point the space, either a direction
  84361. * Reminder: js uses a left handed forward facing system
  84362. */
  84363. export class Vector3 {
  84364. private static _UpReadOnly;
  84365. private static _ZeroReadOnly;
  84366. /** @hidden */
  84367. _x: number;
  84368. /** @hidden */
  84369. _y: number;
  84370. /** @hidden */
  84371. _z: number;
  84372. /** @hidden */
  84373. _isDirty: boolean;
  84374. /** Gets or sets the x coordinate */
  84375. get x(): number;
  84376. set x(value: number);
  84377. /** Gets or sets the y coordinate */
  84378. get y(): number;
  84379. set y(value: number);
  84380. /** Gets or sets the z coordinate */
  84381. get z(): number;
  84382. set z(value: number);
  84383. /**
  84384. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  84385. * @param x defines the first coordinates (on X axis)
  84386. * @param y defines the second coordinates (on Y axis)
  84387. * @param z defines the third coordinates (on Z axis)
  84388. */
  84389. constructor(x?: number, y?: number, z?: number);
  84390. /**
  84391. * Creates a string representation of the Vector3
  84392. * @returns a string with the Vector3 coordinates.
  84393. */
  84394. toString(): string;
  84395. /**
  84396. * Gets the class name
  84397. * @returns the string "Vector3"
  84398. */
  84399. getClassName(): string;
  84400. /**
  84401. * Creates the Vector3 hash code
  84402. * @returns a number which tends to be unique between Vector3 instances
  84403. */
  84404. getHashCode(): number;
  84405. /**
  84406. * Creates an array containing three elements : the coordinates of the Vector3
  84407. * @returns a new array of numbers
  84408. */
  84409. asArray(): number[];
  84410. /**
  84411. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  84412. * @param array defines the destination array
  84413. * @param index defines the offset in the destination array
  84414. * @returns the current Vector3
  84415. */
  84416. toArray(array: FloatArray, index?: number): Vector3;
  84417. /**
  84418. * Update the current vector from an array
  84419. * @param array defines the destination array
  84420. * @param index defines the offset in the destination array
  84421. * @returns the current Vector3
  84422. */
  84423. fromArray(array: FloatArray, index?: number): Vector3;
  84424. /**
  84425. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  84426. * @returns a new Quaternion object, computed from the Vector3 coordinates
  84427. */
  84428. toQuaternion(): Quaternion;
  84429. /**
  84430. * Adds the given vector to the current Vector3
  84431. * @param otherVector defines the second operand
  84432. * @returns the current updated Vector3
  84433. */
  84434. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84435. /**
  84436. * Adds the given coordinates to the current Vector3
  84437. * @param x defines the x coordinate of the operand
  84438. * @param y defines the y coordinate of the operand
  84439. * @param z defines the z coordinate of the operand
  84440. * @returns the current updated Vector3
  84441. */
  84442. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84443. /**
  84444. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  84445. * @param otherVector defines the second operand
  84446. * @returns the resulting Vector3
  84447. */
  84448. add(otherVector: DeepImmutable<Vector3>): Vector3;
  84449. /**
  84450. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  84451. * @param otherVector defines the second operand
  84452. * @param result defines the Vector3 object where to store the result
  84453. * @returns the current Vector3
  84454. */
  84455. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84456. /**
  84457. * Subtract the given vector from the current Vector3
  84458. * @param otherVector defines the second operand
  84459. * @returns the current updated Vector3
  84460. */
  84461. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84462. /**
  84463. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  84464. * @param otherVector defines the second operand
  84465. * @returns the resulting Vector3
  84466. */
  84467. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  84468. /**
  84469. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  84470. * @param otherVector defines the second operand
  84471. * @param result defines the Vector3 object where to store the result
  84472. * @returns the current Vector3
  84473. */
  84474. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84475. /**
  84476. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  84477. * @param x defines the x coordinate of the operand
  84478. * @param y defines the y coordinate of the operand
  84479. * @param z defines the z coordinate of the operand
  84480. * @returns the resulting Vector3
  84481. */
  84482. subtractFromFloats(x: number, y: number, z: number): Vector3;
  84483. /**
  84484. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  84485. * @param x defines the x coordinate of the operand
  84486. * @param y defines the y coordinate of the operand
  84487. * @param z defines the z coordinate of the operand
  84488. * @param result defines the Vector3 object where to store the result
  84489. * @returns the current Vector3
  84490. */
  84491. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  84492. /**
  84493. * Gets a new Vector3 set with the current Vector3 negated coordinates
  84494. * @returns a new Vector3
  84495. */
  84496. negate(): Vector3;
  84497. /**
  84498. * Negate this vector in place
  84499. * @returns this
  84500. */
  84501. negateInPlace(): Vector3;
  84502. /**
  84503. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  84504. * @param result defines the Vector3 object where to store the result
  84505. * @returns the current Vector3
  84506. */
  84507. negateToRef(result: Vector3): Vector3;
  84508. /**
  84509. * Multiplies the Vector3 coordinates by the float "scale"
  84510. * @param scale defines the multiplier factor
  84511. * @returns the current updated Vector3
  84512. */
  84513. scaleInPlace(scale: number): Vector3;
  84514. /**
  84515. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  84516. * @param scale defines the multiplier factor
  84517. * @returns a new Vector3
  84518. */
  84519. scale(scale: number): Vector3;
  84520. /**
  84521. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  84522. * @param scale defines the multiplier factor
  84523. * @param result defines the Vector3 object where to store the result
  84524. * @returns the current Vector3
  84525. */
  84526. scaleToRef(scale: number, result: Vector3): Vector3;
  84527. /**
  84528. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  84529. * @param scale defines the scale factor
  84530. * @param result defines the Vector3 object where to store the result
  84531. * @returns the unmodified current Vector3
  84532. */
  84533. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  84534. /**
  84535. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  84536. * @param origin defines the origin of the projection ray
  84537. * @param plane defines the plane to project to
  84538. * @returns the projected vector3
  84539. */
  84540. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  84541. /**
  84542. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  84543. * @param origin defines the origin of the projection ray
  84544. * @param plane defines the plane to project to
  84545. * @param result defines the Vector3 where to store the result
  84546. */
  84547. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  84548. /**
  84549. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  84550. * @param otherVector defines the second operand
  84551. * @returns true if both vectors are equals
  84552. */
  84553. equals(otherVector: DeepImmutable<Vector3>): boolean;
  84554. /**
  84555. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  84556. * @param otherVector defines the second operand
  84557. * @param epsilon defines the minimal distance to define values as equals
  84558. * @returns true if both vectors are distant less than epsilon
  84559. */
  84560. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  84561. /**
  84562. * Returns true if the current Vector3 coordinates equals the given floats
  84563. * @param x defines the x coordinate of the operand
  84564. * @param y defines the y coordinate of the operand
  84565. * @param z defines the z coordinate of the operand
  84566. * @returns true if both vectors are equals
  84567. */
  84568. equalsToFloats(x: number, y: number, z: number): boolean;
  84569. /**
  84570. * Multiplies the current Vector3 coordinates by the given ones
  84571. * @param otherVector defines the second operand
  84572. * @returns the current updated Vector3
  84573. */
  84574. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84575. /**
  84576. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  84577. * @param otherVector defines the second operand
  84578. * @returns the new Vector3
  84579. */
  84580. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  84581. /**
  84582. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  84583. * @param otherVector defines the second operand
  84584. * @param result defines the Vector3 object where to store the result
  84585. * @returns the current Vector3
  84586. */
  84587. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84588. /**
  84589. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  84590. * @param x defines the x coordinate of the operand
  84591. * @param y defines the y coordinate of the operand
  84592. * @param z defines the z coordinate of the operand
  84593. * @returns the new Vector3
  84594. */
  84595. multiplyByFloats(x: number, y: number, z: number): Vector3;
  84596. /**
  84597. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  84598. * @param otherVector defines the second operand
  84599. * @returns the new Vector3
  84600. */
  84601. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  84602. /**
  84603. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  84604. * @param otherVector defines the second operand
  84605. * @param result defines the Vector3 object where to store the result
  84606. * @returns the current Vector3
  84607. */
  84608. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84609. /**
  84610. * Divides the current Vector3 coordinates by the given ones.
  84611. * @param otherVector defines the second operand
  84612. * @returns the current updated Vector3
  84613. */
  84614. divideInPlace(otherVector: Vector3): Vector3;
  84615. /**
  84616. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  84617. * @param other defines the second operand
  84618. * @returns the current updated Vector3
  84619. */
  84620. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  84621. /**
  84622. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  84623. * @param other defines the second operand
  84624. * @returns the current updated Vector3
  84625. */
  84626. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  84627. /**
  84628. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  84629. * @param x defines the x coordinate of the operand
  84630. * @param y defines the y coordinate of the operand
  84631. * @param z defines the z coordinate of the operand
  84632. * @returns the current updated Vector3
  84633. */
  84634. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84635. /**
  84636. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  84637. * @param x defines the x coordinate of the operand
  84638. * @param y defines the y coordinate of the operand
  84639. * @param z defines the z coordinate of the operand
  84640. * @returns the current updated Vector3
  84641. */
  84642. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84643. /**
  84644. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  84645. * Check if is non uniform within a certain amount of decimal places to account for this
  84646. * @param epsilon the amount the values can differ
  84647. * @returns if the the vector is non uniform to a certain number of decimal places
  84648. */
  84649. isNonUniformWithinEpsilon(epsilon: number): boolean;
  84650. /**
  84651. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  84652. */
  84653. get isNonUniform(): boolean;
  84654. /**
  84655. * Gets a new Vector3 from current Vector3 floored values
  84656. * @returns a new Vector3
  84657. */
  84658. floor(): Vector3;
  84659. /**
  84660. * Gets a new Vector3 from current Vector3 floored values
  84661. * @returns a new Vector3
  84662. */
  84663. fract(): Vector3;
  84664. /**
  84665. * Gets the length of the Vector3
  84666. * @returns the length of the Vector3
  84667. */
  84668. length(): number;
  84669. /**
  84670. * Gets the squared length of the Vector3
  84671. * @returns squared length of the Vector3
  84672. */
  84673. lengthSquared(): number;
  84674. /**
  84675. * Normalize the current Vector3.
  84676. * Please note that this is an in place operation.
  84677. * @returns the current updated Vector3
  84678. */
  84679. normalize(): Vector3;
  84680. /**
  84681. * Reorders the x y z properties of the vector in place
  84682. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  84683. * @returns the current updated vector
  84684. */
  84685. reorderInPlace(order: string): this;
  84686. /**
  84687. * Rotates the vector around 0,0,0 by a quaternion
  84688. * @param quaternion the rotation quaternion
  84689. * @param result vector to store the result
  84690. * @returns the resulting vector
  84691. */
  84692. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  84693. /**
  84694. * Rotates a vector around a given point
  84695. * @param quaternion the rotation quaternion
  84696. * @param point the point to rotate around
  84697. * @param result vector to store the result
  84698. * @returns the resulting vector
  84699. */
  84700. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  84701. /**
  84702. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  84703. * The cross product is then orthogonal to both current and "other"
  84704. * @param other defines the right operand
  84705. * @returns the cross product
  84706. */
  84707. cross(other: Vector3): Vector3;
  84708. /**
  84709. * Normalize the current Vector3 with the given input length.
  84710. * Please note that this is an in place operation.
  84711. * @param len the length of the vector
  84712. * @returns the current updated Vector3
  84713. */
  84714. normalizeFromLength(len: number): Vector3;
  84715. /**
  84716. * Normalize the current Vector3 to a new vector
  84717. * @returns the new Vector3
  84718. */
  84719. normalizeToNew(): Vector3;
  84720. /**
  84721. * Normalize the current Vector3 to the reference
  84722. * @param reference define the Vector3 to update
  84723. * @returns the updated Vector3
  84724. */
  84725. normalizeToRef(reference: Vector3): Vector3;
  84726. /**
  84727. * Creates a new Vector3 copied from the current Vector3
  84728. * @returns the new Vector3
  84729. */
  84730. clone(): Vector3;
  84731. /**
  84732. * Copies the given vector coordinates to the current Vector3 ones
  84733. * @param source defines the source Vector3
  84734. * @returns the current updated Vector3
  84735. */
  84736. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  84737. /**
  84738. * Copies the given floats to the current Vector3 coordinates
  84739. * @param x defines the x coordinate of the operand
  84740. * @param y defines the y coordinate of the operand
  84741. * @param z defines the z coordinate of the operand
  84742. * @returns the current updated Vector3
  84743. */
  84744. copyFromFloats(x: number, y: number, z: number): Vector3;
  84745. /**
  84746. * Copies the given floats to the current Vector3 coordinates
  84747. * @param x defines the x coordinate of the operand
  84748. * @param y defines the y coordinate of the operand
  84749. * @param z defines the z coordinate of the operand
  84750. * @returns the current updated Vector3
  84751. */
  84752. set(x: number, y: number, z: number): Vector3;
  84753. /**
  84754. * Copies the given float to the current Vector3 coordinates
  84755. * @param v defines the x, y and z coordinates of the operand
  84756. * @returns the current updated Vector3
  84757. */
  84758. setAll(v: number): Vector3;
  84759. /**
  84760. * Get the clip factor between two vectors
  84761. * @param vector0 defines the first operand
  84762. * @param vector1 defines the second operand
  84763. * @param axis defines the axis to use
  84764. * @param size defines the size along the axis
  84765. * @returns the clip factor
  84766. */
  84767. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  84768. /**
  84769. * Get angle between two vectors
  84770. * @param vector0 angle between vector0 and vector1
  84771. * @param vector1 angle between vector0 and vector1
  84772. * @param normal direction of the normal
  84773. * @return the angle between vector0 and vector1
  84774. */
  84775. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  84776. /**
  84777. * Returns a new Vector3 set from the index "offset" of the given array
  84778. * @param array defines the source array
  84779. * @param offset defines the offset in the source array
  84780. * @returns the new Vector3
  84781. */
  84782. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  84783. /**
  84784. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  84785. * @param array defines the source array
  84786. * @param offset defines the offset in the source array
  84787. * @returns the new Vector3
  84788. * @deprecated Please use FromArray instead.
  84789. */
  84790. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  84791. /**
  84792. * Sets the given vector "result" with the element values from the index "offset" of the given array
  84793. * @param array defines the source array
  84794. * @param offset defines the offset in the source array
  84795. * @param result defines the Vector3 where to store the result
  84796. */
  84797. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  84798. /**
  84799. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  84800. * @param array defines the source array
  84801. * @param offset defines the offset in the source array
  84802. * @param result defines the Vector3 where to store the result
  84803. * @deprecated Please use FromArrayToRef instead.
  84804. */
  84805. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  84806. /**
  84807. * Sets the given vector "result" with the given floats.
  84808. * @param x defines the x coordinate of the source
  84809. * @param y defines the y coordinate of the source
  84810. * @param z defines the z coordinate of the source
  84811. * @param result defines the Vector3 where to store the result
  84812. */
  84813. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  84814. /**
  84815. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  84816. * @returns a new empty Vector3
  84817. */
  84818. static Zero(): Vector3;
  84819. /**
  84820. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  84821. * @returns a new unit Vector3
  84822. */
  84823. static One(): Vector3;
  84824. /**
  84825. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  84826. * @returns a new up Vector3
  84827. */
  84828. static Up(): Vector3;
  84829. /**
  84830. * Gets a up Vector3 that must not be updated
  84831. */
  84832. static get UpReadOnly(): DeepImmutable<Vector3>;
  84833. /**
  84834. * Gets a zero Vector3 that must not be updated
  84835. */
  84836. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  84837. /**
  84838. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  84839. * @returns a new down Vector3
  84840. */
  84841. static Down(): Vector3;
  84842. /**
  84843. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  84844. * @param rightHandedSystem is the scene right-handed (negative z)
  84845. * @returns a new forward Vector3
  84846. */
  84847. static Forward(rightHandedSystem?: boolean): Vector3;
  84848. /**
  84849. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  84850. * @param rightHandedSystem is the scene right-handed (negative-z)
  84851. * @returns a new forward Vector3
  84852. */
  84853. static Backward(rightHandedSystem?: boolean): Vector3;
  84854. /**
  84855. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  84856. * @returns a new right Vector3
  84857. */
  84858. static Right(): Vector3;
  84859. /**
  84860. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  84861. * @returns a new left Vector3
  84862. */
  84863. static Left(): Vector3;
  84864. /**
  84865. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  84866. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84867. * @param vector defines the Vector3 to transform
  84868. * @param transformation defines the transformation matrix
  84869. * @returns the transformed Vector3
  84870. */
  84871. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84872. /**
  84873. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  84874. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84875. * @param vector defines the Vector3 to transform
  84876. * @param transformation defines the transformation matrix
  84877. * @param result defines the Vector3 where to store the result
  84878. */
  84879. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84880. /**
  84881. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  84882. * This method computes tranformed coordinates only, not transformed direction vectors
  84883. * @param x define the x coordinate of the source vector
  84884. * @param y define the y coordinate of the source vector
  84885. * @param z define the z coordinate of the source vector
  84886. * @param transformation defines the transformation matrix
  84887. * @param result defines the Vector3 where to store the result
  84888. */
  84889. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84890. /**
  84891. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  84892. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84893. * @param vector defines the Vector3 to transform
  84894. * @param transformation defines the transformation matrix
  84895. * @returns the new Vector3
  84896. */
  84897. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84898. /**
  84899. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  84900. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84901. * @param vector defines the Vector3 to transform
  84902. * @param transformation defines the transformation matrix
  84903. * @param result defines the Vector3 where to store the result
  84904. */
  84905. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84906. /**
  84907. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  84908. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84909. * @param x define the x coordinate of the source vector
  84910. * @param y define the y coordinate of the source vector
  84911. * @param z define the z coordinate of the source vector
  84912. * @param transformation defines the transformation matrix
  84913. * @param result defines the Vector3 where to store the result
  84914. */
  84915. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84916. /**
  84917. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  84918. * @param value1 defines the first control point
  84919. * @param value2 defines the second control point
  84920. * @param value3 defines the third control point
  84921. * @param value4 defines the fourth control point
  84922. * @param amount defines the amount on the spline to use
  84923. * @returns the new Vector3
  84924. */
  84925. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  84926. /**
  84927. * 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"
  84928. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84929. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84930. * @param value defines the current value
  84931. * @param min defines the lower range value
  84932. * @param max defines the upper range value
  84933. * @returns the new Vector3
  84934. */
  84935. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  84936. /**
  84937. * 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"
  84938. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84939. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84940. * @param value defines the current value
  84941. * @param min defines the lower range value
  84942. * @param max defines the upper range value
  84943. * @param result defines the Vector3 where to store the result
  84944. */
  84945. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  84946. /**
  84947. * Checks if a given vector is inside a specific range
  84948. * @param v defines the vector to test
  84949. * @param min defines the minimum range
  84950. * @param max defines the maximum range
  84951. */
  84952. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  84953. /**
  84954. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  84955. * @param value1 defines the first control point
  84956. * @param tangent1 defines the first tangent vector
  84957. * @param value2 defines the second control point
  84958. * @param tangent2 defines the second tangent vector
  84959. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  84960. * @returns the new Vector3
  84961. */
  84962. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  84963. /**
  84964. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  84965. * @param start defines the start value
  84966. * @param end defines the end value
  84967. * @param amount max defines amount between both (between 0 and 1)
  84968. * @returns the new Vector3
  84969. */
  84970. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  84971. /**
  84972. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  84973. * @param start defines the start value
  84974. * @param end defines the end value
  84975. * @param amount max defines amount between both (between 0 and 1)
  84976. * @param result defines the Vector3 where to store the result
  84977. */
  84978. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  84979. /**
  84980. * Returns the dot product (float) between the vectors "left" and "right"
  84981. * @param left defines the left operand
  84982. * @param right defines the right operand
  84983. * @returns the dot product
  84984. */
  84985. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  84986. /**
  84987. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  84988. * The cross product is then orthogonal to both "left" and "right"
  84989. * @param left defines the left operand
  84990. * @param right defines the right operand
  84991. * @returns the cross product
  84992. */
  84993. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84994. /**
  84995. * Sets the given vector "result" with the cross product of "left" and "right"
  84996. * The cross product is then orthogonal to both "left" and "right"
  84997. * @param left defines the left operand
  84998. * @param right defines the right operand
  84999. * @param result defines the Vector3 where to store the result
  85000. */
  85001. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  85002. /**
  85003. * Returns a new Vector3 as the normalization of the given vector
  85004. * @param vector defines the Vector3 to normalize
  85005. * @returns the new Vector3
  85006. */
  85007. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  85008. /**
  85009. * Sets the given vector "result" with the normalization of the given first vector
  85010. * @param vector defines the Vector3 to normalize
  85011. * @param result defines the Vector3 where to store the result
  85012. */
  85013. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  85014. /**
  85015. * Project a Vector3 onto screen space
  85016. * @param vector defines the Vector3 to project
  85017. * @param world defines the world matrix to use
  85018. * @param transform defines the transform (view x projection) matrix to use
  85019. * @param viewport defines the screen viewport to use
  85020. * @returns the new Vector3
  85021. */
  85022. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  85023. /**
  85024. * Project a Vector3 onto screen space to reference
  85025. * @param vector defines the Vector3 to project
  85026. * @param world defines the world matrix to use
  85027. * @param transform defines the transform (view x projection) matrix to use
  85028. * @param viewport defines the screen viewport to use
  85029. * @param result the vector in which the screen space will be stored
  85030. * @returns the new Vector3
  85031. */
  85032. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  85033. /** @hidden */
  85034. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  85035. /**
  85036. * Unproject from screen space to object space
  85037. * @param source defines the screen space Vector3 to use
  85038. * @param viewportWidth defines the current width of the viewport
  85039. * @param viewportHeight defines the current height of the viewport
  85040. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85041. * @param transform defines the transform (view x projection) matrix to use
  85042. * @returns the new Vector3
  85043. */
  85044. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  85045. /**
  85046. * Unproject from screen space to object space
  85047. * @param source defines the screen space Vector3 to use
  85048. * @param viewportWidth defines the current width of the viewport
  85049. * @param viewportHeight defines the current height of the viewport
  85050. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85051. * @param view defines the view matrix to use
  85052. * @param projection defines the projection matrix to use
  85053. * @returns the new Vector3
  85054. */
  85055. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  85056. /**
  85057. * Unproject from screen space to object space
  85058. * @param source defines the screen space Vector3 to use
  85059. * @param viewportWidth defines the current width of the viewport
  85060. * @param viewportHeight defines the current height of the viewport
  85061. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85062. * @param view defines the view matrix to use
  85063. * @param projection defines the projection matrix to use
  85064. * @param result defines the Vector3 where to store the result
  85065. */
  85066. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  85067. /**
  85068. * Unproject from screen space to object space
  85069. * @param sourceX defines the screen space x coordinate to use
  85070. * @param sourceY defines the screen space y coordinate to use
  85071. * @param sourceZ defines the screen space z coordinate to use
  85072. * @param viewportWidth defines the current width of the viewport
  85073. * @param viewportHeight defines the current height of the viewport
  85074. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85075. * @param view defines the view matrix to use
  85076. * @param projection defines the projection matrix to use
  85077. * @param result defines the Vector3 where to store the result
  85078. */
  85079. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  85080. /**
  85081. * Gets the minimal coordinate values between two Vector3
  85082. * @param left defines the first operand
  85083. * @param right defines the second operand
  85084. * @returns the new Vector3
  85085. */
  85086. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  85087. /**
  85088. * Gets the maximal coordinate values between two Vector3
  85089. * @param left defines the first operand
  85090. * @param right defines the second operand
  85091. * @returns the new Vector3
  85092. */
  85093. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  85094. /**
  85095. * Returns the distance between the vectors "value1" and "value2"
  85096. * @param value1 defines the first operand
  85097. * @param value2 defines the second operand
  85098. * @returns the distance
  85099. */
  85100. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  85101. /**
  85102. * Returns the squared distance between the vectors "value1" and "value2"
  85103. * @param value1 defines the first operand
  85104. * @param value2 defines the second operand
  85105. * @returns the squared distance
  85106. */
  85107. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  85108. /**
  85109. * Returns a new Vector3 located at the center between "value1" and "value2"
  85110. * @param value1 defines the first operand
  85111. * @param value2 defines the second operand
  85112. * @returns the new Vector3
  85113. */
  85114. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  85115. /**
  85116. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  85117. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  85118. * to something in order to rotate it from its local system to the given target system
  85119. * Note: axis1, axis2 and axis3 are normalized during this operation
  85120. * @param axis1 defines the first axis
  85121. * @param axis2 defines the second axis
  85122. * @param axis3 defines the third axis
  85123. * @returns a new Vector3
  85124. */
  85125. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  85126. /**
  85127. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  85128. * @param axis1 defines the first axis
  85129. * @param axis2 defines the second axis
  85130. * @param axis3 defines the third axis
  85131. * @param ref defines the Vector3 where to store the result
  85132. */
  85133. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  85134. }
  85135. /**
  85136. * Vector4 class created for EulerAngle class conversion to Quaternion
  85137. */
  85138. export class Vector4 {
  85139. /** x value of the vector */
  85140. x: number;
  85141. /** y value of the vector */
  85142. y: number;
  85143. /** z value of the vector */
  85144. z: number;
  85145. /** w value of the vector */
  85146. w: number;
  85147. /**
  85148. * Creates a Vector4 object from the given floats.
  85149. * @param x x value of the vector
  85150. * @param y y value of the vector
  85151. * @param z z value of the vector
  85152. * @param w w value of the vector
  85153. */
  85154. constructor(
  85155. /** x value of the vector */
  85156. x: number,
  85157. /** y value of the vector */
  85158. y: number,
  85159. /** z value of the vector */
  85160. z: number,
  85161. /** w value of the vector */
  85162. w: number);
  85163. /**
  85164. * Returns the string with the Vector4 coordinates.
  85165. * @returns a string containing all the vector values
  85166. */
  85167. toString(): string;
  85168. /**
  85169. * Returns the string "Vector4".
  85170. * @returns "Vector4"
  85171. */
  85172. getClassName(): string;
  85173. /**
  85174. * Returns the Vector4 hash code.
  85175. * @returns a unique hash code
  85176. */
  85177. getHashCode(): number;
  85178. /**
  85179. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  85180. * @returns the resulting array
  85181. */
  85182. asArray(): number[];
  85183. /**
  85184. * Populates the given array from the given index with the Vector4 coordinates.
  85185. * @param array array to populate
  85186. * @param index index of the array to start at (default: 0)
  85187. * @returns the Vector4.
  85188. */
  85189. toArray(array: FloatArray, index?: number): Vector4;
  85190. /**
  85191. * Update the current vector from an array
  85192. * @param array defines the destination array
  85193. * @param index defines the offset in the destination array
  85194. * @returns the current Vector3
  85195. */
  85196. fromArray(array: FloatArray, index?: number): Vector4;
  85197. /**
  85198. * Adds the given vector to the current Vector4.
  85199. * @param otherVector the vector to add
  85200. * @returns the updated Vector4.
  85201. */
  85202. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85203. /**
  85204. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  85205. * @param otherVector the vector to add
  85206. * @returns the resulting vector
  85207. */
  85208. add(otherVector: DeepImmutable<Vector4>): Vector4;
  85209. /**
  85210. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  85211. * @param otherVector the vector to add
  85212. * @param result the vector to store the result
  85213. * @returns the current Vector4.
  85214. */
  85215. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85216. /**
  85217. * Subtract in place the given vector from the current Vector4.
  85218. * @param otherVector the vector to subtract
  85219. * @returns the updated Vector4.
  85220. */
  85221. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85222. /**
  85223. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  85224. * @param otherVector the vector to add
  85225. * @returns the new vector with the result
  85226. */
  85227. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  85228. /**
  85229. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  85230. * @param otherVector the vector to subtract
  85231. * @param result the vector to store the result
  85232. * @returns the current Vector4.
  85233. */
  85234. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85235. /**
  85236. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85237. */
  85238. /**
  85239. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85240. * @param x value to subtract
  85241. * @param y value to subtract
  85242. * @param z value to subtract
  85243. * @param w value to subtract
  85244. * @returns new vector containing the result
  85245. */
  85246. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  85247. /**
  85248. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85249. * @param x value to subtract
  85250. * @param y value to subtract
  85251. * @param z value to subtract
  85252. * @param w value to subtract
  85253. * @param result the vector to store the result in
  85254. * @returns the current Vector4.
  85255. */
  85256. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  85257. /**
  85258. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  85259. * @returns a new vector with the negated values
  85260. */
  85261. negate(): Vector4;
  85262. /**
  85263. * Negate this vector in place
  85264. * @returns this
  85265. */
  85266. negateInPlace(): Vector4;
  85267. /**
  85268. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  85269. * @param result defines the Vector3 object where to store the result
  85270. * @returns the current Vector4
  85271. */
  85272. negateToRef(result: Vector4): Vector4;
  85273. /**
  85274. * Multiplies the current Vector4 coordinates by scale (float).
  85275. * @param scale the number to scale with
  85276. * @returns the updated Vector4.
  85277. */
  85278. scaleInPlace(scale: number): Vector4;
  85279. /**
  85280. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  85281. * @param scale the number to scale with
  85282. * @returns a new vector with the result
  85283. */
  85284. scale(scale: number): Vector4;
  85285. /**
  85286. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  85287. * @param scale the number to scale with
  85288. * @param result a vector to store the result in
  85289. * @returns the current Vector4.
  85290. */
  85291. scaleToRef(scale: number, result: Vector4): Vector4;
  85292. /**
  85293. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  85294. * @param scale defines the scale factor
  85295. * @param result defines the Vector4 object where to store the result
  85296. * @returns the unmodified current Vector4
  85297. */
  85298. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  85299. /**
  85300. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  85301. * @param otherVector the vector to compare against
  85302. * @returns true if they are equal
  85303. */
  85304. equals(otherVector: DeepImmutable<Vector4>): boolean;
  85305. /**
  85306. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  85307. * @param otherVector vector to compare against
  85308. * @param epsilon (Default: very small number)
  85309. * @returns true if they are equal
  85310. */
  85311. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  85312. /**
  85313. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  85314. * @param x x value to compare against
  85315. * @param y y value to compare against
  85316. * @param z z value to compare against
  85317. * @param w w value to compare against
  85318. * @returns true if equal
  85319. */
  85320. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  85321. /**
  85322. * Multiplies in place the current Vector4 by the given one.
  85323. * @param otherVector vector to multiple with
  85324. * @returns the updated Vector4.
  85325. */
  85326. multiplyInPlace(otherVector: Vector4): Vector4;
  85327. /**
  85328. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  85329. * @param otherVector vector to multiple with
  85330. * @returns resulting new vector
  85331. */
  85332. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  85333. /**
  85334. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  85335. * @param otherVector vector to multiple with
  85336. * @param result vector to store the result
  85337. * @returns the current Vector4.
  85338. */
  85339. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85340. /**
  85341. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  85342. * @param x x value multiply with
  85343. * @param y y value multiply with
  85344. * @param z z value multiply with
  85345. * @param w w value multiply with
  85346. * @returns resulting new vector
  85347. */
  85348. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  85349. /**
  85350. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  85351. * @param otherVector vector to devide with
  85352. * @returns resulting new vector
  85353. */
  85354. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  85355. /**
  85356. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  85357. * @param otherVector vector to devide with
  85358. * @param result vector to store the result
  85359. * @returns the current Vector4.
  85360. */
  85361. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85362. /**
  85363. * Divides the current Vector3 coordinates by the given ones.
  85364. * @param otherVector vector to devide with
  85365. * @returns the updated Vector3.
  85366. */
  85367. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85368. /**
  85369. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  85370. * @param other defines the second operand
  85371. * @returns the current updated Vector4
  85372. */
  85373. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  85374. /**
  85375. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  85376. * @param other defines the second operand
  85377. * @returns the current updated Vector4
  85378. */
  85379. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  85380. /**
  85381. * Gets a new Vector4 from current Vector4 floored values
  85382. * @returns a new Vector4
  85383. */
  85384. floor(): Vector4;
  85385. /**
  85386. * Gets a new Vector4 from current Vector3 floored values
  85387. * @returns a new Vector4
  85388. */
  85389. fract(): Vector4;
  85390. /**
  85391. * Returns the Vector4 length (float).
  85392. * @returns the length
  85393. */
  85394. length(): number;
  85395. /**
  85396. * Returns the Vector4 squared length (float).
  85397. * @returns the length squared
  85398. */
  85399. lengthSquared(): number;
  85400. /**
  85401. * Normalizes in place the Vector4.
  85402. * @returns the updated Vector4.
  85403. */
  85404. normalize(): Vector4;
  85405. /**
  85406. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  85407. * @returns this converted to a new vector3
  85408. */
  85409. toVector3(): Vector3;
  85410. /**
  85411. * Returns a new Vector4 copied from the current one.
  85412. * @returns the new cloned vector
  85413. */
  85414. clone(): Vector4;
  85415. /**
  85416. * Updates the current Vector4 with the given one coordinates.
  85417. * @param source the source vector to copy from
  85418. * @returns the updated Vector4.
  85419. */
  85420. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  85421. /**
  85422. * Updates the current Vector4 coordinates with the given floats.
  85423. * @param x float to copy from
  85424. * @param y float to copy from
  85425. * @param z float to copy from
  85426. * @param w float to copy from
  85427. * @returns the updated Vector4.
  85428. */
  85429. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  85430. /**
  85431. * Updates the current Vector4 coordinates with the given floats.
  85432. * @param x float to set from
  85433. * @param y float to set from
  85434. * @param z float to set from
  85435. * @param w float to set from
  85436. * @returns the updated Vector4.
  85437. */
  85438. set(x: number, y: number, z: number, w: number): Vector4;
  85439. /**
  85440. * Copies the given float to the current Vector3 coordinates
  85441. * @param v defines the x, y, z and w coordinates of the operand
  85442. * @returns the current updated Vector3
  85443. */
  85444. setAll(v: number): Vector4;
  85445. /**
  85446. * Returns a new Vector4 set from the starting index of the given array.
  85447. * @param array the array to pull values from
  85448. * @param offset the offset into the array to start at
  85449. * @returns the new vector
  85450. */
  85451. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  85452. /**
  85453. * Updates the given vector "result" from the starting index of the given array.
  85454. * @param array the array to pull values from
  85455. * @param offset the offset into the array to start at
  85456. * @param result the vector to store the result in
  85457. */
  85458. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  85459. /**
  85460. * Updates the given vector "result" from the starting index of the given Float32Array.
  85461. * @param array the array to pull values from
  85462. * @param offset the offset into the array to start at
  85463. * @param result the vector to store the result in
  85464. */
  85465. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  85466. /**
  85467. * Updates the given vector "result" coordinates from the given floats.
  85468. * @param x float to set from
  85469. * @param y float to set from
  85470. * @param z float to set from
  85471. * @param w float to set from
  85472. * @param result the vector to the floats in
  85473. */
  85474. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  85475. /**
  85476. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  85477. * @returns the new vector
  85478. */
  85479. static Zero(): Vector4;
  85480. /**
  85481. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  85482. * @returns the new vector
  85483. */
  85484. static One(): Vector4;
  85485. /**
  85486. * Returns a new normalized Vector4 from the given one.
  85487. * @param vector the vector to normalize
  85488. * @returns the vector
  85489. */
  85490. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  85491. /**
  85492. * Updates the given vector "result" from the normalization of the given one.
  85493. * @param vector the vector to normalize
  85494. * @param result the vector to store the result in
  85495. */
  85496. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  85497. /**
  85498. * Returns a vector with the minimum values from the left and right vectors
  85499. * @param left left vector to minimize
  85500. * @param right right vector to minimize
  85501. * @returns a new vector with the minimum of the left and right vector values
  85502. */
  85503. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  85504. /**
  85505. * Returns a vector with the maximum values from the left and right vectors
  85506. * @param left left vector to maximize
  85507. * @param right right vector to maximize
  85508. * @returns a new vector with the maximum of the left and right vector values
  85509. */
  85510. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  85511. /**
  85512. * Returns the distance (float) between the vectors "value1" and "value2".
  85513. * @param value1 value to calulate the distance between
  85514. * @param value2 value to calulate the distance between
  85515. * @return the distance between the two vectors
  85516. */
  85517. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  85518. /**
  85519. * Returns the squared distance (float) between the vectors "value1" and "value2".
  85520. * @param value1 value to calulate the distance between
  85521. * @param value2 value to calulate the distance between
  85522. * @return the distance between the two vectors squared
  85523. */
  85524. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  85525. /**
  85526. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  85527. * @param value1 value to calulate the center between
  85528. * @param value2 value to calulate the center between
  85529. * @return the center between the two vectors
  85530. */
  85531. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  85532. /**
  85533. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  85534. * This methods computes transformed normalized direction vectors only.
  85535. * @param vector the vector to transform
  85536. * @param transformation the transformation matrix to apply
  85537. * @returns the new vector
  85538. */
  85539. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  85540. /**
  85541. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  85542. * This methods computes transformed normalized direction vectors only.
  85543. * @param vector the vector to transform
  85544. * @param transformation the transformation matrix to apply
  85545. * @param result the vector to store the result in
  85546. */
  85547. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  85548. /**
  85549. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  85550. * This methods computes transformed normalized direction vectors only.
  85551. * @param x value to transform
  85552. * @param y value to transform
  85553. * @param z value to transform
  85554. * @param w value to transform
  85555. * @param transformation the transformation matrix to apply
  85556. * @param result the vector to store the results in
  85557. */
  85558. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  85559. /**
  85560. * Creates a new Vector4 from a Vector3
  85561. * @param source defines the source data
  85562. * @param w defines the 4th component (default is 0)
  85563. * @returns a new Vector4
  85564. */
  85565. static FromVector3(source: Vector3, w?: number): Vector4;
  85566. }
  85567. /**
  85568. * Class used to store quaternion data
  85569. * @see https://en.wikipedia.org/wiki/Quaternion
  85570. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  85571. */
  85572. export class Quaternion {
  85573. /** @hidden */
  85574. _x: number;
  85575. /** @hidden */
  85576. _y: number;
  85577. /** @hidden */
  85578. _z: number;
  85579. /** @hidden */
  85580. _w: number;
  85581. /** @hidden */
  85582. _isDirty: boolean;
  85583. /** Gets or sets the x coordinate */
  85584. get x(): number;
  85585. set x(value: number);
  85586. /** Gets or sets the y coordinate */
  85587. get y(): number;
  85588. set y(value: number);
  85589. /** Gets or sets the z coordinate */
  85590. get z(): number;
  85591. set z(value: number);
  85592. /** Gets or sets the w coordinate */
  85593. get w(): number;
  85594. set w(value: number);
  85595. /**
  85596. * Creates a new Quaternion from the given floats
  85597. * @param x defines the first component (0 by default)
  85598. * @param y defines the second component (0 by default)
  85599. * @param z defines the third component (0 by default)
  85600. * @param w defines the fourth component (1.0 by default)
  85601. */
  85602. constructor(x?: number, y?: number, z?: number, w?: number);
  85603. /**
  85604. * Gets a string representation for the current quaternion
  85605. * @returns a string with the Quaternion coordinates
  85606. */
  85607. toString(): string;
  85608. /**
  85609. * Gets the class name of the quaternion
  85610. * @returns the string "Quaternion"
  85611. */
  85612. getClassName(): string;
  85613. /**
  85614. * Gets a hash code for this quaternion
  85615. * @returns the quaternion hash code
  85616. */
  85617. getHashCode(): number;
  85618. /**
  85619. * Copy the quaternion to an array
  85620. * @returns a new array populated with 4 elements from the quaternion coordinates
  85621. */
  85622. asArray(): number[];
  85623. /**
  85624. * Check if two quaternions are equals
  85625. * @param otherQuaternion defines the second operand
  85626. * @return true if the current quaternion and the given one coordinates are strictly equals
  85627. */
  85628. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  85629. /**
  85630. * Gets a boolean if two quaternions are equals (using an epsilon value)
  85631. * @param otherQuaternion defines the other quaternion
  85632. * @param epsilon defines the minimal distance to consider equality
  85633. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  85634. */
  85635. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  85636. /**
  85637. * Clone the current quaternion
  85638. * @returns a new quaternion copied from the current one
  85639. */
  85640. clone(): Quaternion;
  85641. /**
  85642. * Copy a quaternion to the current one
  85643. * @param other defines the other quaternion
  85644. * @returns the updated current quaternion
  85645. */
  85646. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  85647. /**
  85648. * Updates the current quaternion with the given float coordinates
  85649. * @param x defines the x coordinate
  85650. * @param y defines the y coordinate
  85651. * @param z defines the z coordinate
  85652. * @param w defines the w coordinate
  85653. * @returns the updated current quaternion
  85654. */
  85655. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  85656. /**
  85657. * Updates the current quaternion from the given float coordinates
  85658. * @param x defines the x coordinate
  85659. * @param y defines the y coordinate
  85660. * @param z defines the z coordinate
  85661. * @param w defines the w coordinate
  85662. * @returns the updated current quaternion
  85663. */
  85664. set(x: number, y: number, z: number, w: number): Quaternion;
  85665. /**
  85666. * Adds two quaternions
  85667. * @param other defines the second operand
  85668. * @returns a new quaternion as the addition result of the given one and the current quaternion
  85669. */
  85670. add(other: DeepImmutable<Quaternion>): Quaternion;
  85671. /**
  85672. * Add a quaternion to the current one
  85673. * @param other defines the quaternion to add
  85674. * @returns the current quaternion
  85675. */
  85676. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  85677. /**
  85678. * Subtract two quaternions
  85679. * @param other defines the second operand
  85680. * @returns a new quaternion as the subtraction result of the given one from the current one
  85681. */
  85682. subtract(other: Quaternion): Quaternion;
  85683. /**
  85684. * Multiplies the current quaternion by a scale factor
  85685. * @param value defines the scale factor
  85686. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  85687. */
  85688. scale(value: number): Quaternion;
  85689. /**
  85690. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  85691. * @param scale defines the scale factor
  85692. * @param result defines the Quaternion object where to store the result
  85693. * @returns the unmodified current quaternion
  85694. */
  85695. scaleToRef(scale: number, result: Quaternion): Quaternion;
  85696. /**
  85697. * Multiplies in place the current quaternion by a scale factor
  85698. * @param value defines the scale factor
  85699. * @returns the current modified quaternion
  85700. */
  85701. scaleInPlace(value: number): Quaternion;
  85702. /**
  85703. * Scale the current quaternion values by a factor and add the result to a given quaternion
  85704. * @param scale defines the scale factor
  85705. * @param result defines the Quaternion object where to store the result
  85706. * @returns the unmodified current quaternion
  85707. */
  85708. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  85709. /**
  85710. * Multiplies two quaternions
  85711. * @param q1 defines the second operand
  85712. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  85713. */
  85714. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  85715. /**
  85716. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  85717. * @param q1 defines the second operand
  85718. * @param result defines the target quaternion
  85719. * @returns the current quaternion
  85720. */
  85721. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  85722. /**
  85723. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  85724. * @param q1 defines the second operand
  85725. * @returns the currentupdated quaternion
  85726. */
  85727. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  85728. /**
  85729. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  85730. * @param ref defines the target quaternion
  85731. * @returns the current quaternion
  85732. */
  85733. conjugateToRef(ref: Quaternion): Quaternion;
  85734. /**
  85735. * Conjugates in place (1-q) the current quaternion
  85736. * @returns the current updated quaternion
  85737. */
  85738. conjugateInPlace(): Quaternion;
  85739. /**
  85740. * Conjugates in place (1-q) the current quaternion
  85741. * @returns a new quaternion
  85742. */
  85743. conjugate(): Quaternion;
  85744. /**
  85745. * Gets length of current quaternion
  85746. * @returns the quaternion length (float)
  85747. */
  85748. length(): number;
  85749. /**
  85750. * Normalize in place the current quaternion
  85751. * @returns the current updated quaternion
  85752. */
  85753. normalize(): Quaternion;
  85754. /**
  85755. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  85756. * @param order is a reserved parameter and is ignored for now
  85757. * @returns a new Vector3 containing the Euler angles
  85758. */
  85759. toEulerAngles(order?: string): Vector3;
  85760. /**
  85761. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  85762. * @param result defines the vector which will be filled with the Euler angles
  85763. * @returns the current unchanged quaternion
  85764. */
  85765. toEulerAnglesToRef(result: Vector3): Quaternion;
  85766. /**
  85767. * Updates the given rotation matrix with the current quaternion values
  85768. * @param result defines the target matrix
  85769. * @returns the current unchanged quaternion
  85770. */
  85771. toRotationMatrix(result: Matrix): Quaternion;
  85772. /**
  85773. * Updates the current quaternion from the given rotation matrix values
  85774. * @param matrix defines the source matrix
  85775. * @returns the current updated quaternion
  85776. */
  85777. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85778. /**
  85779. * Creates a new quaternion from a rotation matrix
  85780. * @param matrix defines the source matrix
  85781. * @returns a new quaternion created from the given rotation matrix values
  85782. */
  85783. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85784. /**
  85785. * Updates the given quaternion with the given rotation matrix values
  85786. * @param matrix defines the source matrix
  85787. * @param result defines the target quaternion
  85788. */
  85789. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  85790. /**
  85791. * Returns the dot product (float) between the quaternions "left" and "right"
  85792. * @param left defines the left operand
  85793. * @param right defines the right operand
  85794. * @returns the dot product
  85795. */
  85796. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  85797. /**
  85798. * Checks if the two quaternions are close to each other
  85799. * @param quat0 defines the first quaternion to check
  85800. * @param quat1 defines the second quaternion to check
  85801. * @returns true if the two quaternions are close to each other
  85802. */
  85803. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  85804. /**
  85805. * Creates an empty quaternion
  85806. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  85807. */
  85808. static Zero(): Quaternion;
  85809. /**
  85810. * Inverse a given quaternion
  85811. * @param q defines the source quaternion
  85812. * @returns a new quaternion as the inverted current quaternion
  85813. */
  85814. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  85815. /**
  85816. * Inverse a given quaternion
  85817. * @param q defines the source quaternion
  85818. * @param result the quaternion the result will be stored in
  85819. * @returns the result quaternion
  85820. */
  85821. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  85822. /**
  85823. * Creates an identity quaternion
  85824. * @returns the identity quaternion
  85825. */
  85826. static Identity(): Quaternion;
  85827. /**
  85828. * Gets a boolean indicating if the given quaternion is identity
  85829. * @param quaternion defines the quaternion to check
  85830. * @returns true if the quaternion is identity
  85831. */
  85832. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  85833. /**
  85834. * Creates a quaternion from a rotation around an axis
  85835. * @param axis defines the axis to use
  85836. * @param angle defines the angle to use
  85837. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  85838. */
  85839. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  85840. /**
  85841. * Creates a rotation around an axis and stores it into the given quaternion
  85842. * @param axis defines the axis to use
  85843. * @param angle defines the angle to use
  85844. * @param result defines the target quaternion
  85845. * @returns the target quaternion
  85846. */
  85847. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  85848. /**
  85849. * Creates a new quaternion from data stored into an array
  85850. * @param array defines the data source
  85851. * @param offset defines the offset in the source array where the data starts
  85852. * @returns a new quaternion
  85853. */
  85854. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  85855. /**
  85856. * Updates the given quaternion "result" from the starting index of the given array.
  85857. * @param array the array to pull values from
  85858. * @param offset the offset into the array to start at
  85859. * @param result the quaternion to store the result in
  85860. */
  85861. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  85862. /**
  85863. * Create a quaternion from Euler rotation angles
  85864. * @param x Pitch
  85865. * @param y Yaw
  85866. * @param z Roll
  85867. * @returns the new Quaternion
  85868. */
  85869. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  85870. /**
  85871. * Updates a quaternion from Euler rotation angles
  85872. * @param x Pitch
  85873. * @param y Yaw
  85874. * @param z Roll
  85875. * @param result the quaternion to store the result
  85876. * @returns the updated quaternion
  85877. */
  85878. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  85879. /**
  85880. * Create a quaternion from Euler rotation vector
  85881. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85882. * @returns the new Quaternion
  85883. */
  85884. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  85885. /**
  85886. * Updates a quaternion from Euler rotation vector
  85887. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85888. * @param result the quaternion to store the result
  85889. * @returns the updated quaternion
  85890. */
  85891. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  85892. /**
  85893. * Creates a new quaternion from the given Euler float angles (y, x, z)
  85894. * @param yaw defines the rotation around Y axis
  85895. * @param pitch defines the rotation around X axis
  85896. * @param roll defines the rotation around Z axis
  85897. * @returns the new quaternion
  85898. */
  85899. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  85900. /**
  85901. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  85902. * @param yaw defines the rotation around Y axis
  85903. * @param pitch defines the rotation around X axis
  85904. * @param roll defines the rotation around Z axis
  85905. * @param result defines the target quaternion
  85906. */
  85907. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  85908. /**
  85909. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  85910. * @param alpha defines the rotation around first axis
  85911. * @param beta defines the rotation around second axis
  85912. * @param gamma defines the rotation around third axis
  85913. * @returns the new quaternion
  85914. */
  85915. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  85916. /**
  85917. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  85918. * @param alpha defines the rotation around first axis
  85919. * @param beta defines the rotation around second axis
  85920. * @param gamma defines the rotation around third axis
  85921. * @param result defines the target quaternion
  85922. */
  85923. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  85924. /**
  85925. * 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)
  85926. * @param axis1 defines the first axis
  85927. * @param axis2 defines the second axis
  85928. * @param axis3 defines the third axis
  85929. * @returns the new quaternion
  85930. */
  85931. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  85932. /**
  85933. * 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
  85934. * @param axis1 defines the first axis
  85935. * @param axis2 defines the second axis
  85936. * @param axis3 defines the third axis
  85937. * @param ref defines the target quaternion
  85938. */
  85939. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  85940. /**
  85941. * Interpolates between two quaternions
  85942. * @param left defines first quaternion
  85943. * @param right defines second quaternion
  85944. * @param amount defines the gradient to use
  85945. * @returns the new interpolated quaternion
  85946. */
  85947. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  85948. /**
  85949. * Interpolates between two quaternions and stores it into a target quaternion
  85950. * @param left defines first quaternion
  85951. * @param right defines second quaternion
  85952. * @param amount defines the gradient to use
  85953. * @param result defines the target quaternion
  85954. */
  85955. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  85956. /**
  85957. * Interpolate between two quaternions using Hermite interpolation
  85958. * @param value1 defines first quaternion
  85959. * @param tangent1 defines the incoming tangent
  85960. * @param value2 defines second quaternion
  85961. * @param tangent2 defines the outgoing tangent
  85962. * @param amount defines the target quaternion
  85963. * @returns the new interpolated quaternion
  85964. */
  85965. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  85966. }
  85967. /**
  85968. * Class used to store matrix data (4x4)
  85969. */
  85970. export class Matrix {
  85971. /**
  85972. * Gets the precision of matrix computations
  85973. */
  85974. static get Use64Bits(): boolean;
  85975. private static _updateFlagSeed;
  85976. private static _identityReadOnly;
  85977. private _isIdentity;
  85978. private _isIdentityDirty;
  85979. private _isIdentity3x2;
  85980. private _isIdentity3x2Dirty;
  85981. /**
  85982. * Gets the update flag of the matrix which is an unique number for the matrix.
  85983. * It will be incremented every time the matrix data change.
  85984. * You can use it to speed the comparison between two versions of the same matrix.
  85985. */
  85986. updateFlag: number;
  85987. private readonly _m;
  85988. /**
  85989. * Gets the internal data of the matrix
  85990. */
  85991. get m(): DeepImmutable<Float32Array | Array<number>>;
  85992. /** @hidden */
  85993. _markAsUpdated(): void;
  85994. /** @hidden */
  85995. private _updateIdentityStatus;
  85996. /**
  85997. * Creates an empty matrix (filled with zeros)
  85998. */
  85999. constructor();
  86000. /**
  86001. * Check if the current matrix is identity
  86002. * @returns true is the matrix is the identity matrix
  86003. */
  86004. isIdentity(): boolean;
  86005. /**
  86006. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  86007. * @returns true is the matrix is the identity matrix
  86008. */
  86009. isIdentityAs3x2(): boolean;
  86010. /**
  86011. * Gets the determinant of the matrix
  86012. * @returns the matrix determinant
  86013. */
  86014. determinant(): number;
  86015. /**
  86016. * Returns the matrix as a Float32Array or Array<number>
  86017. * @returns the matrix underlying array
  86018. */
  86019. toArray(): DeepImmutable<Float32Array | Array<number>>;
  86020. /**
  86021. * Returns the matrix as a Float32Array or Array<number>
  86022. * @returns the matrix underlying array.
  86023. */
  86024. asArray(): DeepImmutable<Float32Array | Array<number>>;
  86025. /**
  86026. * Inverts the current matrix in place
  86027. * @returns the current inverted matrix
  86028. */
  86029. invert(): Matrix;
  86030. /**
  86031. * Sets all the matrix elements to zero
  86032. * @returns the current matrix
  86033. */
  86034. reset(): Matrix;
  86035. /**
  86036. * Adds the current matrix with a second one
  86037. * @param other defines the matrix to add
  86038. * @returns a new matrix as the addition of the current matrix and the given one
  86039. */
  86040. add(other: DeepImmutable<Matrix>): Matrix;
  86041. /**
  86042. * Sets the given matrix "result" to the addition of the current matrix and the given one
  86043. * @param other defines the matrix to add
  86044. * @param result defines the target matrix
  86045. * @returns the current matrix
  86046. */
  86047. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  86048. /**
  86049. * Adds in place the given matrix to the current matrix
  86050. * @param other defines the second operand
  86051. * @returns the current updated matrix
  86052. */
  86053. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  86054. /**
  86055. * Sets the given matrix to the current inverted Matrix
  86056. * @param other defines the target matrix
  86057. * @returns the unmodified current matrix
  86058. */
  86059. invertToRef(other: Matrix): Matrix;
  86060. /**
  86061. * add a value at the specified position in the current Matrix
  86062. * @param index the index of the value within the matrix. between 0 and 15.
  86063. * @param value the value to be added
  86064. * @returns the current updated matrix
  86065. */
  86066. addAtIndex(index: number, value: number): Matrix;
  86067. /**
  86068. * mutiply the specified position in the current Matrix by a value
  86069. * @param index the index of the value within the matrix. between 0 and 15.
  86070. * @param value the value to be added
  86071. * @returns the current updated matrix
  86072. */
  86073. multiplyAtIndex(index: number, value: number): Matrix;
  86074. /**
  86075. * Inserts the translation vector (using 3 floats) in the current matrix
  86076. * @param x defines the 1st component of the translation
  86077. * @param y defines the 2nd component of the translation
  86078. * @param z defines the 3rd component of the translation
  86079. * @returns the current updated matrix
  86080. */
  86081. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  86082. /**
  86083. * Adds the translation vector (using 3 floats) in the current matrix
  86084. * @param x defines the 1st component of the translation
  86085. * @param y defines the 2nd component of the translation
  86086. * @param z defines the 3rd component of the translation
  86087. * @returns the current updated matrix
  86088. */
  86089. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  86090. /**
  86091. * Inserts the translation vector in the current matrix
  86092. * @param vector3 defines the translation to insert
  86093. * @returns the current updated matrix
  86094. */
  86095. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  86096. /**
  86097. * Gets the translation value of the current matrix
  86098. * @returns a new Vector3 as the extracted translation from the matrix
  86099. */
  86100. getTranslation(): Vector3;
  86101. /**
  86102. * Fill a Vector3 with the extracted translation from the matrix
  86103. * @param result defines the Vector3 where to store the translation
  86104. * @returns the current matrix
  86105. */
  86106. getTranslationToRef(result: Vector3): Matrix;
  86107. /**
  86108. * Remove rotation and scaling part from the matrix
  86109. * @returns the updated matrix
  86110. */
  86111. removeRotationAndScaling(): Matrix;
  86112. /**
  86113. * Multiply two matrices
  86114. * @param other defines the second operand
  86115. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  86116. */
  86117. multiply(other: DeepImmutable<Matrix>): Matrix;
  86118. /**
  86119. * Copy the current matrix from the given one
  86120. * @param other defines the source matrix
  86121. * @returns the current updated matrix
  86122. */
  86123. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  86124. /**
  86125. * Populates the given array from the starting index with the current matrix values
  86126. * @param array defines the target array
  86127. * @param offset defines the offset in the target array where to start storing values
  86128. * @returns the current matrix
  86129. */
  86130. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  86131. /**
  86132. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  86133. * @param other defines the second operand
  86134. * @param result defines the matrix where to store the multiplication
  86135. * @returns the current matrix
  86136. */
  86137. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  86138. /**
  86139. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  86140. * @param other defines the second operand
  86141. * @param result defines the array where to store the multiplication
  86142. * @param offset defines the offset in the target array where to start storing values
  86143. * @returns the current matrix
  86144. */
  86145. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  86146. /**
  86147. * Check equality between this matrix and a second one
  86148. * @param value defines the second matrix to compare
  86149. * @returns true is the current matrix and the given one values are strictly equal
  86150. */
  86151. equals(value: DeepImmutable<Matrix>): boolean;
  86152. /**
  86153. * Clone the current matrix
  86154. * @returns a new matrix from the current matrix
  86155. */
  86156. clone(): Matrix;
  86157. /**
  86158. * Returns the name of the current matrix class
  86159. * @returns the string "Matrix"
  86160. */
  86161. getClassName(): string;
  86162. /**
  86163. * Gets the hash code of the current matrix
  86164. * @returns the hash code
  86165. */
  86166. getHashCode(): number;
  86167. /**
  86168. * Decomposes the current Matrix into a translation, rotation and scaling components
  86169. * @param scale defines the scale vector3 given as a reference to update
  86170. * @param rotation defines the rotation quaternion given as a reference to update
  86171. * @param translation defines the translation vector3 given as a reference to update
  86172. * @returns true if operation was successful
  86173. */
  86174. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  86175. /**
  86176. * Gets specific row of the matrix
  86177. * @param index defines the number of the row to get
  86178. * @returns the index-th row of the current matrix as a new Vector4
  86179. */
  86180. getRow(index: number): Nullable<Vector4>;
  86181. /**
  86182. * Sets the index-th row of the current matrix to the vector4 values
  86183. * @param index defines the number of the row to set
  86184. * @param row defines the target vector4
  86185. * @returns the updated current matrix
  86186. */
  86187. setRow(index: number, row: Vector4): Matrix;
  86188. /**
  86189. * Compute the transpose of the matrix
  86190. * @returns the new transposed matrix
  86191. */
  86192. transpose(): Matrix;
  86193. /**
  86194. * Compute the transpose of the matrix and store it in a given matrix
  86195. * @param result defines the target matrix
  86196. * @returns the current matrix
  86197. */
  86198. transposeToRef(result: Matrix): Matrix;
  86199. /**
  86200. * Sets the index-th row of the current matrix with the given 4 x float values
  86201. * @param index defines the row index
  86202. * @param x defines the x component to set
  86203. * @param y defines the y component to set
  86204. * @param z defines the z component to set
  86205. * @param w defines the w component to set
  86206. * @returns the updated current matrix
  86207. */
  86208. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  86209. /**
  86210. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  86211. * @param scale defines the scale factor
  86212. * @returns a new matrix
  86213. */
  86214. scale(scale: number): Matrix;
  86215. /**
  86216. * Scale the current matrix values by a factor to a given result matrix
  86217. * @param scale defines the scale factor
  86218. * @param result defines the matrix to store the result
  86219. * @returns the current matrix
  86220. */
  86221. scaleToRef(scale: number, result: Matrix): Matrix;
  86222. /**
  86223. * Scale the current matrix values by a factor and add the result to a given matrix
  86224. * @param scale defines the scale factor
  86225. * @param result defines the Matrix to store the result
  86226. * @returns the current matrix
  86227. */
  86228. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  86229. /**
  86230. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  86231. * @param ref matrix to store the result
  86232. */
  86233. toNormalMatrix(ref: Matrix): void;
  86234. /**
  86235. * Gets only rotation part of the current matrix
  86236. * @returns a new matrix sets to the extracted rotation matrix from the current one
  86237. */
  86238. getRotationMatrix(): Matrix;
  86239. /**
  86240. * Extracts the rotation matrix from the current one and sets it as the given "result"
  86241. * @param result defines the target matrix to store data to
  86242. * @returns the current matrix
  86243. */
  86244. getRotationMatrixToRef(result: Matrix): Matrix;
  86245. /**
  86246. * Toggles model matrix from being right handed to left handed in place and vice versa
  86247. */
  86248. toggleModelMatrixHandInPlace(): void;
  86249. /**
  86250. * Toggles projection matrix from being right handed to left handed in place and vice versa
  86251. */
  86252. toggleProjectionMatrixHandInPlace(): void;
  86253. /**
  86254. * Creates a matrix from an array
  86255. * @param array defines the source array
  86256. * @param offset defines an offset in the source array
  86257. * @returns a new Matrix set from the starting index of the given array
  86258. */
  86259. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  86260. /**
  86261. * Copy the content of an array into a given matrix
  86262. * @param array defines the source array
  86263. * @param offset defines an offset in the source array
  86264. * @param result defines the target matrix
  86265. */
  86266. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  86267. /**
  86268. * Stores an array into a matrix after having multiplied each component by a given factor
  86269. * @param array defines the source array
  86270. * @param offset defines the offset in the source array
  86271. * @param scale defines the scaling factor
  86272. * @param result defines the target matrix
  86273. */
  86274. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  86275. /**
  86276. * Gets an identity matrix that must not be updated
  86277. */
  86278. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  86279. /**
  86280. * Stores a list of values (16) inside a given matrix
  86281. * @param initialM11 defines 1st value of 1st row
  86282. * @param initialM12 defines 2nd value of 1st row
  86283. * @param initialM13 defines 3rd value of 1st row
  86284. * @param initialM14 defines 4th value of 1st row
  86285. * @param initialM21 defines 1st value of 2nd row
  86286. * @param initialM22 defines 2nd value of 2nd row
  86287. * @param initialM23 defines 3rd value of 2nd row
  86288. * @param initialM24 defines 4th value of 2nd row
  86289. * @param initialM31 defines 1st value of 3rd row
  86290. * @param initialM32 defines 2nd value of 3rd row
  86291. * @param initialM33 defines 3rd value of 3rd row
  86292. * @param initialM34 defines 4th value of 3rd row
  86293. * @param initialM41 defines 1st value of 4th row
  86294. * @param initialM42 defines 2nd value of 4th row
  86295. * @param initialM43 defines 3rd value of 4th row
  86296. * @param initialM44 defines 4th value of 4th row
  86297. * @param result defines the target matrix
  86298. */
  86299. 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;
  86300. /**
  86301. * Creates new matrix from a list of values (16)
  86302. * @param initialM11 defines 1st value of 1st row
  86303. * @param initialM12 defines 2nd value of 1st row
  86304. * @param initialM13 defines 3rd value of 1st row
  86305. * @param initialM14 defines 4th value of 1st row
  86306. * @param initialM21 defines 1st value of 2nd row
  86307. * @param initialM22 defines 2nd value of 2nd row
  86308. * @param initialM23 defines 3rd value of 2nd row
  86309. * @param initialM24 defines 4th value of 2nd row
  86310. * @param initialM31 defines 1st value of 3rd row
  86311. * @param initialM32 defines 2nd value of 3rd row
  86312. * @param initialM33 defines 3rd value of 3rd row
  86313. * @param initialM34 defines 4th value of 3rd row
  86314. * @param initialM41 defines 1st value of 4th row
  86315. * @param initialM42 defines 2nd value of 4th row
  86316. * @param initialM43 defines 3rd value of 4th row
  86317. * @param initialM44 defines 4th value of 4th row
  86318. * @returns the new matrix
  86319. */
  86320. 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;
  86321. /**
  86322. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  86323. * @param scale defines the scale vector3
  86324. * @param rotation defines the rotation quaternion
  86325. * @param translation defines the translation vector3
  86326. * @returns a new matrix
  86327. */
  86328. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  86329. /**
  86330. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  86331. * @param scale defines the scale vector3
  86332. * @param rotation defines the rotation quaternion
  86333. * @param translation defines the translation vector3
  86334. * @param result defines the target matrix
  86335. */
  86336. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  86337. /**
  86338. * Creates a new identity matrix
  86339. * @returns a new identity matrix
  86340. */
  86341. static Identity(): Matrix;
  86342. /**
  86343. * Creates a new identity matrix and stores the result in a given matrix
  86344. * @param result defines the target matrix
  86345. */
  86346. static IdentityToRef(result: Matrix): void;
  86347. /**
  86348. * Creates a new zero matrix
  86349. * @returns a new zero matrix
  86350. */
  86351. static Zero(): Matrix;
  86352. /**
  86353. * Creates a new rotation matrix for "angle" radians around the X axis
  86354. * @param angle defines the angle (in radians) to use
  86355. * @return the new matrix
  86356. */
  86357. static RotationX(angle: number): Matrix;
  86358. /**
  86359. * Creates a new matrix as the invert of a given matrix
  86360. * @param source defines the source matrix
  86361. * @returns the new matrix
  86362. */
  86363. static Invert(source: DeepImmutable<Matrix>): Matrix;
  86364. /**
  86365. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  86366. * @param angle defines the angle (in radians) to use
  86367. * @param result defines the target matrix
  86368. */
  86369. static RotationXToRef(angle: number, result: Matrix): void;
  86370. /**
  86371. * Creates a new rotation matrix for "angle" radians around the Y axis
  86372. * @param angle defines the angle (in radians) to use
  86373. * @return the new matrix
  86374. */
  86375. static RotationY(angle: number): Matrix;
  86376. /**
  86377. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  86378. * @param angle defines the angle (in radians) to use
  86379. * @param result defines the target matrix
  86380. */
  86381. static RotationYToRef(angle: number, result: Matrix): void;
  86382. /**
  86383. * Creates a new rotation matrix for "angle" radians around the Z axis
  86384. * @param angle defines the angle (in radians) to use
  86385. * @return the new matrix
  86386. */
  86387. static RotationZ(angle: number): Matrix;
  86388. /**
  86389. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  86390. * @param angle defines the angle (in radians) to use
  86391. * @param result defines the target matrix
  86392. */
  86393. static RotationZToRef(angle: number, result: Matrix): void;
  86394. /**
  86395. * Creates a new rotation matrix for "angle" radians around the given axis
  86396. * @param axis defines the axis to use
  86397. * @param angle defines the angle (in radians) to use
  86398. * @return the new matrix
  86399. */
  86400. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  86401. /**
  86402. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  86403. * @param axis defines the axis to use
  86404. * @param angle defines the angle (in radians) to use
  86405. * @param result defines the target matrix
  86406. */
  86407. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  86408. /**
  86409. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  86410. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  86411. * @param from defines the vector to align
  86412. * @param to defines the vector to align to
  86413. * @param result defines the target matrix
  86414. */
  86415. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  86416. /**
  86417. * Creates a rotation matrix
  86418. * @param yaw defines the yaw angle in radians (Y axis)
  86419. * @param pitch defines the pitch angle in radians (X axis)
  86420. * @param roll defines the roll angle in radians (Z axis)
  86421. * @returns the new rotation matrix
  86422. */
  86423. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  86424. /**
  86425. * Creates a rotation matrix and stores it in a given matrix
  86426. * @param yaw defines the yaw angle in radians (Y axis)
  86427. * @param pitch defines the pitch angle in radians (X axis)
  86428. * @param roll defines the roll angle in radians (Z axis)
  86429. * @param result defines the target matrix
  86430. */
  86431. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  86432. /**
  86433. * Creates a scaling matrix
  86434. * @param x defines the scale factor on X axis
  86435. * @param y defines the scale factor on Y axis
  86436. * @param z defines the scale factor on Z axis
  86437. * @returns the new matrix
  86438. */
  86439. static Scaling(x: number, y: number, z: number): Matrix;
  86440. /**
  86441. * Creates a scaling matrix and stores it in a given matrix
  86442. * @param x defines the scale factor on X axis
  86443. * @param y defines the scale factor on Y axis
  86444. * @param z defines the scale factor on Z axis
  86445. * @param result defines the target matrix
  86446. */
  86447. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  86448. /**
  86449. * Creates a translation matrix
  86450. * @param x defines the translation on X axis
  86451. * @param y defines the translation on Y axis
  86452. * @param z defines the translationon Z axis
  86453. * @returns the new matrix
  86454. */
  86455. static Translation(x: number, y: number, z: number): Matrix;
  86456. /**
  86457. * Creates a translation matrix and stores it in a given matrix
  86458. * @param x defines the translation on X axis
  86459. * @param y defines the translation on Y axis
  86460. * @param z defines the translationon Z axis
  86461. * @param result defines the target matrix
  86462. */
  86463. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  86464. /**
  86465. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  86466. * @param startValue defines the start value
  86467. * @param endValue defines the end value
  86468. * @param gradient defines the gradient factor
  86469. * @returns the new matrix
  86470. */
  86471. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  86472. /**
  86473. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  86474. * @param startValue defines the start value
  86475. * @param endValue defines the end value
  86476. * @param gradient defines the gradient factor
  86477. * @param result defines the Matrix object where to store data
  86478. */
  86479. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  86480. /**
  86481. * Builds a new matrix whose values are computed by:
  86482. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  86483. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  86484. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  86485. * @param startValue defines the first matrix
  86486. * @param endValue defines the second matrix
  86487. * @param gradient defines the gradient between the two matrices
  86488. * @returns the new matrix
  86489. */
  86490. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  86491. /**
  86492. * Update a matrix to values which are computed by:
  86493. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  86494. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  86495. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  86496. * @param startValue defines the first matrix
  86497. * @param endValue defines the second matrix
  86498. * @param gradient defines the gradient between the two matrices
  86499. * @param result defines the target matrix
  86500. */
  86501. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  86502. /**
  86503. * 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"
  86504. * This function works in left handed mode
  86505. * @param eye defines the final position of the entity
  86506. * @param target defines where the entity should look at
  86507. * @param up defines the up vector for the entity
  86508. * @returns the new matrix
  86509. */
  86510. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  86511. /**
  86512. * 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".
  86513. * This function works in left handed mode
  86514. * @param eye defines the final position of the entity
  86515. * @param target defines where the entity should look at
  86516. * @param up defines the up vector for the entity
  86517. * @param result defines the target matrix
  86518. */
  86519. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  86520. /**
  86521. * 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"
  86522. * This function works in right handed mode
  86523. * @param eye defines the final position of the entity
  86524. * @param target defines where the entity should look at
  86525. * @param up defines the up vector for the entity
  86526. * @returns the new matrix
  86527. */
  86528. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  86529. /**
  86530. * 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".
  86531. * This function works in right handed mode
  86532. * @param eye defines the final position of the entity
  86533. * @param target defines where the entity should look at
  86534. * @param up defines the up vector for the entity
  86535. * @param result defines the target matrix
  86536. */
  86537. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  86538. /**
  86539. * Create a left-handed orthographic projection matrix
  86540. * @param width defines the viewport width
  86541. * @param height defines the viewport height
  86542. * @param znear defines the near clip plane
  86543. * @param zfar defines the far clip plane
  86544. * @returns a new matrix as a left-handed orthographic projection matrix
  86545. */
  86546. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  86547. /**
  86548. * Store a left-handed orthographic projection to a given matrix
  86549. * @param width defines the viewport width
  86550. * @param height defines the viewport height
  86551. * @param znear defines the near clip plane
  86552. * @param zfar defines the far clip plane
  86553. * @param result defines the target matrix
  86554. */
  86555. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  86556. /**
  86557. * Create a left-handed orthographic projection matrix
  86558. * @param left defines the viewport left coordinate
  86559. * @param right defines the viewport right coordinate
  86560. * @param bottom defines the viewport bottom coordinate
  86561. * @param top defines the viewport top coordinate
  86562. * @param znear defines the near clip plane
  86563. * @param zfar defines the far clip plane
  86564. * @returns a new matrix as a left-handed orthographic projection matrix
  86565. */
  86566. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  86567. /**
  86568. * Stores a left-handed orthographic projection into a given matrix
  86569. * @param left defines the viewport left coordinate
  86570. * @param right defines the viewport right coordinate
  86571. * @param bottom defines the viewport bottom coordinate
  86572. * @param top defines the viewport top coordinate
  86573. * @param znear defines the near clip plane
  86574. * @param zfar defines the far clip plane
  86575. * @param result defines the target matrix
  86576. */
  86577. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  86578. /**
  86579. * Creates a right-handed orthographic projection matrix
  86580. * @param left defines the viewport left coordinate
  86581. * @param right defines the viewport right coordinate
  86582. * @param bottom defines the viewport bottom coordinate
  86583. * @param top defines the viewport top coordinate
  86584. * @param znear defines the near clip plane
  86585. * @param zfar defines the far clip plane
  86586. * @returns a new matrix as a right-handed orthographic projection matrix
  86587. */
  86588. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  86589. /**
  86590. * Stores a right-handed orthographic projection into a given matrix
  86591. * @param left defines the viewport left coordinate
  86592. * @param right defines the viewport right coordinate
  86593. * @param bottom defines the viewport bottom coordinate
  86594. * @param top defines the viewport top coordinate
  86595. * @param znear defines the near clip plane
  86596. * @param zfar defines the far clip plane
  86597. * @param result defines the target matrix
  86598. */
  86599. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  86600. /**
  86601. * Creates a left-handed perspective projection matrix
  86602. * @param width defines the viewport width
  86603. * @param height defines the viewport height
  86604. * @param znear defines the near clip plane
  86605. * @param zfar defines the far clip plane
  86606. * @returns a new matrix as a left-handed perspective projection matrix
  86607. */
  86608. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  86609. /**
  86610. * Creates a left-handed perspective projection matrix
  86611. * @param fov defines the horizontal field of view
  86612. * @param aspect defines the aspect ratio
  86613. * @param znear defines the near clip plane
  86614. * @param zfar defines the far clip plane
  86615. * @returns a new matrix as a left-handed perspective projection matrix
  86616. */
  86617. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  86618. /**
  86619. * Stores a left-handed perspective projection into a given matrix
  86620. * @param fov defines the horizontal field of view
  86621. * @param aspect defines the aspect ratio
  86622. * @param znear defines the near clip plane
  86623. * @param zfar defines the far clip plane
  86624. * @param result defines the target matrix
  86625. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86626. */
  86627. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86628. /**
  86629. * Stores a left-handed perspective projection into a given matrix with depth reversed
  86630. * @param fov defines the horizontal field of view
  86631. * @param aspect defines the aspect ratio
  86632. * @param znear defines the near clip plane
  86633. * @param zfar not used as infinity is used as far clip
  86634. * @param result defines the target matrix
  86635. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86636. */
  86637. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86638. /**
  86639. * Creates a right-handed perspective projection matrix
  86640. * @param fov defines the horizontal field of view
  86641. * @param aspect defines the aspect ratio
  86642. * @param znear defines the near clip plane
  86643. * @param zfar defines the far clip plane
  86644. * @returns a new matrix as a right-handed perspective projection matrix
  86645. */
  86646. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  86647. /**
  86648. * Stores a right-handed perspective projection into a given matrix
  86649. * @param fov defines the horizontal field of view
  86650. * @param aspect defines the aspect ratio
  86651. * @param znear defines the near clip plane
  86652. * @param zfar defines the far clip plane
  86653. * @param result defines the target matrix
  86654. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86655. */
  86656. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86657. /**
  86658. * Stores a right-handed perspective projection into a given matrix
  86659. * @param fov defines the horizontal field of view
  86660. * @param aspect defines the aspect ratio
  86661. * @param znear defines the near clip plane
  86662. * @param zfar not used as infinity is used as far clip
  86663. * @param result defines the target matrix
  86664. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86665. */
  86666. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86667. /**
  86668. * Stores a perspective projection for WebVR info a given matrix
  86669. * @param fov defines the field of view
  86670. * @param znear defines the near clip plane
  86671. * @param zfar defines the far clip plane
  86672. * @param result defines the target matrix
  86673. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  86674. */
  86675. static PerspectiveFovWebVRToRef(fov: {
  86676. upDegrees: number;
  86677. downDegrees: number;
  86678. leftDegrees: number;
  86679. rightDegrees: number;
  86680. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  86681. /**
  86682. * Computes a complete transformation matrix
  86683. * @param viewport defines the viewport to use
  86684. * @param world defines the world matrix
  86685. * @param view defines the view matrix
  86686. * @param projection defines the projection matrix
  86687. * @param zmin defines the near clip plane
  86688. * @param zmax defines the far clip plane
  86689. * @returns the transformation matrix
  86690. */
  86691. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  86692. /**
  86693. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  86694. * @param matrix defines the matrix to use
  86695. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  86696. */
  86697. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86698. /**
  86699. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  86700. * @param matrix defines the matrix to use
  86701. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  86702. */
  86703. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86704. /**
  86705. * Compute the transpose of a given matrix
  86706. * @param matrix defines the matrix to transpose
  86707. * @returns the new matrix
  86708. */
  86709. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  86710. /**
  86711. * Compute the transpose of a matrix and store it in a target matrix
  86712. * @param matrix defines the matrix to transpose
  86713. * @param result defines the target matrix
  86714. */
  86715. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  86716. /**
  86717. * Computes a reflection matrix from a plane
  86718. * @param plane defines the reflection plane
  86719. * @returns a new matrix
  86720. */
  86721. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  86722. /**
  86723. * Computes a reflection matrix from a plane
  86724. * @param plane defines the reflection plane
  86725. * @param result defines the target matrix
  86726. */
  86727. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  86728. /**
  86729. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  86730. * @param xaxis defines the value of the 1st axis
  86731. * @param yaxis defines the value of the 2nd axis
  86732. * @param zaxis defines the value of the 3rd axis
  86733. * @param result defines the target matrix
  86734. */
  86735. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  86736. /**
  86737. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  86738. * @param quat defines the quaternion to use
  86739. * @param result defines the target matrix
  86740. */
  86741. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  86742. }
  86743. /**
  86744. * @hidden
  86745. */
  86746. export class TmpVectors {
  86747. static Vector2: Vector2[];
  86748. static Vector3: Vector3[];
  86749. static Vector4: Vector4[];
  86750. static Quaternion: Quaternion[];
  86751. static Matrix: Matrix[];
  86752. }
  86753. }
  86754. declare module BABYLON {
  86755. /**
  86756. * Defines potential orientation for back face culling
  86757. */
  86758. export enum Orientation {
  86759. /**
  86760. * Clockwise
  86761. */
  86762. CW = 0,
  86763. /** Counter clockwise */
  86764. CCW = 1
  86765. }
  86766. /** Class used to represent a Bezier curve */
  86767. export class BezierCurve {
  86768. /**
  86769. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  86770. * @param t defines the time
  86771. * @param x1 defines the left coordinate on X axis
  86772. * @param y1 defines the left coordinate on Y axis
  86773. * @param x2 defines the right coordinate on X axis
  86774. * @param y2 defines the right coordinate on Y axis
  86775. * @returns the interpolated value
  86776. */
  86777. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  86778. }
  86779. /**
  86780. * Defines angle representation
  86781. */
  86782. export class Angle {
  86783. private _radians;
  86784. /**
  86785. * Creates an Angle object of "radians" radians (float).
  86786. * @param radians the angle in radians
  86787. */
  86788. constructor(radians: number);
  86789. /**
  86790. * Get value in degrees
  86791. * @returns the Angle value in degrees (float)
  86792. */
  86793. degrees(): number;
  86794. /**
  86795. * Get value in radians
  86796. * @returns the Angle value in radians (float)
  86797. */
  86798. radians(): number;
  86799. /**
  86800. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  86801. * @param a defines first point as the origin
  86802. * @param b defines point
  86803. * @returns a new Angle
  86804. */
  86805. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  86806. /**
  86807. * Gets a new Angle object from the given float in radians
  86808. * @param radians defines the angle value in radians
  86809. * @returns a new Angle
  86810. */
  86811. static FromRadians(radians: number): Angle;
  86812. /**
  86813. * Gets a new Angle object from the given float in degrees
  86814. * @param degrees defines the angle value in degrees
  86815. * @returns a new Angle
  86816. */
  86817. static FromDegrees(degrees: number): Angle;
  86818. }
  86819. /**
  86820. * This represents an arc in a 2d space.
  86821. */
  86822. export class Arc2 {
  86823. /** Defines the start point of the arc */
  86824. startPoint: Vector2;
  86825. /** Defines the mid point of the arc */
  86826. midPoint: Vector2;
  86827. /** Defines the end point of the arc */
  86828. endPoint: Vector2;
  86829. /**
  86830. * Defines the center point of the arc.
  86831. */
  86832. centerPoint: Vector2;
  86833. /**
  86834. * Defines the radius of the arc.
  86835. */
  86836. radius: number;
  86837. /**
  86838. * Defines the angle of the arc (from mid point to end point).
  86839. */
  86840. angle: Angle;
  86841. /**
  86842. * Defines the start angle of the arc (from start point to middle point).
  86843. */
  86844. startAngle: Angle;
  86845. /**
  86846. * Defines the orientation of the arc (clock wise/counter clock wise).
  86847. */
  86848. orientation: Orientation;
  86849. /**
  86850. * Creates an Arc object from the three given points : start, middle and end.
  86851. * @param startPoint Defines the start point of the arc
  86852. * @param midPoint Defines the midlle point of the arc
  86853. * @param endPoint Defines the end point of the arc
  86854. */
  86855. constructor(
  86856. /** Defines the start point of the arc */
  86857. startPoint: Vector2,
  86858. /** Defines the mid point of the arc */
  86859. midPoint: Vector2,
  86860. /** Defines the end point of the arc */
  86861. endPoint: Vector2);
  86862. }
  86863. /**
  86864. * Represents a 2D path made up of multiple 2D points
  86865. */
  86866. export class Path2 {
  86867. private _points;
  86868. private _length;
  86869. /**
  86870. * If the path start and end point are the same
  86871. */
  86872. closed: boolean;
  86873. /**
  86874. * Creates a Path2 object from the starting 2D coordinates x and y.
  86875. * @param x the starting points x value
  86876. * @param y the starting points y value
  86877. */
  86878. constructor(x: number, y: number);
  86879. /**
  86880. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  86881. * @param x the added points x value
  86882. * @param y the added points y value
  86883. * @returns the updated Path2.
  86884. */
  86885. addLineTo(x: number, y: number): Path2;
  86886. /**
  86887. * 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.
  86888. * @param midX middle point x value
  86889. * @param midY middle point y value
  86890. * @param endX end point x value
  86891. * @param endY end point y value
  86892. * @param numberOfSegments (default: 36)
  86893. * @returns the updated Path2.
  86894. */
  86895. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  86896. /**
  86897. * Closes the Path2.
  86898. * @returns the Path2.
  86899. */
  86900. close(): Path2;
  86901. /**
  86902. * Gets the sum of the distance between each sequential point in the path
  86903. * @returns the Path2 total length (float).
  86904. */
  86905. length(): number;
  86906. /**
  86907. * Gets the points which construct the path
  86908. * @returns the Path2 internal array of points.
  86909. */
  86910. getPoints(): Vector2[];
  86911. /**
  86912. * Retreives the point at the distance aways from the starting point
  86913. * @param normalizedLengthPosition the length along the path to retreive the point from
  86914. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  86915. */
  86916. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  86917. /**
  86918. * Creates a new path starting from an x and y position
  86919. * @param x starting x value
  86920. * @param y starting y value
  86921. * @returns a new Path2 starting at the coordinates (x, y).
  86922. */
  86923. static StartingAt(x: number, y: number): Path2;
  86924. }
  86925. /**
  86926. * Represents a 3D path made up of multiple 3D points
  86927. */
  86928. export class Path3D {
  86929. /**
  86930. * an array of Vector3, the curve axis of the Path3D
  86931. */
  86932. path: Vector3[];
  86933. private _curve;
  86934. private _distances;
  86935. private _tangents;
  86936. private _normals;
  86937. private _binormals;
  86938. private _raw;
  86939. private _alignTangentsWithPath;
  86940. private readonly _pointAtData;
  86941. /**
  86942. * new Path3D(path, normal, raw)
  86943. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  86944. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  86945. * @param path an array of Vector3, the curve axis of the Path3D
  86946. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  86947. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  86948. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  86949. */
  86950. constructor(
  86951. /**
  86952. * an array of Vector3, the curve axis of the Path3D
  86953. */
  86954. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  86955. /**
  86956. * Returns the Path3D array of successive Vector3 designing its curve.
  86957. * @returns the Path3D array of successive Vector3 designing its curve.
  86958. */
  86959. getCurve(): Vector3[];
  86960. /**
  86961. * Returns the Path3D array of successive Vector3 designing its curve.
  86962. * @returns the Path3D array of successive Vector3 designing its curve.
  86963. */
  86964. getPoints(): Vector3[];
  86965. /**
  86966. * @returns the computed length (float) of the path.
  86967. */
  86968. length(): number;
  86969. /**
  86970. * Returns an array populated with tangent vectors on each Path3D curve point.
  86971. * @returns an array populated with tangent vectors on each Path3D curve point.
  86972. */
  86973. getTangents(): Vector3[];
  86974. /**
  86975. * Returns an array populated with normal vectors on each Path3D curve point.
  86976. * @returns an array populated with normal vectors on each Path3D curve point.
  86977. */
  86978. getNormals(): Vector3[];
  86979. /**
  86980. * Returns an array populated with binormal vectors on each Path3D curve point.
  86981. * @returns an array populated with binormal vectors on each Path3D curve point.
  86982. */
  86983. getBinormals(): Vector3[];
  86984. /**
  86985. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  86986. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  86987. */
  86988. getDistances(): number[];
  86989. /**
  86990. * Returns an interpolated point along this path
  86991. * @param position the position of the point along this path, from 0.0 to 1.0
  86992. * @returns a new Vector3 as the point
  86993. */
  86994. getPointAt(position: number): Vector3;
  86995. /**
  86996. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  86997. * @param position the position of the point along this path, from 0.0 to 1.0
  86998. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  86999. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  87000. */
  87001. getTangentAt(position: number, interpolated?: boolean): Vector3;
  87002. /**
  87003. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  87004. * @param position the position of the point along this path, from 0.0 to 1.0
  87005. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  87006. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  87007. */
  87008. getNormalAt(position: number, interpolated?: boolean): Vector3;
  87009. /**
  87010. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  87011. * @param position the position of the point along this path, from 0.0 to 1.0
  87012. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  87013. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  87014. */
  87015. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  87016. /**
  87017. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  87018. * @param position the position of the point along this path, from 0.0 to 1.0
  87019. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  87020. */
  87021. getDistanceAt(position: number): number;
  87022. /**
  87023. * Returns the array index of the previous point of an interpolated point along this path
  87024. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  87025. * @returns the array index
  87026. */
  87027. getPreviousPointIndexAt(position: number): number;
  87028. /**
  87029. * 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)
  87030. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  87031. * @returns the sub position
  87032. */
  87033. getSubPositionAt(position: number): number;
  87034. /**
  87035. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  87036. * @param target the vector of which to get the closest position to
  87037. * @returns the position of the closest virtual point on this path to the target vector
  87038. */
  87039. getClosestPositionTo(target: Vector3): number;
  87040. /**
  87041. * Returns a sub path (slice) of this path
  87042. * @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
  87043. * @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
  87044. * @returns a sub path (slice) of this path
  87045. */
  87046. slice(start?: number, end?: number): Path3D;
  87047. /**
  87048. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  87049. * @param path path which all values are copied into the curves points
  87050. * @param firstNormal which should be projected onto the curve
  87051. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  87052. * @returns the same object updated.
  87053. */
  87054. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  87055. private _compute;
  87056. private _getFirstNonNullVector;
  87057. private _getLastNonNullVector;
  87058. private _normalVector;
  87059. /**
  87060. * Updates the point at data for an interpolated point along this curve
  87061. * @param position the position of the point along this curve, from 0.0 to 1.0
  87062. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  87063. * @returns the (updated) point at data
  87064. */
  87065. private _updatePointAtData;
  87066. /**
  87067. * Updates the point at data from the specified parameters
  87068. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  87069. * @param point the interpolated point
  87070. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  87071. */
  87072. private _setPointAtData;
  87073. /**
  87074. * Updates the point at interpolation matrix for the tangents, normals and binormals
  87075. */
  87076. private _updateInterpolationMatrix;
  87077. }
  87078. /**
  87079. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  87080. * A Curve3 is designed from a series of successive Vector3.
  87081. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  87082. */
  87083. export class Curve3 {
  87084. private _points;
  87085. private _length;
  87086. /**
  87087. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  87088. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  87089. * @param v1 (Vector3) the control point
  87090. * @param v2 (Vector3) the end point of the Quadratic Bezier
  87091. * @param nbPoints (integer) the wanted number of points in the curve
  87092. * @returns the created Curve3
  87093. */
  87094. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87095. /**
  87096. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  87097. * @param v0 (Vector3) the origin point of the Cubic Bezier
  87098. * @param v1 (Vector3) the first control point
  87099. * @param v2 (Vector3) the second control point
  87100. * @param v3 (Vector3) the end point of the Cubic Bezier
  87101. * @param nbPoints (integer) the wanted number of points in the curve
  87102. * @returns the created Curve3
  87103. */
  87104. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87105. /**
  87106. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  87107. * @param p1 (Vector3) the origin point of the Hermite Spline
  87108. * @param t1 (Vector3) the tangent vector at the origin point
  87109. * @param p2 (Vector3) the end point of the Hermite Spline
  87110. * @param t2 (Vector3) the tangent vector at the end point
  87111. * @param nbPoints (integer) the wanted number of points in the curve
  87112. * @returns the created Curve3
  87113. */
  87114. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87115. /**
  87116. * Returns a Curve3 object along a CatmullRom Spline curve :
  87117. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  87118. * @param nbPoints (integer) the wanted number of points between each curve control points
  87119. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  87120. * @returns the created Curve3
  87121. */
  87122. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  87123. /**
  87124. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  87125. * A Curve3 is designed from a series of successive Vector3.
  87126. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  87127. * @param points points which make up the curve
  87128. */
  87129. constructor(points: Vector3[]);
  87130. /**
  87131. * @returns the Curve3 stored array of successive Vector3
  87132. */
  87133. getPoints(): Vector3[];
  87134. /**
  87135. * @returns the computed length (float) of the curve.
  87136. */
  87137. length(): number;
  87138. /**
  87139. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  87140. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  87141. * curveA and curveB keep unchanged.
  87142. * @param curve the curve to continue from this curve
  87143. * @returns the newly constructed curve
  87144. */
  87145. continue(curve: DeepImmutable<Curve3>): Curve3;
  87146. private _computeLength;
  87147. }
  87148. }
  87149. declare module BABYLON {
  87150. /**
  87151. * This represents the main contract an easing function should follow.
  87152. * Easing functions are used throughout the animation system.
  87153. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87154. */
  87155. export interface IEasingFunction {
  87156. /**
  87157. * Given an input gradient between 0 and 1, this returns the corrseponding value
  87158. * of the easing function.
  87159. * The link below provides some of the most common examples of easing functions.
  87160. * @see https://easings.net/
  87161. * @param gradient Defines the value between 0 and 1 we want the easing value for
  87162. * @returns the corresponding value on the curve defined by the easing function
  87163. */
  87164. ease(gradient: number): number;
  87165. }
  87166. /**
  87167. * Base class used for every default easing function.
  87168. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87169. */
  87170. export class EasingFunction implements IEasingFunction {
  87171. /**
  87172. * Interpolation follows the mathematical formula associated with the easing function.
  87173. */
  87174. static readonly EASINGMODE_EASEIN: number;
  87175. /**
  87176. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  87177. */
  87178. static readonly EASINGMODE_EASEOUT: number;
  87179. /**
  87180. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  87181. */
  87182. static readonly EASINGMODE_EASEINOUT: number;
  87183. private _easingMode;
  87184. /**
  87185. * Sets the easing mode of the current function.
  87186. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  87187. */
  87188. setEasingMode(easingMode: number): void;
  87189. /**
  87190. * Gets the current easing mode.
  87191. * @returns the easing mode
  87192. */
  87193. getEasingMode(): number;
  87194. /**
  87195. * @hidden
  87196. */
  87197. easeInCore(gradient: number): number;
  87198. /**
  87199. * Given an input gradient between 0 and 1, this returns the corresponding value
  87200. * of the easing function.
  87201. * @param gradient Defines the value between 0 and 1 we want the easing value for
  87202. * @returns the corresponding value on the curve defined by the easing function
  87203. */
  87204. ease(gradient: number): number;
  87205. }
  87206. /**
  87207. * Easing function with a circle shape (see link below).
  87208. * @see https://easings.net/#easeInCirc
  87209. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87210. */
  87211. export class CircleEase extends EasingFunction implements IEasingFunction {
  87212. /** @hidden */
  87213. easeInCore(gradient: number): number;
  87214. }
  87215. /**
  87216. * Easing function with a ease back shape (see link below).
  87217. * @see https://easings.net/#easeInBack
  87218. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87219. */
  87220. export class BackEase extends EasingFunction implements IEasingFunction {
  87221. /** Defines the amplitude of the function */
  87222. amplitude: number;
  87223. /**
  87224. * Instantiates a back ease easing
  87225. * @see https://easings.net/#easeInBack
  87226. * @param amplitude Defines the amplitude of the function
  87227. */
  87228. constructor(
  87229. /** Defines the amplitude of the function */
  87230. amplitude?: number);
  87231. /** @hidden */
  87232. easeInCore(gradient: number): number;
  87233. }
  87234. /**
  87235. * Easing function with a bouncing shape (see link below).
  87236. * @see https://easings.net/#easeInBounce
  87237. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87238. */
  87239. export class BounceEase extends EasingFunction implements IEasingFunction {
  87240. /** Defines the number of bounces */
  87241. bounces: number;
  87242. /** Defines the amplitude of the bounce */
  87243. bounciness: number;
  87244. /**
  87245. * Instantiates a bounce easing
  87246. * @see https://easings.net/#easeInBounce
  87247. * @param bounces Defines the number of bounces
  87248. * @param bounciness Defines the amplitude of the bounce
  87249. */
  87250. constructor(
  87251. /** Defines the number of bounces */
  87252. bounces?: number,
  87253. /** Defines the amplitude of the bounce */
  87254. bounciness?: number);
  87255. /** @hidden */
  87256. easeInCore(gradient: number): number;
  87257. }
  87258. /**
  87259. * Easing function with a power of 3 shape (see link below).
  87260. * @see https://easings.net/#easeInCubic
  87261. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87262. */
  87263. export class CubicEase extends EasingFunction implements IEasingFunction {
  87264. /** @hidden */
  87265. easeInCore(gradient: number): number;
  87266. }
  87267. /**
  87268. * Easing function with an elastic shape (see link below).
  87269. * @see https://easings.net/#easeInElastic
  87270. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87271. */
  87272. export class ElasticEase extends EasingFunction implements IEasingFunction {
  87273. /** Defines the number of oscillations*/
  87274. oscillations: number;
  87275. /** Defines the amplitude of the oscillations*/
  87276. springiness: number;
  87277. /**
  87278. * Instantiates an elastic easing function
  87279. * @see https://easings.net/#easeInElastic
  87280. * @param oscillations Defines the number of oscillations
  87281. * @param springiness Defines the amplitude of the oscillations
  87282. */
  87283. constructor(
  87284. /** Defines the number of oscillations*/
  87285. oscillations?: number,
  87286. /** Defines the amplitude of the oscillations*/
  87287. springiness?: number);
  87288. /** @hidden */
  87289. easeInCore(gradient: number): number;
  87290. }
  87291. /**
  87292. * Easing function with an exponential shape (see link below).
  87293. * @see https://easings.net/#easeInExpo
  87294. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87295. */
  87296. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  87297. /** Defines the exponent of the function */
  87298. exponent: number;
  87299. /**
  87300. * Instantiates an exponential easing function
  87301. * @see https://easings.net/#easeInExpo
  87302. * @param exponent Defines the exponent of the function
  87303. */
  87304. constructor(
  87305. /** Defines the exponent of the function */
  87306. exponent?: number);
  87307. /** @hidden */
  87308. easeInCore(gradient: number): number;
  87309. }
  87310. /**
  87311. * Easing function with a power shape (see link below).
  87312. * @see https://easings.net/#easeInQuad
  87313. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87314. */
  87315. export class PowerEase extends EasingFunction implements IEasingFunction {
  87316. /** Defines the power of the function */
  87317. power: number;
  87318. /**
  87319. * Instantiates an power base easing function
  87320. * @see https://easings.net/#easeInQuad
  87321. * @param power Defines the power of the function
  87322. */
  87323. constructor(
  87324. /** Defines the power of the function */
  87325. power?: number);
  87326. /** @hidden */
  87327. easeInCore(gradient: number): number;
  87328. }
  87329. /**
  87330. * Easing function with a power of 2 shape (see link below).
  87331. * @see https://easings.net/#easeInQuad
  87332. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87333. */
  87334. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  87335. /** @hidden */
  87336. easeInCore(gradient: number): number;
  87337. }
  87338. /**
  87339. * Easing function with a power of 4 shape (see link below).
  87340. * @see https://easings.net/#easeInQuart
  87341. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87342. */
  87343. export class QuarticEase extends EasingFunction implements IEasingFunction {
  87344. /** @hidden */
  87345. easeInCore(gradient: number): number;
  87346. }
  87347. /**
  87348. * Easing function with a power of 5 shape (see link below).
  87349. * @see https://easings.net/#easeInQuint
  87350. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87351. */
  87352. export class QuinticEase extends EasingFunction implements IEasingFunction {
  87353. /** @hidden */
  87354. easeInCore(gradient: number): number;
  87355. }
  87356. /**
  87357. * Easing function with a sin shape (see link below).
  87358. * @see https://easings.net/#easeInSine
  87359. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87360. */
  87361. export class SineEase extends EasingFunction implements IEasingFunction {
  87362. /** @hidden */
  87363. easeInCore(gradient: number): number;
  87364. }
  87365. /**
  87366. * Easing function with a bezier shape (see link below).
  87367. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  87368. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87369. */
  87370. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  87371. /** Defines the x component of the start tangent in the bezier curve */
  87372. x1: number;
  87373. /** Defines the y component of the start tangent in the bezier curve */
  87374. y1: number;
  87375. /** Defines the x component of the end tangent in the bezier curve */
  87376. x2: number;
  87377. /** Defines the y component of the end tangent in the bezier curve */
  87378. y2: number;
  87379. /**
  87380. * Instantiates a bezier function
  87381. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  87382. * @param x1 Defines the x component of the start tangent in the bezier curve
  87383. * @param y1 Defines the y component of the start tangent in the bezier curve
  87384. * @param x2 Defines the x component of the end tangent in the bezier curve
  87385. * @param y2 Defines the y component of the end tangent in the bezier curve
  87386. */
  87387. constructor(
  87388. /** Defines the x component of the start tangent in the bezier curve */
  87389. x1?: number,
  87390. /** Defines the y component of the start tangent in the bezier curve */
  87391. y1?: number,
  87392. /** Defines the x component of the end tangent in the bezier curve */
  87393. x2?: number,
  87394. /** Defines the y component of the end tangent in the bezier curve */
  87395. y2?: number);
  87396. /** @hidden */
  87397. easeInCore(gradient: number): number;
  87398. }
  87399. }
  87400. declare module BABYLON {
  87401. /**
  87402. * Class used to hold a RBG color
  87403. */
  87404. export class Color3 {
  87405. /**
  87406. * Defines the red component (between 0 and 1, default is 0)
  87407. */
  87408. r: number;
  87409. /**
  87410. * Defines the green component (between 0 and 1, default is 0)
  87411. */
  87412. g: number;
  87413. /**
  87414. * Defines the blue component (between 0 and 1, default is 0)
  87415. */
  87416. b: number;
  87417. /**
  87418. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  87419. * @param r defines the red component (between 0 and 1, default is 0)
  87420. * @param g defines the green component (between 0 and 1, default is 0)
  87421. * @param b defines the blue component (between 0 and 1, default is 0)
  87422. */
  87423. constructor(
  87424. /**
  87425. * Defines the red component (between 0 and 1, default is 0)
  87426. */
  87427. r?: number,
  87428. /**
  87429. * Defines the green component (between 0 and 1, default is 0)
  87430. */
  87431. g?: number,
  87432. /**
  87433. * Defines the blue component (between 0 and 1, default is 0)
  87434. */
  87435. b?: number);
  87436. /**
  87437. * Creates a string with the Color3 current values
  87438. * @returns the string representation of the Color3 object
  87439. */
  87440. toString(): string;
  87441. /**
  87442. * Returns the string "Color3"
  87443. * @returns "Color3"
  87444. */
  87445. getClassName(): string;
  87446. /**
  87447. * Compute the Color3 hash code
  87448. * @returns an unique number that can be used to hash Color3 objects
  87449. */
  87450. getHashCode(): number;
  87451. /**
  87452. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  87453. * @param array defines the array where to store the r,g,b components
  87454. * @param index defines an optional index in the target array to define where to start storing values
  87455. * @returns the current Color3 object
  87456. */
  87457. toArray(array: FloatArray, index?: number): Color3;
  87458. /**
  87459. * Update the current color with values stored in an array from the starting index of the given array
  87460. * @param array defines the source array
  87461. * @param offset defines an offset in the source array
  87462. * @returns the current Color3 object
  87463. */
  87464. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  87465. /**
  87466. * Returns a new Color4 object from the current Color3 and the given alpha
  87467. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  87468. * @returns a new Color4 object
  87469. */
  87470. toColor4(alpha?: number): Color4;
  87471. /**
  87472. * Returns a new array populated with 3 numeric elements : red, green and blue values
  87473. * @returns the new array
  87474. */
  87475. asArray(): number[];
  87476. /**
  87477. * Returns the luminance value
  87478. * @returns a float value
  87479. */
  87480. toLuminance(): number;
  87481. /**
  87482. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  87483. * @param otherColor defines the second operand
  87484. * @returns the new Color3 object
  87485. */
  87486. multiply(otherColor: DeepImmutable<Color3>): Color3;
  87487. /**
  87488. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  87489. * @param otherColor defines the second operand
  87490. * @param result defines the Color3 object where to store the result
  87491. * @returns the current Color3
  87492. */
  87493. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87494. /**
  87495. * Determines equality between Color3 objects
  87496. * @param otherColor defines the second operand
  87497. * @returns true if the rgb values are equal to the given ones
  87498. */
  87499. equals(otherColor: DeepImmutable<Color3>): boolean;
  87500. /**
  87501. * Determines equality between the current Color3 object and a set of r,b,g values
  87502. * @param r defines the red component to check
  87503. * @param g defines the green component to check
  87504. * @param b defines the blue component to check
  87505. * @returns true if the rgb values are equal to the given ones
  87506. */
  87507. equalsFloats(r: number, g: number, b: number): boolean;
  87508. /**
  87509. * Multiplies in place each rgb value by scale
  87510. * @param scale defines the scaling factor
  87511. * @returns the updated Color3
  87512. */
  87513. scale(scale: number): Color3;
  87514. /**
  87515. * Multiplies the rgb values by scale and stores the result into "result"
  87516. * @param scale defines the scaling factor
  87517. * @param result defines the Color3 object where to store the result
  87518. * @returns the unmodified current Color3
  87519. */
  87520. scaleToRef(scale: number, result: Color3): Color3;
  87521. /**
  87522. * Scale the current Color3 values by a factor and add the result to a given Color3
  87523. * @param scale defines the scale factor
  87524. * @param result defines color to store the result into
  87525. * @returns the unmodified current Color3
  87526. */
  87527. scaleAndAddToRef(scale: number, result: Color3): Color3;
  87528. /**
  87529. * Clamps the rgb values by the min and max values and stores the result into "result"
  87530. * @param min defines minimum clamping value (default is 0)
  87531. * @param max defines maximum clamping value (default is 1)
  87532. * @param result defines color to store the result into
  87533. * @returns the original Color3
  87534. */
  87535. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  87536. /**
  87537. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  87538. * @param otherColor defines the second operand
  87539. * @returns the new Color3
  87540. */
  87541. add(otherColor: DeepImmutable<Color3>): Color3;
  87542. /**
  87543. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  87544. * @param otherColor defines the second operand
  87545. * @param result defines Color3 object to store the result into
  87546. * @returns the unmodified current Color3
  87547. */
  87548. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87549. /**
  87550. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  87551. * @param otherColor defines the second operand
  87552. * @returns the new Color3
  87553. */
  87554. subtract(otherColor: DeepImmutable<Color3>): Color3;
  87555. /**
  87556. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  87557. * @param otherColor defines the second operand
  87558. * @param result defines Color3 object to store the result into
  87559. * @returns the unmodified current Color3
  87560. */
  87561. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87562. /**
  87563. * Copy the current object
  87564. * @returns a new Color3 copied the current one
  87565. */
  87566. clone(): Color3;
  87567. /**
  87568. * Copies the rgb values from the source in the current Color3
  87569. * @param source defines the source Color3 object
  87570. * @returns the updated Color3 object
  87571. */
  87572. copyFrom(source: DeepImmutable<Color3>): Color3;
  87573. /**
  87574. * Updates the Color3 rgb values from the given floats
  87575. * @param r defines the red component to read from
  87576. * @param g defines the green component to read from
  87577. * @param b defines the blue component to read from
  87578. * @returns the current Color3 object
  87579. */
  87580. copyFromFloats(r: number, g: number, b: number): Color3;
  87581. /**
  87582. * Updates the Color3 rgb values from the given floats
  87583. * @param r defines the red component to read from
  87584. * @param g defines the green component to read from
  87585. * @param b defines the blue component to read from
  87586. * @returns the current Color3 object
  87587. */
  87588. set(r: number, g: number, b: number): Color3;
  87589. /**
  87590. * Compute the Color3 hexadecimal code as a string
  87591. * @returns a string containing the hexadecimal representation of the Color3 object
  87592. */
  87593. toHexString(): string;
  87594. /**
  87595. * Computes a new Color3 converted from the current one to linear space
  87596. * @returns a new Color3 object
  87597. */
  87598. toLinearSpace(): Color3;
  87599. /**
  87600. * Converts current color in rgb space to HSV values
  87601. * @returns a new color3 representing the HSV values
  87602. */
  87603. toHSV(): Color3;
  87604. /**
  87605. * Converts current color in rgb space to HSV values
  87606. * @param result defines the Color3 where to store the HSV values
  87607. */
  87608. toHSVToRef(result: Color3): void;
  87609. /**
  87610. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  87611. * @param convertedColor defines the Color3 object where to store the linear space version
  87612. * @returns the unmodified Color3
  87613. */
  87614. toLinearSpaceToRef(convertedColor: Color3): Color3;
  87615. /**
  87616. * Computes a new Color3 converted from the current one to gamma space
  87617. * @returns a new Color3 object
  87618. */
  87619. toGammaSpace(): Color3;
  87620. /**
  87621. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  87622. * @param convertedColor defines the Color3 object where to store the gamma space version
  87623. * @returns the unmodified Color3
  87624. */
  87625. toGammaSpaceToRef(convertedColor: Color3): Color3;
  87626. private static _BlackReadOnly;
  87627. /**
  87628. * Convert Hue, saturation and value to a Color3 (RGB)
  87629. * @param hue defines the hue
  87630. * @param saturation defines the saturation
  87631. * @param value defines the value
  87632. * @param result defines the Color3 where to store the RGB values
  87633. */
  87634. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  87635. /**
  87636. * Creates a new Color3 from the string containing valid hexadecimal values
  87637. * @param hex defines a string containing valid hexadecimal values
  87638. * @returns a new Color3 object
  87639. */
  87640. static FromHexString(hex: string): Color3;
  87641. /**
  87642. * Creates a new Color3 from the starting index of the given array
  87643. * @param array defines the source array
  87644. * @param offset defines an offset in the source array
  87645. * @returns a new Color3 object
  87646. */
  87647. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  87648. /**
  87649. * Creates a new Color3 from the starting index element of the given array
  87650. * @param array defines the source array to read from
  87651. * @param offset defines the offset in the source array
  87652. * @param result defines the target Color3 object
  87653. */
  87654. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  87655. /**
  87656. * Creates a new Color3 from integer values (< 256)
  87657. * @param r defines the red component to read from (value between 0 and 255)
  87658. * @param g defines the green component to read from (value between 0 and 255)
  87659. * @param b defines the blue component to read from (value between 0 and 255)
  87660. * @returns a new Color3 object
  87661. */
  87662. static FromInts(r: number, g: number, b: number): Color3;
  87663. /**
  87664. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  87665. * @param start defines the start Color3 value
  87666. * @param end defines the end Color3 value
  87667. * @param amount defines the gradient value between start and end
  87668. * @returns a new Color3 object
  87669. */
  87670. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  87671. /**
  87672. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  87673. * @param left defines the start value
  87674. * @param right defines the end value
  87675. * @param amount defines the gradient factor
  87676. * @param result defines the Color3 object where to store the result
  87677. */
  87678. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  87679. /**
  87680. * Returns a Color3 value containing a red color
  87681. * @returns a new Color3 object
  87682. */
  87683. static Red(): Color3;
  87684. /**
  87685. * Returns a Color3 value containing a green color
  87686. * @returns a new Color3 object
  87687. */
  87688. static Green(): Color3;
  87689. /**
  87690. * Returns a Color3 value containing a blue color
  87691. * @returns a new Color3 object
  87692. */
  87693. static Blue(): Color3;
  87694. /**
  87695. * Returns a Color3 value containing a black color
  87696. * @returns a new Color3 object
  87697. */
  87698. static Black(): Color3;
  87699. /**
  87700. * Gets a Color3 value containing a black color that must not be updated
  87701. */
  87702. static get BlackReadOnly(): DeepImmutable<Color3>;
  87703. /**
  87704. * Returns a Color3 value containing a white color
  87705. * @returns a new Color3 object
  87706. */
  87707. static White(): Color3;
  87708. /**
  87709. * Returns a Color3 value containing a purple color
  87710. * @returns a new Color3 object
  87711. */
  87712. static Purple(): Color3;
  87713. /**
  87714. * Returns a Color3 value containing a magenta color
  87715. * @returns a new Color3 object
  87716. */
  87717. static Magenta(): Color3;
  87718. /**
  87719. * Returns a Color3 value containing a yellow color
  87720. * @returns a new Color3 object
  87721. */
  87722. static Yellow(): Color3;
  87723. /**
  87724. * Returns a Color3 value containing a gray color
  87725. * @returns a new Color3 object
  87726. */
  87727. static Gray(): Color3;
  87728. /**
  87729. * Returns a Color3 value containing a teal color
  87730. * @returns a new Color3 object
  87731. */
  87732. static Teal(): Color3;
  87733. /**
  87734. * Returns a Color3 value containing a random color
  87735. * @returns a new Color3 object
  87736. */
  87737. static Random(): Color3;
  87738. }
  87739. /**
  87740. * Class used to hold a RBGA color
  87741. */
  87742. export class Color4 {
  87743. /**
  87744. * Defines the red component (between 0 and 1, default is 0)
  87745. */
  87746. r: number;
  87747. /**
  87748. * Defines the green component (between 0 and 1, default is 0)
  87749. */
  87750. g: number;
  87751. /**
  87752. * Defines the blue component (between 0 and 1, default is 0)
  87753. */
  87754. b: number;
  87755. /**
  87756. * Defines the alpha component (between 0 and 1, default is 1)
  87757. */
  87758. a: number;
  87759. /**
  87760. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  87761. * @param r defines the red component (between 0 and 1, default is 0)
  87762. * @param g defines the green component (between 0 and 1, default is 0)
  87763. * @param b defines the blue component (between 0 and 1, default is 0)
  87764. * @param a defines the alpha component (between 0 and 1, default is 1)
  87765. */
  87766. constructor(
  87767. /**
  87768. * Defines the red component (between 0 and 1, default is 0)
  87769. */
  87770. r?: number,
  87771. /**
  87772. * Defines the green component (between 0 and 1, default is 0)
  87773. */
  87774. g?: number,
  87775. /**
  87776. * Defines the blue component (between 0 and 1, default is 0)
  87777. */
  87778. b?: number,
  87779. /**
  87780. * Defines the alpha component (between 0 and 1, default is 1)
  87781. */
  87782. a?: number);
  87783. /**
  87784. * Adds in place the given Color4 values to the current Color4 object
  87785. * @param right defines the second operand
  87786. * @returns the current updated Color4 object
  87787. */
  87788. addInPlace(right: DeepImmutable<Color4>): Color4;
  87789. /**
  87790. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  87791. * @returns the new array
  87792. */
  87793. asArray(): number[];
  87794. /**
  87795. * Stores from the starting index in the given array the Color4 successive values
  87796. * @param array defines the array where to store the r,g,b components
  87797. * @param index defines an optional index in the target array to define where to start storing values
  87798. * @returns the current Color4 object
  87799. */
  87800. toArray(array: number[], index?: number): Color4;
  87801. /**
  87802. * Update the current color with values stored in an array from the starting index of the given array
  87803. * @param array defines the source array
  87804. * @param offset defines an offset in the source array
  87805. * @returns the current Color4 object
  87806. */
  87807. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87808. /**
  87809. * Determines equality between Color4 objects
  87810. * @param otherColor defines the second operand
  87811. * @returns true if the rgba values are equal to the given ones
  87812. */
  87813. equals(otherColor: DeepImmutable<Color4>): boolean;
  87814. /**
  87815. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  87816. * @param right defines the second operand
  87817. * @returns a new Color4 object
  87818. */
  87819. add(right: DeepImmutable<Color4>): Color4;
  87820. /**
  87821. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  87822. * @param right defines the second operand
  87823. * @returns a new Color4 object
  87824. */
  87825. subtract(right: DeepImmutable<Color4>): Color4;
  87826. /**
  87827. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  87828. * @param right defines the second operand
  87829. * @param result defines the Color4 object where to store the result
  87830. * @returns the current Color4 object
  87831. */
  87832. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  87833. /**
  87834. * Creates a new Color4 with the current Color4 values multiplied by scale
  87835. * @param scale defines the scaling factor to apply
  87836. * @returns a new Color4 object
  87837. */
  87838. scale(scale: number): Color4;
  87839. /**
  87840. * Multiplies the current Color4 values by scale and stores the result in "result"
  87841. * @param scale defines the scaling factor to apply
  87842. * @param result defines the Color4 object where to store the result
  87843. * @returns the current unmodified Color4
  87844. */
  87845. scaleToRef(scale: number, result: Color4): Color4;
  87846. /**
  87847. * Scale the current Color4 values by a factor and add the result to a given Color4
  87848. * @param scale defines the scale factor
  87849. * @param result defines the Color4 object where to store the result
  87850. * @returns the unmodified current Color4
  87851. */
  87852. scaleAndAddToRef(scale: number, result: Color4): Color4;
  87853. /**
  87854. * Clamps the rgb values by the min and max values and stores the result into "result"
  87855. * @param min defines minimum clamping value (default is 0)
  87856. * @param max defines maximum clamping value (default is 1)
  87857. * @param result defines color to store the result into.
  87858. * @returns the cuurent Color4
  87859. */
  87860. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  87861. /**
  87862. * Multipy an Color4 value by another and return a new Color4 object
  87863. * @param color defines the Color4 value to multiply by
  87864. * @returns a new Color4 object
  87865. */
  87866. multiply(color: Color4): Color4;
  87867. /**
  87868. * Multipy a Color4 value by another and push the result in a reference value
  87869. * @param color defines the Color4 value to multiply by
  87870. * @param result defines the Color4 to fill the result in
  87871. * @returns the result Color4
  87872. */
  87873. multiplyToRef(color: Color4, result: Color4): Color4;
  87874. /**
  87875. * Creates a string with the Color4 current values
  87876. * @returns the string representation of the Color4 object
  87877. */
  87878. toString(): string;
  87879. /**
  87880. * Returns the string "Color4"
  87881. * @returns "Color4"
  87882. */
  87883. getClassName(): string;
  87884. /**
  87885. * Compute the Color4 hash code
  87886. * @returns an unique number that can be used to hash Color4 objects
  87887. */
  87888. getHashCode(): number;
  87889. /**
  87890. * Creates a new Color4 copied from the current one
  87891. * @returns a new Color4 object
  87892. */
  87893. clone(): Color4;
  87894. /**
  87895. * Copies the given Color4 values into the current one
  87896. * @param source defines the source Color4 object
  87897. * @returns the current updated Color4 object
  87898. */
  87899. copyFrom(source: Color4): Color4;
  87900. /**
  87901. * Copies the given float values into the current one
  87902. * @param r defines the red component to read from
  87903. * @param g defines the green component to read from
  87904. * @param b defines the blue component to read from
  87905. * @param a defines the alpha component to read from
  87906. * @returns the current updated Color4 object
  87907. */
  87908. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  87909. /**
  87910. * Copies the given float values into the current one
  87911. * @param r defines the red component to read from
  87912. * @param g defines the green component to read from
  87913. * @param b defines the blue component to read from
  87914. * @param a defines the alpha component to read from
  87915. * @returns the current updated Color4 object
  87916. */
  87917. set(r: number, g: number, b: number, a: number): Color4;
  87918. /**
  87919. * Compute the Color4 hexadecimal code as a string
  87920. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  87921. * @returns a string containing the hexadecimal representation of the Color4 object
  87922. */
  87923. toHexString(returnAsColor3?: boolean): string;
  87924. /**
  87925. * Computes a new Color4 converted from the current one to linear space
  87926. * @returns a new Color4 object
  87927. */
  87928. toLinearSpace(): Color4;
  87929. /**
  87930. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  87931. * @param convertedColor defines the Color4 object where to store the linear space version
  87932. * @returns the unmodified Color4
  87933. */
  87934. toLinearSpaceToRef(convertedColor: Color4): Color4;
  87935. /**
  87936. * Computes a new Color4 converted from the current one to gamma space
  87937. * @returns a new Color4 object
  87938. */
  87939. toGammaSpace(): Color4;
  87940. /**
  87941. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  87942. * @param convertedColor defines the Color4 object where to store the gamma space version
  87943. * @returns the unmodified Color4
  87944. */
  87945. toGammaSpaceToRef(convertedColor: Color4): Color4;
  87946. /**
  87947. * Creates a new Color4 from the string containing valid hexadecimal values
  87948. * @param hex defines a string containing valid hexadecimal values
  87949. * @returns a new Color4 object
  87950. */
  87951. static FromHexString(hex: string): Color4;
  87952. /**
  87953. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  87954. * @param left defines the start value
  87955. * @param right defines the end value
  87956. * @param amount defines the gradient factor
  87957. * @returns a new Color4 object
  87958. */
  87959. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  87960. /**
  87961. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  87962. * @param left defines the start value
  87963. * @param right defines the end value
  87964. * @param amount defines the gradient factor
  87965. * @param result defines the Color4 object where to store data
  87966. */
  87967. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  87968. /**
  87969. * Creates a new Color4 from a Color3 and an alpha value
  87970. * @param color3 defines the source Color3 to read from
  87971. * @param alpha defines the alpha component (1.0 by default)
  87972. * @returns a new Color4 object
  87973. */
  87974. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  87975. /**
  87976. * Creates a new Color4 from the starting index element of the given array
  87977. * @param array defines the source array to read from
  87978. * @param offset defines the offset in the source array
  87979. * @returns a new Color4 object
  87980. */
  87981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87982. /**
  87983. * Creates a new Color4 from the starting index element of the given array
  87984. * @param array defines the source array to read from
  87985. * @param offset defines the offset in the source array
  87986. * @param result defines the target Color4 object
  87987. */
  87988. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  87989. /**
  87990. * Creates a new Color3 from integer values (< 256)
  87991. * @param r defines the red component to read from (value between 0 and 255)
  87992. * @param g defines the green component to read from (value between 0 and 255)
  87993. * @param b defines the blue component to read from (value between 0 and 255)
  87994. * @param a defines the alpha component to read from (value between 0 and 255)
  87995. * @returns a new Color3 object
  87996. */
  87997. static FromInts(r: number, g: number, b: number, a: number): Color4;
  87998. /**
  87999. * Check the content of a given array and convert it to an array containing RGBA data
  88000. * If the original array was already containing count * 4 values then it is returned directly
  88001. * @param colors defines the array to check
  88002. * @param count defines the number of RGBA data to expect
  88003. * @returns an array containing count * 4 values (RGBA)
  88004. */
  88005. static CheckColors4(colors: number[], count: number): number[];
  88006. }
  88007. /**
  88008. * @hidden
  88009. */
  88010. export class TmpColors {
  88011. static Color3: Color3[];
  88012. static Color4: Color4[];
  88013. }
  88014. }
  88015. declare module BABYLON {
  88016. /**
  88017. * Defines an interface which represents an animation key frame
  88018. */
  88019. export interface IAnimationKey {
  88020. /**
  88021. * Frame of the key frame
  88022. */
  88023. frame: number;
  88024. /**
  88025. * Value at the specifies key frame
  88026. */
  88027. value: any;
  88028. /**
  88029. * The input tangent for the cubic hermite spline
  88030. */
  88031. inTangent?: any;
  88032. /**
  88033. * The output tangent for the cubic hermite spline
  88034. */
  88035. outTangent?: any;
  88036. /**
  88037. * The animation interpolation type
  88038. */
  88039. interpolation?: AnimationKeyInterpolation;
  88040. }
  88041. /**
  88042. * Enum for the animation key frame interpolation type
  88043. */
  88044. export enum AnimationKeyInterpolation {
  88045. /**
  88046. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  88047. */
  88048. STEP = 1
  88049. }
  88050. }
  88051. declare module BABYLON {
  88052. /**
  88053. * Represents the range of an animation
  88054. */
  88055. export class AnimationRange {
  88056. /**The name of the animation range**/
  88057. name: string;
  88058. /**The starting frame of the animation */
  88059. from: number;
  88060. /**The ending frame of the animation*/
  88061. to: number;
  88062. /**
  88063. * Initializes the range of an animation
  88064. * @param name The name of the animation range
  88065. * @param from The starting frame of the animation
  88066. * @param to The ending frame of the animation
  88067. */
  88068. constructor(
  88069. /**The name of the animation range**/
  88070. name: string,
  88071. /**The starting frame of the animation */
  88072. from: number,
  88073. /**The ending frame of the animation*/
  88074. to: number);
  88075. /**
  88076. * Makes a copy of the animation range
  88077. * @returns A copy of the animation range
  88078. */
  88079. clone(): AnimationRange;
  88080. }
  88081. }
  88082. declare module BABYLON {
  88083. /**
  88084. * Composed of a frame, and an action function
  88085. */
  88086. export class AnimationEvent {
  88087. /** The frame for which the event is triggered **/
  88088. frame: number;
  88089. /** The event to perform when triggered **/
  88090. action: (currentFrame: number) => void;
  88091. /** Specifies if the event should be triggered only once**/
  88092. onlyOnce?: boolean | undefined;
  88093. /**
  88094. * Specifies if the animation event is done
  88095. */
  88096. isDone: boolean;
  88097. /**
  88098. * Initializes the animation event
  88099. * @param frame The frame for which the event is triggered
  88100. * @param action The event to perform when triggered
  88101. * @param onlyOnce Specifies if the event should be triggered only once
  88102. */
  88103. constructor(
  88104. /** The frame for which the event is triggered **/
  88105. frame: number,
  88106. /** The event to perform when triggered **/
  88107. action: (currentFrame: number) => void,
  88108. /** Specifies if the event should be triggered only once**/
  88109. onlyOnce?: boolean | undefined);
  88110. /** @hidden */
  88111. _clone(): AnimationEvent;
  88112. }
  88113. }
  88114. declare module BABYLON {
  88115. /**
  88116. * Interface used to define a behavior
  88117. */
  88118. export interface Behavior<T> {
  88119. /** gets or sets behavior's name */
  88120. name: string;
  88121. /**
  88122. * Function called when the behavior needs to be initialized (after attaching it to a target)
  88123. */
  88124. init(): void;
  88125. /**
  88126. * Called when the behavior is attached to a target
  88127. * @param target defines the target where the behavior is attached to
  88128. */
  88129. attach(target: T): void;
  88130. /**
  88131. * Called when the behavior is detached from its target
  88132. */
  88133. detach(): void;
  88134. }
  88135. /**
  88136. * Interface implemented by classes supporting behaviors
  88137. */
  88138. export interface IBehaviorAware<T> {
  88139. /**
  88140. * Attach a behavior
  88141. * @param behavior defines the behavior to attach
  88142. * @returns the current host
  88143. */
  88144. addBehavior(behavior: Behavior<T>): T;
  88145. /**
  88146. * Remove a behavior from the current object
  88147. * @param behavior defines the behavior to detach
  88148. * @returns the current host
  88149. */
  88150. removeBehavior(behavior: Behavior<T>): T;
  88151. /**
  88152. * Gets a behavior using its name to search
  88153. * @param name defines the name to search
  88154. * @returns the behavior or null if not found
  88155. */
  88156. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  88157. }
  88158. }
  88159. declare module BABYLON {
  88160. /**
  88161. * Class used to store data that will be store in GPU memory
  88162. */
  88163. export class Buffer {
  88164. private _engine;
  88165. private _buffer;
  88166. /** @hidden */
  88167. _data: Nullable<DataArray>;
  88168. private _updatable;
  88169. private _instanced;
  88170. private _divisor;
  88171. private _isAlreadyOwned;
  88172. /**
  88173. * Gets the byte stride.
  88174. */
  88175. readonly byteStride: number;
  88176. /**
  88177. * Constructor
  88178. * @param engine the engine
  88179. * @param data the data to use for this buffer
  88180. * @param updatable whether the data is updatable
  88181. * @param stride the stride (optional)
  88182. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  88183. * @param instanced whether the buffer is instanced (optional)
  88184. * @param useBytes set to true if the stride in in bytes (optional)
  88185. * @param divisor sets an optional divisor for instances (1 by default)
  88186. */
  88187. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  88188. /**
  88189. * Create a new VertexBuffer based on the current buffer
  88190. * @param kind defines the vertex buffer kind (position, normal, etc.)
  88191. * @param offset defines offset in the buffer (0 by default)
  88192. * @param size defines the size in floats of attributes (position is 3 for instance)
  88193. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  88194. * @param instanced defines if the vertex buffer contains indexed data
  88195. * @param useBytes defines if the offset and stride are in bytes *
  88196. * @param divisor sets an optional divisor for instances (1 by default)
  88197. * @returns the new vertex buffer
  88198. */
  88199. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  88200. /**
  88201. * Gets a boolean indicating if the Buffer is updatable?
  88202. * @returns true if the buffer is updatable
  88203. */
  88204. isUpdatable(): boolean;
  88205. /**
  88206. * Gets current buffer's data
  88207. * @returns a DataArray or null
  88208. */
  88209. getData(): Nullable<DataArray>;
  88210. /**
  88211. * Gets underlying native buffer
  88212. * @returns underlying native buffer
  88213. */
  88214. getBuffer(): Nullable<DataBuffer>;
  88215. /**
  88216. * Gets the stride in float32 units (i.e. byte stride / 4).
  88217. * May not be an integer if the byte stride is not divisible by 4.
  88218. * @returns the stride in float32 units
  88219. * @deprecated Please use byteStride instead.
  88220. */
  88221. getStrideSize(): number;
  88222. /**
  88223. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  88224. * @param data defines the data to store
  88225. */
  88226. create(data?: Nullable<DataArray>): void;
  88227. /** @hidden */
  88228. _rebuild(): void;
  88229. /**
  88230. * Update current buffer data
  88231. * @param data defines the data to store
  88232. */
  88233. update(data: DataArray): void;
  88234. /**
  88235. * Updates the data directly.
  88236. * @param data the new data
  88237. * @param offset the new offset
  88238. * @param vertexCount the vertex count (optional)
  88239. * @param useBytes set to true if the offset is in bytes
  88240. */
  88241. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  88242. /** @hidden */
  88243. _increaseReferences(): void;
  88244. /**
  88245. * Release all resources
  88246. */
  88247. dispose(): void;
  88248. }
  88249. /**
  88250. * Specialized buffer used to store vertex data
  88251. */
  88252. export class VertexBuffer {
  88253. /** @hidden */
  88254. _buffer: Buffer;
  88255. private _kind;
  88256. private _size;
  88257. private _ownsBuffer;
  88258. private _instanced;
  88259. private _instanceDivisor;
  88260. /**
  88261. * The byte type.
  88262. */
  88263. static readonly BYTE: number;
  88264. /**
  88265. * The unsigned byte type.
  88266. */
  88267. static readonly UNSIGNED_BYTE: number;
  88268. /**
  88269. * The short type.
  88270. */
  88271. static readonly SHORT: number;
  88272. /**
  88273. * The unsigned short type.
  88274. */
  88275. static readonly UNSIGNED_SHORT: number;
  88276. /**
  88277. * The integer type.
  88278. */
  88279. static readonly INT: number;
  88280. /**
  88281. * The unsigned integer type.
  88282. */
  88283. static readonly UNSIGNED_INT: number;
  88284. /**
  88285. * The float type.
  88286. */
  88287. static readonly FLOAT: number;
  88288. /**
  88289. * Gets or sets the instance divisor when in instanced mode
  88290. */
  88291. get instanceDivisor(): number;
  88292. set instanceDivisor(value: number);
  88293. /**
  88294. * Gets the byte stride.
  88295. */
  88296. readonly byteStride: number;
  88297. /**
  88298. * Gets the byte offset.
  88299. */
  88300. readonly byteOffset: number;
  88301. /**
  88302. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  88303. */
  88304. readonly normalized: boolean;
  88305. /**
  88306. * Gets the data type of each component in the array.
  88307. */
  88308. readonly type: number;
  88309. /**
  88310. * Constructor
  88311. * @param engine the engine
  88312. * @param data the data to use for this vertex buffer
  88313. * @param kind the vertex buffer kind
  88314. * @param updatable whether the data is updatable
  88315. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  88316. * @param stride the stride (optional)
  88317. * @param instanced whether the buffer is instanced (optional)
  88318. * @param offset the offset of the data (optional)
  88319. * @param size the number of components (optional)
  88320. * @param type the type of the component (optional)
  88321. * @param normalized whether the data contains normalized data (optional)
  88322. * @param useBytes set to true if stride and offset are in bytes (optional)
  88323. * @param divisor defines the instance divisor to use (1 by default)
  88324. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  88325. */
  88326. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number, takeBufferOwnership?: boolean);
  88327. /** @hidden */
  88328. _rebuild(): void;
  88329. /**
  88330. * Returns the kind of the VertexBuffer (string)
  88331. * @returns a string
  88332. */
  88333. getKind(): string;
  88334. /**
  88335. * Gets a boolean indicating if the VertexBuffer is updatable?
  88336. * @returns true if the buffer is updatable
  88337. */
  88338. isUpdatable(): boolean;
  88339. /**
  88340. * Gets current buffer's data
  88341. * @returns a DataArray or null
  88342. */
  88343. getData(): Nullable<DataArray>;
  88344. /**
  88345. * Gets underlying native buffer
  88346. * @returns underlying native buffer
  88347. */
  88348. getBuffer(): Nullable<DataBuffer>;
  88349. /**
  88350. * Gets the stride in float32 units (i.e. byte stride / 4).
  88351. * May not be an integer if the byte stride is not divisible by 4.
  88352. * @returns the stride in float32 units
  88353. * @deprecated Please use byteStride instead.
  88354. */
  88355. getStrideSize(): number;
  88356. /**
  88357. * Returns the offset as a multiple of the type byte length.
  88358. * @returns the offset in bytes
  88359. * @deprecated Please use byteOffset instead.
  88360. */
  88361. getOffset(): number;
  88362. /**
  88363. * Returns the number of components per vertex attribute (integer)
  88364. * @returns the size in float
  88365. */
  88366. getSize(): number;
  88367. /**
  88368. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  88369. * @returns true if this buffer is instanced
  88370. */
  88371. getIsInstanced(): boolean;
  88372. /**
  88373. * Returns the instancing divisor, zero for non-instanced (integer).
  88374. * @returns a number
  88375. */
  88376. getInstanceDivisor(): number;
  88377. /**
  88378. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  88379. * @param data defines the data to store
  88380. */
  88381. create(data?: DataArray): void;
  88382. /**
  88383. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  88384. * This function will create a new buffer if the current one is not updatable
  88385. * @param data defines the data to store
  88386. */
  88387. update(data: DataArray): void;
  88388. /**
  88389. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  88390. * Returns the directly updated WebGLBuffer.
  88391. * @param data the new data
  88392. * @param offset the new offset
  88393. * @param useBytes set to true if the offset is in bytes
  88394. */
  88395. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  88396. /**
  88397. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  88398. */
  88399. dispose(): void;
  88400. /**
  88401. * Enumerates each value of this vertex buffer as numbers.
  88402. * @param count the number of values to enumerate
  88403. * @param callback the callback function called for each value
  88404. */
  88405. forEach(count: number, callback: (value: number, index: number) => void): void;
  88406. /**
  88407. * Positions
  88408. */
  88409. static readonly PositionKind: string;
  88410. /**
  88411. * Normals
  88412. */
  88413. static readonly NormalKind: string;
  88414. /**
  88415. * Tangents
  88416. */
  88417. static readonly TangentKind: string;
  88418. /**
  88419. * Texture coordinates
  88420. */
  88421. static readonly UVKind: string;
  88422. /**
  88423. * Texture coordinates 2
  88424. */
  88425. static readonly UV2Kind: string;
  88426. /**
  88427. * Texture coordinates 3
  88428. */
  88429. static readonly UV3Kind: string;
  88430. /**
  88431. * Texture coordinates 4
  88432. */
  88433. static readonly UV4Kind: string;
  88434. /**
  88435. * Texture coordinates 5
  88436. */
  88437. static readonly UV5Kind: string;
  88438. /**
  88439. * Texture coordinates 6
  88440. */
  88441. static readonly UV6Kind: string;
  88442. /**
  88443. * Colors
  88444. */
  88445. static readonly ColorKind: string;
  88446. /**
  88447. * Matrix indices (for bones)
  88448. */
  88449. static readonly MatricesIndicesKind: string;
  88450. /**
  88451. * Matrix weights (for bones)
  88452. */
  88453. static readonly MatricesWeightsKind: string;
  88454. /**
  88455. * Additional matrix indices (for bones)
  88456. */
  88457. static readonly MatricesIndicesExtraKind: string;
  88458. /**
  88459. * Additional matrix weights (for bones)
  88460. */
  88461. static readonly MatricesWeightsExtraKind: string;
  88462. /**
  88463. * Deduces the stride given a kind.
  88464. * @param kind The kind string to deduce
  88465. * @returns The deduced stride
  88466. */
  88467. static DeduceStride(kind: string): number;
  88468. /**
  88469. * Gets the byte length of the given type.
  88470. * @param type the type
  88471. * @returns the number of bytes
  88472. */
  88473. static GetTypeByteLength(type: number): number;
  88474. /**
  88475. * Enumerates each value of the given parameters as numbers.
  88476. * @param data the data to enumerate
  88477. * @param byteOffset the byte offset of the data
  88478. * @param byteStride the byte stride of the data
  88479. * @param componentCount the number of components per element
  88480. * @param componentType the type of the component
  88481. * @param count the number of values to enumerate
  88482. * @param normalized whether the data is normalized
  88483. * @param callback the callback function called for each value
  88484. */
  88485. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  88486. private static _GetFloatValue;
  88487. }
  88488. }
  88489. declare module BABYLON {
  88490. /**
  88491. * @hidden
  88492. */
  88493. export class IntersectionInfo {
  88494. bu: Nullable<number>;
  88495. bv: Nullable<number>;
  88496. distance: number;
  88497. faceId: number;
  88498. subMeshId: number;
  88499. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  88500. }
  88501. }
  88502. declare module BABYLON {
  88503. /**
  88504. * Class used to store bounding sphere information
  88505. */
  88506. export class BoundingSphere {
  88507. /**
  88508. * Gets the center of the bounding sphere in local space
  88509. */
  88510. readonly center: Vector3;
  88511. /**
  88512. * Radius of the bounding sphere in local space
  88513. */
  88514. radius: number;
  88515. /**
  88516. * Gets the center of the bounding sphere in world space
  88517. */
  88518. readonly centerWorld: Vector3;
  88519. /**
  88520. * Radius of the bounding sphere in world space
  88521. */
  88522. radiusWorld: number;
  88523. /**
  88524. * Gets the minimum vector in local space
  88525. */
  88526. readonly minimum: Vector3;
  88527. /**
  88528. * Gets the maximum vector in local space
  88529. */
  88530. readonly maximum: Vector3;
  88531. private _worldMatrix;
  88532. private static readonly TmpVector3;
  88533. /**
  88534. * Creates a new bounding sphere
  88535. * @param min defines the minimum vector (in local space)
  88536. * @param max defines the maximum vector (in local space)
  88537. * @param worldMatrix defines the new world matrix
  88538. */
  88539. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88540. /**
  88541. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  88542. * @param min defines the new minimum vector (in local space)
  88543. * @param max defines the new maximum vector (in local space)
  88544. * @param worldMatrix defines the new world matrix
  88545. */
  88546. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88547. /**
  88548. * Scale the current bounding sphere by applying a scale factor
  88549. * @param factor defines the scale factor to apply
  88550. * @returns the current bounding box
  88551. */
  88552. scale(factor: number): BoundingSphere;
  88553. /**
  88554. * Gets the world matrix of the bounding box
  88555. * @returns a matrix
  88556. */
  88557. getWorldMatrix(): DeepImmutable<Matrix>;
  88558. /** @hidden */
  88559. _update(worldMatrix: DeepImmutable<Matrix>): void;
  88560. /**
  88561. * Tests if the bounding sphere is intersecting the frustum planes
  88562. * @param frustumPlanes defines the frustum planes to test
  88563. * @returns true if there is an intersection
  88564. */
  88565. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88566. /**
  88567. * Tests if the bounding sphere center is in between the frustum planes.
  88568. * Used for optimistic fast inclusion.
  88569. * @param frustumPlanes defines the frustum planes to test
  88570. * @returns true if the sphere center is in between the frustum planes
  88571. */
  88572. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88573. /**
  88574. * Tests if a point is inside the bounding sphere
  88575. * @param point defines the point to test
  88576. * @returns true if the point is inside the bounding sphere
  88577. */
  88578. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88579. /**
  88580. * Checks if two sphere intersct
  88581. * @param sphere0 sphere 0
  88582. * @param sphere1 sphere 1
  88583. * @returns true if the speres intersect
  88584. */
  88585. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  88586. }
  88587. }
  88588. declare module BABYLON {
  88589. /**
  88590. * Class used to store bounding box information
  88591. */
  88592. export class BoundingBox implements ICullable {
  88593. /**
  88594. * Gets the 8 vectors representing the bounding box in local space
  88595. */
  88596. readonly vectors: Vector3[];
  88597. /**
  88598. * Gets the center of the bounding box in local space
  88599. */
  88600. readonly center: Vector3;
  88601. /**
  88602. * Gets the center of the bounding box in world space
  88603. */
  88604. readonly centerWorld: Vector3;
  88605. /**
  88606. * Gets the extend size in local space
  88607. */
  88608. readonly extendSize: Vector3;
  88609. /**
  88610. * Gets the extend size in world space
  88611. */
  88612. readonly extendSizeWorld: Vector3;
  88613. /**
  88614. * Gets the OBB (object bounding box) directions
  88615. */
  88616. readonly directions: Vector3[];
  88617. /**
  88618. * Gets the 8 vectors representing the bounding box in world space
  88619. */
  88620. readonly vectorsWorld: Vector3[];
  88621. /**
  88622. * Gets the minimum vector in world space
  88623. */
  88624. readonly minimumWorld: Vector3;
  88625. /**
  88626. * Gets the maximum vector in world space
  88627. */
  88628. readonly maximumWorld: Vector3;
  88629. /**
  88630. * Gets the minimum vector in local space
  88631. */
  88632. readonly minimum: Vector3;
  88633. /**
  88634. * Gets the maximum vector in local space
  88635. */
  88636. readonly maximum: Vector3;
  88637. private _worldMatrix;
  88638. private static readonly TmpVector3;
  88639. /**
  88640. * @hidden
  88641. */
  88642. _tag: number;
  88643. /**
  88644. * Creates a new bounding box
  88645. * @param min defines the minimum vector (in local space)
  88646. * @param max defines the maximum vector (in local space)
  88647. * @param worldMatrix defines the new world matrix
  88648. */
  88649. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88650. /**
  88651. * Recreates the entire bounding box from scratch as if we call the constructor in place
  88652. * @param min defines the new minimum vector (in local space)
  88653. * @param max defines the new maximum vector (in local space)
  88654. * @param worldMatrix defines the new world matrix
  88655. */
  88656. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88657. /**
  88658. * Scale the current bounding box by applying a scale factor
  88659. * @param factor defines the scale factor to apply
  88660. * @returns the current bounding box
  88661. */
  88662. scale(factor: number): BoundingBox;
  88663. /**
  88664. * Gets the world matrix of the bounding box
  88665. * @returns a matrix
  88666. */
  88667. getWorldMatrix(): DeepImmutable<Matrix>;
  88668. /** @hidden */
  88669. _update(world: DeepImmutable<Matrix>): void;
  88670. /**
  88671. * Tests if the bounding box is intersecting the frustum planes
  88672. * @param frustumPlanes defines the frustum planes to test
  88673. * @returns true if there is an intersection
  88674. */
  88675. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88676. /**
  88677. * Tests if the bounding box is entirely inside the frustum planes
  88678. * @param frustumPlanes defines the frustum planes to test
  88679. * @returns true if there is an inclusion
  88680. */
  88681. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88682. /**
  88683. * Tests if a point is inside the bounding box
  88684. * @param point defines the point to test
  88685. * @returns true if the point is inside the bounding box
  88686. */
  88687. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88688. /**
  88689. * Tests if the bounding box intersects with a bounding sphere
  88690. * @param sphere defines the sphere to test
  88691. * @returns true if there is an intersection
  88692. */
  88693. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  88694. /**
  88695. * Tests if the bounding box intersects with a box defined by a min and max vectors
  88696. * @param min defines the min vector to use
  88697. * @param max defines the max vector to use
  88698. * @returns true if there is an intersection
  88699. */
  88700. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  88701. /**
  88702. * Tests if two bounding boxes are intersections
  88703. * @param box0 defines the first box to test
  88704. * @param box1 defines the second box to test
  88705. * @returns true if there is an intersection
  88706. */
  88707. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  88708. /**
  88709. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  88710. * @param minPoint defines the minimum vector of the bounding box
  88711. * @param maxPoint defines the maximum vector of the bounding box
  88712. * @param sphereCenter defines the sphere center
  88713. * @param sphereRadius defines the sphere radius
  88714. * @returns true if there is an intersection
  88715. */
  88716. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  88717. /**
  88718. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  88719. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88720. * @param frustumPlanes defines the frustum planes to test
  88721. * @return true if there is an inclusion
  88722. */
  88723. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88724. /**
  88725. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  88726. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88727. * @param frustumPlanes defines the frustum planes to test
  88728. * @return true if there is an intersection
  88729. */
  88730. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88731. }
  88732. }
  88733. declare module BABYLON {
  88734. /** @hidden */
  88735. export class Collider {
  88736. /** Define if a collision was found */
  88737. collisionFound: boolean;
  88738. /**
  88739. * Define last intersection point in local space
  88740. */
  88741. intersectionPoint: Vector3;
  88742. /**
  88743. * Define last collided mesh
  88744. */
  88745. collidedMesh: Nullable<AbstractMesh>;
  88746. private _collisionPoint;
  88747. private _planeIntersectionPoint;
  88748. private _tempVector;
  88749. private _tempVector2;
  88750. private _tempVector3;
  88751. private _tempVector4;
  88752. private _edge;
  88753. private _baseToVertex;
  88754. private _destinationPoint;
  88755. private _slidePlaneNormal;
  88756. private _displacementVector;
  88757. /** @hidden */
  88758. _radius: Vector3;
  88759. /** @hidden */
  88760. _retry: number;
  88761. private _velocity;
  88762. private _basePoint;
  88763. private _epsilon;
  88764. /** @hidden */
  88765. _velocityWorldLength: number;
  88766. /** @hidden */
  88767. _basePointWorld: Vector3;
  88768. private _velocityWorld;
  88769. private _normalizedVelocity;
  88770. /** @hidden */
  88771. _initialVelocity: Vector3;
  88772. /** @hidden */
  88773. _initialPosition: Vector3;
  88774. private _nearestDistance;
  88775. private _collisionMask;
  88776. get collisionMask(): number;
  88777. set collisionMask(mask: number);
  88778. /**
  88779. * Gets the plane normal used to compute the sliding response (in local space)
  88780. */
  88781. get slidePlaneNormal(): Vector3;
  88782. /** @hidden */
  88783. _initialize(source: Vector3, dir: Vector3, e: number): void;
  88784. /** @hidden */
  88785. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  88786. /** @hidden */
  88787. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  88788. /** @hidden */
  88789. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88790. /** @hidden */
  88791. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88792. /** @hidden */
  88793. _getResponse(pos: Vector3, vel: Vector3): void;
  88794. }
  88795. }
  88796. declare module BABYLON {
  88797. /**
  88798. * Interface for cullable objects
  88799. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  88800. */
  88801. export interface ICullable {
  88802. /**
  88803. * Checks if the object or part of the object is in the frustum
  88804. * @param frustumPlanes Camera near/planes
  88805. * @returns true if the object is in frustum otherwise false
  88806. */
  88807. isInFrustum(frustumPlanes: Plane[]): boolean;
  88808. /**
  88809. * Checks if a cullable object (mesh...) is in the camera frustum
  88810. * Unlike isInFrustum this cheks the full bounding box
  88811. * @param frustumPlanes Camera near/planes
  88812. * @returns true if the object is in frustum otherwise false
  88813. */
  88814. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88815. }
  88816. /**
  88817. * Info for a bounding data of a mesh
  88818. */
  88819. export class BoundingInfo implements ICullable {
  88820. /**
  88821. * Bounding box for the mesh
  88822. */
  88823. readonly boundingBox: BoundingBox;
  88824. /**
  88825. * Bounding sphere for the mesh
  88826. */
  88827. readonly boundingSphere: BoundingSphere;
  88828. private _isLocked;
  88829. private static readonly TmpVector3;
  88830. /**
  88831. * Constructs bounding info
  88832. * @param minimum min vector of the bounding box/sphere
  88833. * @param maximum max vector of the bounding box/sphere
  88834. * @param worldMatrix defines the new world matrix
  88835. */
  88836. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88837. /**
  88838. * Recreates the entire bounding info from scratch as if we call the constructor in place
  88839. * @param min defines the new minimum vector (in local space)
  88840. * @param max defines the new maximum vector (in local space)
  88841. * @param worldMatrix defines the new world matrix
  88842. */
  88843. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88844. /**
  88845. * min vector of the bounding box/sphere
  88846. */
  88847. get minimum(): Vector3;
  88848. /**
  88849. * max vector of the bounding box/sphere
  88850. */
  88851. get maximum(): Vector3;
  88852. /**
  88853. * If the info is locked and won't be updated to avoid perf overhead
  88854. */
  88855. get isLocked(): boolean;
  88856. set isLocked(value: boolean);
  88857. /**
  88858. * Updates the bounding sphere and box
  88859. * @param world world matrix to be used to update
  88860. */
  88861. update(world: DeepImmutable<Matrix>): void;
  88862. /**
  88863. * Recreate the bounding info to be centered around a specific point given a specific extend.
  88864. * @param center New center of the bounding info
  88865. * @param extend New extend of the bounding info
  88866. * @returns the current bounding info
  88867. */
  88868. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  88869. /**
  88870. * Scale the current bounding info by applying a scale factor
  88871. * @param factor defines the scale factor to apply
  88872. * @returns the current bounding info
  88873. */
  88874. scale(factor: number): BoundingInfo;
  88875. /**
  88876. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  88877. * @param frustumPlanes defines the frustum to test
  88878. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  88879. * @returns true if the bounding info is in the frustum planes
  88880. */
  88881. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  88882. /**
  88883. * Gets the world distance between the min and max points of the bounding box
  88884. */
  88885. get diagonalLength(): number;
  88886. /**
  88887. * Checks if a cullable object (mesh...) is in the camera frustum
  88888. * Unlike isInFrustum this cheks the full bounding box
  88889. * @param frustumPlanes Camera near/planes
  88890. * @returns true if the object is in frustum otherwise false
  88891. */
  88892. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88893. /** @hidden */
  88894. _checkCollision(collider: Collider): boolean;
  88895. /**
  88896. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  88897. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88898. * @param point the point to check intersection with
  88899. * @returns if the point intersects
  88900. */
  88901. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88902. /**
  88903. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  88904. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88905. * @param boundingInfo the bounding info to check intersection with
  88906. * @param precise if the intersection should be done using OBB
  88907. * @returns if the bounding info intersects
  88908. */
  88909. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  88910. }
  88911. }
  88912. declare module BABYLON {
  88913. /**
  88914. * Extracts minimum and maximum values from a list of indexed positions
  88915. * @param positions defines the positions to use
  88916. * @param indices defines the indices to the positions
  88917. * @param indexStart defines the start index
  88918. * @param indexCount defines the end index
  88919. * @param bias defines bias value to add to the result
  88920. * @return minimum and maximum values
  88921. */
  88922. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88923. minimum: Vector3;
  88924. maximum: Vector3;
  88925. };
  88926. /**
  88927. * Extracts minimum and maximum values from a list of positions
  88928. * @param positions defines the positions to use
  88929. * @param start defines the start index in the positions array
  88930. * @param count defines the number of positions to handle
  88931. * @param bias defines bias value to add to the result
  88932. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88933. * @return minimum and maximum values
  88934. */
  88935. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88936. minimum: Vector3;
  88937. maximum: Vector3;
  88938. };
  88939. }
  88940. declare module BABYLON {
  88941. /**
  88942. * Class used to manipulate GUIDs
  88943. */
  88944. export class GUID {
  88945. /**
  88946. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88947. * Be aware Math.random() could cause collisions, but:
  88948. * "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"
  88949. * @returns a pseudo random id
  88950. */
  88951. static RandomId(): string;
  88952. }
  88953. }
  88954. declare module BABYLON {
  88955. /**
  88956. * Base class of all the textures in babylon.
  88957. * It groups all the common properties the materials, post process, lights... might need
  88958. * in order to make a correct use of the texture.
  88959. */
  88960. export class BaseTexture extends ThinTexture implements IAnimatable {
  88961. /**
  88962. * Default anisotropic filtering level for the application.
  88963. * It is set to 4 as a good tradeoff between perf and quality.
  88964. */
  88965. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  88966. /**
  88967. * Gets or sets the unique id of the texture
  88968. */
  88969. uniqueId: number;
  88970. /**
  88971. * Define the name of the texture.
  88972. */
  88973. name: string;
  88974. /**
  88975. * Gets or sets an object used to store user defined information.
  88976. */
  88977. metadata: any;
  88978. /**
  88979. * For internal use only. Please do not use.
  88980. */
  88981. reservedDataStore: any;
  88982. private _hasAlpha;
  88983. /**
  88984. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88985. */
  88986. set hasAlpha(value: boolean);
  88987. get hasAlpha(): boolean;
  88988. /**
  88989. * Defines if the alpha value should be determined via the rgb values.
  88990. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88991. */
  88992. getAlphaFromRGB: boolean;
  88993. /**
  88994. * Intensity or strength of the texture.
  88995. * It is commonly used by materials to fine tune the intensity of the texture
  88996. */
  88997. level: number;
  88998. /**
  88999. * Define the UV chanel to use starting from 0 and defaulting to 0.
  89000. * This is part of the texture as textures usually maps to one uv set.
  89001. */
  89002. coordinatesIndex: number;
  89003. protected _coordinatesMode: number;
  89004. /**
  89005. * How a texture is mapped.
  89006. *
  89007. * | Value | Type | Description |
  89008. * | ----- | ----------------------------------- | ----------- |
  89009. * | 0 | EXPLICIT_MODE | |
  89010. * | 1 | SPHERICAL_MODE | |
  89011. * | 2 | PLANAR_MODE | |
  89012. * | 3 | CUBIC_MODE | |
  89013. * | 4 | PROJECTION_MODE | |
  89014. * | 5 | SKYBOX_MODE | |
  89015. * | 6 | INVCUBIC_MODE | |
  89016. * | 7 | EQUIRECTANGULAR_MODE | |
  89017. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  89018. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  89019. */
  89020. set coordinatesMode(value: number);
  89021. get coordinatesMode(): number;
  89022. /**
  89023. * | Value | Type | Description |
  89024. * | ----- | ------------------ | ----------- |
  89025. * | 0 | CLAMP_ADDRESSMODE | |
  89026. * | 1 | WRAP_ADDRESSMODE | |
  89027. * | 2 | MIRROR_ADDRESSMODE | |
  89028. */
  89029. get wrapU(): number;
  89030. set wrapU(value: number);
  89031. /**
  89032. * | Value | Type | Description |
  89033. * | ----- | ------------------ | ----------- |
  89034. * | 0 | CLAMP_ADDRESSMODE | |
  89035. * | 1 | WRAP_ADDRESSMODE | |
  89036. * | 2 | MIRROR_ADDRESSMODE | |
  89037. */
  89038. get wrapV(): number;
  89039. set wrapV(value: number);
  89040. /**
  89041. * | Value | Type | Description |
  89042. * | ----- | ------------------ | ----------- |
  89043. * | 0 | CLAMP_ADDRESSMODE | |
  89044. * | 1 | WRAP_ADDRESSMODE | |
  89045. * | 2 | MIRROR_ADDRESSMODE | |
  89046. */
  89047. wrapR: number;
  89048. /**
  89049. * With compliant hardware and browser (supporting anisotropic filtering)
  89050. * this defines the level of anisotropic filtering in the texture.
  89051. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  89052. */
  89053. anisotropicFilteringLevel: number;
  89054. private _isCube;
  89055. /**
  89056. * Define if the texture is a cube texture or if false a 2d texture.
  89057. */
  89058. get isCube(): boolean;
  89059. set isCube(value: boolean);
  89060. /**
  89061. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  89062. */
  89063. get is3D(): boolean;
  89064. set is3D(value: boolean);
  89065. /**
  89066. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  89067. */
  89068. get is2DArray(): boolean;
  89069. set is2DArray(value: boolean);
  89070. private _gammaSpace;
  89071. /**
  89072. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  89073. * HDR texture are usually stored in linear space.
  89074. * This only impacts the PBR and Background materials
  89075. */
  89076. get gammaSpace(): boolean;
  89077. set gammaSpace(gamma: boolean);
  89078. /**
  89079. * Gets or sets whether or not the texture contains RGBD data.
  89080. */
  89081. get isRGBD(): boolean;
  89082. set isRGBD(value: boolean);
  89083. /**
  89084. * Is Z inverted in the texture (useful in a cube texture).
  89085. */
  89086. invertZ: boolean;
  89087. /**
  89088. * Are mip maps generated for this texture or not.
  89089. */
  89090. get noMipmap(): boolean;
  89091. /**
  89092. * @hidden
  89093. */
  89094. lodLevelInAlpha: boolean;
  89095. /**
  89096. * With prefiltered texture, defined the offset used during the prefiltering steps.
  89097. */
  89098. get lodGenerationOffset(): number;
  89099. set lodGenerationOffset(value: number);
  89100. /**
  89101. * With prefiltered texture, defined the scale used during the prefiltering steps.
  89102. */
  89103. get lodGenerationScale(): number;
  89104. set lodGenerationScale(value: number);
  89105. /**
  89106. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  89107. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  89108. * average roughness values.
  89109. */
  89110. get linearSpecularLOD(): boolean;
  89111. set linearSpecularLOD(value: boolean);
  89112. /**
  89113. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  89114. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  89115. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  89116. */
  89117. get irradianceTexture(): Nullable<BaseTexture>;
  89118. set irradianceTexture(value: Nullable<BaseTexture>);
  89119. /**
  89120. * Define if the texture is a render target.
  89121. */
  89122. isRenderTarget: boolean;
  89123. /**
  89124. * Define the unique id of the texture in the scene.
  89125. */
  89126. get uid(): string;
  89127. /** @hidden */
  89128. _prefiltered: boolean;
  89129. /**
  89130. * Return a string representation of the texture.
  89131. * @returns the texture as a string
  89132. */
  89133. toString(): string;
  89134. /**
  89135. * Get the class name of the texture.
  89136. * @returns "BaseTexture"
  89137. */
  89138. getClassName(): string;
  89139. /**
  89140. * Define the list of animation attached to the texture.
  89141. */
  89142. animations: Animation[];
  89143. /**
  89144. * An event triggered when the texture is disposed.
  89145. */
  89146. onDisposeObservable: Observable<BaseTexture>;
  89147. private _onDisposeObserver;
  89148. /**
  89149. * Callback triggered when the texture has been disposed.
  89150. * Kept for back compatibility, you can use the onDisposeObservable instead.
  89151. */
  89152. set onDispose(callback: () => void);
  89153. protected _scene: Nullable<Scene>;
  89154. /** @hidden */
  89155. _texture: Nullable<InternalTexture>;
  89156. private _uid;
  89157. /**
  89158. * Define if the texture is preventinga material to render or not.
  89159. * If not and the texture is not ready, the engine will use a default black texture instead.
  89160. */
  89161. get isBlocking(): boolean;
  89162. /**
  89163. * Instantiates a new BaseTexture.
  89164. * Base class of all the textures in babylon.
  89165. * It groups all the common properties the materials, post process, lights... might need
  89166. * in order to make a correct use of the texture.
  89167. * @param sceneOrEngine Define the scene or engine the texture blongs to
  89168. */
  89169. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  89170. /**
  89171. * Get the scene the texture belongs to.
  89172. * @returns the scene or null if undefined
  89173. */
  89174. getScene(): Nullable<Scene>;
  89175. /** @hidden */
  89176. protected _getEngine(): Nullable<ThinEngine>;
  89177. /**
  89178. * Checks if the texture has the same transform matrix than another texture
  89179. * @param texture texture to check against
  89180. * @returns true if the transforms are the same, else false
  89181. */
  89182. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  89183. /**
  89184. * Get the texture transform matrix used to offset tile the texture for istance.
  89185. * @returns the transformation matrix
  89186. */
  89187. getTextureMatrix(): Matrix;
  89188. /**
  89189. * Get the texture reflection matrix used to rotate/transform the reflection.
  89190. * @returns the reflection matrix
  89191. */
  89192. getReflectionTextureMatrix(): Matrix;
  89193. /**
  89194. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89195. * @returns true if ready or not blocking
  89196. */
  89197. isReadyOrNotBlocking(): boolean;
  89198. /**
  89199. * Scales the texture if is `canRescale()`
  89200. * @param ratio the resize factor we want to use to rescale
  89201. */
  89202. scale(ratio: number): void;
  89203. /**
  89204. * Get if the texture can rescale.
  89205. */
  89206. get canRescale(): boolean;
  89207. /** @hidden */
  89208. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89209. /** @hidden */
  89210. _rebuild(): void;
  89211. /**
  89212. * Clones the texture.
  89213. * @returns the cloned texture
  89214. */
  89215. clone(): Nullable<BaseTexture>;
  89216. /**
  89217. * Get the texture underlying type (INT, FLOAT...)
  89218. */
  89219. get textureType(): number;
  89220. /**
  89221. * Get the texture underlying format (RGB, RGBA...)
  89222. */
  89223. get textureFormat(): number;
  89224. /**
  89225. * Indicates that textures need to be re-calculated for all materials
  89226. */
  89227. protected _markAllSubMeshesAsTexturesDirty(): void;
  89228. /**
  89229. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89230. * This will returns an RGBA array buffer containing either in values (0-255) or
  89231. * float values (0-1) depending of the underlying buffer type.
  89232. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89233. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89234. * @param buffer defines a user defined buffer to fill with data (can be null)
  89235. * @returns The Array buffer containing the pixels data.
  89236. */
  89237. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89238. /** @hidden */
  89239. get _lodTextureHigh(): Nullable<BaseTexture>;
  89240. /** @hidden */
  89241. get _lodTextureMid(): Nullable<BaseTexture>;
  89242. /** @hidden */
  89243. get _lodTextureLow(): Nullable<BaseTexture>;
  89244. /**
  89245. * Dispose the texture and release its associated resources.
  89246. */
  89247. dispose(): void;
  89248. /**
  89249. * Serialize the texture into a JSON representation that can be parsed later on.
  89250. * @returns the JSON representation of the texture
  89251. */
  89252. serialize(): any;
  89253. /**
  89254. * Helper function to be called back once a list of texture contains only ready textures.
  89255. * @param textures Define the list of textures to wait for
  89256. * @param callback Define the callback triggered once the entire list will be ready
  89257. */
  89258. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89259. private static _isScene;
  89260. }
  89261. }
  89262. declare module BABYLON {
  89263. /** @hidden */
  89264. export class WebGLDataBuffer extends DataBuffer {
  89265. private _buffer;
  89266. constructor(resource: WebGLBuffer);
  89267. get underlyingResource(): any;
  89268. }
  89269. }
  89270. declare module BABYLON {
  89271. /** @hidden */
  89272. export class WebGLPipelineContext implements IPipelineContext {
  89273. engine: ThinEngine;
  89274. program: Nullable<WebGLProgram>;
  89275. context?: WebGLRenderingContext;
  89276. vertexShader?: WebGLShader;
  89277. fragmentShader?: WebGLShader;
  89278. isParallelCompiled: boolean;
  89279. onCompiled?: () => void;
  89280. transformFeedback?: WebGLTransformFeedback | null;
  89281. vertexCompilationError: Nullable<string>;
  89282. fragmentCompilationError: Nullable<string>;
  89283. programLinkError: Nullable<string>;
  89284. programValidationError: Nullable<string>;
  89285. get isAsync(): boolean;
  89286. get isReady(): boolean;
  89287. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89288. _getVertexShaderCode(): string | null;
  89289. _getFragmentShaderCode(): string | null;
  89290. }
  89291. }
  89292. declare module BABYLON {
  89293. interface ThinEngine {
  89294. /**
  89295. * Create an uniform buffer
  89296. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89297. * @param elements defines the content of the uniform buffer
  89298. * @returns the webGL uniform buffer
  89299. */
  89300. createUniformBuffer(elements: FloatArray): DataBuffer;
  89301. /**
  89302. * Create a dynamic uniform buffer
  89303. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89304. * @param elements defines the content of the uniform buffer
  89305. * @returns the webGL uniform buffer
  89306. */
  89307. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  89308. /**
  89309. * Update an existing uniform buffer
  89310. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89311. * @param uniformBuffer defines the target uniform buffer
  89312. * @param elements defines the content to update
  89313. * @param offset defines the offset in the uniform buffer where update should start
  89314. * @param count defines the size of the data to update
  89315. */
  89316. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  89317. /**
  89318. * Bind an uniform buffer to the current webGL context
  89319. * @param buffer defines the buffer to bind
  89320. */
  89321. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  89322. /**
  89323. * Bind a buffer to the current webGL context at a given location
  89324. * @param buffer defines the buffer to bind
  89325. * @param location defines the index where to bind the buffer
  89326. */
  89327. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  89328. /**
  89329. * Bind a specific block at a given index in a specific shader program
  89330. * @param pipelineContext defines the pipeline context to use
  89331. * @param blockName defines the block name
  89332. * @param index defines the index where to bind the block
  89333. */
  89334. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  89335. }
  89336. }
  89337. declare module BABYLON {
  89338. /**
  89339. * Uniform buffer objects.
  89340. *
  89341. * Handles blocks of uniform on the GPU.
  89342. *
  89343. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89344. *
  89345. * For more information, please refer to :
  89346. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89347. */
  89348. export class UniformBuffer {
  89349. private _engine;
  89350. private _buffer;
  89351. private _data;
  89352. private _bufferData;
  89353. private _dynamic?;
  89354. private _uniformLocations;
  89355. private _uniformSizes;
  89356. private _uniformLocationPointer;
  89357. private _needSync;
  89358. private _noUBO;
  89359. private _currentEffect;
  89360. /** @hidden */
  89361. _alreadyBound: boolean;
  89362. private static _MAX_UNIFORM_SIZE;
  89363. private static _tempBuffer;
  89364. /**
  89365. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89366. * This is dynamic to allow compat with webgl 1 and 2.
  89367. * You will need to pass the name of the uniform as well as the value.
  89368. */
  89369. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89370. /**
  89371. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89372. * This is dynamic to allow compat with webgl 1 and 2.
  89373. * You will need to pass the name of the uniform as well as the value.
  89374. */
  89375. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89376. /**
  89377. * Lambda to Update a single float in a uniform buffer.
  89378. * This is dynamic to allow compat with webgl 1 and 2.
  89379. * You will need to pass the name of the uniform as well as the value.
  89380. */
  89381. updateFloat: (name: string, x: number) => void;
  89382. /**
  89383. * Lambda to Update a vec2 of float in a uniform buffer.
  89384. * This is dynamic to allow compat with webgl 1 and 2.
  89385. * You will need to pass the name of the uniform as well as the value.
  89386. */
  89387. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89388. /**
  89389. * Lambda to Update a vec3 of float in a uniform buffer.
  89390. * This is dynamic to allow compat with webgl 1 and 2.
  89391. * You will need to pass the name of the uniform as well as the value.
  89392. */
  89393. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89394. /**
  89395. * Lambda to Update a vec4 of float in a uniform buffer.
  89396. * This is dynamic to allow compat with webgl 1 and 2.
  89397. * You will need to pass the name of the uniform as well as the value.
  89398. */
  89399. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89400. /**
  89401. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89402. * This is dynamic to allow compat with webgl 1 and 2.
  89403. * You will need to pass the name of the uniform as well as the value.
  89404. */
  89405. updateMatrix: (name: string, mat: Matrix) => void;
  89406. /**
  89407. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89408. * This is dynamic to allow compat with webgl 1 and 2.
  89409. * You will need to pass the name of the uniform as well as the value.
  89410. */
  89411. updateVector3: (name: string, vector: Vector3) => void;
  89412. /**
  89413. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89414. * This is dynamic to allow compat with webgl 1 and 2.
  89415. * You will need to pass the name of the uniform as well as the value.
  89416. */
  89417. updateVector4: (name: string, vector: Vector4) => void;
  89418. /**
  89419. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89420. * This is dynamic to allow compat with webgl 1 and 2.
  89421. * You will need to pass the name of the uniform as well as the value.
  89422. */
  89423. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89424. /**
  89425. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89426. * This is dynamic to allow compat with webgl 1 and 2.
  89427. * You will need to pass the name of the uniform as well as the value.
  89428. */
  89429. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89430. /**
  89431. * Instantiates a new Uniform buffer objects.
  89432. *
  89433. * Handles blocks of uniform on the GPU.
  89434. *
  89435. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89436. *
  89437. * For more information, please refer to :
  89438. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89439. * @param engine Define the engine the buffer is associated with
  89440. * @param data Define the data contained in the buffer
  89441. * @param dynamic Define if the buffer is updatable
  89442. */
  89443. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89444. /**
  89445. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89446. * or just falling back on setUniformXXX calls.
  89447. */
  89448. get useUbo(): boolean;
  89449. /**
  89450. * Indicates if the WebGL underlying uniform buffer is in sync
  89451. * with the javascript cache data.
  89452. */
  89453. get isSync(): boolean;
  89454. /**
  89455. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89456. * Also, a dynamic UniformBuffer will disable cache verification and always
  89457. * update the underlying WebGL uniform buffer to the GPU.
  89458. * @returns if Dynamic, otherwise false
  89459. */
  89460. isDynamic(): boolean;
  89461. /**
  89462. * The data cache on JS side.
  89463. * @returns the underlying data as a float array
  89464. */
  89465. getData(): Float32Array;
  89466. /**
  89467. * The underlying WebGL Uniform buffer.
  89468. * @returns the webgl buffer
  89469. */
  89470. getBuffer(): Nullable<DataBuffer>;
  89471. /**
  89472. * std140 layout specifies how to align data within an UBO structure.
  89473. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89474. * for specs.
  89475. */
  89476. private _fillAlignment;
  89477. /**
  89478. * Adds an uniform in the buffer.
  89479. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89480. * for the layout to be correct !
  89481. * @param name Name of the uniform, as used in the uniform block in the shader.
  89482. * @param size Data size, or data directly.
  89483. */
  89484. addUniform(name: string, size: number | number[]): void;
  89485. /**
  89486. * Adds a Matrix 4x4 to the uniform buffer.
  89487. * @param name Name of the uniform, as used in the uniform block in the shader.
  89488. * @param mat A 4x4 matrix.
  89489. */
  89490. addMatrix(name: string, mat: Matrix): void;
  89491. /**
  89492. * Adds a vec2 to the uniform buffer.
  89493. * @param name Name of the uniform, as used in the uniform block in the shader.
  89494. * @param x Define the x component value of the vec2
  89495. * @param y Define the y component value of the vec2
  89496. */
  89497. addFloat2(name: string, x: number, y: number): void;
  89498. /**
  89499. * Adds a vec3 to the uniform buffer.
  89500. * @param name Name of the uniform, as used in the uniform block in the shader.
  89501. * @param x Define the x component value of the vec3
  89502. * @param y Define the y component value of the vec3
  89503. * @param z Define the z component value of the vec3
  89504. */
  89505. addFloat3(name: string, x: number, y: number, z: number): void;
  89506. /**
  89507. * Adds a vec3 to the uniform buffer.
  89508. * @param name Name of the uniform, as used in the uniform block in the shader.
  89509. * @param color Define the vec3 from a Color
  89510. */
  89511. addColor3(name: string, color: Color3): void;
  89512. /**
  89513. * Adds a vec4 to the uniform buffer.
  89514. * @param name Name of the uniform, as used in the uniform block in the shader.
  89515. * @param color Define the rgb components from a Color
  89516. * @param alpha Define the a component of the vec4
  89517. */
  89518. addColor4(name: string, color: Color3, alpha: number): void;
  89519. /**
  89520. * Adds a vec3 to the uniform buffer.
  89521. * @param name Name of the uniform, as used in the uniform block in the shader.
  89522. * @param vector Define the vec3 components from a Vector
  89523. */
  89524. addVector3(name: string, vector: Vector3): void;
  89525. /**
  89526. * Adds a Matrix 3x3 to the uniform buffer.
  89527. * @param name Name of the uniform, as used in the uniform block in the shader.
  89528. */
  89529. addMatrix3x3(name: string): void;
  89530. /**
  89531. * Adds a Matrix 2x2 to the uniform buffer.
  89532. * @param name Name of the uniform, as used in the uniform block in the shader.
  89533. */
  89534. addMatrix2x2(name: string): void;
  89535. /**
  89536. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89537. */
  89538. create(): void;
  89539. /** @hidden */
  89540. _rebuild(): void;
  89541. /**
  89542. * Updates the WebGL Uniform Buffer on the GPU.
  89543. * If the `dynamic` flag is set to true, no cache comparison is done.
  89544. * Otherwise, the buffer will be updated only if the cache differs.
  89545. */
  89546. update(): void;
  89547. /**
  89548. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89549. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89550. * @param data Define the flattened data
  89551. * @param size Define the size of the data.
  89552. */
  89553. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89554. private _valueCache;
  89555. private _cacheMatrix;
  89556. private _updateMatrix3x3ForUniform;
  89557. private _updateMatrix3x3ForEffect;
  89558. private _updateMatrix2x2ForEffect;
  89559. private _updateMatrix2x2ForUniform;
  89560. private _updateFloatForEffect;
  89561. private _updateFloatForUniform;
  89562. private _updateFloat2ForEffect;
  89563. private _updateFloat2ForUniform;
  89564. private _updateFloat3ForEffect;
  89565. private _updateFloat3ForUniform;
  89566. private _updateFloat4ForEffect;
  89567. private _updateFloat4ForUniform;
  89568. private _updateMatrixForEffect;
  89569. private _updateMatrixForUniform;
  89570. private _updateVector3ForEffect;
  89571. private _updateVector3ForUniform;
  89572. private _updateVector4ForEffect;
  89573. private _updateVector4ForUniform;
  89574. private _updateColor3ForEffect;
  89575. private _updateColor3ForUniform;
  89576. private _updateColor4ForEffect;
  89577. private _updateColor4ForUniform;
  89578. /**
  89579. * Sets a sampler uniform on the effect.
  89580. * @param name Define the name of the sampler.
  89581. * @param texture Define the texture to set in the sampler
  89582. */
  89583. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89584. /**
  89585. * Directly updates the value of the uniform in the cache AND on the GPU.
  89586. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89587. * @param data Define the flattened data
  89588. */
  89589. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89590. /**
  89591. * Binds this uniform buffer to an effect.
  89592. * @param effect Define the effect to bind the buffer to
  89593. * @param name Name of the uniform block in the shader.
  89594. */
  89595. bindToEffect(effect: Effect, name: string): void;
  89596. /**
  89597. * Disposes the uniform buffer.
  89598. */
  89599. dispose(): void;
  89600. }
  89601. }
  89602. declare module BABYLON {
  89603. /**
  89604. * Manages the defines for the Material
  89605. */
  89606. export class MaterialDefines {
  89607. /** @hidden */
  89608. protected _keys: string[];
  89609. private _isDirty;
  89610. /** @hidden */
  89611. _renderId: number;
  89612. /** @hidden */
  89613. _areLightsDirty: boolean;
  89614. /** @hidden */
  89615. _areLightsDisposed: boolean;
  89616. /** @hidden */
  89617. _areAttributesDirty: boolean;
  89618. /** @hidden */
  89619. _areTexturesDirty: boolean;
  89620. /** @hidden */
  89621. _areFresnelDirty: boolean;
  89622. /** @hidden */
  89623. _areMiscDirty: boolean;
  89624. /** @hidden */
  89625. _arePrePassDirty: boolean;
  89626. /** @hidden */
  89627. _areImageProcessingDirty: boolean;
  89628. /** @hidden */
  89629. _normals: boolean;
  89630. /** @hidden */
  89631. _uvs: boolean;
  89632. /** @hidden */
  89633. _needNormals: boolean;
  89634. /** @hidden */
  89635. _needUVs: boolean;
  89636. [id: string]: any;
  89637. /**
  89638. * Specifies if the material needs to be re-calculated
  89639. */
  89640. get isDirty(): boolean;
  89641. /**
  89642. * Marks the material to indicate that it has been re-calculated
  89643. */
  89644. markAsProcessed(): void;
  89645. /**
  89646. * Marks the material to indicate that it needs to be re-calculated
  89647. */
  89648. markAsUnprocessed(): void;
  89649. /**
  89650. * Marks the material to indicate all of its defines need to be re-calculated
  89651. */
  89652. markAllAsDirty(): void;
  89653. /**
  89654. * Marks the material to indicate that image processing needs to be re-calculated
  89655. */
  89656. markAsImageProcessingDirty(): void;
  89657. /**
  89658. * Marks the material to indicate the lights need to be re-calculated
  89659. * @param disposed Defines whether the light is dirty due to dispose or not
  89660. */
  89661. markAsLightDirty(disposed?: boolean): void;
  89662. /**
  89663. * Marks the attribute state as changed
  89664. */
  89665. markAsAttributesDirty(): void;
  89666. /**
  89667. * Marks the texture state as changed
  89668. */
  89669. markAsTexturesDirty(): void;
  89670. /**
  89671. * Marks the fresnel state as changed
  89672. */
  89673. markAsFresnelDirty(): void;
  89674. /**
  89675. * Marks the misc state as changed
  89676. */
  89677. markAsMiscDirty(): void;
  89678. /**
  89679. * Marks the prepass state as changed
  89680. */
  89681. markAsPrePassDirty(): void;
  89682. /**
  89683. * Rebuilds the material defines
  89684. */
  89685. rebuild(): void;
  89686. /**
  89687. * Specifies if two material defines are equal
  89688. * @param other - A material define instance to compare to
  89689. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  89690. */
  89691. isEqual(other: MaterialDefines): boolean;
  89692. /**
  89693. * Clones this instance's defines to another instance
  89694. * @param other - material defines to clone values to
  89695. */
  89696. cloneTo(other: MaterialDefines): void;
  89697. /**
  89698. * Resets the material define values
  89699. */
  89700. reset(): void;
  89701. /**
  89702. * Converts the material define values to a string
  89703. * @returns - String of material define information
  89704. */
  89705. toString(): string;
  89706. }
  89707. }
  89708. declare module BABYLON {
  89709. /**
  89710. * Enum that determines the text-wrapping mode to use.
  89711. */
  89712. export enum InspectableType {
  89713. /**
  89714. * Checkbox for booleans
  89715. */
  89716. Checkbox = 0,
  89717. /**
  89718. * Sliders for numbers
  89719. */
  89720. Slider = 1,
  89721. /**
  89722. * Vector3
  89723. */
  89724. Vector3 = 2,
  89725. /**
  89726. * Quaternions
  89727. */
  89728. Quaternion = 3,
  89729. /**
  89730. * Color3
  89731. */
  89732. Color3 = 4,
  89733. /**
  89734. * String
  89735. */
  89736. String = 5
  89737. }
  89738. /**
  89739. * Interface used to define custom inspectable properties.
  89740. * This interface is used by the inspector to display custom property grids
  89741. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89742. */
  89743. export interface IInspectable {
  89744. /**
  89745. * Gets the label to display
  89746. */
  89747. label: string;
  89748. /**
  89749. * Gets the name of the property to edit
  89750. */
  89751. propertyName: string;
  89752. /**
  89753. * Gets the type of the editor to use
  89754. */
  89755. type: InspectableType;
  89756. /**
  89757. * Gets the minimum value of the property when using in "slider" mode
  89758. */
  89759. min?: number;
  89760. /**
  89761. * Gets the maximum value of the property when using in "slider" mode
  89762. */
  89763. max?: number;
  89764. /**
  89765. * Gets the setp to use when using in "slider" mode
  89766. */
  89767. step?: number;
  89768. }
  89769. }
  89770. declare module BABYLON {
  89771. /**
  89772. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89773. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89774. * 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.
  89775. */
  89776. export abstract class Light extends Node {
  89777. /**
  89778. * Falloff Default: light is falling off following the material specification:
  89779. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89780. */
  89781. static readonly FALLOFF_DEFAULT: number;
  89782. /**
  89783. * Falloff Physical: light is falling off following the inverse squared distance law.
  89784. */
  89785. static readonly FALLOFF_PHYSICAL: number;
  89786. /**
  89787. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89788. * to enhance interoperability with other engines.
  89789. */
  89790. static readonly FALLOFF_GLTF: number;
  89791. /**
  89792. * Falloff Standard: light is falling off like in the standard material
  89793. * to enhance interoperability with other materials.
  89794. */
  89795. static readonly FALLOFF_STANDARD: number;
  89796. /**
  89797. * If every light affecting the material is in this lightmapMode,
  89798. * material.lightmapTexture adds or multiplies
  89799. * (depends on material.useLightmapAsShadowmap)
  89800. * after every other light calculations.
  89801. */
  89802. static readonly LIGHTMAP_DEFAULT: number;
  89803. /**
  89804. * material.lightmapTexture as only diffuse lighting from this light
  89805. * adds only specular lighting from this light
  89806. * adds dynamic shadows
  89807. */
  89808. static readonly LIGHTMAP_SPECULAR: number;
  89809. /**
  89810. * material.lightmapTexture as only lighting
  89811. * no light calculation from this light
  89812. * only adds dynamic shadows from this light
  89813. */
  89814. static readonly LIGHTMAP_SHADOWSONLY: number;
  89815. /**
  89816. * Each light type uses the default quantity according to its type:
  89817. * point/spot lights use luminous intensity
  89818. * directional lights use illuminance
  89819. */
  89820. static readonly INTENSITYMODE_AUTOMATIC: number;
  89821. /**
  89822. * lumen (lm)
  89823. */
  89824. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  89825. /**
  89826. * candela (lm/sr)
  89827. */
  89828. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  89829. /**
  89830. * lux (lm/m^2)
  89831. */
  89832. static readonly INTENSITYMODE_ILLUMINANCE: number;
  89833. /**
  89834. * nit (cd/m^2)
  89835. */
  89836. static readonly INTENSITYMODE_LUMINANCE: number;
  89837. /**
  89838. * Light type const id of the point light.
  89839. */
  89840. static readonly LIGHTTYPEID_POINTLIGHT: number;
  89841. /**
  89842. * Light type const id of the directional light.
  89843. */
  89844. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  89845. /**
  89846. * Light type const id of the spot light.
  89847. */
  89848. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  89849. /**
  89850. * Light type const id of the hemispheric light.
  89851. */
  89852. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  89853. /**
  89854. * Diffuse gives the basic color to an object.
  89855. */
  89856. diffuse: Color3;
  89857. /**
  89858. * Specular produces a highlight color on an object.
  89859. * Note: This is note affecting PBR materials.
  89860. */
  89861. specular: Color3;
  89862. /**
  89863. * Defines the falloff type for this light. This lets overrriding how punctual light are
  89864. * falling off base on range or angle.
  89865. * This can be set to any values in Light.FALLOFF_x.
  89866. *
  89867. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  89868. * other types of materials.
  89869. */
  89870. falloffType: number;
  89871. /**
  89872. * Strength of the light.
  89873. * Note: By default it is define in the framework own unit.
  89874. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  89875. */
  89876. intensity: number;
  89877. private _range;
  89878. protected _inverseSquaredRange: number;
  89879. /**
  89880. * Defines how far from the source the light is impacting in scene units.
  89881. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89882. */
  89883. get range(): number;
  89884. /**
  89885. * Defines how far from the source the light is impacting in scene units.
  89886. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89887. */
  89888. set range(value: number);
  89889. /**
  89890. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  89891. * of light.
  89892. */
  89893. private _photometricScale;
  89894. private _intensityMode;
  89895. /**
  89896. * Gets the photometric scale used to interpret the intensity.
  89897. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  89898. */
  89899. get intensityMode(): number;
  89900. /**
  89901. * Sets the photometric scale used to interpret the intensity.
  89902. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  89903. */
  89904. set intensityMode(value: number);
  89905. private _radius;
  89906. /**
  89907. * Gets the light radius used by PBR Materials to simulate soft area lights.
  89908. */
  89909. get radius(): number;
  89910. /**
  89911. * sets the light radius used by PBR Materials to simulate soft area lights.
  89912. */
  89913. set radius(value: number);
  89914. private _renderPriority;
  89915. /**
  89916. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  89917. * exceeding the number allowed of the materials.
  89918. */
  89919. renderPriority: number;
  89920. private _shadowEnabled;
  89921. /**
  89922. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  89923. * the current shadow generator.
  89924. */
  89925. get shadowEnabled(): boolean;
  89926. /**
  89927. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  89928. * the current shadow generator.
  89929. */
  89930. set shadowEnabled(value: boolean);
  89931. private _includedOnlyMeshes;
  89932. /**
  89933. * Gets the only meshes impacted by this light.
  89934. */
  89935. get includedOnlyMeshes(): AbstractMesh[];
  89936. /**
  89937. * Sets the only meshes impacted by this light.
  89938. */
  89939. set includedOnlyMeshes(value: AbstractMesh[]);
  89940. private _excludedMeshes;
  89941. /**
  89942. * Gets the meshes not impacted by this light.
  89943. */
  89944. get excludedMeshes(): AbstractMesh[];
  89945. /**
  89946. * Sets the meshes not impacted by this light.
  89947. */
  89948. set excludedMeshes(value: AbstractMesh[]);
  89949. private _excludeWithLayerMask;
  89950. /**
  89951. * Gets the layer id use to find what meshes are not impacted by the light.
  89952. * Inactive if 0
  89953. */
  89954. get excludeWithLayerMask(): number;
  89955. /**
  89956. * Sets the layer id use to find what meshes are not impacted by the light.
  89957. * Inactive if 0
  89958. */
  89959. set excludeWithLayerMask(value: number);
  89960. private _includeOnlyWithLayerMask;
  89961. /**
  89962. * Gets the layer id use to find what meshes are impacted by the light.
  89963. * Inactive if 0
  89964. */
  89965. get includeOnlyWithLayerMask(): number;
  89966. /**
  89967. * Sets the layer id use to find what meshes are impacted by the light.
  89968. * Inactive if 0
  89969. */
  89970. set includeOnlyWithLayerMask(value: number);
  89971. private _lightmapMode;
  89972. /**
  89973. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  89974. */
  89975. get lightmapMode(): number;
  89976. /**
  89977. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  89978. */
  89979. set lightmapMode(value: number);
  89980. /**
  89981. * Shadow generator associted to the light.
  89982. * @hidden Internal use only.
  89983. */
  89984. _shadowGenerator: Nullable<IShadowGenerator>;
  89985. /**
  89986. * @hidden Internal use only.
  89987. */
  89988. _excludedMeshesIds: string[];
  89989. /**
  89990. * @hidden Internal use only.
  89991. */
  89992. _includedOnlyMeshesIds: string[];
  89993. /**
  89994. * The current light unifom buffer.
  89995. * @hidden Internal use only.
  89996. */
  89997. _uniformBuffer: UniformBuffer;
  89998. /** @hidden */
  89999. _renderId: number;
  90000. /**
  90001. * Creates a Light object in the scene.
  90002. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90003. * @param name The firendly name of the light
  90004. * @param scene The scene the light belongs too
  90005. */
  90006. constructor(name: string, scene: Scene);
  90007. protected abstract _buildUniformLayout(): void;
  90008. /**
  90009. * Sets the passed Effect "effect" with the Light information.
  90010. * @param effect The effect to update
  90011. * @param lightIndex The index of the light in the effect to update
  90012. * @returns The light
  90013. */
  90014. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90015. /**
  90016. * Sets the passed Effect "effect" with the Light textures.
  90017. * @param effect The effect to update
  90018. * @param lightIndex The index of the light in the effect to update
  90019. * @returns The light
  90020. */
  90021. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90022. /**
  90023. * Binds the lights information from the scene to the effect for the given mesh.
  90024. * @param lightIndex Light index
  90025. * @param scene The scene where the light belongs to
  90026. * @param effect The effect we are binding the data to
  90027. * @param useSpecular Defines if specular is supported
  90028. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90029. */
  90030. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90031. /**
  90032. * Sets the passed Effect "effect" with the Light information.
  90033. * @param effect The effect to update
  90034. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90035. * @returns The light
  90036. */
  90037. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90038. /**
  90039. * Returns the string "Light".
  90040. * @returns the class name
  90041. */
  90042. getClassName(): string;
  90043. /** @hidden */
  90044. readonly _isLight: boolean;
  90045. /**
  90046. * Converts the light information to a readable string for debug purpose.
  90047. * @param fullDetails Supports for multiple levels of logging within scene loading
  90048. * @returns the human readable light info
  90049. */
  90050. toString(fullDetails?: boolean): string;
  90051. /** @hidden */
  90052. protected _syncParentEnabledState(): void;
  90053. /**
  90054. * Set the enabled state of this node.
  90055. * @param value - the new enabled state
  90056. */
  90057. setEnabled(value: boolean): void;
  90058. /**
  90059. * Returns the Light associated shadow generator if any.
  90060. * @return the associated shadow generator.
  90061. */
  90062. getShadowGenerator(): Nullable<IShadowGenerator>;
  90063. /**
  90064. * Returns a Vector3, the absolute light position in the World.
  90065. * @returns the world space position of the light
  90066. */
  90067. getAbsolutePosition(): Vector3;
  90068. /**
  90069. * Specifies if the light will affect the passed mesh.
  90070. * @param mesh The mesh to test against the light
  90071. * @return true the mesh is affected otherwise, false.
  90072. */
  90073. canAffectMesh(mesh: AbstractMesh): boolean;
  90074. /**
  90075. * Sort function to order lights for rendering.
  90076. * @param a First Light object to compare to second.
  90077. * @param b Second Light object to compare first.
  90078. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90079. */
  90080. static CompareLightsPriority(a: Light, b: Light): number;
  90081. /**
  90082. * Releases resources associated with this node.
  90083. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90084. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90085. */
  90086. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90087. /**
  90088. * Returns the light type ID (integer).
  90089. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90090. */
  90091. getTypeID(): number;
  90092. /**
  90093. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90094. * @returns the scaled intensity in intensity mode unit
  90095. */
  90096. getScaledIntensity(): number;
  90097. /**
  90098. * Returns a new Light object, named "name", from the current one.
  90099. * @param name The name of the cloned light
  90100. * @param newParent The parent of this light, if it has one
  90101. * @returns the new created light
  90102. */
  90103. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  90104. /**
  90105. * Serializes the current light into a Serialization object.
  90106. * @returns the serialized object.
  90107. */
  90108. serialize(): any;
  90109. /**
  90110. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90111. * This new light is named "name" and added to the passed scene.
  90112. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90113. * @param name The friendly name of the light
  90114. * @param scene The scene the new light will belong to
  90115. * @returns the constructor function
  90116. */
  90117. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90118. /**
  90119. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90120. * @param parsedLight The JSON representation of the light
  90121. * @param scene The scene to create the parsed light in
  90122. * @returns the created light after parsing
  90123. */
  90124. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90125. private _hookArrayForExcluded;
  90126. private _hookArrayForIncludedOnly;
  90127. private _resyncMeshes;
  90128. /**
  90129. * Forces the meshes to update their light related information in their rendering used effects
  90130. * @hidden Internal Use Only
  90131. */
  90132. _markMeshesAsLightDirty(): void;
  90133. /**
  90134. * Recomputes the cached photometric scale if needed.
  90135. */
  90136. private _computePhotometricScale;
  90137. /**
  90138. * Returns the Photometric Scale according to the light type and intensity mode.
  90139. */
  90140. private _getPhotometricScale;
  90141. /**
  90142. * Reorder the light in the scene according to their defined priority.
  90143. * @hidden Internal Use Only
  90144. */
  90145. _reorderLightsInScene(): void;
  90146. /**
  90147. * Prepares the list of defines specific to the light type.
  90148. * @param defines the list of defines
  90149. * @param lightIndex defines the index of the light for the effect
  90150. */
  90151. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90152. }
  90153. }
  90154. declare module BABYLON {
  90155. /** Defines supported spaces */
  90156. export enum Space {
  90157. /** Local (object) space */
  90158. LOCAL = 0,
  90159. /** World space */
  90160. WORLD = 1,
  90161. /** Bone space */
  90162. BONE = 2
  90163. }
  90164. /** Defines the 3 main axes */
  90165. export class Axis {
  90166. /** X axis */
  90167. static X: Vector3;
  90168. /** Y axis */
  90169. static Y: Vector3;
  90170. /** Z axis */
  90171. static Z: Vector3;
  90172. }
  90173. /**
  90174. * Defines cartesian components.
  90175. */
  90176. export enum Coordinate {
  90177. /** X axis */
  90178. X = 0,
  90179. /** Y axis */
  90180. Y = 1,
  90181. /** Z axis */
  90182. Z = 2
  90183. }
  90184. }
  90185. declare module BABYLON {
  90186. /**
  90187. * Interface describing all the common properties and methods a shadow light needs to implement.
  90188. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  90189. * as well as binding the different shadow properties to the effects.
  90190. */
  90191. export interface IShadowLight extends Light {
  90192. /**
  90193. * The light id in the scene (used in scene.findLighById for instance)
  90194. */
  90195. id: string;
  90196. /**
  90197. * The position the shdow will be casted from.
  90198. */
  90199. position: Vector3;
  90200. /**
  90201. * In 2d mode (needCube being false), the direction used to cast the shadow.
  90202. */
  90203. direction: Vector3;
  90204. /**
  90205. * The transformed position. Position of the light in world space taking parenting in account.
  90206. */
  90207. transformedPosition: Vector3;
  90208. /**
  90209. * The transformed direction. Direction of the light in world space taking parenting in account.
  90210. */
  90211. transformedDirection: Vector3;
  90212. /**
  90213. * The friendly name of the light in the scene.
  90214. */
  90215. name: string;
  90216. /**
  90217. * Defines the shadow projection clipping minimum z value.
  90218. */
  90219. shadowMinZ: number;
  90220. /**
  90221. * Defines the shadow projection clipping maximum z value.
  90222. */
  90223. shadowMaxZ: number;
  90224. /**
  90225. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90226. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90227. */
  90228. computeTransformedInformation(): boolean;
  90229. /**
  90230. * Gets the scene the light belongs to.
  90231. * @returns The scene
  90232. */
  90233. getScene(): Scene;
  90234. /**
  90235. * Callback defining a custom Projection Matrix Builder.
  90236. * This can be used to override the default projection matrix computation.
  90237. */
  90238. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90239. /**
  90240. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90241. * @param matrix The materix to updated with the projection information
  90242. * @param viewMatrix The transform matrix of the light
  90243. * @param renderList The list of mesh to render in the map
  90244. * @returns The current light
  90245. */
  90246. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90247. /**
  90248. * Gets the current depth scale used in ESM.
  90249. * @returns The scale
  90250. */
  90251. getDepthScale(): number;
  90252. /**
  90253. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90254. * @returns true if a cube texture needs to be use
  90255. */
  90256. needCube(): boolean;
  90257. /**
  90258. * Detects if the projection matrix requires to be recomputed this frame.
  90259. * @returns true if it requires to be recomputed otherwise, false.
  90260. */
  90261. needProjectionMatrixCompute(): boolean;
  90262. /**
  90263. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90264. */
  90265. forceProjectionMatrixCompute(): void;
  90266. /**
  90267. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90268. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90269. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90270. */
  90271. getShadowDirection(faceIndex?: number): Vector3;
  90272. /**
  90273. * Gets the minZ used for shadow according to both the scene and the light.
  90274. * @param activeCamera The camera we are returning the min for
  90275. * @returns the depth min z
  90276. */
  90277. getDepthMinZ(activeCamera: Camera): number;
  90278. /**
  90279. * Gets the maxZ used for shadow according to both the scene and the light.
  90280. * @param activeCamera The camera we are returning the max for
  90281. * @returns the depth max z
  90282. */
  90283. getDepthMaxZ(activeCamera: Camera): number;
  90284. }
  90285. /**
  90286. * Base implementation IShadowLight
  90287. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  90288. */
  90289. export abstract class ShadowLight extends Light implements IShadowLight {
  90290. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  90291. protected _position: Vector3;
  90292. protected _setPosition(value: Vector3): void;
  90293. /**
  90294. * Sets the position the shadow will be casted from. Also use as the light position for both
  90295. * point and spot lights.
  90296. */
  90297. get position(): Vector3;
  90298. /**
  90299. * Sets the position the shadow will be casted from. Also use as the light position for both
  90300. * point and spot lights.
  90301. */
  90302. set position(value: Vector3);
  90303. protected _direction: Vector3;
  90304. protected _setDirection(value: Vector3): void;
  90305. /**
  90306. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  90307. * Also use as the light direction on spot and directional lights.
  90308. */
  90309. get direction(): Vector3;
  90310. /**
  90311. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  90312. * Also use as the light direction on spot and directional lights.
  90313. */
  90314. set direction(value: Vector3);
  90315. protected _shadowMinZ: number;
  90316. /**
  90317. * Gets the shadow projection clipping minimum z value.
  90318. */
  90319. get shadowMinZ(): number;
  90320. /**
  90321. * Sets the shadow projection clipping minimum z value.
  90322. */
  90323. set shadowMinZ(value: number);
  90324. protected _shadowMaxZ: number;
  90325. /**
  90326. * Sets the shadow projection clipping maximum z value.
  90327. */
  90328. get shadowMaxZ(): number;
  90329. /**
  90330. * Gets the shadow projection clipping maximum z value.
  90331. */
  90332. set shadowMaxZ(value: number);
  90333. /**
  90334. * Callback defining a custom Projection Matrix Builder.
  90335. * This can be used to override the default projection matrix computation.
  90336. */
  90337. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90338. /**
  90339. * The transformed position. Position of the light in world space taking parenting in account.
  90340. */
  90341. transformedPosition: Vector3;
  90342. /**
  90343. * The transformed direction. Direction of the light in world space taking parenting in account.
  90344. */
  90345. transformedDirection: Vector3;
  90346. private _needProjectionMatrixCompute;
  90347. /**
  90348. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90349. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90350. */
  90351. computeTransformedInformation(): boolean;
  90352. /**
  90353. * Return the depth scale used for the shadow map.
  90354. * @returns the depth scale.
  90355. */
  90356. getDepthScale(): number;
  90357. /**
  90358. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90359. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90360. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90361. */
  90362. getShadowDirection(faceIndex?: number): Vector3;
  90363. /**
  90364. * Returns the ShadowLight absolute position in the World.
  90365. * @returns the position vector in world space
  90366. */
  90367. getAbsolutePosition(): Vector3;
  90368. /**
  90369. * Sets the ShadowLight direction toward the passed target.
  90370. * @param target The point to target in local space
  90371. * @returns the updated ShadowLight direction
  90372. */
  90373. setDirectionToTarget(target: Vector3): Vector3;
  90374. /**
  90375. * Returns the light rotation in euler definition.
  90376. * @returns the x y z rotation in local space.
  90377. */
  90378. getRotation(): Vector3;
  90379. /**
  90380. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90381. * @returns true if a cube texture needs to be use
  90382. */
  90383. needCube(): boolean;
  90384. /**
  90385. * Detects if the projection matrix requires to be recomputed this frame.
  90386. * @returns true if it requires to be recomputed otherwise, false.
  90387. */
  90388. needProjectionMatrixCompute(): boolean;
  90389. /**
  90390. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90391. */
  90392. forceProjectionMatrixCompute(): void;
  90393. /** @hidden */
  90394. _initCache(): void;
  90395. /** @hidden */
  90396. _isSynchronized(): boolean;
  90397. /**
  90398. * Computes the world matrix of the node
  90399. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90400. * @returns the world matrix
  90401. */
  90402. computeWorldMatrix(force?: boolean): Matrix;
  90403. /**
  90404. * Gets the minZ used for shadow according to both the scene and the light.
  90405. * @param activeCamera The camera we are returning the min for
  90406. * @returns the depth min z
  90407. */
  90408. getDepthMinZ(activeCamera: Camera): number;
  90409. /**
  90410. * Gets the maxZ used for shadow according to both the scene and the light.
  90411. * @param activeCamera The camera we are returning the max for
  90412. * @returns the depth max z
  90413. */
  90414. getDepthMaxZ(activeCamera: Camera): number;
  90415. /**
  90416. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90417. * @param matrix The materix to updated with the projection information
  90418. * @param viewMatrix The transform matrix of the light
  90419. * @param renderList The list of mesh to render in the map
  90420. * @returns The current light
  90421. */
  90422. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90423. }
  90424. }
  90425. declare module BABYLON {
  90426. /**
  90427. * Configuration needed for prepass-capable materials
  90428. */
  90429. export class PrePassConfiguration {
  90430. /**
  90431. * Previous world matrices of meshes carrying this material
  90432. * Used for computing velocity
  90433. */
  90434. previousWorldMatrices: {
  90435. [index: number]: Matrix;
  90436. };
  90437. /**
  90438. * Previous view project matrix
  90439. * Used for computing velocity
  90440. */
  90441. previousViewProjection: Matrix;
  90442. /**
  90443. * Previous bones of meshes carrying this material
  90444. * Used for computing velocity
  90445. */
  90446. previousBones: {
  90447. [index: number]: Float32Array;
  90448. };
  90449. /**
  90450. * Add the required uniforms to the current list.
  90451. * @param uniforms defines the current uniform list.
  90452. */
  90453. static AddUniforms(uniforms: string[]): void;
  90454. /**
  90455. * Add the required samplers to the current list.
  90456. * @param samplers defines the current sampler list.
  90457. */
  90458. static AddSamplers(samplers: string[]): void;
  90459. /**
  90460. * Binds the material data.
  90461. * @param effect defines the effect to update
  90462. * @param scene defines the scene the material belongs to.
  90463. * @param mesh The mesh
  90464. * @param world World matrix of this mesh
  90465. * @param isFrozen Is the material frozen
  90466. */
  90467. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  90468. }
  90469. }
  90470. declare module BABYLON {
  90471. /**
  90472. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  90473. * This is the base of the follow, arc rotate cameras and Free camera
  90474. * @see https://doc.babylonjs.com/features/cameras
  90475. */
  90476. export class TargetCamera extends Camera {
  90477. private static _RigCamTransformMatrix;
  90478. private static _TargetTransformMatrix;
  90479. private static _TargetFocalPoint;
  90480. private _tmpUpVector;
  90481. private _tmpTargetVector;
  90482. /**
  90483. * Define the current direction the camera is moving to
  90484. */
  90485. cameraDirection: Vector3;
  90486. /**
  90487. * Define the current rotation the camera is rotating to
  90488. */
  90489. cameraRotation: Vector2;
  90490. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  90491. ignoreParentScaling: boolean;
  90492. /**
  90493. * When set, the up vector of the camera will be updated by the rotation of the camera
  90494. */
  90495. updateUpVectorFromRotation: boolean;
  90496. private _tmpQuaternion;
  90497. /**
  90498. * Define the current rotation of the camera
  90499. */
  90500. rotation: Vector3;
  90501. /**
  90502. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  90503. */
  90504. rotationQuaternion: Quaternion;
  90505. /**
  90506. * Define the current speed of the camera
  90507. */
  90508. speed: number;
  90509. /**
  90510. * Add constraint to the camera to prevent it to move freely in all directions and
  90511. * around all axis.
  90512. */
  90513. noRotationConstraint: boolean;
  90514. /**
  90515. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  90516. * panning
  90517. */
  90518. invertRotation: boolean;
  90519. /**
  90520. * Speed multiplier for inverse camera panning
  90521. */
  90522. inverseRotationSpeed: number;
  90523. /**
  90524. * Define the current target of the camera as an object or a position.
  90525. */
  90526. lockedTarget: any;
  90527. /** @hidden */
  90528. _currentTarget: Vector3;
  90529. /** @hidden */
  90530. _initialFocalDistance: number;
  90531. /** @hidden */
  90532. _viewMatrix: Matrix;
  90533. /** @hidden */
  90534. _camMatrix: Matrix;
  90535. /** @hidden */
  90536. _cameraTransformMatrix: Matrix;
  90537. /** @hidden */
  90538. _cameraRotationMatrix: Matrix;
  90539. /** @hidden */
  90540. _referencePoint: Vector3;
  90541. /** @hidden */
  90542. _transformedReferencePoint: Vector3;
  90543. /** @hidden */
  90544. _reset: () => void;
  90545. private _defaultUp;
  90546. /**
  90547. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  90548. * This is the base of the follow, arc rotate cameras and Free camera
  90549. * @see https://doc.babylonjs.com/features/cameras
  90550. * @param name Defines the name of the camera in the scene
  90551. * @param position Defines the start position of the camera in the scene
  90552. * @param scene Defines the scene the camera belongs to
  90553. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  90554. */
  90555. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90556. /**
  90557. * Gets the position in front of the camera at a given distance.
  90558. * @param distance The distance from the camera we want the position to be
  90559. * @returns the position
  90560. */
  90561. getFrontPosition(distance: number): Vector3;
  90562. /** @hidden */
  90563. _getLockedTargetPosition(): Nullable<Vector3>;
  90564. private _storedPosition;
  90565. private _storedRotation;
  90566. private _storedRotationQuaternion;
  90567. /**
  90568. * Store current camera state of the camera (fov, position, rotation, etc..)
  90569. * @returns the camera
  90570. */
  90571. storeState(): Camera;
  90572. /**
  90573. * Restored camera state. You must call storeState() first
  90574. * @returns whether it was successful or not
  90575. * @hidden
  90576. */
  90577. _restoreStateValues(): boolean;
  90578. /** @hidden */
  90579. _initCache(): void;
  90580. /** @hidden */
  90581. _updateCache(ignoreParentClass?: boolean): void;
  90582. /** @hidden */
  90583. _isSynchronizedViewMatrix(): boolean;
  90584. /** @hidden */
  90585. _computeLocalCameraSpeed(): number;
  90586. /**
  90587. * Defines the target the camera should look at.
  90588. * @param target Defines the new target as a Vector or a mesh
  90589. */
  90590. setTarget(target: Vector3): void;
  90591. /**
  90592. * Defines the target point of the camera.
  90593. * The camera looks towards it form the radius distance.
  90594. */
  90595. get target(): Vector3;
  90596. set target(value: Vector3);
  90597. /**
  90598. * Return the current target position of the camera. This value is expressed in local space.
  90599. * @returns the target position
  90600. */
  90601. getTarget(): Vector3;
  90602. /** @hidden */
  90603. _decideIfNeedsToMove(): boolean;
  90604. /** @hidden */
  90605. _updatePosition(): void;
  90606. /** @hidden */
  90607. _checkInputs(): void;
  90608. protected _updateCameraRotationMatrix(): void;
  90609. /**
  90610. * 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)
  90611. * @returns the current camera
  90612. */
  90613. private _rotateUpVectorWithCameraRotationMatrix;
  90614. private _cachedRotationZ;
  90615. private _cachedQuaternionRotationZ;
  90616. /** @hidden */
  90617. _getViewMatrix(): Matrix;
  90618. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  90619. /**
  90620. * @hidden
  90621. */
  90622. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90623. /**
  90624. * @hidden
  90625. */
  90626. _updateRigCameras(): void;
  90627. private _getRigCamPositionAndTarget;
  90628. /**
  90629. * Gets the current object class name.
  90630. * @return the class name
  90631. */
  90632. getClassName(): string;
  90633. }
  90634. }
  90635. declare module BABYLON {
  90636. /**
  90637. * @ignore
  90638. * This is a list of all the different input types that are available in the application.
  90639. * Fo instance: ArcRotateCameraGamepadInput...
  90640. */
  90641. export var CameraInputTypes: {};
  90642. /**
  90643. * This is the contract to implement in order to create a new input class.
  90644. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  90645. */
  90646. export interface ICameraInput<TCamera extends Camera> {
  90647. /**
  90648. * Defines the camera the input is attached to.
  90649. */
  90650. camera: Nullable<TCamera>;
  90651. /**
  90652. * Gets the class name of the current intput.
  90653. * @returns the class name
  90654. */
  90655. getClassName(): string;
  90656. /**
  90657. * Get the friendly name associated with the input class.
  90658. * @returns the input friendly name
  90659. */
  90660. getSimpleName(): string;
  90661. /**
  90662. * Attach the input controls to a specific dom element to get the input from.
  90663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90664. */
  90665. attachControl(noPreventDefault?: boolean): void;
  90666. /**
  90667. * Detach the current controls from the specified dom element.
  90668. */
  90669. detachControl(): void;
  90670. /**
  90671. * Update the current camera state depending on the inputs that have been used this frame.
  90672. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90673. */
  90674. checkInputs?: () => void;
  90675. }
  90676. /**
  90677. * Represents a map of input types to input instance or input index to input instance.
  90678. */
  90679. export interface CameraInputsMap<TCamera extends Camera> {
  90680. /**
  90681. * Accessor to the input by input type.
  90682. */
  90683. [name: string]: ICameraInput<TCamera>;
  90684. /**
  90685. * Accessor to the input by input index.
  90686. */
  90687. [idx: number]: ICameraInput<TCamera>;
  90688. }
  90689. /**
  90690. * This represents the input manager used within a camera.
  90691. * It helps dealing with all the different kind of input attached to a camera.
  90692. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90693. */
  90694. export class CameraInputsManager<TCamera extends Camera> {
  90695. /**
  90696. * Defines the list of inputs attahed to the camera.
  90697. */
  90698. attached: CameraInputsMap<TCamera>;
  90699. /**
  90700. * Defines the dom element the camera is collecting inputs from.
  90701. * This is null if the controls have not been attached.
  90702. */
  90703. attachedToElement: boolean;
  90704. /**
  90705. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90706. */
  90707. noPreventDefault: boolean;
  90708. /**
  90709. * Defined the camera the input manager belongs to.
  90710. */
  90711. camera: TCamera;
  90712. /**
  90713. * Update the current camera state depending on the inputs that have been used this frame.
  90714. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90715. */
  90716. checkInputs: () => void;
  90717. /**
  90718. * Instantiate a new Camera Input Manager.
  90719. * @param camera Defines the camera the input manager blongs to
  90720. */
  90721. constructor(camera: TCamera);
  90722. /**
  90723. * Add an input method to a camera
  90724. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90725. * @param input camera input method
  90726. */
  90727. add(input: ICameraInput<TCamera>): void;
  90728. /**
  90729. * Remove a specific input method from a camera
  90730. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  90731. * @param inputToRemove camera input method
  90732. */
  90733. remove(inputToRemove: ICameraInput<TCamera>): void;
  90734. /**
  90735. * Remove a specific input type from a camera
  90736. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  90737. * @param inputType the type of the input to remove
  90738. */
  90739. removeByType(inputType: string): void;
  90740. private _addCheckInputs;
  90741. /**
  90742. * Attach the input controls to the currently attached dom element to listen the events from.
  90743. * @param input Defines the input to attach
  90744. */
  90745. attachInput(input: ICameraInput<TCamera>): void;
  90746. /**
  90747. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  90748. * @param element Defines the dom element to collect the events from
  90749. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90750. */
  90751. attachElement(noPreventDefault?: boolean): void;
  90752. /**
  90753. * Detach the current manager inputs controls from a specific dom element.
  90754. * @param element Defines the dom element to collect the events from
  90755. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  90756. */
  90757. detachElement(disconnect?: boolean): void;
  90758. /**
  90759. * Rebuild the dynamic inputCheck function from the current list of
  90760. * defined inputs in the manager.
  90761. */
  90762. rebuildInputCheck(): void;
  90763. /**
  90764. * Remove all attached input methods from a camera
  90765. */
  90766. clear(): void;
  90767. /**
  90768. * Serialize the current input manager attached to a camera.
  90769. * This ensures than once parsed,
  90770. * the input associated to the camera will be identical to the current ones
  90771. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  90772. */
  90773. serialize(serializedCamera: any): void;
  90774. /**
  90775. * Parses an input manager serialized JSON to restore the previous list of inputs
  90776. * and states associated to a camera.
  90777. * @param parsedCamera Defines the JSON to parse
  90778. */
  90779. parse(parsedCamera: any): void;
  90780. }
  90781. }
  90782. declare module BABYLON {
  90783. /**
  90784. * Gather the list of keyboard event types as constants.
  90785. */
  90786. export class KeyboardEventTypes {
  90787. /**
  90788. * The keydown event is fired when a key becomes active (pressed).
  90789. */
  90790. static readonly KEYDOWN: number;
  90791. /**
  90792. * The keyup event is fired when a key has been released.
  90793. */
  90794. static readonly KEYUP: number;
  90795. }
  90796. /**
  90797. * This class is used to store keyboard related info for the onKeyboardObservable event.
  90798. */
  90799. export class KeyboardInfo {
  90800. /**
  90801. * Defines the type of event (KeyboardEventTypes)
  90802. */
  90803. type: number;
  90804. /**
  90805. * Defines the related dom event
  90806. */
  90807. event: KeyboardEvent;
  90808. /**
  90809. * Instantiates a new keyboard info.
  90810. * This class is used to store keyboard related info for the onKeyboardObservable event.
  90811. * @param type Defines the type of event (KeyboardEventTypes)
  90812. * @param event Defines the related dom event
  90813. */
  90814. constructor(
  90815. /**
  90816. * Defines the type of event (KeyboardEventTypes)
  90817. */
  90818. type: number,
  90819. /**
  90820. * Defines the related dom event
  90821. */
  90822. event: KeyboardEvent);
  90823. }
  90824. /**
  90825. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  90826. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  90827. */
  90828. export class KeyboardInfoPre extends KeyboardInfo {
  90829. /**
  90830. * Defines the type of event (KeyboardEventTypes)
  90831. */
  90832. type: number;
  90833. /**
  90834. * Defines the related dom event
  90835. */
  90836. event: KeyboardEvent;
  90837. /**
  90838. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  90839. */
  90840. skipOnPointerObservable: boolean;
  90841. /**
  90842. * Instantiates a new keyboard pre info.
  90843. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  90844. * @param type Defines the type of event (KeyboardEventTypes)
  90845. * @param event Defines the related dom event
  90846. */
  90847. constructor(
  90848. /**
  90849. * Defines the type of event (KeyboardEventTypes)
  90850. */
  90851. type: number,
  90852. /**
  90853. * Defines the related dom event
  90854. */
  90855. event: KeyboardEvent);
  90856. }
  90857. }
  90858. declare module BABYLON {
  90859. /**
  90860. * Manage the keyboard inputs to control the movement of a free camera.
  90861. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90862. */
  90863. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  90864. /**
  90865. * Defines the camera the input is attached to.
  90866. */
  90867. camera: FreeCamera;
  90868. /**
  90869. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  90870. */
  90871. keysUp: number[];
  90872. /**
  90873. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  90874. */
  90875. keysUpward: number[];
  90876. /**
  90877. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  90878. */
  90879. keysDown: number[];
  90880. /**
  90881. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  90882. */
  90883. keysDownward: number[];
  90884. /**
  90885. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  90886. */
  90887. keysLeft: number[];
  90888. /**
  90889. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  90890. */
  90891. keysRight: number[];
  90892. private _keys;
  90893. private _onCanvasBlurObserver;
  90894. private _onKeyboardObserver;
  90895. private _engine;
  90896. private _scene;
  90897. /**
  90898. * Attach the input controls to a specific dom element to get the input from.
  90899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90900. */
  90901. attachControl(noPreventDefault?: boolean): void;
  90902. /**
  90903. * Detach the current controls from the specified dom element.
  90904. */
  90905. detachControl(): void;
  90906. /**
  90907. * Update the current camera state depending on the inputs that have been used this frame.
  90908. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90909. */
  90910. checkInputs(): void;
  90911. /**
  90912. * Gets the class name of the current intput.
  90913. * @returns the class name
  90914. */
  90915. getClassName(): string;
  90916. /** @hidden */
  90917. _onLostFocus(): void;
  90918. /**
  90919. * Get the friendly name associated with the input class.
  90920. * @returns the input friendly name
  90921. */
  90922. getSimpleName(): string;
  90923. }
  90924. }
  90925. declare module BABYLON {
  90926. /**
  90927. * Interface used to define Action
  90928. */
  90929. export interface IAction {
  90930. /**
  90931. * Trigger for the action
  90932. */
  90933. trigger: number;
  90934. /** Options of the trigger */
  90935. triggerOptions: any;
  90936. /**
  90937. * Gets the trigger parameters
  90938. * @returns the trigger parameters
  90939. */
  90940. getTriggerParameter(): any;
  90941. /**
  90942. * Internal only - executes current action event
  90943. * @hidden
  90944. */
  90945. _executeCurrent(evt?: ActionEvent): void;
  90946. /**
  90947. * Serialize placeholder for child classes
  90948. * @param parent of child
  90949. * @returns the serialized object
  90950. */
  90951. serialize(parent: any): any;
  90952. /**
  90953. * Internal only
  90954. * @hidden
  90955. */
  90956. _prepare(): void;
  90957. /**
  90958. * Internal only - manager for action
  90959. * @hidden
  90960. */
  90961. _actionManager: Nullable<AbstractActionManager>;
  90962. /**
  90963. * Adds action to chain of actions, may be a DoNothingAction
  90964. * @param action defines the next action to execute
  90965. * @returns The action passed in
  90966. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90967. */
  90968. then(action: IAction): IAction;
  90969. }
  90970. /**
  90971. * The action to be carried out following a trigger
  90972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90973. */
  90974. export class Action implements IAction {
  90975. /** the trigger, with or without parameters, for the action */
  90976. triggerOptions: any;
  90977. /**
  90978. * Trigger for the action
  90979. */
  90980. trigger: number;
  90981. /**
  90982. * Internal only - manager for action
  90983. * @hidden
  90984. */
  90985. _actionManager: ActionManager;
  90986. private _nextActiveAction;
  90987. private _child;
  90988. private _condition?;
  90989. private _triggerParameter;
  90990. /**
  90991. * An event triggered prior to action being executed.
  90992. */
  90993. onBeforeExecuteObservable: Observable<Action>;
  90994. /**
  90995. * Creates a new Action
  90996. * @param triggerOptions the trigger, with or without parameters, for the action
  90997. * @param condition an optional determinant of action
  90998. */
  90999. constructor(
  91000. /** the trigger, with or without parameters, for the action */
  91001. triggerOptions: any, condition?: Condition);
  91002. /**
  91003. * Internal only
  91004. * @hidden
  91005. */
  91006. _prepare(): void;
  91007. /**
  91008. * Gets the trigger parameters
  91009. * @returns the trigger parameters
  91010. */
  91011. getTriggerParameter(): any;
  91012. /**
  91013. * Internal only - executes current action event
  91014. * @hidden
  91015. */
  91016. _executeCurrent(evt?: ActionEvent): void;
  91017. /**
  91018. * Execute placeholder for child classes
  91019. * @param evt optional action event
  91020. */
  91021. execute(evt?: ActionEvent): void;
  91022. /**
  91023. * Skips to next active action
  91024. */
  91025. skipToNextActiveAction(): void;
  91026. /**
  91027. * Adds action to chain of actions, may be a DoNothingAction
  91028. * @param action defines the next action to execute
  91029. * @returns The action passed in
  91030. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91031. */
  91032. then(action: Action): Action;
  91033. /**
  91034. * Internal only
  91035. * @hidden
  91036. */
  91037. _getProperty(propertyPath: string): string;
  91038. /**
  91039. * Internal only
  91040. * @hidden
  91041. */
  91042. _getEffectiveTarget(target: any, propertyPath: string): any;
  91043. /**
  91044. * Serialize placeholder for child classes
  91045. * @param parent of child
  91046. * @returns the serialized object
  91047. */
  91048. serialize(parent: any): any;
  91049. /**
  91050. * Internal only called by serialize
  91051. * @hidden
  91052. */
  91053. protected _serialize(serializedAction: any, parent?: any): any;
  91054. /**
  91055. * Internal only
  91056. * @hidden
  91057. */
  91058. static _SerializeValueAsString: (value: any) => string;
  91059. /**
  91060. * Internal only
  91061. * @hidden
  91062. */
  91063. static _GetTargetProperty: (target: Scene | Node) => {
  91064. name: string;
  91065. targetType: string;
  91066. value: string;
  91067. };
  91068. }
  91069. }
  91070. declare module BABYLON {
  91071. /**
  91072. * A Condition applied to an Action
  91073. */
  91074. export class Condition {
  91075. /**
  91076. * Internal only - manager for action
  91077. * @hidden
  91078. */
  91079. _actionManager: ActionManager;
  91080. /**
  91081. * Internal only
  91082. * @hidden
  91083. */
  91084. _evaluationId: number;
  91085. /**
  91086. * Internal only
  91087. * @hidden
  91088. */
  91089. _currentResult: boolean;
  91090. /**
  91091. * Creates a new Condition
  91092. * @param actionManager the manager of the action the condition is applied to
  91093. */
  91094. constructor(actionManager: ActionManager);
  91095. /**
  91096. * Check if the current condition is valid
  91097. * @returns a boolean
  91098. */
  91099. isValid(): boolean;
  91100. /**
  91101. * Internal only
  91102. * @hidden
  91103. */
  91104. _getProperty(propertyPath: string): string;
  91105. /**
  91106. * Internal only
  91107. * @hidden
  91108. */
  91109. _getEffectiveTarget(target: any, propertyPath: string): any;
  91110. /**
  91111. * Serialize placeholder for child classes
  91112. * @returns the serialized object
  91113. */
  91114. serialize(): any;
  91115. /**
  91116. * Internal only
  91117. * @hidden
  91118. */
  91119. protected _serialize(serializedCondition: any): any;
  91120. }
  91121. /**
  91122. * Defines specific conditional operators as extensions of Condition
  91123. */
  91124. export class ValueCondition extends Condition {
  91125. /** path to specify the property of the target the conditional operator uses */
  91126. propertyPath: string;
  91127. /** the value compared by the conditional operator against the current value of the property */
  91128. value: any;
  91129. /** the conditional operator, default ValueCondition.IsEqual */
  91130. operator: number;
  91131. /**
  91132. * Internal only
  91133. * @hidden
  91134. */
  91135. private static _IsEqual;
  91136. /**
  91137. * Internal only
  91138. * @hidden
  91139. */
  91140. private static _IsDifferent;
  91141. /**
  91142. * Internal only
  91143. * @hidden
  91144. */
  91145. private static _IsGreater;
  91146. /**
  91147. * Internal only
  91148. * @hidden
  91149. */
  91150. private static _IsLesser;
  91151. /**
  91152. * returns the number for IsEqual
  91153. */
  91154. static get IsEqual(): number;
  91155. /**
  91156. * Returns the number for IsDifferent
  91157. */
  91158. static get IsDifferent(): number;
  91159. /**
  91160. * Returns the number for IsGreater
  91161. */
  91162. static get IsGreater(): number;
  91163. /**
  91164. * Returns the number for IsLesser
  91165. */
  91166. static get IsLesser(): number;
  91167. /**
  91168. * Internal only The action manager for the condition
  91169. * @hidden
  91170. */
  91171. _actionManager: ActionManager;
  91172. /**
  91173. * Internal only
  91174. * @hidden
  91175. */
  91176. private _target;
  91177. /**
  91178. * Internal only
  91179. * @hidden
  91180. */
  91181. private _effectiveTarget;
  91182. /**
  91183. * Internal only
  91184. * @hidden
  91185. */
  91186. private _property;
  91187. /**
  91188. * Creates a new ValueCondition
  91189. * @param actionManager manager for the action the condition applies to
  91190. * @param target for the action
  91191. * @param propertyPath path to specify the property of the target the conditional operator uses
  91192. * @param value the value compared by the conditional operator against the current value of the property
  91193. * @param operator the conditional operator, default ValueCondition.IsEqual
  91194. */
  91195. constructor(actionManager: ActionManager, target: any,
  91196. /** path to specify the property of the target the conditional operator uses */
  91197. propertyPath: string,
  91198. /** the value compared by the conditional operator against the current value of the property */
  91199. value: any,
  91200. /** the conditional operator, default ValueCondition.IsEqual */
  91201. operator?: number);
  91202. /**
  91203. * Compares the given value with the property value for the specified conditional operator
  91204. * @returns the result of the comparison
  91205. */
  91206. isValid(): boolean;
  91207. /**
  91208. * Serialize the ValueCondition into a JSON compatible object
  91209. * @returns serialization object
  91210. */
  91211. serialize(): any;
  91212. /**
  91213. * Gets the name of the conditional operator for the ValueCondition
  91214. * @param operator the conditional operator
  91215. * @returns the name
  91216. */
  91217. static GetOperatorName(operator: number): string;
  91218. }
  91219. /**
  91220. * Defines a predicate condition as an extension of Condition
  91221. */
  91222. export class PredicateCondition extends Condition {
  91223. /** defines the predicate function used to validate the condition */
  91224. predicate: () => boolean;
  91225. /**
  91226. * Internal only - manager for action
  91227. * @hidden
  91228. */
  91229. _actionManager: ActionManager;
  91230. /**
  91231. * Creates a new PredicateCondition
  91232. * @param actionManager manager for the action the condition applies to
  91233. * @param predicate defines the predicate function used to validate the condition
  91234. */
  91235. constructor(actionManager: ActionManager,
  91236. /** defines the predicate function used to validate the condition */
  91237. predicate: () => boolean);
  91238. /**
  91239. * @returns the validity of the predicate condition
  91240. */
  91241. isValid(): boolean;
  91242. }
  91243. /**
  91244. * Defines a state condition as an extension of Condition
  91245. */
  91246. export class StateCondition extends Condition {
  91247. /** Value to compare with target state */
  91248. value: string;
  91249. /**
  91250. * Internal only - manager for action
  91251. * @hidden
  91252. */
  91253. _actionManager: ActionManager;
  91254. /**
  91255. * Internal only
  91256. * @hidden
  91257. */
  91258. private _target;
  91259. /**
  91260. * Creates a new StateCondition
  91261. * @param actionManager manager for the action the condition applies to
  91262. * @param target of the condition
  91263. * @param value to compare with target state
  91264. */
  91265. constructor(actionManager: ActionManager, target: any,
  91266. /** Value to compare with target state */
  91267. value: string);
  91268. /**
  91269. * Gets a boolean indicating if the current condition is met
  91270. * @returns the validity of the state
  91271. */
  91272. isValid(): boolean;
  91273. /**
  91274. * Serialize the StateCondition into a JSON compatible object
  91275. * @returns serialization object
  91276. */
  91277. serialize(): any;
  91278. }
  91279. }
  91280. declare module BABYLON {
  91281. /**
  91282. * This defines an action responsible to toggle a boolean once triggered.
  91283. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91284. */
  91285. export class SwitchBooleanAction extends Action {
  91286. /**
  91287. * The path to the boolean property in the target object
  91288. */
  91289. propertyPath: string;
  91290. private _target;
  91291. private _effectiveTarget;
  91292. private _property;
  91293. /**
  91294. * Instantiate the action
  91295. * @param triggerOptions defines the trigger options
  91296. * @param target defines the object containing the boolean
  91297. * @param propertyPath defines the path to the boolean property in the target object
  91298. * @param condition defines the trigger related conditions
  91299. */
  91300. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91301. /** @hidden */
  91302. _prepare(): void;
  91303. /**
  91304. * Execute the action toggle the boolean value.
  91305. */
  91306. execute(): void;
  91307. /**
  91308. * Serializes the actions and its related information.
  91309. * @param parent defines the object to serialize in
  91310. * @returns the serialized object
  91311. */
  91312. serialize(parent: any): any;
  91313. }
  91314. /**
  91315. * This defines an action responsible to set a the state field of the target
  91316. * to a desired value once triggered.
  91317. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91318. */
  91319. export class SetStateAction extends Action {
  91320. /**
  91321. * The value to store in the state field.
  91322. */
  91323. value: string;
  91324. private _target;
  91325. /**
  91326. * Instantiate the action
  91327. * @param triggerOptions defines the trigger options
  91328. * @param target defines the object containing the state property
  91329. * @param value defines the value to store in the state field
  91330. * @param condition defines the trigger related conditions
  91331. */
  91332. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91333. /**
  91334. * Execute the action and store the value on the target state property.
  91335. */
  91336. execute(): void;
  91337. /**
  91338. * Serializes the actions and its related information.
  91339. * @param parent defines the object to serialize in
  91340. * @returns the serialized object
  91341. */
  91342. serialize(parent: any): any;
  91343. }
  91344. /**
  91345. * This defines an action responsible to set a property of the target
  91346. * to a desired value once triggered.
  91347. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91348. */
  91349. export class SetValueAction extends Action {
  91350. /**
  91351. * The path of the property to set in the target.
  91352. */
  91353. propertyPath: string;
  91354. /**
  91355. * The value to set in the property
  91356. */
  91357. value: any;
  91358. private _target;
  91359. private _effectiveTarget;
  91360. private _property;
  91361. /**
  91362. * Instantiate the action
  91363. * @param triggerOptions defines the trigger options
  91364. * @param target defines the object containing the property
  91365. * @param propertyPath defines the path of the property to set in the target
  91366. * @param value defines the value to set in the property
  91367. * @param condition defines the trigger related conditions
  91368. */
  91369. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91370. /** @hidden */
  91371. _prepare(): void;
  91372. /**
  91373. * Execute the action and set the targetted property to the desired value.
  91374. */
  91375. execute(): void;
  91376. /**
  91377. * Serializes the actions and its related information.
  91378. * @param parent defines the object to serialize in
  91379. * @returns the serialized object
  91380. */
  91381. serialize(parent: any): any;
  91382. }
  91383. /**
  91384. * This defines an action responsible to increment the target value
  91385. * to a desired value once triggered.
  91386. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91387. */
  91388. export class IncrementValueAction extends Action {
  91389. /**
  91390. * The path of the property to increment in the target.
  91391. */
  91392. propertyPath: string;
  91393. /**
  91394. * The value we should increment the property by.
  91395. */
  91396. value: any;
  91397. private _target;
  91398. private _effectiveTarget;
  91399. private _property;
  91400. /**
  91401. * Instantiate the action
  91402. * @param triggerOptions defines the trigger options
  91403. * @param target defines the object containing the property
  91404. * @param propertyPath defines the path of the property to increment in the target
  91405. * @param value defines the value value we should increment the property by
  91406. * @param condition defines the trigger related conditions
  91407. */
  91408. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91409. /** @hidden */
  91410. _prepare(): void;
  91411. /**
  91412. * Execute the action and increment the target of the value amount.
  91413. */
  91414. execute(): void;
  91415. /**
  91416. * Serializes the actions and its related information.
  91417. * @param parent defines the object to serialize in
  91418. * @returns the serialized object
  91419. */
  91420. serialize(parent: any): any;
  91421. }
  91422. /**
  91423. * This defines an action responsible to start an animation once triggered.
  91424. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91425. */
  91426. export class PlayAnimationAction extends Action {
  91427. /**
  91428. * Where the animation should start (animation frame)
  91429. */
  91430. from: number;
  91431. /**
  91432. * Where the animation should stop (animation frame)
  91433. */
  91434. to: number;
  91435. /**
  91436. * Define if the animation should loop or stop after the first play.
  91437. */
  91438. loop?: boolean;
  91439. private _target;
  91440. /**
  91441. * Instantiate the action
  91442. * @param triggerOptions defines the trigger options
  91443. * @param target defines the target animation or animation name
  91444. * @param from defines from where the animation should start (animation frame)
  91445. * @param end defines where the animation should stop (animation frame)
  91446. * @param loop defines if the animation should loop or stop after the first play
  91447. * @param condition defines the trigger related conditions
  91448. */
  91449. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91450. /** @hidden */
  91451. _prepare(): void;
  91452. /**
  91453. * Execute the action and play the animation.
  91454. */
  91455. execute(): void;
  91456. /**
  91457. * Serializes the actions and its related information.
  91458. * @param parent defines the object to serialize in
  91459. * @returns the serialized object
  91460. */
  91461. serialize(parent: any): any;
  91462. }
  91463. /**
  91464. * This defines an action responsible to stop an animation once triggered.
  91465. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91466. */
  91467. export class StopAnimationAction extends Action {
  91468. private _target;
  91469. /**
  91470. * Instantiate the action
  91471. * @param triggerOptions defines the trigger options
  91472. * @param target defines the target animation or animation name
  91473. * @param condition defines the trigger related conditions
  91474. */
  91475. constructor(triggerOptions: any, target: any, condition?: Condition);
  91476. /** @hidden */
  91477. _prepare(): void;
  91478. /**
  91479. * Execute the action and stop the animation.
  91480. */
  91481. execute(): void;
  91482. /**
  91483. * Serializes the actions and its related information.
  91484. * @param parent defines the object to serialize in
  91485. * @returns the serialized object
  91486. */
  91487. serialize(parent: any): any;
  91488. }
  91489. /**
  91490. * This defines an action responsible that does nothing once triggered.
  91491. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91492. */
  91493. export class DoNothingAction extends Action {
  91494. /**
  91495. * Instantiate the action
  91496. * @param triggerOptions defines the trigger options
  91497. * @param condition defines the trigger related conditions
  91498. */
  91499. constructor(triggerOptions?: any, condition?: Condition);
  91500. /**
  91501. * Execute the action and do nothing.
  91502. */
  91503. execute(): void;
  91504. /**
  91505. * Serializes the actions and its related information.
  91506. * @param parent defines the object to serialize in
  91507. * @returns the serialized object
  91508. */
  91509. serialize(parent: any): any;
  91510. }
  91511. /**
  91512. * This defines an action responsible to trigger several actions once triggered.
  91513. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91514. */
  91515. export class CombineAction extends Action {
  91516. /**
  91517. * The list of aggregated animations to run.
  91518. */
  91519. children: Action[];
  91520. /**
  91521. * Instantiate the action
  91522. * @param triggerOptions defines the trigger options
  91523. * @param children defines the list of aggregated animations to run
  91524. * @param condition defines the trigger related conditions
  91525. */
  91526. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91527. /** @hidden */
  91528. _prepare(): void;
  91529. /**
  91530. * Execute the action and executes all the aggregated actions.
  91531. */
  91532. execute(evt: ActionEvent): void;
  91533. /**
  91534. * Serializes the actions and its related information.
  91535. * @param parent defines the object to serialize in
  91536. * @returns the serialized object
  91537. */
  91538. serialize(parent: any): any;
  91539. }
  91540. /**
  91541. * This defines an action responsible to run code (external event) once triggered.
  91542. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91543. */
  91544. export class ExecuteCodeAction extends Action {
  91545. /**
  91546. * The callback function to run.
  91547. */
  91548. func: (evt: ActionEvent) => void;
  91549. /**
  91550. * Instantiate the action
  91551. * @param triggerOptions defines the trigger options
  91552. * @param func defines the callback function to run
  91553. * @param condition defines the trigger related conditions
  91554. */
  91555. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91556. /**
  91557. * Execute the action and run the attached code.
  91558. */
  91559. execute(evt: ActionEvent): void;
  91560. }
  91561. /**
  91562. * This defines an action responsible to set the parent property of the target once triggered.
  91563. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91564. */
  91565. export class SetParentAction extends Action {
  91566. private _parent;
  91567. private _target;
  91568. /**
  91569. * Instantiate the action
  91570. * @param triggerOptions defines the trigger options
  91571. * @param target defines the target containing the parent property
  91572. * @param parent defines from where the animation should start (animation frame)
  91573. * @param condition defines the trigger related conditions
  91574. */
  91575. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91576. /** @hidden */
  91577. _prepare(): void;
  91578. /**
  91579. * Execute the action and set the parent property.
  91580. */
  91581. execute(): void;
  91582. /**
  91583. * Serializes the actions and its related information.
  91584. * @param parent defines the object to serialize in
  91585. * @returns the serialized object
  91586. */
  91587. serialize(parent: any): any;
  91588. }
  91589. }
  91590. declare module BABYLON {
  91591. /**
  91592. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91593. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91594. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91595. */
  91596. export class ActionManager extends AbstractActionManager {
  91597. /**
  91598. * Nothing
  91599. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91600. */
  91601. static readonly NothingTrigger: number;
  91602. /**
  91603. * On pick
  91604. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91605. */
  91606. static readonly OnPickTrigger: number;
  91607. /**
  91608. * On left pick
  91609. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91610. */
  91611. static readonly OnLeftPickTrigger: number;
  91612. /**
  91613. * On right pick
  91614. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91615. */
  91616. static readonly OnRightPickTrigger: number;
  91617. /**
  91618. * On center pick
  91619. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91620. */
  91621. static readonly OnCenterPickTrigger: number;
  91622. /**
  91623. * On pick down
  91624. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91625. */
  91626. static readonly OnPickDownTrigger: number;
  91627. /**
  91628. * On double pick
  91629. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91630. */
  91631. static readonly OnDoublePickTrigger: number;
  91632. /**
  91633. * On pick up
  91634. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91635. */
  91636. static readonly OnPickUpTrigger: number;
  91637. /**
  91638. * On pick out.
  91639. * This trigger will only be raised if you also declared a OnPickDown
  91640. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91641. */
  91642. static readonly OnPickOutTrigger: number;
  91643. /**
  91644. * On long press
  91645. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91646. */
  91647. static readonly OnLongPressTrigger: number;
  91648. /**
  91649. * On pointer over
  91650. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91651. */
  91652. static readonly OnPointerOverTrigger: number;
  91653. /**
  91654. * On pointer out
  91655. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91656. */
  91657. static readonly OnPointerOutTrigger: number;
  91658. /**
  91659. * On every frame
  91660. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91661. */
  91662. static readonly OnEveryFrameTrigger: number;
  91663. /**
  91664. * On intersection enter
  91665. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91666. */
  91667. static readonly OnIntersectionEnterTrigger: number;
  91668. /**
  91669. * On intersection exit
  91670. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91671. */
  91672. static readonly OnIntersectionExitTrigger: number;
  91673. /**
  91674. * On key down
  91675. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91676. */
  91677. static readonly OnKeyDownTrigger: number;
  91678. /**
  91679. * On key up
  91680. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91681. */
  91682. static readonly OnKeyUpTrigger: number;
  91683. private _scene;
  91684. /**
  91685. * Creates a new action manager
  91686. * @param scene defines the hosting scene
  91687. */
  91688. constructor(scene: Scene);
  91689. /**
  91690. * Releases all associated resources
  91691. */
  91692. dispose(): void;
  91693. /**
  91694. * Gets hosting scene
  91695. * @returns the hosting scene
  91696. */
  91697. getScene(): Scene;
  91698. /**
  91699. * Does this action manager handles actions of any of the given triggers
  91700. * @param triggers defines the triggers to be tested
  91701. * @return a boolean indicating whether one (or more) of the triggers is handled
  91702. */
  91703. hasSpecificTriggers(triggers: number[]): boolean;
  91704. /**
  91705. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91706. * speed.
  91707. * @param triggerA defines the trigger to be tested
  91708. * @param triggerB defines the trigger to be tested
  91709. * @return a boolean indicating whether one (or more) of the triggers is handled
  91710. */
  91711. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91712. /**
  91713. * Does this action manager handles actions of a given trigger
  91714. * @param trigger defines the trigger to be tested
  91715. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91716. * @return whether the trigger is handled
  91717. */
  91718. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91719. /**
  91720. * Does this action manager has pointer triggers
  91721. */
  91722. get hasPointerTriggers(): boolean;
  91723. /**
  91724. * Does this action manager has pick triggers
  91725. */
  91726. get hasPickTriggers(): boolean;
  91727. /**
  91728. * Registers an action to this action manager
  91729. * @param action defines the action to be registered
  91730. * @return the action amended (prepared) after registration
  91731. */
  91732. registerAction(action: IAction): Nullable<IAction>;
  91733. /**
  91734. * Unregisters an action to this action manager
  91735. * @param action defines the action to be unregistered
  91736. * @return a boolean indicating whether the action has been unregistered
  91737. */
  91738. unregisterAction(action: IAction): Boolean;
  91739. /**
  91740. * Process a specific trigger
  91741. * @param trigger defines the trigger to process
  91742. * @param evt defines the event details to be processed
  91743. */
  91744. processTrigger(trigger: number, evt?: IActionEvent): void;
  91745. /** @hidden */
  91746. _getEffectiveTarget(target: any, propertyPath: string): any;
  91747. /** @hidden */
  91748. _getProperty(propertyPath: string): string;
  91749. /**
  91750. * Serialize this manager to a JSON object
  91751. * @param name defines the property name to store this manager
  91752. * @returns a JSON representation of this manager
  91753. */
  91754. serialize(name: string): any;
  91755. /**
  91756. * Creates a new ActionManager from a JSON data
  91757. * @param parsedActions defines the JSON data to read from
  91758. * @param object defines the hosting mesh
  91759. * @param scene defines the hosting scene
  91760. */
  91761. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91762. /**
  91763. * Get a trigger name by index
  91764. * @param trigger defines the trigger index
  91765. * @returns a trigger name
  91766. */
  91767. static GetTriggerName(trigger: number): string;
  91768. }
  91769. }
  91770. declare module BABYLON {
  91771. /**
  91772. * Class representing a ray with position and direction
  91773. */
  91774. export class Ray {
  91775. /** origin point */
  91776. origin: Vector3;
  91777. /** direction */
  91778. direction: Vector3;
  91779. /** length of the ray */
  91780. length: number;
  91781. private static readonly _TmpVector3;
  91782. private _tmpRay;
  91783. /**
  91784. * Creates a new ray
  91785. * @param origin origin point
  91786. * @param direction direction
  91787. * @param length length of the ray
  91788. */
  91789. constructor(
  91790. /** origin point */
  91791. origin: Vector3,
  91792. /** direction */
  91793. direction: Vector3,
  91794. /** length of the ray */
  91795. length?: number);
  91796. /**
  91797. * Checks if the ray intersects a box
  91798. * This does not account for the ray lenght by design to improve perfs.
  91799. * @param minimum bound of the box
  91800. * @param maximum bound of the box
  91801. * @param intersectionTreshold extra extend to be added to the box in all direction
  91802. * @returns if the box was hit
  91803. */
  91804. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91805. /**
  91806. * Checks if the ray intersects a box
  91807. * This does not account for the ray lenght by design to improve perfs.
  91808. * @param box the bounding box to check
  91809. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91810. * @returns if the box was hit
  91811. */
  91812. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91813. /**
  91814. * If the ray hits a sphere
  91815. * @param sphere the bounding sphere to check
  91816. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91817. * @returns true if it hits the sphere
  91818. */
  91819. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91820. /**
  91821. * If the ray hits a triange
  91822. * @param vertex0 triangle vertex
  91823. * @param vertex1 triangle vertex
  91824. * @param vertex2 triangle vertex
  91825. * @returns intersection information if hit
  91826. */
  91827. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91828. /**
  91829. * Checks if ray intersects a plane
  91830. * @param plane the plane to check
  91831. * @returns the distance away it was hit
  91832. */
  91833. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91834. /**
  91835. * Calculate the intercept of a ray on a given axis
  91836. * @param axis to check 'x' | 'y' | 'z'
  91837. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91838. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91839. */
  91840. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91841. /**
  91842. * Checks if ray intersects a mesh
  91843. * @param mesh the mesh to check
  91844. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91845. * @returns picking info of the intersecton
  91846. */
  91847. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91848. /**
  91849. * Checks if ray intersects a mesh
  91850. * @param meshes the meshes to check
  91851. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91852. * @param results array to store result in
  91853. * @returns Array of picking infos
  91854. */
  91855. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91856. private _comparePickingInfo;
  91857. private static smallnum;
  91858. private static rayl;
  91859. /**
  91860. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91861. * @param sega the first point of the segment to test the intersection against
  91862. * @param segb the second point of the segment to test the intersection against
  91863. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91864. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91865. */
  91866. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91867. /**
  91868. * Update the ray from viewport position
  91869. * @param x position
  91870. * @param y y position
  91871. * @param viewportWidth viewport width
  91872. * @param viewportHeight viewport height
  91873. * @param world world matrix
  91874. * @param view view matrix
  91875. * @param projection projection matrix
  91876. * @returns this ray updated
  91877. */
  91878. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91879. /**
  91880. * Creates a ray with origin and direction of 0,0,0
  91881. * @returns the new ray
  91882. */
  91883. static Zero(): Ray;
  91884. /**
  91885. * Creates a new ray from screen space and viewport
  91886. * @param x position
  91887. * @param y y position
  91888. * @param viewportWidth viewport width
  91889. * @param viewportHeight viewport height
  91890. * @param world world matrix
  91891. * @param view view matrix
  91892. * @param projection projection matrix
  91893. * @returns new ray
  91894. */
  91895. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91896. /**
  91897. * 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
  91898. * transformed to the given world matrix.
  91899. * @param origin The origin point
  91900. * @param end The end point
  91901. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91902. * @returns the new ray
  91903. */
  91904. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91905. /**
  91906. * Transforms a ray by a matrix
  91907. * @param ray ray to transform
  91908. * @param matrix matrix to apply
  91909. * @returns the resulting new ray
  91910. */
  91911. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91912. /**
  91913. * Transforms a ray by a matrix
  91914. * @param ray ray to transform
  91915. * @param matrix matrix to apply
  91916. * @param result ray to store result in
  91917. */
  91918. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91919. /**
  91920. * Unproject a ray from screen space to object space
  91921. * @param sourceX defines the screen space x coordinate to use
  91922. * @param sourceY defines the screen space y coordinate to use
  91923. * @param viewportWidth defines the current width of the viewport
  91924. * @param viewportHeight defines the current height of the viewport
  91925. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91926. * @param view defines the view matrix to use
  91927. * @param projection defines the projection matrix to use
  91928. */
  91929. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91930. }
  91931. /**
  91932. * Type used to define predicate used to select faces when a mesh intersection is detected
  91933. */
  91934. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91935. interface Scene {
  91936. /** @hidden */
  91937. _tempPickingRay: Nullable<Ray>;
  91938. /** @hidden */
  91939. _cachedRayForTransform: Ray;
  91940. /** @hidden */
  91941. _pickWithRayInverseMatrix: Matrix;
  91942. /** @hidden */
  91943. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91944. /** @hidden */
  91945. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91946. /** @hidden */
  91947. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  91948. }
  91949. }
  91950. declare module BABYLON {
  91951. /**
  91952. * Groups all the scene component constants in one place to ease maintenance.
  91953. * @hidden
  91954. */
  91955. export class SceneComponentConstants {
  91956. static readonly NAME_EFFECTLAYER: string;
  91957. static readonly NAME_LAYER: string;
  91958. static readonly NAME_LENSFLARESYSTEM: string;
  91959. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91960. static readonly NAME_PARTICLESYSTEM: string;
  91961. static readonly NAME_GAMEPAD: string;
  91962. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91963. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91964. static readonly NAME_PREPASSRENDERER: string;
  91965. static readonly NAME_DEPTHRENDERER: string;
  91966. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91967. static readonly NAME_SPRITE: string;
  91968. static readonly NAME_SUBSURFACE: string;
  91969. static readonly NAME_OUTLINERENDERER: string;
  91970. static readonly NAME_PROCEDURALTEXTURE: string;
  91971. static readonly NAME_SHADOWGENERATOR: string;
  91972. static readonly NAME_OCTREE: string;
  91973. static readonly NAME_PHYSICSENGINE: string;
  91974. static readonly NAME_AUDIO: string;
  91975. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91976. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91977. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91978. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91979. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91980. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91981. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91982. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91983. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91984. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91985. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91986. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91987. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91988. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91989. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91990. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91991. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91992. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91993. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91994. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91995. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91996. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91997. static readonly STEP_AFTERRENDER_AUDIO: number;
  91998. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91999. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  92000. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  92001. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  92002. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  92003. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  92004. static readonly STEP_POINTERMOVE_SPRITE: number;
  92005. static readonly STEP_POINTERDOWN_SPRITE: number;
  92006. static readonly STEP_POINTERUP_SPRITE: number;
  92007. }
  92008. /**
  92009. * This represents a scene component.
  92010. *
  92011. * This is used to decouple the dependency the scene is having on the different workloads like
  92012. * layers, post processes...
  92013. */
  92014. export interface ISceneComponent {
  92015. /**
  92016. * The name of the component. Each component must have a unique name.
  92017. */
  92018. name: string;
  92019. /**
  92020. * The scene the component belongs to.
  92021. */
  92022. scene: Scene;
  92023. /**
  92024. * Register the component to one instance of a scene.
  92025. */
  92026. register(): void;
  92027. /**
  92028. * Rebuilds the elements related to this component in case of
  92029. * context lost for instance.
  92030. */
  92031. rebuild(): void;
  92032. /**
  92033. * Disposes the component and the associated ressources.
  92034. */
  92035. dispose(): void;
  92036. }
  92037. /**
  92038. * This represents a SERIALIZABLE scene component.
  92039. *
  92040. * This extends Scene Component to add Serialization methods on top.
  92041. */
  92042. export interface ISceneSerializableComponent extends ISceneComponent {
  92043. /**
  92044. * Adds all the elements from the container to the scene
  92045. * @param container the container holding the elements
  92046. */
  92047. addFromContainer(container: AbstractScene): void;
  92048. /**
  92049. * Removes all the elements in the container from the scene
  92050. * @param container contains the elements to remove
  92051. * @param dispose if the removed element should be disposed (default: false)
  92052. */
  92053. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  92054. /**
  92055. * Serializes the component data to the specified json object
  92056. * @param serializationObject The object to serialize to
  92057. */
  92058. serialize(serializationObject: any): void;
  92059. }
  92060. /**
  92061. * Strong typing of a Mesh related stage step action
  92062. */
  92063. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  92064. /**
  92065. * Strong typing of a Evaluate Sub Mesh related stage step action
  92066. */
  92067. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  92068. /**
  92069. * Strong typing of a pre active Mesh related stage step action
  92070. */
  92071. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  92072. /**
  92073. * Strong typing of a Camera related stage step action
  92074. */
  92075. export type CameraStageAction = (camera: Camera) => void;
  92076. /**
  92077. * Strong typing of a Camera Frame buffer related stage step action
  92078. */
  92079. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  92080. /**
  92081. * Strong typing of a Render Target related stage step action
  92082. */
  92083. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  92084. /**
  92085. * Strong typing of a RenderingGroup related stage step action
  92086. */
  92087. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  92088. /**
  92089. * Strong typing of a Mesh Render related stage step action
  92090. */
  92091. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  92092. /**
  92093. * Strong typing of a simple stage step action
  92094. */
  92095. export type SimpleStageAction = () => void;
  92096. /**
  92097. * Strong typing of a render target action.
  92098. */
  92099. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  92100. /**
  92101. * Strong typing of a pointer move action.
  92102. */
  92103. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  92104. /**
  92105. * Strong typing of a pointer up/down action.
  92106. */
  92107. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  92108. /**
  92109. * Representation of a stage in the scene (Basically a list of ordered steps)
  92110. * @hidden
  92111. */
  92112. export class Stage<T extends Function> extends Array<{
  92113. index: number;
  92114. component: ISceneComponent;
  92115. action: T;
  92116. }> {
  92117. /**
  92118. * Hide ctor from the rest of the world.
  92119. * @param items The items to add.
  92120. */
  92121. private constructor();
  92122. /**
  92123. * Creates a new Stage.
  92124. * @returns A new instance of a Stage
  92125. */
  92126. static Create<T extends Function>(): Stage<T>;
  92127. /**
  92128. * Registers a step in an ordered way in the targeted stage.
  92129. * @param index Defines the position to register the step in
  92130. * @param component Defines the component attached to the step
  92131. * @param action Defines the action to launch during the step
  92132. */
  92133. registerStep(index: number, component: ISceneComponent, action: T): void;
  92134. /**
  92135. * Clears all the steps from the stage.
  92136. */
  92137. clear(): void;
  92138. }
  92139. }
  92140. declare module BABYLON {
  92141. interface Scene {
  92142. /** @hidden */
  92143. _pointerOverSprite: Nullable<Sprite>;
  92144. /** @hidden */
  92145. _pickedDownSprite: Nullable<Sprite>;
  92146. /** @hidden */
  92147. _tempSpritePickingRay: Nullable<Ray>;
  92148. /**
  92149. * All of the sprite managers added to this scene
  92150. * @see https://doc.babylonjs.com/babylon101/sprites
  92151. */
  92152. spriteManagers: Array<ISpriteManager>;
  92153. /**
  92154. * An event triggered when sprites rendering is about to start
  92155. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92156. */
  92157. onBeforeSpritesRenderingObservable: Observable<Scene>;
  92158. /**
  92159. * An event triggered when sprites rendering is done
  92160. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92161. */
  92162. onAfterSpritesRenderingObservable: Observable<Scene>;
  92163. /** @hidden */
  92164. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92165. /** Launch a ray to try to pick a sprite in the scene
  92166. * @param x position on screen
  92167. * @param y position on screen
  92168. * @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
  92169. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92170. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92171. * @returns a PickingInfo
  92172. */
  92173. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92174. /** Use the given ray to pick a sprite in the scene
  92175. * @param ray The ray (in world space) to use to pick meshes
  92176. * @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
  92177. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92178. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92179. * @returns a PickingInfo
  92180. */
  92181. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92182. /** @hidden */
  92183. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92184. /** Launch a ray to try to pick sprites in the scene
  92185. * @param x position on screen
  92186. * @param y position on screen
  92187. * @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
  92188. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92189. * @returns a PickingInfo array
  92190. */
  92191. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92192. /** Use the given ray to pick sprites in the scene
  92193. * @param ray The ray (in world space) to use to pick meshes
  92194. * @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
  92195. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92196. * @returns a PickingInfo array
  92197. */
  92198. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92199. /**
  92200. * Force the sprite under the pointer
  92201. * @param sprite defines the sprite to use
  92202. */
  92203. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  92204. /**
  92205. * Gets the sprite under the pointer
  92206. * @returns a Sprite or null if no sprite is under the pointer
  92207. */
  92208. getPointerOverSprite(): Nullable<Sprite>;
  92209. }
  92210. /**
  92211. * Defines the sprite scene component responsible to manage sprites
  92212. * in a given scene.
  92213. */
  92214. export class SpriteSceneComponent implements ISceneComponent {
  92215. /**
  92216. * The component name helpfull to identify the component in the list of scene components.
  92217. */
  92218. readonly name: string;
  92219. /**
  92220. * The scene the component belongs to.
  92221. */
  92222. scene: Scene;
  92223. /** @hidden */
  92224. private _spritePredicate;
  92225. /**
  92226. * Creates a new instance of the component for the given scene
  92227. * @param scene Defines the scene to register the component in
  92228. */
  92229. constructor(scene: Scene);
  92230. /**
  92231. * Registers the component in a given scene
  92232. */
  92233. register(): void;
  92234. /**
  92235. * Rebuilds the elements related to this component in case of
  92236. * context lost for instance.
  92237. */
  92238. rebuild(): void;
  92239. /**
  92240. * Disposes the component and the associated ressources.
  92241. */
  92242. dispose(): void;
  92243. private _pickSpriteButKeepRay;
  92244. private _pointerMove;
  92245. private _pointerDown;
  92246. private _pointerUp;
  92247. }
  92248. }
  92249. declare module BABYLON {
  92250. /**
  92251. * Class used to provide helper for timing
  92252. */
  92253. export class TimingTools {
  92254. /**
  92255. * Polyfill for setImmediate
  92256. * @param action defines the action to execute after the current execution block
  92257. */
  92258. static SetImmediate(action: () => void): void;
  92259. }
  92260. }
  92261. declare module BABYLON {
  92262. /**
  92263. * Class used to enable instatition of objects by class name
  92264. */
  92265. export class InstantiationTools {
  92266. /**
  92267. * Use this object to register external classes like custom textures or material
  92268. * to allow the laoders to instantiate them
  92269. */
  92270. static RegisteredExternalClasses: {
  92271. [key: string]: Object;
  92272. };
  92273. /**
  92274. * Tries to instantiate a new object from a given class name
  92275. * @param className defines the class name to instantiate
  92276. * @returns the new object or null if the system was not able to do the instantiation
  92277. */
  92278. static Instantiate(className: string): any;
  92279. }
  92280. }
  92281. declare module BABYLON {
  92282. /**
  92283. * Class used to host copy specific utilities
  92284. */
  92285. export class CopyTools {
  92286. /**
  92287. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  92288. * @param texture defines the texture to read pixels from
  92289. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92290. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92291. * @returns The base64 encoded string or null
  92292. */
  92293. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  92294. }
  92295. }
  92296. declare module BABYLON {
  92297. /**
  92298. * Define options used to create a depth texture
  92299. */
  92300. export class DepthTextureCreationOptions {
  92301. /** Specifies whether or not a stencil should be allocated in the texture */
  92302. generateStencil?: boolean;
  92303. /** Specifies whether or not bilinear filtering is enable on the texture */
  92304. bilinearFiltering?: boolean;
  92305. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  92306. comparisonFunction?: number;
  92307. /** Specifies if the created texture is a cube texture */
  92308. isCube?: boolean;
  92309. }
  92310. }
  92311. declare module BABYLON {
  92312. interface ThinEngine {
  92313. /**
  92314. * Creates a depth stencil cube texture.
  92315. * This is only available in WebGL 2.
  92316. * @param size The size of face edge in the cube texture.
  92317. * @param options The options defining the cube texture.
  92318. * @returns The cube texture
  92319. */
  92320. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  92321. /**
  92322. * Creates a cube texture
  92323. * @param rootUrl defines the url where the files to load is located
  92324. * @param scene defines the current scene
  92325. * @param files defines the list of files to load (1 per face)
  92326. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92327. * @param onLoad defines an optional callback raised when the texture is loaded
  92328. * @param onError defines an optional callback raised if there is an issue to load the texture
  92329. * @param format defines the format of the data
  92330. * @param forcedExtension defines the extension to use to pick the right loader
  92331. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  92332. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92333. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92334. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  92335. * @param loaderOptions options to be passed to the loader
  92336. * @returns the cube texture as an InternalTexture
  92337. */
  92338. 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;
  92339. /**
  92340. * Creates a cube texture
  92341. * @param rootUrl defines the url where the files to load is located
  92342. * @param scene defines the current scene
  92343. * @param files defines the list of files to load (1 per face)
  92344. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92345. * @param onLoad defines an optional callback raised when the texture is loaded
  92346. * @param onError defines an optional callback raised if there is an issue to load the texture
  92347. * @param format defines the format of the data
  92348. * @param forcedExtension defines the extension to use to pick the right loader
  92349. * @returns the cube texture as an InternalTexture
  92350. */
  92351. 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;
  92352. /**
  92353. * Creates a cube texture
  92354. * @param rootUrl defines the url where the files to load is located
  92355. * @param scene defines the current scene
  92356. * @param files defines the list of files to load (1 per face)
  92357. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92358. * @param onLoad defines an optional callback raised when the texture is loaded
  92359. * @param onError defines an optional callback raised if there is an issue to load the texture
  92360. * @param format defines the format of the data
  92361. * @param forcedExtension defines the extension to use to pick the right loader
  92362. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  92363. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92364. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92365. * @returns the cube texture as an InternalTexture
  92366. */
  92367. 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;
  92368. /** @hidden */
  92369. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  92370. /** @hidden */
  92371. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  92372. /** @hidden */
  92373. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  92374. /** @hidden */
  92375. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  92376. /**
  92377. * @hidden
  92378. */
  92379. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  92380. }
  92381. }
  92382. declare module BABYLON {
  92383. /**
  92384. * Class for creating a cube texture
  92385. */
  92386. export class CubeTexture extends BaseTexture {
  92387. private _delayedOnLoad;
  92388. /**
  92389. * Observable triggered once the texture has been loaded.
  92390. */
  92391. onLoadObservable: Observable<CubeTexture>;
  92392. /**
  92393. * The url of the texture
  92394. */
  92395. url: string;
  92396. /**
  92397. * Gets or sets the center of the bounding box associated with the cube texture.
  92398. * It must define where the camera used to render the texture was set
  92399. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  92400. */
  92401. boundingBoxPosition: Vector3;
  92402. private _boundingBoxSize;
  92403. /**
  92404. * Gets or sets the size of the bounding box associated with the cube texture
  92405. * When defined, the cubemap will switch to local mode
  92406. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  92407. * @example https://www.babylonjs-playground.com/#RNASML
  92408. */
  92409. set boundingBoxSize(value: Vector3);
  92410. /**
  92411. * Returns the bounding box size
  92412. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  92413. */
  92414. get boundingBoxSize(): Vector3;
  92415. protected _rotationY: number;
  92416. /**
  92417. * Sets texture matrix rotation angle around Y axis in radians.
  92418. */
  92419. set rotationY(value: number);
  92420. /**
  92421. * Gets texture matrix rotation angle around Y axis radians.
  92422. */
  92423. get rotationY(): number;
  92424. /**
  92425. * Are mip maps generated for this texture or not.
  92426. */
  92427. get noMipmap(): boolean;
  92428. private _noMipmap;
  92429. private _files;
  92430. protected _forcedExtension: Nullable<string>;
  92431. private _extensions;
  92432. private _textureMatrix;
  92433. private _format;
  92434. private _createPolynomials;
  92435. private _loaderOptions;
  92436. /**
  92437. * Creates a cube texture from an array of image urls
  92438. * @param files defines an array of image urls
  92439. * @param scene defines the hosting scene
  92440. * @param noMipmap specifies if mip maps are not used
  92441. * @returns a cube texture
  92442. */
  92443. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  92444. /**
  92445. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  92446. * @param url defines the url of the prefiltered texture
  92447. * @param scene defines the scene the texture is attached to
  92448. * @param forcedExtension defines the extension of the file if different from the url
  92449. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  92450. * @return the prefiltered texture
  92451. */
  92452. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  92453. /**
  92454. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  92455. * as prefiltered data.
  92456. * @param rootUrl defines the url of the texture or the root name of the six images
  92457. * @param null defines the scene or engine the texture is attached to
  92458. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  92459. * @param noMipmap defines if mipmaps should be created or not
  92460. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  92461. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  92462. * @param onError defines a callback triggered in case of error during load
  92463. * @param format defines the internal format to use for the texture once loaded
  92464. * @param prefiltered defines whether or not the texture is created from prefiltered data
  92465. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  92466. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  92467. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92468. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92469. * @param loaderOptions options to be passed to the loader
  92470. * @return the cube texture
  92471. */
  92472. 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);
  92473. /**
  92474. * Get the current class name of the texture useful for serialization or dynamic coding.
  92475. * @returns "CubeTexture"
  92476. */
  92477. getClassName(): string;
  92478. /**
  92479. * Update the url (and optional buffer) of this texture if url was null during construction.
  92480. * @param url the url of the texture
  92481. * @param forcedExtension defines the extension to use
  92482. * @param onLoad callback called when the texture is loaded (defaults to null)
  92483. * @param prefiltered Defines whether the updated texture is prefiltered or not
  92484. */
  92485. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  92486. /**
  92487. * Delays loading of the cube texture
  92488. * @param forcedExtension defines the extension to use
  92489. */
  92490. delayLoad(forcedExtension?: string): void;
  92491. /**
  92492. * Returns the reflection texture matrix
  92493. * @returns the reflection texture matrix
  92494. */
  92495. getReflectionTextureMatrix(): Matrix;
  92496. /**
  92497. * Sets the reflection texture matrix
  92498. * @param value Reflection texture matrix
  92499. */
  92500. setReflectionTextureMatrix(value: Matrix): void;
  92501. /**
  92502. * Parses text to create a cube texture
  92503. * @param parsedTexture define the serialized text to read from
  92504. * @param scene defines the hosting scene
  92505. * @param rootUrl defines the root url of the cube texture
  92506. * @returns a cube texture
  92507. */
  92508. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  92509. /**
  92510. * Makes a clone, or deep copy, of the cube texture
  92511. * @returns a new cube texture
  92512. */
  92513. clone(): CubeTexture;
  92514. }
  92515. }
  92516. declare module BABYLON {
  92517. /**
  92518. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92519. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92520. * 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;
  92521. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92522. */
  92523. export class ColorCurves {
  92524. private _dirty;
  92525. private _tempColor;
  92526. private _globalCurve;
  92527. private _highlightsCurve;
  92528. private _midtonesCurve;
  92529. private _shadowsCurve;
  92530. private _positiveCurve;
  92531. private _negativeCurve;
  92532. private _globalHue;
  92533. private _globalDensity;
  92534. private _globalSaturation;
  92535. private _globalExposure;
  92536. /**
  92537. * Gets the global Hue value.
  92538. * 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).
  92539. */
  92540. get globalHue(): number;
  92541. /**
  92542. * Sets the global Hue value.
  92543. * 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).
  92544. */
  92545. set globalHue(value: number);
  92546. /**
  92547. * Gets the global Density value.
  92548. * 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.
  92549. * Values less than zero provide a filter of opposite hue.
  92550. */
  92551. get globalDensity(): number;
  92552. /**
  92553. * Sets the global Density value.
  92554. * 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.
  92555. * Values less than zero provide a filter of opposite hue.
  92556. */
  92557. set globalDensity(value: number);
  92558. /**
  92559. * Gets the global Saturation value.
  92560. * 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.
  92561. */
  92562. get globalSaturation(): number;
  92563. /**
  92564. * Sets the global Saturation value.
  92565. * 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.
  92566. */
  92567. set globalSaturation(value: number);
  92568. /**
  92569. * Gets the global Exposure value.
  92570. * 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.
  92571. */
  92572. get globalExposure(): number;
  92573. /**
  92574. * Sets the global Exposure value.
  92575. * 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.
  92576. */
  92577. set globalExposure(value: number);
  92578. private _highlightsHue;
  92579. private _highlightsDensity;
  92580. private _highlightsSaturation;
  92581. private _highlightsExposure;
  92582. /**
  92583. * Gets the highlights Hue value.
  92584. * 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).
  92585. */
  92586. get highlightsHue(): number;
  92587. /**
  92588. * Sets the highlights Hue value.
  92589. * 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).
  92590. */
  92591. set highlightsHue(value: number);
  92592. /**
  92593. * Gets the highlights Density value.
  92594. * 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.
  92595. * Values less than zero provide a filter of opposite hue.
  92596. */
  92597. get highlightsDensity(): number;
  92598. /**
  92599. * Sets the highlights Density value.
  92600. * 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.
  92601. * Values less than zero provide a filter of opposite hue.
  92602. */
  92603. set highlightsDensity(value: number);
  92604. /**
  92605. * Gets the highlights Saturation value.
  92606. * 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.
  92607. */
  92608. get highlightsSaturation(): number;
  92609. /**
  92610. * Sets the highlights Saturation value.
  92611. * 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.
  92612. */
  92613. set highlightsSaturation(value: number);
  92614. /**
  92615. * Gets the highlights Exposure value.
  92616. * 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.
  92617. */
  92618. get highlightsExposure(): number;
  92619. /**
  92620. * Sets the highlights Exposure value.
  92621. * 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.
  92622. */
  92623. set highlightsExposure(value: number);
  92624. private _midtonesHue;
  92625. private _midtonesDensity;
  92626. private _midtonesSaturation;
  92627. private _midtonesExposure;
  92628. /**
  92629. * Gets the midtones Hue value.
  92630. * 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).
  92631. */
  92632. get midtonesHue(): number;
  92633. /**
  92634. * Sets the midtones Hue value.
  92635. * 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).
  92636. */
  92637. set midtonesHue(value: number);
  92638. /**
  92639. * Gets the midtones Density value.
  92640. * 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.
  92641. * Values less than zero provide a filter of opposite hue.
  92642. */
  92643. get midtonesDensity(): number;
  92644. /**
  92645. * Sets the midtones Density value.
  92646. * 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.
  92647. * Values less than zero provide a filter of opposite hue.
  92648. */
  92649. set midtonesDensity(value: number);
  92650. /**
  92651. * Gets the midtones Saturation value.
  92652. * 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.
  92653. */
  92654. get midtonesSaturation(): number;
  92655. /**
  92656. * Sets the midtones Saturation value.
  92657. * 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.
  92658. */
  92659. set midtonesSaturation(value: number);
  92660. /**
  92661. * Gets the midtones Exposure value.
  92662. * 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.
  92663. */
  92664. get midtonesExposure(): number;
  92665. /**
  92666. * Sets the midtones Exposure value.
  92667. * 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.
  92668. */
  92669. set midtonesExposure(value: number);
  92670. private _shadowsHue;
  92671. private _shadowsDensity;
  92672. private _shadowsSaturation;
  92673. private _shadowsExposure;
  92674. /**
  92675. * Gets the shadows Hue value.
  92676. * 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).
  92677. */
  92678. get shadowsHue(): number;
  92679. /**
  92680. * Sets the shadows Hue value.
  92681. * 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).
  92682. */
  92683. set shadowsHue(value: number);
  92684. /**
  92685. * Gets the shadows Density value.
  92686. * 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.
  92687. * Values less than zero provide a filter of opposite hue.
  92688. */
  92689. get shadowsDensity(): number;
  92690. /**
  92691. * Sets the shadows Density value.
  92692. * 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.
  92693. * Values less than zero provide a filter of opposite hue.
  92694. */
  92695. set shadowsDensity(value: number);
  92696. /**
  92697. * Gets the shadows Saturation value.
  92698. * 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.
  92699. */
  92700. get shadowsSaturation(): number;
  92701. /**
  92702. * Sets the shadows Saturation value.
  92703. * 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.
  92704. */
  92705. set shadowsSaturation(value: number);
  92706. /**
  92707. * Gets the shadows Exposure value.
  92708. * 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.
  92709. */
  92710. get shadowsExposure(): number;
  92711. /**
  92712. * Sets the shadows Exposure value.
  92713. * 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.
  92714. */
  92715. set shadowsExposure(value: number);
  92716. /**
  92717. * Returns the class name
  92718. * @returns The class name
  92719. */
  92720. getClassName(): string;
  92721. /**
  92722. * Binds the color curves to the shader.
  92723. * @param colorCurves The color curve to bind
  92724. * @param effect The effect to bind to
  92725. * @param positiveUniform The positive uniform shader parameter
  92726. * @param neutralUniform The neutral uniform shader parameter
  92727. * @param negativeUniform The negative uniform shader parameter
  92728. */
  92729. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92730. /**
  92731. * Prepare the list of uniforms associated with the ColorCurves effects.
  92732. * @param uniformsList The list of uniforms used in the effect
  92733. */
  92734. static PrepareUniforms(uniformsList: string[]): void;
  92735. /**
  92736. * Returns color grading data based on a hue, density, saturation and exposure value.
  92737. * @param filterHue The hue of the color filter.
  92738. * @param filterDensity The density of the color filter.
  92739. * @param saturation The saturation.
  92740. * @param exposure The exposure.
  92741. * @param result The result data container.
  92742. */
  92743. private getColorGradingDataToRef;
  92744. /**
  92745. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92746. * @param value The input slider value in range [-100,100].
  92747. * @returns Adjusted value.
  92748. */
  92749. private static applyColorGradingSliderNonlinear;
  92750. /**
  92751. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92752. * @param hue The hue (H) input.
  92753. * @param saturation The saturation (S) input.
  92754. * @param brightness The brightness (B) input.
  92755. * @result An RGBA color represented as Vector4.
  92756. */
  92757. private static fromHSBToRef;
  92758. /**
  92759. * Returns a value clamped between min and max
  92760. * @param value The value to clamp
  92761. * @param min The minimum of value
  92762. * @param max The maximum of value
  92763. * @returns The clamped value.
  92764. */
  92765. private static clamp;
  92766. /**
  92767. * Clones the current color curve instance.
  92768. * @return The cloned curves
  92769. */
  92770. clone(): ColorCurves;
  92771. /**
  92772. * Serializes the current color curve instance to a json representation.
  92773. * @return a JSON representation
  92774. */
  92775. serialize(): any;
  92776. /**
  92777. * Parses the color curve from a json representation.
  92778. * @param source the JSON source to parse
  92779. * @return The parsed curves
  92780. */
  92781. static Parse(source: any): ColorCurves;
  92782. }
  92783. }
  92784. declare module BABYLON {
  92785. /**
  92786. * Interface to follow in your material defines to integrate easily the
  92787. * Image proccessing functions.
  92788. * @hidden
  92789. */
  92790. export interface IImageProcessingConfigurationDefines {
  92791. IMAGEPROCESSING: boolean;
  92792. VIGNETTE: boolean;
  92793. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92794. VIGNETTEBLENDMODEOPAQUE: boolean;
  92795. TONEMAPPING: boolean;
  92796. TONEMAPPING_ACES: boolean;
  92797. CONTRAST: boolean;
  92798. EXPOSURE: boolean;
  92799. COLORCURVES: boolean;
  92800. COLORGRADING: boolean;
  92801. COLORGRADING3D: boolean;
  92802. SAMPLER3DGREENDEPTH: boolean;
  92803. SAMPLER3DBGRMAP: boolean;
  92804. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92805. }
  92806. /**
  92807. * @hidden
  92808. */
  92809. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92810. IMAGEPROCESSING: boolean;
  92811. VIGNETTE: boolean;
  92812. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92813. VIGNETTEBLENDMODEOPAQUE: boolean;
  92814. TONEMAPPING: boolean;
  92815. TONEMAPPING_ACES: boolean;
  92816. CONTRAST: boolean;
  92817. COLORCURVES: boolean;
  92818. COLORGRADING: boolean;
  92819. COLORGRADING3D: boolean;
  92820. SAMPLER3DGREENDEPTH: boolean;
  92821. SAMPLER3DBGRMAP: boolean;
  92822. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92823. EXPOSURE: boolean;
  92824. constructor();
  92825. }
  92826. /**
  92827. * This groups together the common properties used for image processing either in direct forward pass
  92828. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92829. * or not.
  92830. */
  92831. export class ImageProcessingConfiguration {
  92832. /**
  92833. * Default tone mapping applied in BabylonJS.
  92834. */
  92835. static readonly TONEMAPPING_STANDARD: number;
  92836. /**
  92837. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92838. * to other engines rendering to increase portability.
  92839. */
  92840. static readonly TONEMAPPING_ACES: number;
  92841. /**
  92842. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92843. */
  92844. colorCurves: Nullable<ColorCurves>;
  92845. private _colorCurvesEnabled;
  92846. /**
  92847. * Gets wether the color curves effect is enabled.
  92848. */
  92849. get colorCurvesEnabled(): boolean;
  92850. /**
  92851. * Sets wether the color curves effect is enabled.
  92852. */
  92853. set colorCurvesEnabled(value: boolean);
  92854. private _colorGradingTexture;
  92855. /**
  92856. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92857. */
  92858. get colorGradingTexture(): Nullable<BaseTexture>;
  92859. /**
  92860. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92861. */
  92862. set colorGradingTexture(value: Nullable<BaseTexture>);
  92863. private _colorGradingEnabled;
  92864. /**
  92865. * Gets wether the color grading effect is enabled.
  92866. */
  92867. get colorGradingEnabled(): boolean;
  92868. /**
  92869. * Sets wether the color grading effect is enabled.
  92870. */
  92871. set colorGradingEnabled(value: boolean);
  92872. private _colorGradingWithGreenDepth;
  92873. /**
  92874. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92875. */
  92876. get colorGradingWithGreenDepth(): boolean;
  92877. /**
  92878. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92879. */
  92880. set colorGradingWithGreenDepth(value: boolean);
  92881. private _colorGradingBGR;
  92882. /**
  92883. * Gets wether the color grading texture contains BGR values.
  92884. */
  92885. get colorGradingBGR(): boolean;
  92886. /**
  92887. * Sets wether the color grading texture contains BGR values.
  92888. */
  92889. set colorGradingBGR(value: boolean);
  92890. /** @hidden */
  92891. _exposure: number;
  92892. /**
  92893. * Gets the Exposure used in the effect.
  92894. */
  92895. get exposure(): number;
  92896. /**
  92897. * Sets the Exposure used in the effect.
  92898. */
  92899. set exposure(value: number);
  92900. private _toneMappingEnabled;
  92901. /**
  92902. * Gets wether the tone mapping effect is enabled.
  92903. */
  92904. get toneMappingEnabled(): boolean;
  92905. /**
  92906. * Sets wether the tone mapping effect is enabled.
  92907. */
  92908. set toneMappingEnabled(value: boolean);
  92909. private _toneMappingType;
  92910. /**
  92911. * Gets the type of tone mapping effect.
  92912. */
  92913. get toneMappingType(): number;
  92914. /**
  92915. * Sets the type of tone mapping effect used in BabylonJS.
  92916. */
  92917. set toneMappingType(value: number);
  92918. protected _contrast: number;
  92919. /**
  92920. * Gets the contrast used in the effect.
  92921. */
  92922. get contrast(): number;
  92923. /**
  92924. * Sets the contrast used in the effect.
  92925. */
  92926. set contrast(value: number);
  92927. /**
  92928. * Vignette stretch size.
  92929. */
  92930. vignetteStretch: number;
  92931. /**
  92932. * Vignette centre X Offset.
  92933. */
  92934. vignetteCentreX: number;
  92935. /**
  92936. * Vignette centre Y Offset.
  92937. */
  92938. vignetteCentreY: number;
  92939. /**
  92940. * Vignette weight or intensity of the vignette effect.
  92941. */
  92942. vignetteWeight: number;
  92943. /**
  92944. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  92945. * if vignetteEnabled is set to true.
  92946. */
  92947. vignetteColor: Color4;
  92948. /**
  92949. * Camera field of view used by the Vignette effect.
  92950. */
  92951. vignetteCameraFov: number;
  92952. private _vignetteBlendMode;
  92953. /**
  92954. * Gets the vignette blend mode allowing different kind of effect.
  92955. */
  92956. get vignetteBlendMode(): number;
  92957. /**
  92958. * Sets the vignette blend mode allowing different kind of effect.
  92959. */
  92960. set vignetteBlendMode(value: number);
  92961. private _vignetteEnabled;
  92962. /**
  92963. * Gets wether the vignette effect is enabled.
  92964. */
  92965. get vignetteEnabled(): boolean;
  92966. /**
  92967. * Sets wether the vignette effect is enabled.
  92968. */
  92969. set vignetteEnabled(value: boolean);
  92970. private _applyByPostProcess;
  92971. /**
  92972. * Gets wether the image processing is applied through a post process or not.
  92973. */
  92974. get applyByPostProcess(): boolean;
  92975. /**
  92976. * Sets wether the image processing is applied through a post process or not.
  92977. */
  92978. set applyByPostProcess(value: boolean);
  92979. private _isEnabled;
  92980. /**
  92981. * Gets wether the image processing is enabled or not.
  92982. */
  92983. get isEnabled(): boolean;
  92984. /**
  92985. * Sets wether the image processing is enabled or not.
  92986. */
  92987. set isEnabled(value: boolean);
  92988. /**
  92989. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  92990. */
  92991. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  92992. /**
  92993. * Method called each time the image processing information changes requires to recompile the effect.
  92994. */
  92995. protected _updateParameters(): void;
  92996. /**
  92997. * Gets the current class name.
  92998. * @return "ImageProcessingConfiguration"
  92999. */
  93000. getClassName(): string;
  93001. /**
  93002. * Prepare the list of uniforms associated with the Image Processing effects.
  93003. * @param uniforms The list of uniforms used in the effect
  93004. * @param defines the list of defines currently in use
  93005. */
  93006. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  93007. /**
  93008. * Prepare the list of samplers associated with the Image Processing effects.
  93009. * @param samplersList The list of uniforms used in the effect
  93010. * @param defines the list of defines currently in use
  93011. */
  93012. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  93013. /**
  93014. * Prepare the list of defines associated to the shader.
  93015. * @param defines the list of defines to complete
  93016. * @param forPostProcess Define if we are currently in post process mode or not
  93017. */
  93018. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  93019. /**
  93020. * Returns true if all the image processing information are ready.
  93021. * @returns True if ready, otherwise, false
  93022. */
  93023. isReady(): boolean;
  93024. /**
  93025. * Binds the image processing to the shader.
  93026. * @param effect The effect to bind to
  93027. * @param overrideAspectRatio Override the aspect ratio of the effect
  93028. */
  93029. bind(effect: Effect, overrideAspectRatio?: number): void;
  93030. /**
  93031. * Clones the current image processing instance.
  93032. * @return The cloned image processing
  93033. */
  93034. clone(): ImageProcessingConfiguration;
  93035. /**
  93036. * Serializes the current image processing instance to a json representation.
  93037. * @return a JSON representation
  93038. */
  93039. serialize(): any;
  93040. /**
  93041. * Parses the image processing from a json representation.
  93042. * @param source the JSON source to parse
  93043. * @return The parsed image processing
  93044. */
  93045. static Parse(source: any): ImageProcessingConfiguration;
  93046. private static _VIGNETTEMODE_MULTIPLY;
  93047. private static _VIGNETTEMODE_OPAQUE;
  93048. /**
  93049. * Used to apply the vignette as a mix with the pixel color.
  93050. */
  93051. static get VIGNETTEMODE_MULTIPLY(): number;
  93052. /**
  93053. * Used to apply the vignette as a replacement of the pixel color.
  93054. */
  93055. static get VIGNETTEMODE_OPAQUE(): number;
  93056. }
  93057. }
  93058. declare module BABYLON {
  93059. /** @hidden */
  93060. export var postprocessVertexShader: {
  93061. name: string;
  93062. shader: string;
  93063. };
  93064. }
  93065. declare module BABYLON {
  93066. /**
  93067. * Type used to define a render target texture size (either with a number or with a rect width and height)
  93068. */
  93069. export type RenderTargetTextureSize = number | {
  93070. width: number;
  93071. height: number;
  93072. layers?: number;
  93073. };
  93074. interface ThinEngine {
  93075. /**
  93076. * Creates a new render target texture
  93077. * @param size defines the size of the texture
  93078. * @param options defines the options used to create the texture
  93079. * @returns a new render target texture stored in an InternalTexture
  93080. */
  93081. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  93082. /**
  93083. * Creates a depth stencil texture.
  93084. * This is only available in WebGL 2 or with the depth texture extension available.
  93085. * @param size The size of face edge in the texture.
  93086. * @param options The options defining the texture.
  93087. * @returns The texture
  93088. */
  93089. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  93090. /** @hidden */
  93091. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  93092. }
  93093. }
  93094. declare module BABYLON {
  93095. /**
  93096. * Defines the kind of connection point for node based material
  93097. */
  93098. export enum NodeMaterialBlockConnectionPointTypes {
  93099. /** Float */
  93100. Float = 1,
  93101. /** Int */
  93102. Int = 2,
  93103. /** Vector2 */
  93104. Vector2 = 4,
  93105. /** Vector3 */
  93106. Vector3 = 8,
  93107. /** Vector4 */
  93108. Vector4 = 16,
  93109. /** Color3 */
  93110. Color3 = 32,
  93111. /** Color4 */
  93112. Color4 = 64,
  93113. /** Matrix */
  93114. Matrix = 128,
  93115. /** Custom object */
  93116. Object = 256,
  93117. /** Detect type based on connection */
  93118. AutoDetect = 1024,
  93119. /** Output type that will be defined by input type */
  93120. BasedOnInput = 2048
  93121. }
  93122. }
  93123. declare module BABYLON {
  93124. /**
  93125. * Enum used to define the target of a block
  93126. */
  93127. export enum NodeMaterialBlockTargets {
  93128. /** Vertex shader */
  93129. Vertex = 1,
  93130. /** Fragment shader */
  93131. Fragment = 2,
  93132. /** Neutral */
  93133. Neutral = 4,
  93134. /** Vertex and Fragment */
  93135. VertexAndFragment = 3
  93136. }
  93137. }
  93138. declare module BABYLON {
  93139. /**
  93140. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  93141. */
  93142. export enum NodeMaterialBlockConnectionPointMode {
  93143. /** Value is an uniform */
  93144. Uniform = 0,
  93145. /** Value is a mesh attribute */
  93146. Attribute = 1,
  93147. /** Value is a varying between vertex and fragment shaders */
  93148. Varying = 2,
  93149. /** Mode is undefined */
  93150. Undefined = 3
  93151. }
  93152. }
  93153. declare module BABYLON {
  93154. /**
  93155. * Enum used to define system values e.g. values automatically provided by the system
  93156. */
  93157. export enum NodeMaterialSystemValues {
  93158. /** World */
  93159. World = 1,
  93160. /** View */
  93161. View = 2,
  93162. /** Projection */
  93163. Projection = 3,
  93164. /** ViewProjection */
  93165. ViewProjection = 4,
  93166. /** WorldView */
  93167. WorldView = 5,
  93168. /** WorldViewProjection */
  93169. WorldViewProjection = 6,
  93170. /** CameraPosition */
  93171. CameraPosition = 7,
  93172. /** Fog Color */
  93173. FogColor = 8,
  93174. /** Delta time */
  93175. DeltaTime = 9
  93176. }
  93177. }
  93178. declare module BABYLON {
  93179. /**
  93180. * Represents a camera frustum
  93181. */
  93182. export class Frustum {
  93183. /**
  93184. * Gets the planes representing the frustum
  93185. * @param transform matrix to be applied to the returned planes
  93186. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  93187. */
  93188. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  93189. /**
  93190. * Gets the near frustum plane transformed by the transform matrix
  93191. * @param transform transformation matrix to be applied to the resulting frustum plane
  93192. * @param frustumPlane the resuling frustum plane
  93193. */
  93194. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93195. /**
  93196. * Gets the far frustum plane transformed by the transform matrix
  93197. * @param transform transformation matrix to be applied to the resulting frustum plane
  93198. * @param frustumPlane the resuling frustum plane
  93199. */
  93200. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93201. /**
  93202. * Gets the left frustum plane transformed by the transform matrix
  93203. * @param transform transformation matrix to be applied to the resulting frustum plane
  93204. * @param frustumPlane the resuling frustum plane
  93205. */
  93206. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93207. /**
  93208. * Gets the right frustum plane transformed by the transform matrix
  93209. * @param transform transformation matrix to be applied to the resulting frustum plane
  93210. * @param frustumPlane the resuling frustum plane
  93211. */
  93212. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93213. /**
  93214. * Gets the top frustum plane transformed by the transform matrix
  93215. * @param transform transformation matrix to be applied to the resulting frustum plane
  93216. * @param frustumPlane the resuling frustum plane
  93217. */
  93218. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93219. /**
  93220. * Gets the bottom frustum plane transformed by the transform matrix
  93221. * @param transform transformation matrix to be applied to the resulting frustum plane
  93222. * @param frustumPlane the resuling frustum plane
  93223. */
  93224. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93225. /**
  93226. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  93227. * @param transform transformation matrix to be applied to the resulting frustum planes
  93228. * @param frustumPlanes the resuling frustum planes
  93229. */
  93230. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  93231. }
  93232. }
  93233. declare module BABYLON {
  93234. /**
  93235. * Contains position and normal vectors for a vertex
  93236. */
  93237. export class PositionNormalVertex {
  93238. /** the position of the vertex (defaut: 0,0,0) */
  93239. position: Vector3;
  93240. /** the normal of the vertex (defaut: 0,1,0) */
  93241. normal: Vector3;
  93242. /**
  93243. * Creates a PositionNormalVertex
  93244. * @param position the position of the vertex (defaut: 0,0,0)
  93245. * @param normal the normal of the vertex (defaut: 0,1,0)
  93246. */
  93247. constructor(
  93248. /** the position of the vertex (defaut: 0,0,0) */
  93249. position?: Vector3,
  93250. /** the normal of the vertex (defaut: 0,1,0) */
  93251. normal?: Vector3);
  93252. /**
  93253. * Clones the PositionNormalVertex
  93254. * @returns the cloned PositionNormalVertex
  93255. */
  93256. clone(): PositionNormalVertex;
  93257. }
  93258. /**
  93259. * Contains position, normal and uv vectors for a vertex
  93260. */
  93261. export class PositionNormalTextureVertex {
  93262. /** the position of the vertex (defaut: 0,0,0) */
  93263. position: Vector3;
  93264. /** the normal of the vertex (defaut: 0,1,0) */
  93265. normal: Vector3;
  93266. /** the uv of the vertex (default: 0,0) */
  93267. uv: Vector2;
  93268. /**
  93269. * Creates a PositionNormalTextureVertex
  93270. * @param position the position of the vertex (defaut: 0,0,0)
  93271. * @param normal the normal of the vertex (defaut: 0,1,0)
  93272. * @param uv the uv of the vertex (default: 0,0)
  93273. */
  93274. constructor(
  93275. /** the position of the vertex (defaut: 0,0,0) */
  93276. position?: Vector3,
  93277. /** the normal of the vertex (defaut: 0,1,0) */
  93278. normal?: Vector3,
  93279. /** the uv of the vertex (default: 0,0) */
  93280. uv?: Vector2);
  93281. /**
  93282. * Clones the PositionNormalTextureVertex
  93283. * @returns the cloned PositionNormalTextureVertex
  93284. */
  93285. clone(): PositionNormalTextureVertex;
  93286. }
  93287. }
  93288. declare module BABYLON {
  93289. /**
  93290. * Enum defining the type of animations supported by InputBlock
  93291. */
  93292. export enum AnimatedInputBlockTypes {
  93293. /** No animation */
  93294. None = 0,
  93295. /** Time based animation. Will only work for floats */
  93296. Time = 1
  93297. }
  93298. }
  93299. declare module BABYLON {
  93300. /**
  93301. * Block used to expose an input value
  93302. */
  93303. export class InputBlock extends NodeMaterialBlock {
  93304. private _mode;
  93305. private _associatedVariableName;
  93306. private _storedValue;
  93307. private _valueCallback;
  93308. private _type;
  93309. private _animationType;
  93310. /** Gets or set a value used to limit the range of float values */
  93311. min: number;
  93312. /** Gets or set a value used to limit the range of float values */
  93313. max: number;
  93314. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  93315. isBoolean: boolean;
  93316. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  93317. matrixMode: number;
  93318. /** @hidden */
  93319. _systemValue: Nullable<NodeMaterialSystemValues>;
  93320. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  93321. isConstant: boolean;
  93322. /** Gets or sets the group to use to display this block in the Inspector */
  93323. groupInInspector: string;
  93324. /** Gets an observable raised when the value is changed */
  93325. onValueChangedObservable: Observable<InputBlock>;
  93326. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  93327. convertToGammaSpace: boolean;
  93328. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  93329. convertToLinearSpace: boolean;
  93330. /**
  93331. * Gets or sets the connection point type (default is float)
  93332. */
  93333. get type(): NodeMaterialBlockConnectionPointTypes;
  93334. /**
  93335. * Creates a new InputBlock
  93336. * @param name defines the block name
  93337. * @param target defines the target of that block (Vertex by default)
  93338. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  93339. */
  93340. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  93341. /**
  93342. * Validates if a name is a reserve word.
  93343. * @param newName the new name to be given to the node.
  93344. * @returns false if the name is a reserve word, else true.
  93345. */
  93346. validateBlockName(newName: string): boolean;
  93347. /**
  93348. * Gets the output component
  93349. */
  93350. get output(): NodeMaterialConnectionPoint;
  93351. /**
  93352. * Set the source of this connection point to a vertex attribute
  93353. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  93354. * @returns the current connection point
  93355. */
  93356. setAsAttribute(attributeName?: string): InputBlock;
  93357. /**
  93358. * Set the source of this connection point to a system value
  93359. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  93360. * @returns the current connection point
  93361. */
  93362. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  93363. /**
  93364. * Gets or sets the value of that point.
  93365. * Please note that this value will be ignored if valueCallback is defined
  93366. */
  93367. get value(): any;
  93368. set value(value: any);
  93369. /**
  93370. * Gets or sets a callback used to get the value of that point.
  93371. * Please note that setting this value will force the connection point to ignore the value property
  93372. */
  93373. get valueCallback(): () => any;
  93374. set valueCallback(value: () => any);
  93375. /**
  93376. * Gets or sets the associated variable name in the shader
  93377. */
  93378. get associatedVariableName(): string;
  93379. set associatedVariableName(value: string);
  93380. /** Gets or sets the type of animation applied to the input */
  93381. get animationType(): AnimatedInputBlockTypes;
  93382. set animationType(value: AnimatedInputBlockTypes);
  93383. /**
  93384. * Gets a boolean indicating that this connection point not defined yet
  93385. */
  93386. get isUndefined(): boolean;
  93387. /**
  93388. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  93389. * In this case the connection point name must be the name of the uniform to use.
  93390. * Can only be set on inputs
  93391. */
  93392. get isUniform(): boolean;
  93393. set isUniform(value: boolean);
  93394. /**
  93395. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  93396. * In this case the connection point name must be the name of the attribute to use
  93397. * Can only be set on inputs
  93398. */
  93399. get isAttribute(): boolean;
  93400. set isAttribute(value: boolean);
  93401. /**
  93402. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  93403. * Can only be set on exit points
  93404. */
  93405. get isVarying(): boolean;
  93406. set isVarying(value: boolean);
  93407. /**
  93408. * Gets a boolean indicating that the current connection point is a system value
  93409. */
  93410. get isSystemValue(): boolean;
  93411. /**
  93412. * Gets or sets the current well known value or null if not defined as a system value
  93413. */
  93414. get systemValue(): Nullable<NodeMaterialSystemValues>;
  93415. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  93416. /**
  93417. * Gets the current class name
  93418. * @returns the class name
  93419. */
  93420. getClassName(): string;
  93421. /**
  93422. * Animate the input if animationType !== None
  93423. * @param scene defines the rendering scene
  93424. */
  93425. animate(scene: Scene): void;
  93426. private _emitDefine;
  93427. initialize(state: NodeMaterialBuildState): void;
  93428. /**
  93429. * Set the input block to its default value (based on its type)
  93430. */
  93431. setDefaultValue(): void;
  93432. private _emitConstant;
  93433. /** @hidden */
  93434. get _noContextSwitch(): boolean;
  93435. private _emit;
  93436. /** @hidden */
  93437. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  93438. /** @hidden */
  93439. _transmit(effect: Effect, scene: Scene): void;
  93440. protected _buildBlock(state: NodeMaterialBuildState): void;
  93441. protected _dumpPropertiesCode(): string;
  93442. dispose(): void;
  93443. serialize(): any;
  93444. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93445. }
  93446. }
  93447. declare module BABYLON {
  93448. /**
  93449. * Enum used to define the compatibility state between two connection points
  93450. */
  93451. export enum NodeMaterialConnectionPointCompatibilityStates {
  93452. /** Points are compatibles */
  93453. Compatible = 0,
  93454. /** Points are incompatible because of their types */
  93455. TypeIncompatible = 1,
  93456. /** Points are incompatible because of their targets (vertex vs fragment) */
  93457. TargetIncompatible = 2
  93458. }
  93459. /**
  93460. * Defines the direction of a connection point
  93461. */
  93462. export enum NodeMaterialConnectionPointDirection {
  93463. /** Input */
  93464. Input = 0,
  93465. /** Output */
  93466. Output = 1
  93467. }
  93468. /**
  93469. * Defines a connection point for a block
  93470. */
  93471. export class NodeMaterialConnectionPoint {
  93472. /**
  93473. * Checks if two types are equivalent
  93474. * @param type1 type 1 to check
  93475. * @param type2 type 2 to check
  93476. * @returns true if both types are equivalent, else false
  93477. */
  93478. static AreEquivalentTypes(type1: number, type2: number): boolean;
  93479. /** @hidden */
  93480. _ownerBlock: NodeMaterialBlock;
  93481. /** @hidden */
  93482. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  93483. private _endpoints;
  93484. private _associatedVariableName;
  93485. private _direction;
  93486. /** @hidden */
  93487. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  93488. /** @hidden */
  93489. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  93490. /** @hidden */
  93491. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  93492. private _type;
  93493. /** @hidden */
  93494. _enforceAssociatedVariableName: boolean;
  93495. /** Gets the direction of the point */
  93496. get direction(): NodeMaterialConnectionPointDirection;
  93497. /** Indicates that this connection point needs dual validation before being connected to another point */
  93498. needDualDirectionValidation: boolean;
  93499. /**
  93500. * Gets or sets the additional types supported by this connection point
  93501. */
  93502. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  93503. /**
  93504. * Gets or sets the additional types excluded by this connection point
  93505. */
  93506. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  93507. /**
  93508. * Observable triggered when this point is connected
  93509. */
  93510. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  93511. /**
  93512. * Gets or sets the associated variable name in the shader
  93513. */
  93514. get associatedVariableName(): string;
  93515. set associatedVariableName(value: string);
  93516. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  93517. get innerType(): NodeMaterialBlockConnectionPointTypes;
  93518. /**
  93519. * Gets or sets the connection point type (default is float)
  93520. */
  93521. get type(): NodeMaterialBlockConnectionPointTypes;
  93522. set type(value: NodeMaterialBlockConnectionPointTypes);
  93523. /**
  93524. * Gets or sets the connection point name
  93525. */
  93526. name: string;
  93527. /**
  93528. * Gets or sets the connection point name
  93529. */
  93530. displayName: string;
  93531. /**
  93532. * Gets or sets a boolean indicating that this connection point can be omitted
  93533. */
  93534. isOptional: boolean;
  93535. /**
  93536. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  93537. */
  93538. isExposedOnFrame: boolean;
  93539. /**
  93540. * Gets or sets number indicating the position that the port is exposed to on a frame
  93541. */
  93542. exposedPortPosition: number;
  93543. /**
  93544. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  93545. */
  93546. define: string;
  93547. /** @hidden */
  93548. _prioritizeVertex: boolean;
  93549. private _target;
  93550. /** Gets or sets the target of that connection point */
  93551. get target(): NodeMaterialBlockTargets;
  93552. set target(value: NodeMaterialBlockTargets);
  93553. /**
  93554. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  93555. */
  93556. get isConnected(): boolean;
  93557. /**
  93558. * Gets a boolean indicating that the current point is connected to an input block
  93559. */
  93560. get isConnectedToInputBlock(): boolean;
  93561. /**
  93562. * Gets a the connected input block (if any)
  93563. */
  93564. get connectInputBlock(): Nullable<InputBlock>;
  93565. /** Get the other side of the connection (if any) */
  93566. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  93567. /** Get the block that owns this connection point */
  93568. get ownerBlock(): NodeMaterialBlock;
  93569. /** Get the block connected on the other side of this connection (if any) */
  93570. get sourceBlock(): Nullable<NodeMaterialBlock>;
  93571. /** Get the block connected on the endpoints of this connection (if any) */
  93572. get connectedBlocks(): Array<NodeMaterialBlock>;
  93573. /** Gets the list of connected endpoints */
  93574. get endpoints(): NodeMaterialConnectionPoint[];
  93575. /** Gets a boolean indicating if that output point is connected to at least one input */
  93576. get hasEndpoints(): boolean;
  93577. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  93578. get isConnectedInVertexShader(): boolean;
  93579. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  93580. get isConnectedInFragmentShader(): boolean;
  93581. /**
  93582. * Creates a block suitable to be used as an input for this input point.
  93583. * If null is returned, a block based on the point type will be created.
  93584. * @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
  93585. */
  93586. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  93587. /**
  93588. * Creates a new connection point
  93589. * @param name defines the connection point name
  93590. * @param ownerBlock defines the block hosting this connection point
  93591. * @param direction defines the direction of the connection point
  93592. */
  93593. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  93594. /**
  93595. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  93596. * @returns the class name
  93597. */
  93598. getClassName(): string;
  93599. /**
  93600. * Gets a boolean indicating if the current point can be connected to another point
  93601. * @param connectionPoint defines the other connection point
  93602. * @returns a boolean
  93603. */
  93604. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  93605. /**
  93606. * Gets a number indicating if the current point can be connected to another point
  93607. * @param connectionPoint defines the other connection point
  93608. * @returns a number defining the compatibility state
  93609. */
  93610. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  93611. /**
  93612. * Connect this point to another connection point
  93613. * @param connectionPoint defines the other connection point
  93614. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  93615. * @returns the current connection point
  93616. */
  93617. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  93618. /**
  93619. * Disconnect this point from one of his endpoint
  93620. * @param endpoint defines the other connection point
  93621. * @returns the current connection point
  93622. */
  93623. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  93624. /**
  93625. * Serializes this point in a JSON representation
  93626. * @param isInput defines if the connection point is an input (default is true)
  93627. * @returns the serialized point object
  93628. */
  93629. serialize(isInput?: boolean): any;
  93630. /**
  93631. * Release resources
  93632. */
  93633. dispose(): void;
  93634. }
  93635. }
  93636. declare module BABYLON {
  93637. /**
  93638. * Enum used to define the material modes
  93639. */
  93640. export enum NodeMaterialModes {
  93641. /** Regular material */
  93642. Material = 0,
  93643. /** For post process */
  93644. PostProcess = 1,
  93645. /** For particle system */
  93646. Particle = 2,
  93647. /** For procedural texture */
  93648. ProceduralTexture = 3
  93649. }
  93650. }
  93651. declare module BABYLON {
  93652. /** @hidden */
  93653. export var helperFunctions: {
  93654. name: string;
  93655. shader: string;
  93656. };
  93657. }
  93658. declare module BABYLON {
  93659. /**
  93660. * Block used to read a texture from a sampler
  93661. */
  93662. export class TextureBlock extends NodeMaterialBlock {
  93663. private _defineName;
  93664. private _linearDefineName;
  93665. private _gammaDefineName;
  93666. private _tempTextureRead;
  93667. private _samplerName;
  93668. private _transformedUVName;
  93669. private _textureTransformName;
  93670. private _textureInfoName;
  93671. private _mainUVName;
  93672. private _mainUVDefineName;
  93673. private _fragmentOnly;
  93674. /**
  93675. * Gets or sets the texture associated with the node
  93676. */
  93677. texture: Nullable<Texture>;
  93678. /**
  93679. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  93680. */
  93681. convertToGammaSpace: boolean;
  93682. /**
  93683. * Gets or sets a boolean indicating if content needs to be converted to linear space
  93684. */
  93685. convertToLinearSpace: boolean;
  93686. /**
  93687. * Create a new TextureBlock
  93688. * @param name defines the block name
  93689. */
  93690. constructor(name: string, fragmentOnly?: boolean);
  93691. /**
  93692. * Gets the current class name
  93693. * @returns the class name
  93694. */
  93695. getClassName(): string;
  93696. /**
  93697. * Gets the uv input component
  93698. */
  93699. get uv(): NodeMaterialConnectionPoint;
  93700. /**
  93701. * Gets the rgba output component
  93702. */
  93703. get rgba(): NodeMaterialConnectionPoint;
  93704. /**
  93705. * Gets the rgb output component
  93706. */
  93707. get rgb(): NodeMaterialConnectionPoint;
  93708. /**
  93709. * Gets the r output component
  93710. */
  93711. get r(): NodeMaterialConnectionPoint;
  93712. /**
  93713. * Gets the g output component
  93714. */
  93715. get g(): NodeMaterialConnectionPoint;
  93716. /**
  93717. * Gets the b output component
  93718. */
  93719. get b(): NodeMaterialConnectionPoint;
  93720. /**
  93721. * Gets the a output component
  93722. */
  93723. get a(): NodeMaterialConnectionPoint;
  93724. get target(): NodeMaterialBlockTargets;
  93725. autoConfigure(material: NodeMaterial): void;
  93726. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  93727. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  93728. isReady(): boolean;
  93729. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  93730. private get _isMixed();
  93731. private _injectVertexCode;
  93732. private _writeTextureRead;
  93733. private _writeOutput;
  93734. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  93735. protected _dumpPropertiesCode(): string;
  93736. serialize(): any;
  93737. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93738. }
  93739. }
  93740. declare module BABYLON {
  93741. /** @hidden */
  93742. export var reflectionFunction: {
  93743. name: string;
  93744. shader: string;
  93745. };
  93746. }
  93747. declare module BABYLON {
  93748. /**
  93749. * Base block used to read a reflection texture from a sampler
  93750. */
  93751. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  93752. /** @hidden */
  93753. _define3DName: string;
  93754. /** @hidden */
  93755. _defineCubicName: string;
  93756. /** @hidden */
  93757. _defineExplicitName: string;
  93758. /** @hidden */
  93759. _defineProjectionName: string;
  93760. /** @hidden */
  93761. _defineLocalCubicName: string;
  93762. /** @hidden */
  93763. _defineSphericalName: string;
  93764. /** @hidden */
  93765. _definePlanarName: string;
  93766. /** @hidden */
  93767. _defineEquirectangularName: string;
  93768. /** @hidden */
  93769. _defineMirroredEquirectangularFixedName: string;
  93770. /** @hidden */
  93771. _defineEquirectangularFixedName: string;
  93772. /** @hidden */
  93773. _defineSkyboxName: string;
  93774. /** @hidden */
  93775. _defineOppositeZ: string;
  93776. /** @hidden */
  93777. _cubeSamplerName: string;
  93778. /** @hidden */
  93779. _2DSamplerName: string;
  93780. protected _positionUVWName: string;
  93781. protected _directionWName: string;
  93782. protected _reflectionVectorName: string;
  93783. /** @hidden */
  93784. _reflectionCoordsName: string;
  93785. /** @hidden */
  93786. _reflectionMatrixName: string;
  93787. protected _reflectionColorName: string;
  93788. /**
  93789. * Gets or sets the texture associated with the node
  93790. */
  93791. texture: Nullable<BaseTexture>;
  93792. /**
  93793. * Create a new ReflectionTextureBaseBlock
  93794. * @param name defines the block name
  93795. */
  93796. constructor(name: string);
  93797. /**
  93798. * Gets the current class name
  93799. * @returns the class name
  93800. */
  93801. getClassName(): string;
  93802. /**
  93803. * Gets the world position input component
  93804. */
  93805. abstract get position(): NodeMaterialConnectionPoint;
  93806. /**
  93807. * Gets the world position input component
  93808. */
  93809. abstract get worldPosition(): NodeMaterialConnectionPoint;
  93810. /**
  93811. * Gets the world normal input component
  93812. */
  93813. abstract get worldNormal(): NodeMaterialConnectionPoint;
  93814. /**
  93815. * Gets the world input component
  93816. */
  93817. abstract get world(): NodeMaterialConnectionPoint;
  93818. /**
  93819. * Gets the camera (or eye) position component
  93820. */
  93821. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  93822. /**
  93823. * Gets the view input component
  93824. */
  93825. abstract get view(): NodeMaterialConnectionPoint;
  93826. protected _getTexture(): Nullable<BaseTexture>;
  93827. autoConfigure(material: NodeMaterial): void;
  93828. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  93829. isReady(): boolean;
  93830. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  93831. /**
  93832. * Gets the code to inject in the vertex shader
  93833. * @param state current state of the node material building
  93834. * @returns the shader code
  93835. */
  93836. handleVertexSide(state: NodeMaterialBuildState): string;
  93837. /**
  93838. * Handles the inits for the fragment code path
  93839. * @param state node material build state
  93840. */
  93841. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  93842. /**
  93843. * Generates the reflection coords code for the fragment code path
  93844. * @param worldNormalVarName name of the world normal variable
  93845. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  93846. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  93847. * @returns the shader code
  93848. */
  93849. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  93850. /**
  93851. * Generates the reflection color code for the fragment code path
  93852. * @param lodVarName name of the lod variable
  93853. * @param swizzleLookupTexture swizzle to use for the final color variable
  93854. * @returns the shader code
  93855. */
  93856. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  93857. /**
  93858. * Generates the code corresponding to the connected output points
  93859. * @param state node material build state
  93860. * @param varName name of the variable to output
  93861. * @returns the shader code
  93862. */
  93863. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  93864. protected _buildBlock(state: NodeMaterialBuildState): this;
  93865. protected _dumpPropertiesCode(): string;
  93866. serialize(): any;
  93867. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93868. }
  93869. }
  93870. declare module BABYLON {
  93871. /**
  93872. * Defines a connection point to be used for points with a custom object type
  93873. */
  93874. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  93875. private _blockType;
  93876. private _blockName;
  93877. private _nameForCheking?;
  93878. /**
  93879. * Creates a new connection point
  93880. * @param name defines the connection point name
  93881. * @param ownerBlock defines the block hosting this connection point
  93882. * @param direction defines the direction of the connection point
  93883. */
  93884. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  93885. /**
  93886. * Gets a number indicating if the current point can be connected to another point
  93887. * @param connectionPoint defines the other connection point
  93888. * @returns a number defining the compatibility state
  93889. */
  93890. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  93891. /**
  93892. * Creates a block suitable to be used as an input for this input point.
  93893. * If null is returned, a block based on the point type will be created.
  93894. * @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
  93895. */
  93896. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  93897. }
  93898. }
  93899. declare module BABYLON {
  93900. /**
  93901. * Enum defining the type of properties that can be edited in the property pages in the NME
  93902. */
  93903. export enum PropertyTypeForEdition {
  93904. /** property is a boolean */
  93905. Boolean = 0,
  93906. /** property is a float */
  93907. Float = 1,
  93908. /** property is a Vector2 */
  93909. Vector2 = 2,
  93910. /** property is a list of values */
  93911. List = 3
  93912. }
  93913. /**
  93914. * Interface that defines an option in a variable of type list
  93915. */
  93916. export interface IEditablePropertyListOption {
  93917. /** label of the option */
  93918. "label": string;
  93919. /** value of the option */
  93920. "value": number;
  93921. }
  93922. /**
  93923. * Interface that defines the options available for an editable property
  93924. */
  93925. export interface IEditablePropertyOption {
  93926. /** min value */
  93927. "min"?: number;
  93928. /** max value */
  93929. "max"?: number;
  93930. /** notifiers: indicates which actions to take when the property is changed */
  93931. "notifiers"?: {
  93932. /** the material should be rebuilt */
  93933. "rebuild"?: boolean;
  93934. /** the preview should be updated */
  93935. "update"?: boolean;
  93936. };
  93937. /** list of the options for a variable of type list */
  93938. "options"?: IEditablePropertyListOption[];
  93939. }
  93940. /**
  93941. * Interface that describes an editable property
  93942. */
  93943. export interface IPropertyDescriptionForEdition {
  93944. /** name of the property */
  93945. "propertyName": string;
  93946. /** display name of the property */
  93947. "displayName": string;
  93948. /** type of the property */
  93949. "type": PropertyTypeForEdition;
  93950. /** group of the property - all properties with the same group value will be displayed in a specific section */
  93951. "groupName": string;
  93952. /** options for the property */
  93953. "options": IEditablePropertyOption;
  93954. }
  93955. /**
  93956. * Decorator that flags a property in a node material block as being editable
  93957. */
  93958. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  93959. }
  93960. declare module BABYLON {
  93961. /**
  93962. * Block used to implement the refraction part of the sub surface module of the PBR material
  93963. */
  93964. export class RefractionBlock extends NodeMaterialBlock {
  93965. /** @hidden */
  93966. _define3DName: string;
  93967. /** @hidden */
  93968. _refractionMatrixName: string;
  93969. /** @hidden */
  93970. _defineLODRefractionAlpha: string;
  93971. /** @hidden */
  93972. _defineLinearSpecularRefraction: string;
  93973. /** @hidden */
  93974. _defineOppositeZ: string;
  93975. /** @hidden */
  93976. _cubeSamplerName: string;
  93977. /** @hidden */
  93978. _2DSamplerName: string;
  93979. /** @hidden */
  93980. _vRefractionMicrosurfaceInfosName: string;
  93981. /** @hidden */
  93982. _vRefractionInfosName: string;
  93983. private _scene;
  93984. /**
  93985. * The properties below are set by the main PBR block prior to calling methods of this class.
  93986. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  93987. * It's less burden on the user side in the editor part.
  93988. */
  93989. /** @hidden */
  93990. viewConnectionPoint: NodeMaterialConnectionPoint;
  93991. /** @hidden */
  93992. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  93993. /**
  93994. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  93995. * Materials half opaque for instance using refraction could benefit from this control.
  93996. */
  93997. linkRefractionWithTransparency: boolean;
  93998. /**
  93999. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  94000. */
  94001. invertRefractionY: boolean;
  94002. /**
  94003. * Gets or sets the texture associated with the node
  94004. */
  94005. texture: Nullable<BaseTexture>;
  94006. /**
  94007. * Create a new RefractionBlock
  94008. * @param name defines the block name
  94009. */
  94010. constructor(name: string);
  94011. /**
  94012. * Gets the current class name
  94013. * @returns the class name
  94014. */
  94015. getClassName(): string;
  94016. /**
  94017. * Gets the intensity input component
  94018. */
  94019. get intensity(): NodeMaterialConnectionPoint;
  94020. /**
  94021. * Gets the tint at distance input component
  94022. */
  94023. get tintAtDistance(): NodeMaterialConnectionPoint;
  94024. /**
  94025. * Gets the view input component
  94026. */
  94027. get view(): NodeMaterialConnectionPoint;
  94028. /**
  94029. * Gets the refraction object output component
  94030. */
  94031. get refraction(): NodeMaterialConnectionPoint;
  94032. /**
  94033. * Returns true if the block has a texture
  94034. */
  94035. get hasTexture(): boolean;
  94036. protected _getTexture(): Nullable<BaseTexture>;
  94037. autoConfigure(material: NodeMaterial): void;
  94038. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94039. isReady(): boolean;
  94040. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  94041. /**
  94042. * Gets the main code of the block (fragment side)
  94043. * @param state current state of the node material building
  94044. * @returns the shader code
  94045. */
  94046. getCode(state: NodeMaterialBuildState): string;
  94047. protected _buildBlock(state: NodeMaterialBuildState): this;
  94048. protected _dumpPropertiesCode(): string;
  94049. serialize(): any;
  94050. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94051. }
  94052. }
  94053. declare module BABYLON {
  94054. /**
  94055. * Base block used as input for post process
  94056. */
  94057. export class CurrentScreenBlock extends NodeMaterialBlock {
  94058. private _samplerName;
  94059. private _linearDefineName;
  94060. private _gammaDefineName;
  94061. private _mainUVName;
  94062. private _tempTextureRead;
  94063. /**
  94064. * Gets or sets the texture associated with the node
  94065. */
  94066. texture: Nullable<BaseTexture>;
  94067. /**
  94068. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  94069. */
  94070. convertToGammaSpace: boolean;
  94071. /**
  94072. * Gets or sets a boolean indicating if content needs to be converted to linear space
  94073. */
  94074. convertToLinearSpace: boolean;
  94075. /**
  94076. * Create a new CurrentScreenBlock
  94077. * @param name defines the block name
  94078. */
  94079. constructor(name: string);
  94080. /**
  94081. * Gets the current class name
  94082. * @returns the class name
  94083. */
  94084. getClassName(): string;
  94085. /**
  94086. * Gets the uv input component
  94087. */
  94088. get uv(): NodeMaterialConnectionPoint;
  94089. /**
  94090. * Gets the rgba output component
  94091. */
  94092. get rgba(): NodeMaterialConnectionPoint;
  94093. /**
  94094. * Gets the rgb output component
  94095. */
  94096. get rgb(): NodeMaterialConnectionPoint;
  94097. /**
  94098. * Gets the r output component
  94099. */
  94100. get r(): NodeMaterialConnectionPoint;
  94101. /**
  94102. * Gets the g output component
  94103. */
  94104. get g(): NodeMaterialConnectionPoint;
  94105. /**
  94106. * Gets the b output component
  94107. */
  94108. get b(): NodeMaterialConnectionPoint;
  94109. /**
  94110. * Gets the a output component
  94111. */
  94112. get a(): NodeMaterialConnectionPoint;
  94113. /**
  94114. * Initialize the block and prepare the context for build
  94115. * @param state defines the state that will be used for the build
  94116. */
  94117. initialize(state: NodeMaterialBuildState): void;
  94118. get target(): NodeMaterialBlockTargets;
  94119. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94120. isReady(): boolean;
  94121. private _injectVertexCode;
  94122. private _writeTextureRead;
  94123. private _writeOutput;
  94124. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94125. serialize(): any;
  94126. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94127. }
  94128. }
  94129. declare module BABYLON {
  94130. /**
  94131. * Base block used for the particle texture
  94132. */
  94133. export class ParticleTextureBlock extends NodeMaterialBlock {
  94134. private _samplerName;
  94135. private _linearDefineName;
  94136. private _gammaDefineName;
  94137. private _tempTextureRead;
  94138. /**
  94139. * Gets or sets the texture associated with the node
  94140. */
  94141. texture: Nullable<BaseTexture>;
  94142. /**
  94143. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  94144. */
  94145. convertToGammaSpace: boolean;
  94146. /**
  94147. * Gets or sets a boolean indicating if content needs to be converted to linear space
  94148. */
  94149. convertToLinearSpace: boolean;
  94150. /**
  94151. * Create a new ParticleTextureBlock
  94152. * @param name defines the block name
  94153. */
  94154. constructor(name: string);
  94155. /**
  94156. * Gets the current class name
  94157. * @returns the class name
  94158. */
  94159. getClassName(): string;
  94160. /**
  94161. * Gets the uv input component
  94162. */
  94163. get uv(): NodeMaterialConnectionPoint;
  94164. /**
  94165. * Gets the rgba output component
  94166. */
  94167. get rgba(): NodeMaterialConnectionPoint;
  94168. /**
  94169. * Gets the rgb output component
  94170. */
  94171. get rgb(): NodeMaterialConnectionPoint;
  94172. /**
  94173. * Gets the r output component
  94174. */
  94175. get r(): NodeMaterialConnectionPoint;
  94176. /**
  94177. * Gets the g output component
  94178. */
  94179. get g(): NodeMaterialConnectionPoint;
  94180. /**
  94181. * Gets the b output component
  94182. */
  94183. get b(): NodeMaterialConnectionPoint;
  94184. /**
  94185. * Gets the a output component
  94186. */
  94187. get a(): NodeMaterialConnectionPoint;
  94188. /**
  94189. * Initialize the block and prepare the context for build
  94190. * @param state defines the state that will be used for the build
  94191. */
  94192. initialize(state: NodeMaterialBuildState): void;
  94193. autoConfigure(material: NodeMaterial): void;
  94194. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94195. isReady(): boolean;
  94196. private _writeOutput;
  94197. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94198. serialize(): any;
  94199. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94200. }
  94201. }
  94202. declare module BABYLON {
  94203. /**
  94204. * Class used to store shared data between 2 NodeMaterialBuildState
  94205. */
  94206. export class NodeMaterialBuildStateSharedData {
  94207. /**
  94208. * Gets the list of emitted varyings
  94209. */
  94210. temps: string[];
  94211. /**
  94212. * Gets the list of emitted varyings
  94213. */
  94214. varyings: string[];
  94215. /**
  94216. * Gets the varying declaration string
  94217. */
  94218. varyingDeclaration: string;
  94219. /**
  94220. * Input blocks
  94221. */
  94222. inputBlocks: InputBlock[];
  94223. /**
  94224. * Input blocks
  94225. */
  94226. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  94227. /**
  94228. * Bindable blocks (Blocks that need to set data to the effect)
  94229. */
  94230. bindableBlocks: NodeMaterialBlock[];
  94231. /**
  94232. * List of blocks that can provide a compilation fallback
  94233. */
  94234. blocksWithFallbacks: NodeMaterialBlock[];
  94235. /**
  94236. * List of blocks that can provide a define update
  94237. */
  94238. blocksWithDefines: NodeMaterialBlock[];
  94239. /**
  94240. * List of blocks that can provide a repeatable content
  94241. */
  94242. repeatableContentBlocks: NodeMaterialBlock[];
  94243. /**
  94244. * List of blocks that can provide a dynamic list of uniforms
  94245. */
  94246. dynamicUniformBlocks: NodeMaterialBlock[];
  94247. /**
  94248. * List of blocks that can block the isReady function for the material
  94249. */
  94250. blockingBlocks: NodeMaterialBlock[];
  94251. /**
  94252. * Gets the list of animated inputs
  94253. */
  94254. animatedInputs: InputBlock[];
  94255. /**
  94256. * Build Id used to avoid multiple recompilations
  94257. */
  94258. buildId: number;
  94259. /** List of emitted variables */
  94260. variableNames: {
  94261. [key: string]: number;
  94262. };
  94263. /** List of emitted defines */
  94264. defineNames: {
  94265. [key: string]: number;
  94266. };
  94267. /** Should emit comments? */
  94268. emitComments: boolean;
  94269. /** Emit build activity */
  94270. verbose: boolean;
  94271. /** Gets or sets the hosting scene */
  94272. scene: Scene;
  94273. /**
  94274. * Gets the compilation hints emitted at compilation time
  94275. */
  94276. hints: {
  94277. needWorldViewMatrix: boolean;
  94278. needWorldViewProjectionMatrix: boolean;
  94279. needAlphaBlending: boolean;
  94280. needAlphaTesting: boolean;
  94281. };
  94282. /**
  94283. * List of compilation checks
  94284. */
  94285. checks: {
  94286. emitVertex: boolean;
  94287. emitFragment: boolean;
  94288. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  94289. };
  94290. /**
  94291. * Is vertex program allowed to be empty?
  94292. */
  94293. allowEmptyVertexProgram: boolean;
  94294. /** Creates a new shared data */
  94295. constructor();
  94296. /**
  94297. * Emits console errors and exceptions if there is a failing check
  94298. */
  94299. emitErrors(): void;
  94300. }
  94301. }
  94302. declare module BABYLON {
  94303. /**
  94304. * Class used to store node based material build state
  94305. */
  94306. export class NodeMaterialBuildState {
  94307. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  94308. supportUniformBuffers: boolean;
  94309. /**
  94310. * Gets the list of emitted attributes
  94311. */
  94312. attributes: string[];
  94313. /**
  94314. * Gets the list of emitted uniforms
  94315. */
  94316. uniforms: string[];
  94317. /**
  94318. * Gets the list of emitted constants
  94319. */
  94320. constants: string[];
  94321. /**
  94322. * Gets the list of emitted samplers
  94323. */
  94324. samplers: string[];
  94325. /**
  94326. * Gets the list of emitted functions
  94327. */
  94328. functions: {
  94329. [key: string]: string;
  94330. };
  94331. /**
  94332. * Gets the list of emitted extensions
  94333. */
  94334. extensions: {
  94335. [key: string]: string;
  94336. };
  94337. /**
  94338. * Gets the target of the compilation state
  94339. */
  94340. target: NodeMaterialBlockTargets;
  94341. /**
  94342. * Gets the list of emitted counters
  94343. */
  94344. counters: {
  94345. [key: string]: number;
  94346. };
  94347. /**
  94348. * Shared data between multiple NodeMaterialBuildState instances
  94349. */
  94350. sharedData: NodeMaterialBuildStateSharedData;
  94351. /** @hidden */
  94352. _vertexState: NodeMaterialBuildState;
  94353. /** @hidden */
  94354. _attributeDeclaration: string;
  94355. /** @hidden */
  94356. _uniformDeclaration: string;
  94357. /** @hidden */
  94358. _constantDeclaration: string;
  94359. /** @hidden */
  94360. _samplerDeclaration: string;
  94361. /** @hidden */
  94362. _varyingTransfer: string;
  94363. /** @hidden */
  94364. _injectAtEnd: string;
  94365. private _repeatableContentAnchorIndex;
  94366. /** @hidden */
  94367. _builtCompilationString: string;
  94368. /**
  94369. * Gets the emitted compilation strings
  94370. */
  94371. compilationString: string;
  94372. /**
  94373. * Finalize the compilation strings
  94374. * @param state defines the current compilation state
  94375. */
  94376. finalize(state: NodeMaterialBuildState): void;
  94377. /** @hidden */
  94378. get _repeatableContentAnchor(): string;
  94379. /** @hidden */
  94380. _getFreeVariableName(prefix: string): string;
  94381. /** @hidden */
  94382. _getFreeDefineName(prefix: string): string;
  94383. /** @hidden */
  94384. _excludeVariableName(name: string): void;
  94385. /** @hidden */
  94386. _emit2DSampler(name: string): void;
  94387. /** @hidden */
  94388. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  94389. /** @hidden */
  94390. _emitExtension(name: string, extension: string, define?: string): void;
  94391. /** @hidden */
  94392. _emitFunction(name: string, code: string, comments: string): void;
  94393. /** @hidden */
  94394. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  94395. replaceStrings?: {
  94396. search: RegExp;
  94397. replace: string;
  94398. }[];
  94399. repeatKey?: string;
  94400. }): string;
  94401. /** @hidden */
  94402. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  94403. repeatKey?: string;
  94404. removeAttributes?: boolean;
  94405. removeUniforms?: boolean;
  94406. removeVaryings?: boolean;
  94407. removeIfDef?: boolean;
  94408. replaceStrings?: {
  94409. search: RegExp;
  94410. replace: string;
  94411. }[];
  94412. }, storeKey?: string): void;
  94413. /** @hidden */
  94414. _registerTempVariable(name: string): boolean;
  94415. /** @hidden */
  94416. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  94417. /** @hidden */
  94418. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  94419. /** @hidden */
  94420. _emitFloat(value: number): string;
  94421. }
  94422. }
  94423. declare module BABYLON {
  94424. /**
  94425. * Helper class used to generate session unique ID
  94426. */
  94427. export class UniqueIdGenerator {
  94428. private static _UniqueIdCounter;
  94429. /**
  94430. * Gets an unique (relatively to the current scene) Id
  94431. */
  94432. static get UniqueId(): number;
  94433. }
  94434. }
  94435. declare module BABYLON {
  94436. /**
  94437. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  94438. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  94439. */
  94440. export class EffectFallbacks implements IEffectFallbacks {
  94441. private _defines;
  94442. private _currentRank;
  94443. private _maxRank;
  94444. private _mesh;
  94445. /**
  94446. * Removes the fallback from the bound mesh.
  94447. */
  94448. unBindMesh(): void;
  94449. /**
  94450. * Adds a fallback on the specified property.
  94451. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94452. * @param define The name of the define in the shader
  94453. */
  94454. addFallback(rank: number, define: string): void;
  94455. /**
  94456. * Sets the mesh to use CPU skinning when needing to fallback.
  94457. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94458. * @param mesh The mesh to use the fallbacks.
  94459. */
  94460. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  94461. /**
  94462. * Checks to see if more fallbacks are still availible.
  94463. */
  94464. get hasMoreFallbacks(): boolean;
  94465. /**
  94466. * Removes the defines that should be removed when falling back.
  94467. * @param currentDefines defines the current define statements for the shader.
  94468. * @param effect defines the current effect we try to compile
  94469. * @returns The resulting defines with defines of the current rank removed.
  94470. */
  94471. reduce(currentDefines: string, effect: Effect): string;
  94472. }
  94473. }
  94474. declare module BABYLON {
  94475. /**
  94476. * Defines a block that can be used inside a node based material
  94477. */
  94478. export class NodeMaterialBlock {
  94479. private _buildId;
  94480. private _buildTarget;
  94481. private _target;
  94482. private _isFinalMerger;
  94483. private _isInput;
  94484. private _name;
  94485. protected _isUnique: boolean;
  94486. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  94487. inputsAreExclusive: boolean;
  94488. /** @hidden */
  94489. _codeVariableName: string;
  94490. /** @hidden */
  94491. _inputs: NodeMaterialConnectionPoint[];
  94492. /** @hidden */
  94493. _outputs: NodeMaterialConnectionPoint[];
  94494. /** @hidden */
  94495. _preparationId: number;
  94496. /**
  94497. * Gets the name of the block
  94498. */
  94499. get name(): string;
  94500. /**
  94501. * Sets the name of the block. Will check if the name is valid.
  94502. */
  94503. set name(newName: string);
  94504. /**
  94505. * Gets or sets the unique id of the node
  94506. */
  94507. uniqueId: number;
  94508. /**
  94509. * Gets or sets the comments associated with this block
  94510. */
  94511. comments: string;
  94512. /**
  94513. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  94514. */
  94515. get isUnique(): boolean;
  94516. /**
  94517. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  94518. */
  94519. get isFinalMerger(): boolean;
  94520. /**
  94521. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  94522. */
  94523. get isInput(): boolean;
  94524. /**
  94525. * Gets or sets the build Id
  94526. */
  94527. get buildId(): number;
  94528. set buildId(value: number);
  94529. /**
  94530. * Gets or sets the target of the block
  94531. */
  94532. get target(): NodeMaterialBlockTargets;
  94533. set target(value: NodeMaterialBlockTargets);
  94534. /**
  94535. * Gets the list of input points
  94536. */
  94537. get inputs(): NodeMaterialConnectionPoint[];
  94538. /** Gets the list of output points */
  94539. get outputs(): NodeMaterialConnectionPoint[];
  94540. /**
  94541. * Find an input by its name
  94542. * @param name defines the name of the input to look for
  94543. * @returns the input or null if not found
  94544. */
  94545. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  94546. /**
  94547. * Find an output by its name
  94548. * @param name defines the name of the outputto look for
  94549. * @returns the output or null if not found
  94550. */
  94551. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  94552. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  94553. visibleInInspector: boolean;
  94554. /**
  94555. * Creates a new NodeMaterialBlock
  94556. * @param name defines the block name
  94557. * @param target defines the target of that block (Vertex by default)
  94558. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  94559. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  94560. */
  94561. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  94562. /**
  94563. * Initialize the block and prepare the context for build
  94564. * @param state defines the state that will be used for the build
  94565. */
  94566. initialize(state: NodeMaterialBuildState): void;
  94567. /**
  94568. * Bind data to effect. Will only be called for blocks with isBindable === true
  94569. * @param effect defines the effect to bind data to
  94570. * @param nodeMaterial defines the hosting NodeMaterial
  94571. * @param mesh defines the mesh that will be rendered
  94572. * @param subMesh defines the submesh that will be rendered
  94573. */
  94574. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  94575. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  94576. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  94577. protected _writeFloat(value: number): string;
  94578. /**
  94579. * Gets the current class name e.g. "NodeMaterialBlock"
  94580. * @returns the class name
  94581. */
  94582. getClassName(): string;
  94583. /**
  94584. * Register a new input. Must be called inside a block constructor
  94585. * @param name defines the connection point name
  94586. * @param type defines the connection point type
  94587. * @param isOptional defines a boolean indicating that this input can be omitted
  94588. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  94589. * @param point an already created connection point. If not provided, create a new one
  94590. * @returns the current block
  94591. */
  94592. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  94593. /**
  94594. * Register a new output. Must be called inside a block constructor
  94595. * @param name defines the connection point name
  94596. * @param type defines the connection point type
  94597. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  94598. * @param point an already created connection point. If not provided, create a new one
  94599. * @returns the current block
  94600. */
  94601. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  94602. /**
  94603. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  94604. * @param forOutput defines an optional connection point to check compatibility with
  94605. * @returns the first available input or null
  94606. */
  94607. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  94608. /**
  94609. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  94610. * @param forBlock defines an optional block to check compatibility with
  94611. * @returns the first available input or null
  94612. */
  94613. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  94614. /**
  94615. * Gets the sibling of the given output
  94616. * @param current defines the current output
  94617. * @returns the next output in the list or null
  94618. */
  94619. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  94620. /**
  94621. * Connect current block with another block
  94622. * @param other defines the block to connect with
  94623. * @param options define the various options to help pick the right connections
  94624. * @returns the current block
  94625. */
  94626. connectTo(other: NodeMaterialBlock, options?: {
  94627. input?: string;
  94628. output?: string;
  94629. outputSwizzle?: string;
  94630. }): this | undefined;
  94631. protected _buildBlock(state: NodeMaterialBuildState): void;
  94632. /**
  94633. * Add uniforms, samplers and uniform buffers at compilation time
  94634. * @param state defines the state to update
  94635. * @param nodeMaterial defines the node material requesting the update
  94636. * @param defines defines the material defines to update
  94637. * @param uniformBuffers defines the list of uniform buffer names
  94638. */
  94639. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  94640. /**
  94641. * Add potential fallbacks if shader compilation fails
  94642. * @param mesh defines the mesh to be rendered
  94643. * @param fallbacks defines the current prioritized list of fallbacks
  94644. */
  94645. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  94646. /**
  94647. * Initialize defines for shader compilation
  94648. * @param mesh defines the mesh to be rendered
  94649. * @param nodeMaterial defines the node material requesting the update
  94650. * @param defines defines the material defines to update
  94651. * @param useInstances specifies that instances should be used
  94652. */
  94653. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  94654. /**
  94655. * Update defines for shader compilation
  94656. * @param mesh defines the mesh to be rendered
  94657. * @param nodeMaterial defines the node material requesting the update
  94658. * @param defines defines the material defines to update
  94659. * @param useInstances specifies that instances should be used
  94660. * @param subMesh defines which submesh to render
  94661. */
  94662. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  94663. /**
  94664. * Lets the block try to connect some inputs automatically
  94665. * @param material defines the hosting NodeMaterial
  94666. */
  94667. autoConfigure(material: NodeMaterial): void;
  94668. /**
  94669. * Function called when a block is declared as repeatable content generator
  94670. * @param vertexShaderState defines the current compilation state for the vertex shader
  94671. * @param fragmentShaderState defines the current compilation state for the fragment shader
  94672. * @param mesh defines the mesh to be rendered
  94673. * @param defines defines the material defines to update
  94674. */
  94675. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  94676. /**
  94677. * Checks if the block is ready
  94678. * @param mesh defines the mesh to be rendered
  94679. * @param nodeMaterial defines the node material requesting the update
  94680. * @param defines defines the material defines to update
  94681. * @param useInstances specifies that instances should be used
  94682. * @returns true if the block is ready
  94683. */
  94684. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  94685. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  94686. private _processBuild;
  94687. /**
  94688. * Validates the new name for the block node.
  94689. * @param newName the new name to be given to the node.
  94690. * @returns false if the name is a reserve word, else true.
  94691. */
  94692. validateBlockName(newName: string): boolean;
  94693. /**
  94694. * Compile the current node and generate the shader code
  94695. * @param state defines the current compilation state (uniforms, samplers, current string)
  94696. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  94697. * @returns true if already built
  94698. */
  94699. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  94700. protected _inputRename(name: string): string;
  94701. protected _outputRename(name: string): string;
  94702. protected _dumpPropertiesCode(): string;
  94703. /** @hidden */
  94704. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  94705. /** @hidden */
  94706. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  94707. /**
  94708. * Clone the current block to a new identical block
  94709. * @param scene defines the hosting scene
  94710. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94711. * @returns a copy of the current block
  94712. */
  94713. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  94714. /**
  94715. * Serializes this block in a JSON representation
  94716. * @returns the serialized block object
  94717. */
  94718. serialize(): any;
  94719. /** @hidden */
  94720. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94721. private _deserializePortDisplayNamesAndExposedOnFrame;
  94722. /**
  94723. * Release resources
  94724. */
  94725. dispose(): void;
  94726. }
  94727. }
  94728. declare module BABYLON {
  94729. /**
  94730. * Base class of materials working in push mode in babylon JS
  94731. * @hidden
  94732. */
  94733. export class PushMaterial extends Material {
  94734. protected _activeEffect: Effect;
  94735. protected _normalMatrix: Matrix;
  94736. constructor(name: string, scene: Scene);
  94737. getEffect(): Effect;
  94738. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94739. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  94740. /**
  94741. * Binds the given world matrix to the active effect
  94742. *
  94743. * @param world the matrix to bind
  94744. */
  94745. bindOnlyWorldMatrix(world: Matrix): void;
  94746. /**
  94747. * Binds the given normal matrix to the active effect
  94748. *
  94749. * @param normalMatrix the matrix to bind
  94750. */
  94751. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94752. bind(world: Matrix, mesh?: Mesh): void;
  94753. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94754. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94755. }
  94756. }
  94757. declare module BABYLON {
  94758. /**
  94759. * Root class for all node material optimizers
  94760. */
  94761. export class NodeMaterialOptimizer {
  94762. /**
  94763. * Function used to optimize a NodeMaterial graph
  94764. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  94765. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  94766. */
  94767. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  94768. }
  94769. }
  94770. declare module BABYLON {
  94771. /**
  94772. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  94773. */
  94774. export class TransformBlock extends NodeMaterialBlock {
  94775. /**
  94776. * Defines the value to use to complement W value to transform it to a Vector4
  94777. */
  94778. complementW: number;
  94779. /**
  94780. * Defines the value to use to complement z value to transform it to a Vector4
  94781. */
  94782. complementZ: number;
  94783. /**
  94784. * Creates a new TransformBlock
  94785. * @param name defines the block name
  94786. */
  94787. constructor(name: string);
  94788. /**
  94789. * Gets the current class name
  94790. * @returns the class name
  94791. */
  94792. getClassName(): string;
  94793. /**
  94794. * Gets the vector input
  94795. */
  94796. get vector(): NodeMaterialConnectionPoint;
  94797. /**
  94798. * Gets the output component
  94799. */
  94800. get output(): NodeMaterialConnectionPoint;
  94801. /**
  94802. * Gets the xyz output component
  94803. */
  94804. get xyz(): NodeMaterialConnectionPoint;
  94805. /**
  94806. * Gets the matrix transform input
  94807. */
  94808. get transform(): NodeMaterialConnectionPoint;
  94809. protected _buildBlock(state: NodeMaterialBuildState): this;
  94810. /**
  94811. * Update defines for shader compilation
  94812. * @param mesh defines the mesh to be rendered
  94813. * @param nodeMaterial defines the node material requesting the update
  94814. * @param defines defines the material defines to update
  94815. * @param useInstances specifies that instances should be used
  94816. * @param subMesh defines which submesh to render
  94817. */
  94818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  94819. serialize(): any;
  94820. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94821. protected _dumpPropertiesCode(): string;
  94822. }
  94823. }
  94824. declare module BABYLON {
  94825. /**
  94826. * Block used to output the vertex position
  94827. */
  94828. export class VertexOutputBlock extends NodeMaterialBlock {
  94829. /**
  94830. * Creates a new VertexOutputBlock
  94831. * @param name defines the block name
  94832. */
  94833. constructor(name: string);
  94834. /**
  94835. * Gets the current class name
  94836. * @returns the class name
  94837. */
  94838. getClassName(): string;
  94839. /**
  94840. * Gets the vector input component
  94841. */
  94842. get vector(): NodeMaterialConnectionPoint;
  94843. protected _buildBlock(state: NodeMaterialBuildState): this;
  94844. }
  94845. }
  94846. declare module BABYLON {
  94847. /**
  94848. * Block used to output the final color
  94849. */
  94850. export class FragmentOutputBlock extends NodeMaterialBlock {
  94851. /**
  94852. * Create a new FragmentOutputBlock
  94853. * @param name defines the block name
  94854. */
  94855. constructor(name: string);
  94856. /**
  94857. * Gets the current class name
  94858. * @returns the class name
  94859. */
  94860. getClassName(): string;
  94861. /**
  94862. * Gets the rgba input component
  94863. */
  94864. get rgba(): NodeMaterialConnectionPoint;
  94865. /**
  94866. * Gets the rgb input component
  94867. */
  94868. get rgb(): NodeMaterialConnectionPoint;
  94869. /**
  94870. * Gets the a input component
  94871. */
  94872. get a(): NodeMaterialConnectionPoint;
  94873. protected _buildBlock(state: NodeMaterialBuildState): this;
  94874. }
  94875. }
  94876. declare module BABYLON {
  94877. /**
  94878. * Block used for the particle ramp gradient section
  94879. */
  94880. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  94881. /**
  94882. * Create a new ParticleRampGradientBlock
  94883. * @param name defines the block name
  94884. */
  94885. constructor(name: string);
  94886. /**
  94887. * Gets the current class name
  94888. * @returns the class name
  94889. */
  94890. getClassName(): string;
  94891. /**
  94892. * Gets the color input component
  94893. */
  94894. get color(): NodeMaterialConnectionPoint;
  94895. /**
  94896. * Gets the rampColor output component
  94897. */
  94898. get rampColor(): NodeMaterialConnectionPoint;
  94899. /**
  94900. * Initialize the block and prepare the context for build
  94901. * @param state defines the state that will be used for the build
  94902. */
  94903. initialize(state: NodeMaterialBuildState): void;
  94904. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94905. }
  94906. }
  94907. declare module BABYLON {
  94908. /**
  94909. * Block used for the particle blend multiply section
  94910. */
  94911. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  94912. /**
  94913. * Create a new ParticleBlendMultiplyBlock
  94914. * @param name defines the block name
  94915. */
  94916. constructor(name: string);
  94917. /**
  94918. * Gets the current class name
  94919. * @returns the class name
  94920. */
  94921. getClassName(): string;
  94922. /**
  94923. * Gets the color input component
  94924. */
  94925. get color(): NodeMaterialConnectionPoint;
  94926. /**
  94927. * Gets the alphaTexture input component
  94928. */
  94929. get alphaTexture(): NodeMaterialConnectionPoint;
  94930. /**
  94931. * Gets the alphaColor input component
  94932. */
  94933. get alphaColor(): NodeMaterialConnectionPoint;
  94934. /**
  94935. * Gets the blendColor output component
  94936. */
  94937. get blendColor(): NodeMaterialConnectionPoint;
  94938. /**
  94939. * Initialize the block and prepare the context for build
  94940. * @param state defines the state that will be used for the build
  94941. */
  94942. initialize(state: NodeMaterialBuildState): void;
  94943. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94944. }
  94945. }
  94946. declare module BABYLON {
  94947. /**
  94948. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  94949. */
  94950. export class VectorMergerBlock extends NodeMaterialBlock {
  94951. /**
  94952. * Create a new VectorMergerBlock
  94953. * @param name defines the block name
  94954. */
  94955. constructor(name: string);
  94956. /**
  94957. * Gets the current class name
  94958. * @returns the class name
  94959. */
  94960. getClassName(): string;
  94961. /**
  94962. * Gets the xyz component (input)
  94963. */
  94964. get xyzIn(): NodeMaterialConnectionPoint;
  94965. /**
  94966. * Gets the xy component (input)
  94967. */
  94968. get xyIn(): NodeMaterialConnectionPoint;
  94969. /**
  94970. * Gets the x component (input)
  94971. */
  94972. get x(): NodeMaterialConnectionPoint;
  94973. /**
  94974. * Gets the y component (input)
  94975. */
  94976. get y(): NodeMaterialConnectionPoint;
  94977. /**
  94978. * Gets the z component (input)
  94979. */
  94980. get z(): NodeMaterialConnectionPoint;
  94981. /**
  94982. * Gets the w component (input)
  94983. */
  94984. get w(): NodeMaterialConnectionPoint;
  94985. /**
  94986. * Gets the xyzw component (output)
  94987. */
  94988. get xyzw(): NodeMaterialConnectionPoint;
  94989. /**
  94990. * Gets the xyz component (output)
  94991. */
  94992. get xyzOut(): NodeMaterialConnectionPoint;
  94993. /**
  94994. * Gets the xy component (output)
  94995. */
  94996. get xyOut(): NodeMaterialConnectionPoint;
  94997. /**
  94998. * Gets the xy component (output)
  94999. * @deprecated Please use xyOut instead.
  95000. */
  95001. get xy(): NodeMaterialConnectionPoint;
  95002. /**
  95003. * Gets the xyz component (output)
  95004. * @deprecated Please use xyzOut instead.
  95005. */
  95006. get xyz(): NodeMaterialConnectionPoint;
  95007. protected _buildBlock(state: NodeMaterialBuildState): this;
  95008. }
  95009. }
  95010. declare module BABYLON {
  95011. /**
  95012. * Block used to remap a float from a range to a new one
  95013. */
  95014. export class RemapBlock extends NodeMaterialBlock {
  95015. /**
  95016. * Gets or sets the source range
  95017. */
  95018. sourceRange: Vector2;
  95019. /**
  95020. * Gets or sets the target range
  95021. */
  95022. targetRange: Vector2;
  95023. /**
  95024. * Creates a new RemapBlock
  95025. * @param name defines the block name
  95026. */
  95027. constructor(name: string);
  95028. /**
  95029. * Gets the current class name
  95030. * @returns the class name
  95031. */
  95032. getClassName(): string;
  95033. /**
  95034. * Gets the input component
  95035. */
  95036. get input(): NodeMaterialConnectionPoint;
  95037. /**
  95038. * Gets the source min input component
  95039. */
  95040. get sourceMin(): NodeMaterialConnectionPoint;
  95041. /**
  95042. * Gets the source max input component
  95043. */
  95044. get sourceMax(): NodeMaterialConnectionPoint;
  95045. /**
  95046. * Gets the target min input component
  95047. */
  95048. get targetMin(): NodeMaterialConnectionPoint;
  95049. /**
  95050. * Gets the target max input component
  95051. */
  95052. get targetMax(): NodeMaterialConnectionPoint;
  95053. /**
  95054. * Gets the output component
  95055. */
  95056. get output(): NodeMaterialConnectionPoint;
  95057. protected _buildBlock(state: NodeMaterialBuildState): this;
  95058. protected _dumpPropertiesCode(): string;
  95059. serialize(): any;
  95060. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  95061. }
  95062. }
  95063. declare module BABYLON {
  95064. /**
  95065. * Block used to multiply 2 values
  95066. */
  95067. export class MultiplyBlock extends NodeMaterialBlock {
  95068. /**
  95069. * Creates a new MultiplyBlock
  95070. * @param name defines the block name
  95071. */
  95072. constructor(name: string);
  95073. /**
  95074. * Gets the current class name
  95075. * @returns the class name
  95076. */
  95077. getClassName(): string;
  95078. /**
  95079. * Gets the left operand input component
  95080. */
  95081. get left(): NodeMaterialConnectionPoint;
  95082. /**
  95083. * Gets the right operand input component
  95084. */
  95085. get right(): NodeMaterialConnectionPoint;
  95086. /**
  95087. * Gets the output component
  95088. */
  95089. get output(): NodeMaterialConnectionPoint;
  95090. protected _buildBlock(state: NodeMaterialBuildState): this;
  95091. }
  95092. }
  95093. declare module BABYLON {
  95094. /** Interface used by value gradients (color, factor, ...) */
  95095. export interface IValueGradient {
  95096. /**
  95097. * Gets or sets the gradient value (between 0 and 1)
  95098. */
  95099. gradient: number;
  95100. }
  95101. /** Class used to store color4 gradient */
  95102. export class ColorGradient implements IValueGradient {
  95103. /**
  95104. * Gets or sets the gradient value (between 0 and 1)
  95105. */
  95106. gradient: number;
  95107. /**
  95108. * Gets or sets first associated color
  95109. */
  95110. color1: Color4;
  95111. /**
  95112. * Gets or sets second associated color
  95113. */
  95114. color2?: Color4 | undefined;
  95115. /**
  95116. * Creates a new color4 gradient
  95117. * @param gradient gets or sets the gradient value (between 0 and 1)
  95118. * @param color1 gets or sets first associated color
  95119. * @param color2 gets or sets first second color
  95120. */
  95121. constructor(
  95122. /**
  95123. * Gets or sets the gradient value (between 0 and 1)
  95124. */
  95125. gradient: number,
  95126. /**
  95127. * Gets or sets first associated color
  95128. */
  95129. color1: Color4,
  95130. /**
  95131. * Gets or sets second associated color
  95132. */
  95133. color2?: Color4 | undefined);
  95134. /**
  95135. * Will get a color picked randomly between color1 and color2.
  95136. * If color2 is undefined then color1 will be used
  95137. * @param result defines the target Color4 to store the result in
  95138. */
  95139. getColorToRef(result: Color4): void;
  95140. }
  95141. /** Class used to store color 3 gradient */
  95142. export class Color3Gradient implements IValueGradient {
  95143. /**
  95144. * Gets or sets the gradient value (between 0 and 1)
  95145. */
  95146. gradient: number;
  95147. /**
  95148. * Gets or sets the associated color
  95149. */
  95150. color: Color3;
  95151. /**
  95152. * Creates a new color3 gradient
  95153. * @param gradient gets or sets the gradient value (between 0 and 1)
  95154. * @param color gets or sets associated color
  95155. */
  95156. constructor(
  95157. /**
  95158. * Gets or sets the gradient value (between 0 and 1)
  95159. */
  95160. gradient: number,
  95161. /**
  95162. * Gets or sets the associated color
  95163. */
  95164. color: Color3);
  95165. }
  95166. /** Class used to store factor gradient */
  95167. export class FactorGradient implements IValueGradient {
  95168. /**
  95169. * Gets or sets the gradient value (between 0 and 1)
  95170. */
  95171. gradient: number;
  95172. /**
  95173. * Gets or sets first associated factor
  95174. */
  95175. factor1: number;
  95176. /**
  95177. * Gets or sets second associated factor
  95178. */
  95179. factor2?: number | undefined;
  95180. /**
  95181. * Creates a new factor gradient
  95182. * @param gradient gets or sets the gradient value (between 0 and 1)
  95183. * @param factor1 gets or sets first associated factor
  95184. * @param factor2 gets or sets second associated factor
  95185. */
  95186. constructor(
  95187. /**
  95188. * Gets or sets the gradient value (between 0 and 1)
  95189. */
  95190. gradient: number,
  95191. /**
  95192. * Gets or sets first associated factor
  95193. */
  95194. factor1: number,
  95195. /**
  95196. * Gets or sets second associated factor
  95197. */
  95198. factor2?: number | undefined);
  95199. /**
  95200. * Will get a number picked randomly between factor1 and factor2.
  95201. * If factor2 is undefined then factor1 will be used
  95202. * @returns the picked number
  95203. */
  95204. getFactor(): number;
  95205. }
  95206. /**
  95207. * Helper used to simplify some generic gradient tasks
  95208. */
  95209. export class GradientHelper {
  95210. /**
  95211. * Gets the current gradient from an array of IValueGradient
  95212. * @param ratio defines the current ratio to get
  95213. * @param gradients defines the array of IValueGradient
  95214. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  95215. */
  95216. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  95217. }
  95218. }
  95219. declare module BABYLON {
  95220. interface ThinEngine {
  95221. /**
  95222. * Creates a raw texture
  95223. * @param data defines the data to store in the texture
  95224. * @param width defines the width of the texture
  95225. * @param height defines the height of the texture
  95226. * @param format defines the format of the data
  95227. * @param generateMipMaps defines if the engine should generate the mip levels
  95228. * @param invertY defines if data must be stored with Y axis inverted
  95229. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  95230. * @param compression defines the compression used (null by default)
  95231. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95232. * @returns the raw texture inside an InternalTexture
  95233. */
  95234. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  95235. /**
  95236. * Update a raw texture
  95237. * @param texture defines the texture to update
  95238. * @param data defines the data to store in the texture
  95239. * @param format defines the format of the data
  95240. * @param invertY defines if data must be stored with Y axis inverted
  95241. */
  95242. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95243. /**
  95244. * Update a raw texture
  95245. * @param texture defines the texture to update
  95246. * @param data defines the data to store in the texture
  95247. * @param format defines the format of the data
  95248. * @param invertY defines if data must be stored with Y axis inverted
  95249. * @param compression defines the compression used (null by default)
  95250. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95251. */
  95252. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  95253. /**
  95254. * Creates a new raw cube texture
  95255. * @param data defines the array of data to use to create each face
  95256. * @param size defines the size of the textures
  95257. * @param format defines the format of the data
  95258. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95259. * @param generateMipMaps defines if the engine should generate the mip levels
  95260. * @param invertY defines if data must be stored with Y axis inverted
  95261. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95262. * @param compression defines the compression used (null by default)
  95263. * @returns the cube texture as an InternalTexture
  95264. */
  95265. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  95266. /**
  95267. * Update a raw cube texture
  95268. * @param texture defines the texture to udpdate
  95269. * @param data defines the data to store
  95270. * @param format defines the data format
  95271. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95272. * @param invertY defines if data must be stored with Y axis inverted
  95273. */
  95274. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  95275. /**
  95276. * Update a raw cube texture
  95277. * @param texture defines the texture to udpdate
  95278. * @param data defines the data to store
  95279. * @param format defines the data format
  95280. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95281. * @param invertY defines if data must be stored with Y axis inverted
  95282. * @param compression defines the compression used (null by default)
  95283. */
  95284. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  95285. /**
  95286. * Update a raw cube texture
  95287. * @param texture defines the texture to udpdate
  95288. * @param data defines the data to store
  95289. * @param format defines the data format
  95290. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95291. * @param invertY defines if data must be stored with Y axis inverted
  95292. * @param compression defines the compression used (null by default)
  95293. * @param level defines which level of the texture to update
  95294. */
  95295. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  95296. /**
  95297. * Creates a new raw cube texture from a specified url
  95298. * @param url defines the url where the data is located
  95299. * @param scene defines the current scene
  95300. * @param size defines the size of the textures
  95301. * @param format defines the format of the data
  95302. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95303. * @param noMipmap defines if the engine should avoid generating the mip levels
  95304. * @param callback defines a callback used to extract texture data from loaded data
  95305. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  95306. * @param onLoad defines a callback called when texture is loaded
  95307. * @param onError defines a callback called if there is an error
  95308. * @returns the cube texture as an InternalTexture
  95309. */
  95310. 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;
  95311. /**
  95312. * Creates a new raw cube texture from a specified url
  95313. * @param url defines the url where the data is located
  95314. * @param scene defines the current scene
  95315. * @param size defines the size of the textures
  95316. * @param format defines the format of the data
  95317. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95318. * @param noMipmap defines if the engine should avoid generating the mip levels
  95319. * @param callback defines a callback used to extract texture data from loaded data
  95320. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  95321. * @param onLoad defines a callback called when texture is loaded
  95322. * @param onError defines a callback called if there is an error
  95323. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95324. * @param invertY defines if data must be stored with Y axis inverted
  95325. * @returns the cube texture as an InternalTexture
  95326. */
  95327. 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;
  95328. /**
  95329. * Creates a new raw 3D texture
  95330. * @param data defines the data used to create the texture
  95331. * @param width defines the width of the texture
  95332. * @param height defines the height of the texture
  95333. * @param depth defines the depth of the texture
  95334. * @param format defines the format of the texture
  95335. * @param generateMipMaps defines if the engine must generate mip levels
  95336. * @param invertY defines if data must be stored with Y axis inverted
  95337. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95338. * @param compression defines the compressed used (can be null)
  95339. * @param textureType defines the compressed used (can be null)
  95340. * @returns a new raw 3D texture (stored in an InternalTexture)
  95341. */
  95342. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  95343. /**
  95344. * Update a raw 3D texture
  95345. * @param texture defines the texture to update
  95346. * @param data defines the data to store
  95347. * @param format defines the data format
  95348. * @param invertY defines if data must be stored with Y axis inverted
  95349. */
  95350. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95351. /**
  95352. * Update a raw 3D texture
  95353. * @param texture defines the texture to update
  95354. * @param data defines the data to store
  95355. * @param format defines the data format
  95356. * @param invertY defines if data must be stored with Y axis inverted
  95357. * @param compression defines the used compression (can be null)
  95358. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  95359. */
  95360. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  95361. /**
  95362. * Creates a new raw 2D array texture
  95363. * @param data defines the data used to create the texture
  95364. * @param width defines the width of the texture
  95365. * @param height defines the height of the texture
  95366. * @param depth defines the number of layers of the texture
  95367. * @param format defines the format of the texture
  95368. * @param generateMipMaps defines if the engine must generate mip levels
  95369. * @param invertY defines if data must be stored with Y axis inverted
  95370. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95371. * @param compression defines the compressed used (can be null)
  95372. * @param textureType defines the compressed used (can be null)
  95373. * @returns a new raw 2D array texture (stored in an InternalTexture)
  95374. */
  95375. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  95376. /**
  95377. * Update a raw 2D array texture
  95378. * @param texture defines the texture to update
  95379. * @param data defines the data to store
  95380. * @param format defines the data format
  95381. * @param invertY defines if data must be stored with Y axis inverted
  95382. */
  95383. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95384. /**
  95385. * Update a raw 2D array texture
  95386. * @param texture defines the texture to update
  95387. * @param data defines the data to store
  95388. * @param format defines the data format
  95389. * @param invertY defines if data must be stored with Y axis inverted
  95390. * @param compression defines the used compression (can be null)
  95391. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  95392. */
  95393. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  95394. }
  95395. }
  95396. declare module BABYLON {
  95397. /**
  95398. * Raw texture can help creating a texture directly from an array of data.
  95399. * This can be super useful if you either get the data from an uncompressed source or
  95400. * if you wish to create your texture pixel by pixel.
  95401. */
  95402. export class RawTexture extends Texture {
  95403. /**
  95404. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95405. */
  95406. format: number;
  95407. /**
  95408. * Instantiates a new RawTexture.
  95409. * Raw texture can help creating a texture directly from an array of data.
  95410. * This can be super useful if you either get the data from an uncompressed source or
  95411. * if you wish to create your texture pixel by pixel.
  95412. * @param data define the array of data to use to create the texture
  95413. * @param width define the width of the texture
  95414. * @param height define the height of the texture
  95415. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95416. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95417. * @param generateMipMaps define whether mip maps should be generated or not
  95418. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95419. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95420. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95421. */
  95422. constructor(data: ArrayBufferView, width: number, height: number,
  95423. /**
  95424. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95425. */
  95426. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  95427. /**
  95428. * Updates the texture underlying data.
  95429. * @param data Define the new data of the texture
  95430. */
  95431. update(data: ArrayBufferView): void;
  95432. /**
  95433. * Creates a luminance texture from some data.
  95434. * @param data Define the texture data
  95435. * @param width Define the width of the texture
  95436. * @param height Define the height of the texture
  95437. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95438. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95439. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95440. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95441. * @returns the luminance texture
  95442. */
  95443. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95444. /**
  95445. * Creates a luminance alpha texture from some data.
  95446. * @param data Define the texture data
  95447. * @param width Define the width of the texture
  95448. * @param height Define the height of the texture
  95449. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95450. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95451. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95452. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95453. * @returns the luminance alpha texture
  95454. */
  95455. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95456. /**
  95457. * Creates an alpha texture from some data.
  95458. * @param data Define the texture data
  95459. * @param width Define the width of the texture
  95460. * @param height Define the height of the texture
  95461. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95462. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95463. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95464. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95465. * @returns the alpha texture
  95466. */
  95467. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95468. /**
  95469. * Creates a RGB texture from some data.
  95470. * @param data Define the texture data
  95471. * @param width Define the width of the texture
  95472. * @param height Define the height of the texture
  95473. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95474. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95475. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95476. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95477. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95478. * @returns the RGB alpha texture
  95479. */
  95480. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95481. /**
  95482. * Creates a RGBA texture from some data.
  95483. * @param data Define the texture data
  95484. * @param width Define the width of the texture
  95485. * @param height Define the height of the texture
  95486. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95487. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95488. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95489. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95490. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95491. * @returns the RGBA texture
  95492. */
  95493. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95494. /**
  95495. * Creates a R texture from some data.
  95496. * @param data Define the texture data
  95497. * @param width Define the width of the texture
  95498. * @param height Define the height of the texture
  95499. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95500. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95501. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95502. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95503. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95504. * @returns the R texture
  95505. */
  95506. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95507. }
  95508. }
  95509. declare module BABYLON {
  95510. interface ThinEngine {
  95511. /**
  95512. * Update a dynamic index buffer
  95513. * @param indexBuffer defines the target index buffer
  95514. * @param indices defines the data to update
  95515. * @param offset defines the offset in the target index buffer where update should start
  95516. */
  95517. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95518. /**
  95519. * Updates a dynamic vertex buffer.
  95520. * @param vertexBuffer the vertex buffer to update
  95521. * @param data the data used to update the vertex buffer
  95522. * @param byteOffset the byte offset of the data
  95523. * @param byteLength the byte length of the data
  95524. */
  95525. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  95526. }
  95527. }
  95528. declare module BABYLON {
  95529. interface AbstractScene {
  95530. /**
  95531. * The list of procedural textures added to the scene
  95532. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95533. */
  95534. proceduralTextures: Array<ProceduralTexture>;
  95535. }
  95536. /**
  95537. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  95538. * in a given scene.
  95539. */
  95540. export class ProceduralTextureSceneComponent implements ISceneComponent {
  95541. /**
  95542. * The component name helpfull to identify the component in the list of scene components.
  95543. */
  95544. readonly name: string;
  95545. /**
  95546. * The scene the component belongs to.
  95547. */
  95548. scene: Scene;
  95549. /**
  95550. * Creates a new instance of the component for the given scene
  95551. * @param scene Defines the scene to register the component in
  95552. */
  95553. constructor(scene: Scene);
  95554. /**
  95555. * Registers the component in a given scene
  95556. */
  95557. register(): void;
  95558. /**
  95559. * Rebuilds the elements related to this component in case of
  95560. * context lost for instance.
  95561. */
  95562. rebuild(): void;
  95563. /**
  95564. * Disposes the component and the associated ressources.
  95565. */
  95566. dispose(): void;
  95567. private _beforeClear;
  95568. }
  95569. }
  95570. declare module BABYLON {
  95571. interface ThinEngine {
  95572. /**
  95573. * Creates a new render target cube texture
  95574. * @param size defines the size of the texture
  95575. * @param options defines the options used to create the texture
  95576. * @returns a new render target cube texture stored in an InternalTexture
  95577. */
  95578. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  95579. }
  95580. }
  95581. declare module BABYLON {
  95582. /** @hidden */
  95583. export var proceduralVertexShader: {
  95584. name: string;
  95585. shader: string;
  95586. };
  95587. }
  95588. declare module BABYLON {
  95589. /**
  95590. * 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.
  95591. * This is the base class of any Procedural texture and contains most of the shareable code.
  95592. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95593. */
  95594. export class ProceduralTexture extends Texture {
  95595. /**
  95596. * Define if the texture is enabled or not (disabled texture will not render)
  95597. */
  95598. isEnabled: boolean;
  95599. /**
  95600. * Define if the texture must be cleared before rendering (default is true)
  95601. */
  95602. autoClear: boolean;
  95603. /**
  95604. * Callback called when the texture is generated
  95605. */
  95606. onGenerated: () => void;
  95607. /**
  95608. * Event raised when the texture is generated
  95609. */
  95610. onGeneratedObservable: Observable<ProceduralTexture>;
  95611. /**
  95612. * Event raised before the texture is generated
  95613. */
  95614. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  95615. /**
  95616. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  95617. */
  95618. nodeMaterialSource: Nullable<NodeMaterial>;
  95619. /** @hidden */
  95620. _generateMipMaps: boolean;
  95621. /** @hidden **/
  95622. _effect: Effect;
  95623. /** @hidden */
  95624. _textures: {
  95625. [key: string]: Texture;
  95626. };
  95627. /** @hidden */
  95628. protected _fallbackTexture: Nullable<Texture>;
  95629. private _size;
  95630. private _currentRefreshId;
  95631. private _frameId;
  95632. private _refreshRate;
  95633. private _vertexBuffers;
  95634. private _indexBuffer;
  95635. private _uniforms;
  95636. private _samplers;
  95637. private _fragment;
  95638. private _floats;
  95639. private _ints;
  95640. private _floatsArrays;
  95641. private _colors3;
  95642. private _colors4;
  95643. private _vectors2;
  95644. private _vectors3;
  95645. private _matrices;
  95646. private _fallbackTextureUsed;
  95647. private _fullEngine;
  95648. private _cachedDefines;
  95649. private _contentUpdateId;
  95650. private _contentData;
  95651. /**
  95652. * Instantiates a new procedural texture.
  95653. * 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.
  95654. * This is the base class of any Procedural texture and contains most of the shareable code.
  95655. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95656. * @param name Define the name of the texture
  95657. * @param size Define the size of the texture to create
  95658. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  95659. * @param scene Define the scene the texture belongs to
  95660. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  95661. * @param generateMipMaps Define if the texture should creates mip maps or not
  95662. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  95663. * @param textureType The FBO internal texture type
  95664. */
  95665. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  95666. /**
  95667. * The effect that is created when initializing the post process.
  95668. * @returns The created effect corresponding the the postprocess.
  95669. */
  95670. getEffect(): Effect;
  95671. /**
  95672. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  95673. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  95674. */
  95675. getContent(): Nullable<ArrayBufferView>;
  95676. private _createIndexBuffer;
  95677. /** @hidden */
  95678. _rebuild(): void;
  95679. /**
  95680. * Resets the texture in order to recreate its associated resources.
  95681. * This can be called in case of context loss
  95682. */
  95683. reset(): void;
  95684. protected _getDefines(): string;
  95685. /**
  95686. * Is the texture ready to be used ? (rendered at least once)
  95687. * @returns true if ready, otherwise, false.
  95688. */
  95689. isReady(): boolean;
  95690. /**
  95691. * Resets the refresh counter of the texture and start bak from scratch.
  95692. * Could be useful to regenerate the texture if it is setup to render only once.
  95693. */
  95694. resetRefreshCounter(): void;
  95695. /**
  95696. * Set the fragment shader to use in order to render the texture.
  95697. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  95698. */
  95699. setFragment(fragment: any): void;
  95700. /**
  95701. * Define the refresh rate of the texture or the rendering frequency.
  95702. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  95703. */
  95704. get refreshRate(): number;
  95705. set refreshRate(value: number);
  95706. /** @hidden */
  95707. _shouldRender(): boolean;
  95708. /**
  95709. * Get the size the texture is rendering at.
  95710. * @returns the size (on cube texture it is always squared)
  95711. */
  95712. getRenderSize(): RenderTargetTextureSize;
  95713. /**
  95714. * Resize the texture to new value.
  95715. * @param size Define the new size the texture should have
  95716. * @param generateMipMaps Define whether the new texture should create mip maps
  95717. */
  95718. resize(size: number, generateMipMaps: boolean): void;
  95719. private _checkUniform;
  95720. /**
  95721. * Set a texture in the shader program used to render.
  95722. * @param name Define the name of the uniform samplers as defined in the shader
  95723. * @param texture Define the texture to bind to this sampler
  95724. * @return the texture itself allowing "fluent" like uniform updates
  95725. */
  95726. setTexture(name: string, texture: Texture): ProceduralTexture;
  95727. /**
  95728. * Set a float in the shader.
  95729. * @param name Define the name of the uniform as defined in the shader
  95730. * @param value Define the value to give to the uniform
  95731. * @return the texture itself allowing "fluent" like uniform updates
  95732. */
  95733. setFloat(name: string, value: number): ProceduralTexture;
  95734. /**
  95735. * Set a int in the shader.
  95736. * @param name Define the name of the uniform as defined in the shader
  95737. * @param value Define the value to give to the uniform
  95738. * @return the texture itself allowing "fluent" like uniform updates
  95739. */
  95740. setInt(name: string, value: number): ProceduralTexture;
  95741. /**
  95742. * Set an array of floats in the shader.
  95743. * @param name Define the name of the uniform as defined in the shader
  95744. * @param value Define the value to give to the uniform
  95745. * @return the texture itself allowing "fluent" like uniform updates
  95746. */
  95747. setFloats(name: string, value: number[]): ProceduralTexture;
  95748. /**
  95749. * Set a vec3 in the shader from a Color3.
  95750. * @param name Define the name of the uniform as defined in the shader
  95751. * @param value Define the value to give to the uniform
  95752. * @return the texture itself allowing "fluent" like uniform updates
  95753. */
  95754. setColor3(name: string, value: Color3): ProceduralTexture;
  95755. /**
  95756. * Set a vec4 in the shader from a Color4.
  95757. * @param name Define the name of the uniform as defined in the shader
  95758. * @param value Define the value to give to the uniform
  95759. * @return the texture itself allowing "fluent" like uniform updates
  95760. */
  95761. setColor4(name: string, value: Color4): ProceduralTexture;
  95762. /**
  95763. * Set a vec2 in the shader from a Vector2.
  95764. * @param name Define the name of the uniform as defined in the shader
  95765. * @param value Define the value to give to the uniform
  95766. * @return the texture itself allowing "fluent" like uniform updates
  95767. */
  95768. setVector2(name: string, value: Vector2): ProceduralTexture;
  95769. /**
  95770. * Set a vec3 in the shader from a Vector3.
  95771. * @param name Define the name of the uniform as defined in the shader
  95772. * @param value Define the value to give to the uniform
  95773. * @return the texture itself allowing "fluent" like uniform updates
  95774. */
  95775. setVector3(name: string, value: Vector3): ProceduralTexture;
  95776. /**
  95777. * Set a mat4 in the shader from a MAtrix.
  95778. * @param name Define the name of the uniform as defined in the shader
  95779. * @param value Define the value to give to the uniform
  95780. * @return the texture itself allowing "fluent" like uniform updates
  95781. */
  95782. setMatrix(name: string, value: Matrix): ProceduralTexture;
  95783. /**
  95784. * Render the texture to its associated render target.
  95785. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  95786. */
  95787. render(useCameraPostProcess?: boolean): void;
  95788. /**
  95789. * Clone the texture.
  95790. * @returns the cloned texture
  95791. */
  95792. clone(): ProceduralTexture;
  95793. /**
  95794. * Dispose the texture and release its asoociated resources.
  95795. */
  95796. dispose(): void;
  95797. }
  95798. }
  95799. declare module BABYLON {
  95800. /**
  95801. * This represents the base class for particle system in Babylon.
  95802. * 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.
  95803. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  95804. * @example https://doc.babylonjs.com/babylon101/particles
  95805. */
  95806. export class BaseParticleSystem {
  95807. /**
  95808. * Source color is added to the destination color without alpha affecting the result
  95809. */
  95810. static BLENDMODE_ONEONE: number;
  95811. /**
  95812. * Blend current color and particle color using particle’s alpha
  95813. */
  95814. static BLENDMODE_STANDARD: number;
  95815. /**
  95816. * Add current color and particle color multiplied by particle’s alpha
  95817. */
  95818. static BLENDMODE_ADD: number;
  95819. /**
  95820. * Multiply current color with particle color
  95821. */
  95822. static BLENDMODE_MULTIPLY: number;
  95823. /**
  95824. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  95825. */
  95826. static BLENDMODE_MULTIPLYADD: number;
  95827. /**
  95828. * List of animations used by the particle system.
  95829. */
  95830. animations: Animation[];
  95831. /**
  95832. * Gets or sets the unique id of the particle system
  95833. */
  95834. uniqueId: number;
  95835. /**
  95836. * The id of the Particle system.
  95837. */
  95838. id: string;
  95839. /**
  95840. * The friendly name of the Particle system.
  95841. */
  95842. name: string;
  95843. /**
  95844. * Snippet ID if the particle system was created from the snippet server
  95845. */
  95846. snippetId: string;
  95847. /**
  95848. * The rendering group used by the Particle system to chose when to render.
  95849. */
  95850. renderingGroupId: number;
  95851. /**
  95852. * The emitter represents the Mesh or position we are attaching the particle system to.
  95853. */
  95854. emitter: Nullable<AbstractMesh | Vector3>;
  95855. /**
  95856. * The maximum number of particles to emit per frame
  95857. */
  95858. emitRate: number;
  95859. /**
  95860. * If you want to launch only a few particles at once, that can be done, as well.
  95861. */
  95862. manualEmitCount: number;
  95863. /**
  95864. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  95865. */
  95866. updateSpeed: number;
  95867. /**
  95868. * The amount of time the particle system is running (depends of the overall update speed).
  95869. */
  95870. targetStopDuration: number;
  95871. /**
  95872. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  95873. */
  95874. disposeOnStop: boolean;
  95875. /**
  95876. * Minimum power of emitting particles.
  95877. */
  95878. minEmitPower: number;
  95879. /**
  95880. * Maximum power of emitting particles.
  95881. */
  95882. maxEmitPower: number;
  95883. /**
  95884. * Minimum life time of emitting particles.
  95885. */
  95886. minLifeTime: number;
  95887. /**
  95888. * Maximum life time of emitting particles.
  95889. */
  95890. maxLifeTime: number;
  95891. /**
  95892. * Minimum Size of emitting particles.
  95893. */
  95894. minSize: number;
  95895. /**
  95896. * Maximum Size of emitting particles.
  95897. */
  95898. maxSize: number;
  95899. /**
  95900. * Minimum scale of emitting particles on X axis.
  95901. */
  95902. minScaleX: number;
  95903. /**
  95904. * Maximum scale of emitting particles on X axis.
  95905. */
  95906. maxScaleX: number;
  95907. /**
  95908. * Minimum scale of emitting particles on Y axis.
  95909. */
  95910. minScaleY: number;
  95911. /**
  95912. * Maximum scale of emitting particles on Y axis.
  95913. */
  95914. maxScaleY: number;
  95915. /**
  95916. * Gets or sets the minimal initial rotation in radians.
  95917. */
  95918. minInitialRotation: number;
  95919. /**
  95920. * Gets or sets the maximal initial rotation in radians.
  95921. */
  95922. maxInitialRotation: number;
  95923. /**
  95924. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  95925. */
  95926. minAngularSpeed: number;
  95927. /**
  95928. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  95929. */
  95930. maxAngularSpeed: number;
  95931. /**
  95932. * The texture used to render each particle. (this can be a spritesheet)
  95933. */
  95934. particleTexture: Nullable<BaseTexture>;
  95935. /**
  95936. * The layer mask we are rendering the particles through.
  95937. */
  95938. layerMask: number;
  95939. /**
  95940. * This can help using your own shader to render the particle system.
  95941. * The according effect will be created
  95942. */
  95943. customShader: any;
  95944. /**
  95945. * By default particle system starts as soon as they are created. This prevents the
  95946. * automatic start to happen and let you decide when to start emitting particles.
  95947. */
  95948. preventAutoStart: boolean;
  95949. private _noiseTexture;
  95950. /**
  95951. * Gets or sets a texture used to add random noise to particle positions
  95952. */
  95953. get noiseTexture(): Nullable<ProceduralTexture>;
  95954. set noiseTexture(value: Nullable<ProceduralTexture>);
  95955. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  95956. noiseStrength: Vector3;
  95957. /**
  95958. * Callback triggered when the particle animation is ending.
  95959. */
  95960. onAnimationEnd: Nullable<() => void>;
  95961. /**
  95962. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  95963. */
  95964. blendMode: number;
  95965. /**
  95966. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  95967. * to override the particles.
  95968. */
  95969. forceDepthWrite: boolean;
  95970. /** 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 */
  95971. preWarmCycles: number;
  95972. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  95973. preWarmStepOffset: number;
  95974. /**
  95975. * 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)
  95976. */
  95977. spriteCellChangeSpeed: number;
  95978. /**
  95979. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  95980. */
  95981. startSpriteCellID: number;
  95982. /**
  95983. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  95984. */
  95985. endSpriteCellID: number;
  95986. /**
  95987. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  95988. */
  95989. spriteCellWidth: number;
  95990. /**
  95991. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  95992. */
  95993. spriteCellHeight: number;
  95994. /**
  95995. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  95996. */
  95997. spriteRandomStartCell: boolean;
  95998. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  95999. translationPivot: Vector2;
  96000. /** @hidden */
  96001. protected _isAnimationSheetEnabled: boolean;
  96002. /**
  96003. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  96004. */
  96005. beginAnimationOnStart: boolean;
  96006. /**
  96007. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  96008. */
  96009. beginAnimationFrom: number;
  96010. /**
  96011. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  96012. */
  96013. beginAnimationTo: number;
  96014. /**
  96015. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  96016. */
  96017. beginAnimationLoop: boolean;
  96018. /**
  96019. * Gets or sets a world offset applied to all particles
  96020. */
  96021. worldOffset: Vector3;
  96022. /**
  96023. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  96024. */
  96025. get isAnimationSheetEnabled(): boolean;
  96026. set isAnimationSheetEnabled(value: boolean);
  96027. /**
  96028. * Get hosting scene
  96029. * @returns the scene
  96030. */
  96031. getScene(): Nullable<Scene>;
  96032. /**
  96033. * You can use gravity if you want to give an orientation to your particles.
  96034. */
  96035. gravity: Vector3;
  96036. protected _colorGradients: Nullable<Array<ColorGradient>>;
  96037. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  96038. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  96039. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  96040. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  96041. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  96042. protected _dragGradients: Nullable<Array<FactorGradient>>;
  96043. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  96044. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  96045. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  96046. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  96047. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  96048. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  96049. /**
  96050. * Defines the delay in milliseconds before starting the system (0 by default)
  96051. */
  96052. startDelay: number;
  96053. /**
  96054. * Gets the current list of drag gradients.
  96055. * You must use addDragGradient and removeDragGradient to udpate this list
  96056. * @returns the list of drag gradients
  96057. */
  96058. getDragGradients(): Nullable<Array<FactorGradient>>;
  96059. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  96060. limitVelocityDamping: number;
  96061. /**
  96062. * Gets the current list of limit velocity gradients.
  96063. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  96064. * @returns the list of limit velocity gradients
  96065. */
  96066. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  96067. /**
  96068. * Gets the current list of color gradients.
  96069. * You must use addColorGradient and removeColorGradient to udpate this list
  96070. * @returns the list of color gradients
  96071. */
  96072. getColorGradients(): Nullable<Array<ColorGradient>>;
  96073. /**
  96074. * Gets the current list of size gradients.
  96075. * You must use addSizeGradient and removeSizeGradient to udpate this list
  96076. * @returns the list of size gradients
  96077. */
  96078. getSizeGradients(): Nullable<Array<FactorGradient>>;
  96079. /**
  96080. * Gets the current list of color remap gradients.
  96081. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  96082. * @returns the list of color remap gradients
  96083. */
  96084. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  96085. /**
  96086. * Gets the current list of alpha remap gradients.
  96087. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  96088. * @returns the list of alpha remap gradients
  96089. */
  96090. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  96091. /**
  96092. * Gets the current list of life time gradients.
  96093. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  96094. * @returns the list of life time gradients
  96095. */
  96096. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  96097. /**
  96098. * Gets the current list of angular speed gradients.
  96099. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  96100. * @returns the list of angular speed gradients
  96101. */
  96102. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  96103. /**
  96104. * Gets the current list of velocity gradients.
  96105. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  96106. * @returns the list of velocity gradients
  96107. */
  96108. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  96109. /**
  96110. * Gets the current list of start size gradients.
  96111. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  96112. * @returns the list of start size gradients
  96113. */
  96114. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  96115. /**
  96116. * Gets the current list of emit rate gradients.
  96117. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  96118. * @returns the list of emit rate gradients
  96119. */
  96120. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  96121. /**
  96122. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  96123. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96124. */
  96125. get direction1(): Vector3;
  96126. set direction1(value: Vector3);
  96127. /**
  96128. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  96129. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96130. */
  96131. get direction2(): Vector3;
  96132. set direction2(value: Vector3);
  96133. /**
  96134. * 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.
  96135. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96136. */
  96137. get minEmitBox(): Vector3;
  96138. set minEmitBox(value: Vector3);
  96139. /**
  96140. * 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.
  96141. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96142. */
  96143. get maxEmitBox(): Vector3;
  96144. set maxEmitBox(value: Vector3);
  96145. /**
  96146. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  96147. */
  96148. color1: Color4;
  96149. /**
  96150. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  96151. */
  96152. color2: Color4;
  96153. /**
  96154. * Color the particle will have at the end of its lifetime
  96155. */
  96156. colorDead: Color4;
  96157. /**
  96158. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  96159. */
  96160. textureMask: Color4;
  96161. /**
  96162. * The particle emitter type defines the emitter used by the particle system.
  96163. * It can be for example box, sphere, or cone...
  96164. */
  96165. particleEmitterType: IParticleEmitterType;
  96166. /** @hidden */
  96167. _isSubEmitter: boolean;
  96168. /**
  96169. * Gets or sets the billboard mode to use when isBillboardBased = true.
  96170. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  96171. */
  96172. billboardMode: number;
  96173. protected _isBillboardBased: boolean;
  96174. /**
  96175. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  96176. */
  96177. get isBillboardBased(): boolean;
  96178. set isBillboardBased(value: boolean);
  96179. /**
  96180. * The scene the particle system belongs to.
  96181. */
  96182. protected _scene: Nullable<Scene>;
  96183. /**
  96184. * The engine the particle system belongs to.
  96185. */
  96186. protected _engine: ThinEngine;
  96187. /**
  96188. * Local cache of defines for image processing.
  96189. */
  96190. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  96191. /**
  96192. * Default configuration related to image processing available in the standard Material.
  96193. */
  96194. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  96195. /**
  96196. * Gets the image processing configuration used either in this material.
  96197. */
  96198. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  96199. /**
  96200. * Sets the Default image processing configuration used either in the this material.
  96201. *
  96202. * If sets to null, the scene one is in use.
  96203. */
  96204. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  96205. /**
  96206. * Attaches a new image processing configuration to the Standard Material.
  96207. * @param configuration
  96208. */
  96209. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96210. /** @hidden */
  96211. protected _reset(): void;
  96212. /** @hidden */
  96213. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  96214. /**
  96215. * Instantiates a particle system.
  96216. * 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.
  96217. * @param name The name of the particle system
  96218. */
  96219. constructor(name: string);
  96220. /**
  96221. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  96222. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  96223. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  96224. * @returns the emitter
  96225. */
  96226. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  96227. /**
  96228. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  96229. * @param radius The radius of the hemisphere to emit from
  96230. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  96231. * @returns the emitter
  96232. */
  96233. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  96234. /**
  96235. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  96236. * @param radius The radius of the sphere to emit from
  96237. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  96238. * @returns the emitter
  96239. */
  96240. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  96241. /**
  96242. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  96243. * @param radius The radius of the sphere to emit from
  96244. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  96245. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  96246. * @returns the emitter
  96247. */
  96248. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  96249. /**
  96250. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  96251. * @param radius The radius of the emission cylinder
  96252. * @param height The height of the emission cylinder
  96253. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  96254. * @param directionRandomizer How much to randomize the particle direction [0-1]
  96255. * @returns the emitter
  96256. */
  96257. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  96258. /**
  96259. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  96260. * @param radius The radius of the cylinder to emit from
  96261. * @param height The height of the emission cylinder
  96262. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  96263. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  96264. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  96265. * @returns the emitter
  96266. */
  96267. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  96268. /**
  96269. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  96270. * @param radius The radius of the cone to emit from
  96271. * @param angle The base angle of the cone
  96272. * @returns the emitter
  96273. */
  96274. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  96275. /**
  96276. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  96277. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  96278. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  96279. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  96280. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  96281. * @returns the emitter
  96282. */
  96283. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  96284. }
  96285. }
  96286. declare module BABYLON {
  96287. /**
  96288. * Type of sub emitter
  96289. */
  96290. export enum SubEmitterType {
  96291. /**
  96292. * Attached to the particle over it's lifetime
  96293. */
  96294. ATTACHED = 0,
  96295. /**
  96296. * Created when the particle dies
  96297. */
  96298. END = 1
  96299. }
  96300. /**
  96301. * Sub emitter class used to emit particles from an existing particle
  96302. */
  96303. export class SubEmitter {
  96304. /**
  96305. * the particle system to be used by the sub emitter
  96306. */
  96307. particleSystem: ParticleSystem;
  96308. /**
  96309. * Type of the submitter (Default: END)
  96310. */
  96311. type: SubEmitterType;
  96312. /**
  96313. * 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)
  96314. * Note: This only is supported when using an emitter of type Mesh
  96315. */
  96316. inheritDirection: boolean;
  96317. /**
  96318. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  96319. */
  96320. inheritedVelocityAmount: number;
  96321. /**
  96322. * Creates a sub emitter
  96323. * @param particleSystem the particle system to be used by the sub emitter
  96324. */
  96325. constructor(
  96326. /**
  96327. * the particle system to be used by the sub emitter
  96328. */
  96329. particleSystem: ParticleSystem);
  96330. /**
  96331. * Clones the sub emitter
  96332. * @returns the cloned sub emitter
  96333. */
  96334. clone(): SubEmitter;
  96335. /**
  96336. * Serialize current object to a JSON object
  96337. * @returns the serialized object
  96338. */
  96339. serialize(): any;
  96340. /** @hidden */
  96341. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  96342. /**
  96343. * Creates a new SubEmitter from a serialized JSON version
  96344. * @param serializationObject defines the JSON object to read from
  96345. * @param sceneOrEngine defines the hosting scene or the hosting engine
  96346. * @param rootUrl defines the rootUrl for data loading
  96347. * @returns a new SubEmitter
  96348. */
  96349. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  96350. /** Release associated resources */
  96351. dispose(): void;
  96352. }
  96353. }
  96354. declare module BABYLON {
  96355. /** @hidden */
  96356. export var clipPlaneFragmentDeclaration: {
  96357. name: string;
  96358. shader: string;
  96359. };
  96360. }
  96361. declare module BABYLON {
  96362. /** @hidden */
  96363. export var imageProcessingDeclaration: {
  96364. name: string;
  96365. shader: string;
  96366. };
  96367. }
  96368. declare module BABYLON {
  96369. /** @hidden */
  96370. export var imageProcessingFunctions: {
  96371. name: string;
  96372. shader: string;
  96373. };
  96374. }
  96375. declare module BABYLON {
  96376. /** @hidden */
  96377. export var clipPlaneFragment: {
  96378. name: string;
  96379. shader: string;
  96380. };
  96381. }
  96382. declare module BABYLON {
  96383. /** @hidden */
  96384. export var particlesPixelShader: {
  96385. name: string;
  96386. shader: string;
  96387. };
  96388. }
  96389. declare module BABYLON {
  96390. /** @hidden */
  96391. export var clipPlaneVertexDeclaration: {
  96392. name: string;
  96393. shader: string;
  96394. };
  96395. }
  96396. declare module BABYLON {
  96397. /** @hidden */
  96398. export var clipPlaneVertex: {
  96399. name: string;
  96400. shader: string;
  96401. };
  96402. }
  96403. declare module BABYLON {
  96404. /** @hidden */
  96405. export var particlesVertexShader: {
  96406. name: string;
  96407. shader: string;
  96408. };
  96409. }
  96410. declare module BABYLON {
  96411. /**
  96412. * Interface used to define entities containing multiple clip planes
  96413. */
  96414. export interface IClipPlanesHolder {
  96415. /**
  96416. * Gets or sets the active clipplane 1
  96417. */
  96418. clipPlane: Nullable<Plane>;
  96419. /**
  96420. * Gets or sets the active clipplane 2
  96421. */
  96422. clipPlane2: Nullable<Plane>;
  96423. /**
  96424. * Gets or sets the active clipplane 3
  96425. */
  96426. clipPlane3: Nullable<Plane>;
  96427. /**
  96428. * Gets or sets the active clipplane 4
  96429. */
  96430. clipPlane4: Nullable<Plane>;
  96431. /**
  96432. * Gets or sets the active clipplane 5
  96433. */
  96434. clipPlane5: Nullable<Plane>;
  96435. /**
  96436. * Gets or sets the active clipplane 6
  96437. */
  96438. clipPlane6: Nullable<Plane>;
  96439. }
  96440. }
  96441. declare module BABYLON {
  96442. /**
  96443. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  96444. *
  96445. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  96446. *
  96447. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  96448. */
  96449. export class ThinMaterialHelper {
  96450. /**
  96451. * Binds the clip plane information from the holder to the effect.
  96452. * @param effect The effect we are binding the data to
  96453. * @param holder The entity containing the clip plane information
  96454. */
  96455. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  96456. }
  96457. }
  96458. declare module BABYLON {
  96459. interface ThinEngine {
  96460. /**
  96461. * Sets alpha constants used by some alpha blending modes
  96462. * @param r defines the red component
  96463. * @param g defines the green component
  96464. * @param b defines the blue component
  96465. * @param a defines the alpha component
  96466. */
  96467. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  96468. /**
  96469. * Sets the current alpha mode
  96470. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  96471. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  96472. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96473. */
  96474. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96475. /**
  96476. * Gets the current alpha mode
  96477. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96478. * @returns the current alpha mode
  96479. */
  96480. getAlphaMode(): number;
  96481. /**
  96482. * Sets the current alpha equation
  96483. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  96484. */
  96485. setAlphaEquation(equation: number): void;
  96486. /**
  96487. * Gets the current alpha equation.
  96488. * @returns the current alpha equation
  96489. */
  96490. getAlphaEquation(): number;
  96491. }
  96492. }
  96493. declare module BABYLON {
  96494. /**
  96495. * This represents a particle system in Babylon.
  96496. * 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.
  96497. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  96498. * @example https://doc.babylonjs.com/babylon101/particles
  96499. */
  96500. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  96501. /**
  96502. * Billboard mode will only apply to Y axis
  96503. */
  96504. static readonly BILLBOARDMODE_Y: number;
  96505. /**
  96506. * Billboard mode will apply to all axes
  96507. */
  96508. static readonly BILLBOARDMODE_ALL: number;
  96509. /**
  96510. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  96511. */
  96512. static readonly BILLBOARDMODE_STRETCHED: number;
  96513. /**
  96514. * This function can be defined to provide custom update for active particles.
  96515. * This function will be called instead of regular update (age, position, color, etc.).
  96516. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  96517. */
  96518. updateFunction: (particles: Particle[]) => void;
  96519. private _emitterWorldMatrix;
  96520. /**
  96521. * This function can be defined to specify initial direction for every new particle.
  96522. * It by default use the emitterType defined function
  96523. */
  96524. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  96525. /**
  96526. * This function can be defined to specify initial position for every new particle.
  96527. * It by default use the emitterType defined function
  96528. */
  96529. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  96530. /**
  96531. * @hidden
  96532. */
  96533. _inheritedVelocityOffset: Vector3;
  96534. /**
  96535. * An event triggered when the system is disposed
  96536. */
  96537. onDisposeObservable: Observable<IParticleSystem>;
  96538. /**
  96539. * An event triggered when the system is stopped
  96540. */
  96541. onStoppedObservable: Observable<IParticleSystem>;
  96542. private _onDisposeObserver;
  96543. /**
  96544. * Sets a callback that will be triggered when the system is disposed
  96545. */
  96546. set onDispose(callback: () => void);
  96547. private _particles;
  96548. private _epsilon;
  96549. private _capacity;
  96550. private _stockParticles;
  96551. private _newPartsExcess;
  96552. private _vertexData;
  96553. private _vertexBuffer;
  96554. private _vertexBuffers;
  96555. private _spriteBuffer;
  96556. private _indexBuffer;
  96557. private _effect;
  96558. private _customEffect;
  96559. private _cachedDefines;
  96560. private _scaledColorStep;
  96561. private _colorDiff;
  96562. private _scaledDirection;
  96563. private _scaledGravity;
  96564. private _currentRenderId;
  96565. private _alive;
  96566. private _useInstancing;
  96567. private _vertexArrayObject;
  96568. private _started;
  96569. private _stopped;
  96570. private _actualFrame;
  96571. private _scaledUpdateSpeed;
  96572. private _vertexBufferSize;
  96573. /** @hidden */
  96574. _currentEmitRateGradient: Nullable<FactorGradient>;
  96575. /** @hidden */
  96576. _currentEmitRate1: number;
  96577. /** @hidden */
  96578. _currentEmitRate2: number;
  96579. /** @hidden */
  96580. _currentStartSizeGradient: Nullable<FactorGradient>;
  96581. /** @hidden */
  96582. _currentStartSize1: number;
  96583. /** @hidden */
  96584. _currentStartSize2: number;
  96585. private readonly _rawTextureWidth;
  96586. private _rampGradientsTexture;
  96587. private _useRampGradients;
  96588. /** Gets or sets a matrix to use to compute projection */
  96589. defaultProjectionMatrix: Matrix;
  96590. /** Gets or sets a matrix to use to compute view */
  96591. defaultViewMatrix: Matrix;
  96592. /** Gets or sets a boolean indicating that ramp gradients must be used
  96593. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  96594. */
  96595. get useRampGradients(): boolean;
  96596. set useRampGradients(value: boolean);
  96597. /**
  96598. * 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.
  96599. * 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: [])
  96600. */
  96601. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  96602. private _subEmitters;
  96603. /**
  96604. * @hidden
  96605. * If the particle systems emitter should be disposed when the particle system is disposed
  96606. */
  96607. _disposeEmitterOnDispose: boolean;
  96608. /**
  96609. * The current active Sub-systems, this property is used by the root particle system only.
  96610. */
  96611. activeSubSystems: Array<ParticleSystem>;
  96612. /**
  96613. * Specifies if the particles are updated in emitter local space or world space
  96614. */
  96615. isLocal: boolean;
  96616. private _rootParticleSystem;
  96617. /**
  96618. * Gets the current list of active particles
  96619. */
  96620. get particles(): Particle[];
  96621. /**
  96622. * Gets the number of particles active at the same time.
  96623. * @returns The number of active particles.
  96624. */
  96625. getActiveCount(): number;
  96626. /**
  96627. * Returns the string "ParticleSystem"
  96628. * @returns a string containing the class name
  96629. */
  96630. getClassName(): string;
  96631. /**
  96632. * Gets a boolean indicating that the system is stopping
  96633. * @returns true if the system is currently stopping
  96634. */
  96635. isStopping(): boolean;
  96636. /**
  96637. * Gets the custom effect used to render the particles
  96638. * @param blendMode Blend mode for which the effect should be retrieved
  96639. * @returns The effect
  96640. */
  96641. getCustomEffect(blendMode?: number): Nullable<Effect>;
  96642. /**
  96643. * Sets the custom effect used to render the particles
  96644. * @param effect The effect to set
  96645. * @param blendMode Blend mode for which the effect should be set
  96646. */
  96647. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  96648. /** @hidden */
  96649. private _onBeforeDrawParticlesObservable;
  96650. /**
  96651. * Observable that will be called just before the particles are drawn
  96652. */
  96653. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  96654. /**
  96655. * Gets the name of the particle vertex shader
  96656. */
  96657. get vertexShaderName(): string;
  96658. /**
  96659. * Instantiates a particle system.
  96660. * 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.
  96661. * @param name The name of the particle system
  96662. * @param capacity The max number of particles alive at the same time
  96663. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  96664. * @param customEffect a custom effect used to change the way particles are rendered by default
  96665. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  96666. * @param epsilon Offset used to render the particles
  96667. */
  96668. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  96669. private _addFactorGradient;
  96670. private _removeFactorGradient;
  96671. /**
  96672. * Adds a new life time gradient
  96673. * @param gradient defines the gradient to use (between 0 and 1)
  96674. * @param factor defines the life time factor to affect to the specified gradient
  96675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96676. * @returns the current particle system
  96677. */
  96678. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96679. /**
  96680. * Remove a specific life time gradient
  96681. * @param gradient defines the gradient to remove
  96682. * @returns the current particle system
  96683. */
  96684. removeLifeTimeGradient(gradient: number): IParticleSystem;
  96685. /**
  96686. * Adds a new size gradient
  96687. * @param gradient defines the gradient to use (between 0 and 1)
  96688. * @param factor defines the size factor to affect to the specified gradient
  96689. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96690. * @returns the current particle system
  96691. */
  96692. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96693. /**
  96694. * Remove a specific size gradient
  96695. * @param gradient defines the gradient to remove
  96696. * @returns the current particle system
  96697. */
  96698. removeSizeGradient(gradient: number): IParticleSystem;
  96699. /**
  96700. * Adds a new color remap gradient
  96701. * @param gradient defines the gradient to use (between 0 and 1)
  96702. * @param min defines the color remap minimal range
  96703. * @param max defines the color remap maximal range
  96704. * @returns the current particle system
  96705. */
  96706. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  96707. /**
  96708. * Remove a specific color remap gradient
  96709. * @param gradient defines the gradient to remove
  96710. * @returns the current particle system
  96711. */
  96712. removeColorRemapGradient(gradient: number): IParticleSystem;
  96713. /**
  96714. * Adds a new alpha remap gradient
  96715. * @param gradient defines the gradient to use (between 0 and 1)
  96716. * @param min defines the alpha remap minimal range
  96717. * @param max defines the alpha remap maximal range
  96718. * @returns the current particle system
  96719. */
  96720. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  96721. /**
  96722. * Remove a specific alpha remap gradient
  96723. * @param gradient defines the gradient to remove
  96724. * @returns the current particle system
  96725. */
  96726. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  96727. /**
  96728. * Adds a new angular speed gradient
  96729. * @param gradient defines the gradient to use (between 0 and 1)
  96730. * @param factor defines the angular speed to affect to the specified gradient
  96731. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96732. * @returns the current particle system
  96733. */
  96734. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96735. /**
  96736. * Remove a specific angular speed gradient
  96737. * @param gradient defines the gradient to remove
  96738. * @returns the current particle system
  96739. */
  96740. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  96741. /**
  96742. * Adds a new velocity gradient
  96743. * @param gradient defines the gradient to use (between 0 and 1)
  96744. * @param factor defines the velocity to affect to the specified gradient
  96745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96746. * @returns the current particle system
  96747. */
  96748. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96749. /**
  96750. * Remove a specific velocity gradient
  96751. * @param gradient defines the gradient to remove
  96752. * @returns the current particle system
  96753. */
  96754. removeVelocityGradient(gradient: number): IParticleSystem;
  96755. /**
  96756. * Adds a new limit velocity gradient
  96757. * @param gradient defines the gradient to use (between 0 and 1)
  96758. * @param factor defines the limit velocity value to affect to the specified gradient
  96759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96760. * @returns the current particle system
  96761. */
  96762. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96763. /**
  96764. * Remove a specific limit velocity gradient
  96765. * @param gradient defines the gradient to remove
  96766. * @returns the current particle system
  96767. */
  96768. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  96769. /**
  96770. * Adds a new drag gradient
  96771. * @param gradient defines the gradient to use (between 0 and 1)
  96772. * @param factor defines the drag value to affect to the specified gradient
  96773. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96774. * @returns the current particle system
  96775. */
  96776. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96777. /**
  96778. * Remove a specific drag gradient
  96779. * @param gradient defines the gradient to remove
  96780. * @returns the current particle system
  96781. */
  96782. removeDragGradient(gradient: number): IParticleSystem;
  96783. /**
  96784. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  96785. * @param gradient defines the gradient to use (between 0 and 1)
  96786. * @param factor defines the emit rate value to affect to the specified gradient
  96787. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96788. * @returns the current particle system
  96789. */
  96790. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96791. /**
  96792. * Remove a specific emit rate gradient
  96793. * @param gradient defines the gradient to remove
  96794. * @returns the current particle system
  96795. */
  96796. removeEmitRateGradient(gradient: number): IParticleSystem;
  96797. /**
  96798. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  96799. * @param gradient defines the gradient to use (between 0 and 1)
  96800. * @param factor defines the start size value to affect to the specified gradient
  96801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96802. * @returns the current particle system
  96803. */
  96804. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96805. /**
  96806. * Remove a specific start size gradient
  96807. * @param gradient defines the gradient to remove
  96808. * @returns the current particle system
  96809. */
  96810. removeStartSizeGradient(gradient: number): IParticleSystem;
  96811. private _createRampGradientTexture;
  96812. /**
  96813. * Gets the current list of ramp gradients.
  96814. * You must use addRampGradient and removeRampGradient to udpate this list
  96815. * @returns the list of ramp gradients
  96816. */
  96817. getRampGradients(): Nullable<Array<Color3Gradient>>;
  96818. /** Force the system to rebuild all gradients that need to be resync */
  96819. forceRefreshGradients(): void;
  96820. private _syncRampGradientTexture;
  96821. /**
  96822. * Adds a new ramp gradient used to remap particle colors
  96823. * @param gradient defines the gradient to use (between 0 and 1)
  96824. * @param color defines the color to affect to the specified gradient
  96825. * @returns the current particle system
  96826. */
  96827. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  96828. /**
  96829. * Remove a specific ramp gradient
  96830. * @param gradient defines the gradient to remove
  96831. * @returns the current particle system
  96832. */
  96833. removeRampGradient(gradient: number): ParticleSystem;
  96834. /**
  96835. * Adds a new color gradient
  96836. * @param gradient defines the gradient to use (between 0 and 1)
  96837. * @param color1 defines the color to affect to the specified gradient
  96838. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  96839. * @returns this particle system
  96840. */
  96841. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  96842. /**
  96843. * Remove a specific color gradient
  96844. * @param gradient defines the gradient to remove
  96845. * @returns this particle system
  96846. */
  96847. removeColorGradient(gradient: number): IParticleSystem;
  96848. private _fetchR;
  96849. protected _reset(): void;
  96850. private _resetEffect;
  96851. private _createVertexBuffers;
  96852. private _createIndexBuffer;
  96853. /**
  96854. * Gets the maximum number of particles active at the same time.
  96855. * @returns The max number of active particles.
  96856. */
  96857. getCapacity(): number;
  96858. /**
  96859. * Gets whether there are still active particles in the system.
  96860. * @returns True if it is alive, otherwise false.
  96861. */
  96862. isAlive(): boolean;
  96863. /**
  96864. * Gets if the system has been started. (Note: this will still be true after stop is called)
  96865. * @returns True if it has been started, otherwise false.
  96866. */
  96867. isStarted(): boolean;
  96868. private _prepareSubEmitterInternalArray;
  96869. /**
  96870. * Starts the particle system and begins to emit
  96871. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  96872. */
  96873. start(delay?: number): void;
  96874. /**
  96875. * Stops the particle system.
  96876. * @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.
  96877. */
  96878. stop(stopSubEmitters?: boolean): void;
  96879. /**
  96880. * Remove all active particles
  96881. */
  96882. reset(): void;
  96883. /**
  96884. * @hidden (for internal use only)
  96885. */
  96886. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  96887. /**
  96888. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  96889. * Its lifetime will start back at 0.
  96890. */
  96891. recycleParticle: (particle: Particle) => void;
  96892. private _stopSubEmitters;
  96893. private _createParticle;
  96894. private _removeFromRoot;
  96895. private _emitFromParticle;
  96896. private _update;
  96897. /** @hidden */
  96898. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  96899. /** @hidden */
  96900. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  96901. /**
  96902. * Fill the defines array according to the current settings of the particle system
  96903. * @param defines Array to be updated
  96904. * @param blendMode blend mode to take into account when updating the array
  96905. */
  96906. fillDefines(defines: Array<string>, blendMode: number): void;
  96907. /**
  96908. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  96909. * @param uniforms Uniforms array to fill
  96910. * @param attributes Attributes array to fill
  96911. * @param samplers Samplers array to fill
  96912. */
  96913. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  96914. /** @hidden */
  96915. private _getEffect;
  96916. /**
  96917. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  96918. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  96919. */
  96920. animate(preWarmOnly?: boolean): void;
  96921. private _appendParticleVertices;
  96922. /**
  96923. * Rebuilds the particle system.
  96924. */
  96925. rebuild(): void;
  96926. /**
  96927. * Is this system ready to be used/rendered
  96928. * @return true if the system is ready
  96929. */
  96930. isReady(): boolean;
  96931. private _render;
  96932. /**
  96933. * Renders the particle system in its current state.
  96934. * @returns the current number of particles
  96935. */
  96936. render(): number;
  96937. /**
  96938. * Disposes the particle system and free the associated resources
  96939. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  96940. */
  96941. dispose(disposeTexture?: boolean): void;
  96942. /**
  96943. * Clones the particle system.
  96944. * @param name The name of the cloned object
  96945. * @param newEmitter The new emitter to use
  96946. * @returns the cloned particle system
  96947. */
  96948. clone(name: string, newEmitter: any): ParticleSystem;
  96949. /**
  96950. * Serializes the particle system to a JSON object
  96951. * @param serializeTexture defines if the texture must be serialized as well
  96952. * @returns the JSON object
  96953. */
  96954. serialize(serializeTexture?: boolean): any;
  96955. /** @hidden */
  96956. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  96957. /** @hidden */
  96958. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  96959. /**
  96960. * Parses a JSON object to create a particle system.
  96961. * @param parsedParticleSystem The JSON object to parse
  96962. * @param sceneOrEngine The scene or the engine to create the particle system in
  96963. * @param rootUrl The root url to use to load external dependencies like texture
  96964. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  96965. * @returns the Parsed particle system
  96966. */
  96967. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  96968. }
  96969. }
  96970. declare module BABYLON {
  96971. /**
  96972. * A particle represents one of the element emitted by a particle system.
  96973. * This is mainly define by its coordinates, direction, velocity and age.
  96974. */
  96975. export class Particle {
  96976. /**
  96977. * The particle system the particle belongs to.
  96978. */
  96979. particleSystem: ParticleSystem;
  96980. private static _Count;
  96981. /**
  96982. * Unique ID of the particle
  96983. */
  96984. id: number;
  96985. /**
  96986. * The world position of the particle in the scene.
  96987. */
  96988. position: Vector3;
  96989. /**
  96990. * The world direction of the particle in the scene.
  96991. */
  96992. direction: Vector3;
  96993. /**
  96994. * The color of the particle.
  96995. */
  96996. color: Color4;
  96997. /**
  96998. * The color change of the particle per step.
  96999. */
  97000. colorStep: Color4;
  97001. /**
  97002. * Defines how long will the life of the particle be.
  97003. */
  97004. lifeTime: number;
  97005. /**
  97006. * The current age of the particle.
  97007. */
  97008. age: number;
  97009. /**
  97010. * The current size of the particle.
  97011. */
  97012. size: number;
  97013. /**
  97014. * The current scale of the particle.
  97015. */
  97016. scale: Vector2;
  97017. /**
  97018. * The current angle of the particle.
  97019. */
  97020. angle: number;
  97021. /**
  97022. * Defines how fast is the angle changing.
  97023. */
  97024. angularSpeed: number;
  97025. /**
  97026. * Defines the cell index used by the particle to be rendered from a sprite.
  97027. */
  97028. cellIndex: number;
  97029. /**
  97030. * The information required to support color remapping
  97031. */
  97032. remapData: Vector4;
  97033. /** @hidden */
  97034. _randomCellOffset?: number;
  97035. /** @hidden */
  97036. _initialDirection: Nullable<Vector3>;
  97037. /** @hidden */
  97038. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  97039. /** @hidden */
  97040. _initialStartSpriteCellID: number;
  97041. /** @hidden */
  97042. _initialEndSpriteCellID: number;
  97043. /** @hidden */
  97044. _currentColorGradient: Nullable<ColorGradient>;
  97045. /** @hidden */
  97046. _currentColor1: Color4;
  97047. /** @hidden */
  97048. _currentColor2: Color4;
  97049. /** @hidden */
  97050. _currentSizeGradient: Nullable<FactorGradient>;
  97051. /** @hidden */
  97052. _currentSize1: number;
  97053. /** @hidden */
  97054. _currentSize2: number;
  97055. /** @hidden */
  97056. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  97057. /** @hidden */
  97058. _currentAngularSpeed1: number;
  97059. /** @hidden */
  97060. _currentAngularSpeed2: number;
  97061. /** @hidden */
  97062. _currentVelocityGradient: Nullable<FactorGradient>;
  97063. /** @hidden */
  97064. _currentVelocity1: number;
  97065. /** @hidden */
  97066. _currentVelocity2: number;
  97067. /** @hidden */
  97068. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  97069. /** @hidden */
  97070. _currentLimitVelocity1: number;
  97071. /** @hidden */
  97072. _currentLimitVelocity2: number;
  97073. /** @hidden */
  97074. _currentDragGradient: Nullable<FactorGradient>;
  97075. /** @hidden */
  97076. _currentDrag1: number;
  97077. /** @hidden */
  97078. _currentDrag2: number;
  97079. /** @hidden */
  97080. _randomNoiseCoordinates1: Vector3;
  97081. /** @hidden */
  97082. _randomNoiseCoordinates2: Vector3;
  97083. /** @hidden */
  97084. _localPosition?: Vector3;
  97085. /**
  97086. * Creates a new instance Particle
  97087. * @param particleSystem the particle system the particle belongs to
  97088. */
  97089. constructor(
  97090. /**
  97091. * The particle system the particle belongs to.
  97092. */
  97093. particleSystem: ParticleSystem);
  97094. private updateCellInfoFromSystem;
  97095. /**
  97096. * Defines how the sprite cell index is updated for the particle
  97097. */
  97098. updateCellIndex(): void;
  97099. /** @hidden */
  97100. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  97101. /** @hidden */
  97102. _inheritParticleInfoToSubEmitters(): void;
  97103. /** @hidden */
  97104. _reset(): void;
  97105. /**
  97106. * Copy the properties of particle to another one.
  97107. * @param other the particle to copy the information to.
  97108. */
  97109. copyTo(other: Particle): void;
  97110. }
  97111. }
  97112. declare module BABYLON {
  97113. /**
  97114. * Particle emitter represents a volume emitting particles.
  97115. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  97116. */
  97117. export interface IParticleEmitterType {
  97118. /**
  97119. * Called by the particle System when the direction is computed for the created particle.
  97120. * @param worldMatrix is the world matrix of the particle system
  97121. * @param directionToUpdate is the direction vector to update with the result
  97122. * @param particle is the particle we are computed the direction for
  97123. * @param isLocal defines if the direction should be set in local space
  97124. */
  97125. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97126. /**
  97127. * Called by the particle System when the position is computed for the created particle.
  97128. * @param worldMatrix is the world matrix of the particle system
  97129. * @param positionToUpdate is the position vector to update with the result
  97130. * @param particle is the particle we are computed the position for
  97131. * @param isLocal defines if the position should be set in local space
  97132. */
  97133. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97134. /**
  97135. * Clones the current emitter and returns a copy of it
  97136. * @returns the new emitter
  97137. */
  97138. clone(): IParticleEmitterType;
  97139. /**
  97140. * Called by the GPUParticleSystem to setup the update shader
  97141. * @param effect defines the update shader
  97142. */
  97143. applyToShader(effect: Effect): void;
  97144. /**
  97145. * Returns a string to use to update the GPU particles update shader
  97146. * @returns the effect defines string
  97147. */
  97148. getEffectDefines(): string;
  97149. /**
  97150. * Returns a string representing the class name
  97151. * @returns a string containing the class name
  97152. */
  97153. getClassName(): string;
  97154. /**
  97155. * Serializes the particle system to a JSON object.
  97156. * @returns the JSON object
  97157. */
  97158. serialize(): any;
  97159. /**
  97160. * Parse properties from a JSON object
  97161. * @param serializationObject defines the JSON object
  97162. * @param scene defines the hosting scene
  97163. */
  97164. parse(serializationObject: any, scene: Nullable<Scene>): void;
  97165. }
  97166. }
  97167. declare module BABYLON {
  97168. /**
  97169. * Particle emitter emitting particles from the inside of a box.
  97170. * It emits the particles randomly between 2 given directions.
  97171. */
  97172. export class BoxParticleEmitter implements IParticleEmitterType {
  97173. /**
  97174. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97175. */
  97176. direction1: Vector3;
  97177. /**
  97178. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97179. */
  97180. direction2: Vector3;
  97181. /**
  97182. * 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.
  97183. */
  97184. minEmitBox: Vector3;
  97185. /**
  97186. * 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.
  97187. */
  97188. maxEmitBox: Vector3;
  97189. /**
  97190. * Creates a new instance BoxParticleEmitter
  97191. */
  97192. constructor();
  97193. /**
  97194. * Called by the particle System when the direction is computed for the created particle.
  97195. * @param worldMatrix is the world matrix of the particle system
  97196. * @param directionToUpdate is the direction vector to update with the result
  97197. * @param particle is the particle we are computed the direction for
  97198. * @param isLocal defines if the direction should be set in local space
  97199. */
  97200. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97201. /**
  97202. * Called by the particle System when the position is computed for the created particle.
  97203. * @param worldMatrix is the world matrix of the particle system
  97204. * @param positionToUpdate is the position vector to update with the result
  97205. * @param particle is the particle we are computed the position for
  97206. * @param isLocal defines if the position should be set in local space
  97207. */
  97208. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97209. /**
  97210. * Clones the current emitter and returns a copy of it
  97211. * @returns the new emitter
  97212. */
  97213. clone(): BoxParticleEmitter;
  97214. /**
  97215. * Called by the GPUParticleSystem to setup the update shader
  97216. * @param effect defines the update shader
  97217. */
  97218. applyToShader(effect: Effect): void;
  97219. /**
  97220. * Returns a string to use to update the GPU particles update shader
  97221. * @returns a string containng the defines string
  97222. */
  97223. getEffectDefines(): string;
  97224. /**
  97225. * Returns the string "BoxParticleEmitter"
  97226. * @returns a string containing the class name
  97227. */
  97228. getClassName(): string;
  97229. /**
  97230. * Serializes the particle system to a JSON object.
  97231. * @returns the JSON object
  97232. */
  97233. serialize(): any;
  97234. /**
  97235. * Parse properties from a JSON object
  97236. * @param serializationObject defines the JSON object
  97237. */
  97238. parse(serializationObject: any): void;
  97239. }
  97240. }
  97241. declare module BABYLON {
  97242. /**
  97243. * Particle emitter emitting particles from the inside of a cone.
  97244. * It emits the particles alongside the cone volume from the base to the particle.
  97245. * The emission direction might be randomized.
  97246. */
  97247. export class ConeParticleEmitter implements IParticleEmitterType {
  97248. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  97249. directionRandomizer: number;
  97250. private _radius;
  97251. private _angle;
  97252. private _height;
  97253. /**
  97254. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  97255. */
  97256. radiusRange: number;
  97257. /**
  97258. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  97259. */
  97260. heightRange: number;
  97261. /**
  97262. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  97263. */
  97264. emitFromSpawnPointOnly: boolean;
  97265. /**
  97266. * Gets or sets the radius of the emission cone
  97267. */
  97268. get radius(): number;
  97269. set radius(value: number);
  97270. /**
  97271. * Gets or sets the angle of the emission cone
  97272. */
  97273. get angle(): number;
  97274. set angle(value: number);
  97275. private _buildHeight;
  97276. /**
  97277. * Creates a new instance ConeParticleEmitter
  97278. * @param radius the radius of the emission cone (1 by default)
  97279. * @param angle the cone base angle (PI by default)
  97280. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  97281. */
  97282. constructor(radius?: number, angle?: number,
  97283. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  97284. directionRandomizer?: number);
  97285. /**
  97286. * Called by the particle System when the direction is computed for the created particle.
  97287. * @param worldMatrix is the world matrix of the particle system
  97288. * @param directionToUpdate is the direction vector to update with the result
  97289. * @param particle is the particle we are computed the direction for
  97290. * @param isLocal defines if the direction should be set in local space
  97291. */
  97292. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97293. /**
  97294. * Called by the particle System when the position is computed for the created particle.
  97295. * @param worldMatrix is the world matrix of the particle system
  97296. * @param positionToUpdate is the position vector to update with the result
  97297. * @param particle is the particle we are computed the position for
  97298. * @param isLocal defines if the position should be set in local space
  97299. */
  97300. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97301. /**
  97302. * Clones the current emitter and returns a copy of it
  97303. * @returns the new emitter
  97304. */
  97305. clone(): ConeParticleEmitter;
  97306. /**
  97307. * Called by the GPUParticleSystem to setup the update shader
  97308. * @param effect defines the update shader
  97309. */
  97310. applyToShader(effect: Effect): void;
  97311. /**
  97312. * Returns a string to use to update the GPU particles update shader
  97313. * @returns a string containng the defines string
  97314. */
  97315. getEffectDefines(): string;
  97316. /**
  97317. * Returns the string "ConeParticleEmitter"
  97318. * @returns a string containing the class name
  97319. */
  97320. getClassName(): string;
  97321. /**
  97322. * Serializes the particle system to a JSON object.
  97323. * @returns the JSON object
  97324. */
  97325. serialize(): any;
  97326. /**
  97327. * Parse properties from a JSON object
  97328. * @param serializationObject defines the JSON object
  97329. */
  97330. parse(serializationObject: any): void;
  97331. }
  97332. }
  97333. declare module BABYLON {
  97334. /**
  97335. * Particle emitter emitting particles from the inside of a cylinder.
  97336. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  97337. */
  97338. export class CylinderParticleEmitter implements IParticleEmitterType {
  97339. /**
  97340. * The radius of the emission cylinder.
  97341. */
  97342. radius: number;
  97343. /**
  97344. * The height of the emission cylinder.
  97345. */
  97346. height: number;
  97347. /**
  97348. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97349. */
  97350. radiusRange: number;
  97351. /**
  97352. * How much to randomize the particle direction [0-1].
  97353. */
  97354. directionRandomizer: number;
  97355. /**
  97356. * Creates a new instance CylinderParticleEmitter
  97357. * @param radius the radius of the emission cylinder (1 by default)
  97358. * @param height the height of the emission cylinder (1 by default)
  97359. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97360. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97361. */
  97362. constructor(
  97363. /**
  97364. * The radius of the emission cylinder.
  97365. */
  97366. radius?: number,
  97367. /**
  97368. * The height of the emission cylinder.
  97369. */
  97370. height?: number,
  97371. /**
  97372. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97373. */
  97374. radiusRange?: number,
  97375. /**
  97376. * How much to randomize the particle direction [0-1].
  97377. */
  97378. directionRandomizer?: number);
  97379. /**
  97380. * Called by the particle System when the direction is computed for the created particle.
  97381. * @param worldMatrix is the world matrix of the particle system
  97382. * @param directionToUpdate is the direction vector to update with the result
  97383. * @param particle is the particle we are computed the direction for
  97384. * @param isLocal defines if the direction should be set in local space
  97385. */
  97386. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97387. /**
  97388. * Called by the particle System when the position is computed for the created particle.
  97389. * @param worldMatrix is the world matrix of the particle system
  97390. * @param positionToUpdate is the position vector to update with the result
  97391. * @param particle is the particle we are computed the position for
  97392. * @param isLocal defines if the position should be set in local space
  97393. */
  97394. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97395. /**
  97396. * Clones the current emitter and returns a copy of it
  97397. * @returns the new emitter
  97398. */
  97399. clone(): CylinderParticleEmitter;
  97400. /**
  97401. * Called by the GPUParticleSystem to setup the update shader
  97402. * @param effect defines the update shader
  97403. */
  97404. applyToShader(effect: Effect): void;
  97405. /**
  97406. * Returns a string to use to update the GPU particles update shader
  97407. * @returns a string containng the defines string
  97408. */
  97409. getEffectDefines(): string;
  97410. /**
  97411. * Returns the string "CylinderParticleEmitter"
  97412. * @returns a string containing the class name
  97413. */
  97414. getClassName(): string;
  97415. /**
  97416. * Serializes the particle system to a JSON object.
  97417. * @returns the JSON object
  97418. */
  97419. serialize(): any;
  97420. /**
  97421. * Parse properties from a JSON object
  97422. * @param serializationObject defines the JSON object
  97423. */
  97424. parse(serializationObject: any): void;
  97425. }
  97426. /**
  97427. * Particle emitter emitting particles from the inside of a cylinder.
  97428. * It emits the particles randomly between two vectors.
  97429. */
  97430. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  97431. /**
  97432. * The min limit of the emission direction.
  97433. */
  97434. direction1: Vector3;
  97435. /**
  97436. * The max limit of the emission direction.
  97437. */
  97438. direction2: Vector3;
  97439. /**
  97440. * Creates a new instance CylinderDirectedParticleEmitter
  97441. * @param radius the radius of the emission cylinder (1 by default)
  97442. * @param height the height of the emission cylinder (1 by default)
  97443. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97444. * @param direction1 the min limit of the emission direction (up vector by default)
  97445. * @param direction2 the max limit of the emission direction (up vector by default)
  97446. */
  97447. constructor(radius?: number, height?: number, radiusRange?: number,
  97448. /**
  97449. * The min limit of the emission direction.
  97450. */
  97451. direction1?: Vector3,
  97452. /**
  97453. * The max limit of the emission direction.
  97454. */
  97455. direction2?: Vector3);
  97456. /**
  97457. * Called by the particle System when the direction is computed for the created particle.
  97458. * @param worldMatrix is the world matrix of the particle system
  97459. * @param directionToUpdate is the direction vector to update with the result
  97460. * @param particle is the particle we are computed the direction for
  97461. */
  97462. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  97463. /**
  97464. * Clones the current emitter and returns a copy of it
  97465. * @returns the new emitter
  97466. */
  97467. clone(): CylinderDirectedParticleEmitter;
  97468. /**
  97469. * Called by the GPUParticleSystem to setup the update shader
  97470. * @param effect defines the update shader
  97471. */
  97472. applyToShader(effect: Effect): void;
  97473. /**
  97474. * Returns a string to use to update the GPU particles update shader
  97475. * @returns a string containng the defines string
  97476. */
  97477. getEffectDefines(): string;
  97478. /**
  97479. * Returns the string "CylinderDirectedParticleEmitter"
  97480. * @returns a string containing the class name
  97481. */
  97482. getClassName(): string;
  97483. /**
  97484. * Serializes the particle system to a JSON object.
  97485. * @returns the JSON object
  97486. */
  97487. serialize(): any;
  97488. /**
  97489. * Parse properties from a JSON object
  97490. * @param serializationObject defines the JSON object
  97491. */
  97492. parse(serializationObject: any): void;
  97493. }
  97494. }
  97495. declare module BABYLON {
  97496. /**
  97497. * Particle emitter emitting particles from the inside of a hemisphere.
  97498. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  97499. */
  97500. export class HemisphericParticleEmitter implements IParticleEmitterType {
  97501. /**
  97502. * The radius of the emission hemisphere.
  97503. */
  97504. radius: number;
  97505. /**
  97506. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97507. */
  97508. radiusRange: number;
  97509. /**
  97510. * How much to randomize the particle direction [0-1].
  97511. */
  97512. directionRandomizer: number;
  97513. /**
  97514. * Creates a new instance HemisphericParticleEmitter
  97515. * @param radius the radius of the emission hemisphere (1 by default)
  97516. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97517. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97518. */
  97519. constructor(
  97520. /**
  97521. * The radius of the emission hemisphere.
  97522. */
  97523. radius?: number,
  97524. /**
  97525. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97526. */
  97527. radiusRange?: number,
  97528. /**
  97529. * How much to randomize the particle direction [0-1].
  97530. */
  97531. directionRandomizer?: number);
  97532. /**
  97533. * Called by the particle System when the direction is computed for the created particle.
  97534. * @param worldMatrix is the world matrix of the particle system
  97535. * @param directionToUpdate is the direction vector to update with the result
  97536. * @param particle is the particle we are computed the direction for
  97537. * @param isLocal defines if the direction should be set in local space
  97538. */
  97539. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97540. /**
  97541. * Called by the particle System when the position is computed for the created particle.
  97542. * @param worldMatrix is the world matrix of the particle system
  97543. * @param positionToUpdate is the position vector to update with the result
  97544. * @param particle is the particle we are computed the position for
  97545. * @param isLocal defines if the position should be set in local space
  97546. */
  97547. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97548. /**
  97549. * Clones the current emitter and returns a copy of it
  97550. * @returns the new emitter
  97551. */
  97552. clone(): HemisphericParticleEmitter;
  97553. /**
  97554. * Called by the GPUParticleSystem to setup the update shader
  97555. * @param effect defines the update shader
  97556. */
  97557. applyToShader(effect: Effect): void;
  97558. /**
  97559. * Returns a string to use to update the GPU particles update shader
  97560. * @returns a string containng the defines string
  97561. */
  97562. getEffectDefines(): string;
  97563. /**
  97564. * Returns the string "HemisphericParticleEmitter"
  97565. * @returns a string containing the class name
  97566. */
  97567. getClassName(): string;
  97568. /**
  97569. * Serializes the particle system to a JSON object.
  97570. * @returns the JSON object
  97571. */
  97572. serialize(): any;
  97573. /**
  97574. * Parse properties from a JSON object
  97575. * @param serializationObject defines the JSON object
  97576. */
  97577. parse(serializationObject: any): void;
  97578. }
  97579. }
  97580. declare module BABYLON {
  97581. /**
  97582. * Particle emitter emitting particles from a point.
  97583. * It emits the particles randomly between 2 given directions.
  97584. */
  97585. export class PointParticleEmitter implements IParticleEmitterType {
  97586. /**
  97587. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97588. */
  97589. direction1: Vector3;
  97590. /**
  97591. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97592. */
  97593. direction2: Vector3;
  97594. /**
  97595. * Creates a new instance PointParticleEmitter
  97596. */
  97597. constructor();
  97598. /**
  97599. * Called by the particle System when the direction is computed for the created particle.
  97600. * @param worldMatrix is the world matrix of the particle system
  97601. * @param directionToUpdate is the direction vector to update with the result
  97602. * @param particle is the particle we are computed the direction for
  97603. * @param isLocal defines if the direction should be set in local space
  97604. */
  97605. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97606. /**
  97607. * Called by the particle System when the position is computed for the created particle.
  97608. * @param worldMatrix is the world matrix of the particle system
  97609. * @param positionToUpdate is the position vector to update with the result
  97610. * @param particle is the particle we are computed the position for
  97611. * @param isLocal defines if the position should be set in local space
  97612. */
  97613. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97614. /**
  97615. * Clones the current emitter and returns a copy of it
  97616. * @returns the new emitter
  97617. */
  97618. clone(): PointParticleEmitter;
  97619. /**
  97620. * Called by the GPUParticleSystem to setup the update shader
  97621. * @param effect defines the update shader
  97622. */
  97623. applyToShader(effect: Effect): void;
  97624. /**
  97625. * Returns a string to use to update the GPU particles update shader
  97626. * @returns a string containng the defines string
  97627. */
  97628. getEffectDefines(): string;
  97629. /**
  97630. * Returns the string "PointParticleEmitter"
  97631. * @returns a string containing the class name
  97632. */
  97633. getClassName(): string;
  97634. /**
  97635. * Serializes the particle system to a JSON object.
  97636. * @returns the JSON object
  97637. */
  97638. serialize(): any;
  97639. /**
  97640. * Parse properties from a JSON object
  97641. * @param serializationObject defines the JSON object
  97642. */
  97643. parse(serializationObject: any): void;
  97644. }
  97645. }
  97646. declare module BABYLON {
  97647. /**
  97648. * Particle emitter emitting particles from the inside of a sphere.
  97649. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  97650. */
  97651. export class SphereParticleEmitter implements IParticleEmitterType {
  97652. /**
  97653. * The radius of the emission sphere.
  97654. */
  97655. radius: number;
  97656. /**
  97657. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97658. */
  97659. radiusRange: number;
  97660. /**
  97661. * How much to randomize the particle direction [0-1].
  97662. */
  97663. directionRandomizer: number;
  97664. /**
  97665. * Creates a new instance SphereParticleEmitter
  97666. * @param radius the radius of the emission sphere (1 by default)
  97667. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97668. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97669. */
  97670. constructor(
  97671. /**
  97672. * The radius of the emission sphere.
  97673. */
  97674. radius?: number,
  97675. /**
  97676. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97677. */
  97678. radiusRange?: number,
  97679. /**
  97680. * How much to randomize the particle direction [0-1].
  97681. */
  97682. directionRandomizer?: number);
  97683. /**
  97684. * Called by the particle System when the direction is computed for the created particle.
  97685. * @param worldMatrix is the world matrix of the particle system
  97686. * @param directionToUpdate is the direction vector to update with the result
  97687. * @param particle is the particle we are computed the direction for
  97688. * @param isLocal defines if the direction should be set in local space
  97689. */
  97690. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97691. /**
  97692. * Called by the particle System when the position is computed for the created particle.
  97693. * @param worldMatrix is the world matrix of the particle system
  97694. * @param positionToUpdate is the position vector to update with the result
  97695. * @param particle is the particle we are computed the position for
  97696. * @param isLocal defines if the position should be set in local space
  97697. */
  97698. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97699. /**
  97700. * Clones the current emitter and returns a copy of it
  97701. * @returns the new emitter
  97702. */
  97703. clone(): SphereParticleEmitter;
  97704. /**
  97705. * Called by the GPUParticleSystem to setup the update shader
  97706. * @param effect defines the update shader
  97707. */
  97708. applyToShader(effect: Effect): void;
  97709. /**
  97710. * Returns a string to use to update the GPU particles update shader
  97711. * @returns a string containng the defines string
  97712. */
  97713. getEffectDefines(): string;
  97714. /**
  97715. * Returns the string "SphereParticleEmitter"
  97716. * @returns a string containing the class name
  97717. */
  97718. getClassName(): string;
  97719. /**
  97720. * Serializes the particle system to a JSON object.
  97721. * @returns the JSON object
  97722. */
  97723. serialize(): any;
  97724. /**
  97725. * Parse properties from a JSON object
  97726. * @param serializationObject defines the JSON object
  97727. */
  97728. parse(serializationObject: any): void;
  97729. }
  97730. /**
  97731. * Particle emitter emitting particles from the inside of a sphere.
  97732. * It emits the particles randomly between two vectors.
  97733. */
  97734. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  97735. /**
  97736. * The min limit of the emission direction.
  97737. */
  97738. direction1: Vector3;
  97739. /**
  97740. * The max limit of the emission direction.
  97741. */
  97742. direction2: Vector3;
  97743. /**
  97744. * Creates a new instance SphereDirectedParticleEmitter
  97745. * @param radius the radius of the emission sphere (1 by default)
  97746. * @param direction1 the min limit of the emission direction (up vector by default)
  97747. * @param direction2 the max limit of the emission direction (up vector by default)
  97748. */
  97749. constructor(radius?: number,
  97750. /**
  97751. * The min limit of the emission direction.
  97752. */
  97753. direction1?: Vector3,
  97754. /**
  97755. * The max limit of the emission direction.
  97756. */
  97757. direction2?: Vector3);
  97758. /**
  97759. * Called by the particle System when the direction is computed for the created particle.
  97760. * @param worldMatrix is the world matrix of the particle system
  97761. * @param directionToUpdate is the direction vector to update with the result
  97762. * @param particle is the particle we are computed the direction for
  97763. */
  97764. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  97765. /**
  97766. * Clones the current emitter and returns a copy of it
  97767. * @returns the new emitter
  97768. */
  97769. clone(): SphereDirectedParticleEmitter;
  97770. /**
  97771. * Called by the GPUParticleSystem to setup the update shader
  97772. * @param effect defines the update shader
  97773. */
  97774. applyToShader(effect: Effect): void;
  97775. /**
  97776. * Returns a string to use to update the GPU particles update shader
  97777. * @returns a string containng the defines string
  97778. */
  97779. getEffectDefines(): string;
  97780. /**
  97781. * Returns the string "SphereDirectedParticleEmitter"
  97782. * @returns a string containing the class name
  97783. */
  97784. getClassName(): string;
  97785. /**
  97786. * Serializes the particle system to a JSON object.
  97787. * @returns the JSON object
  97788. */
  97789. serialize(): any;
  97790. /**
  97791. * Parse properties from a JSON object
  97792. * @param serializationObject defines the JSON object
  97793. */
  97794. parse(serializationObject: any): void;
  97795. }
  97796. }
  97797. declare module BABYLON {
  97798. /**
  97799. * Particle emitter emitting particles from a custom list of positions.
  97800. */
  97801. export class CustomParticleEmitter implements IParticleEmitterType {
  97802. /**
  97803. * Gets or sets the position generator that will create the inital position of each particle.
  97804. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  97805. */
  97806. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  97807. /**
  97808. * Gets or sets the destination generator that will create the final destination of each particle.
  97809. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  97810. */
  97811. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  97812. /**
  97813. * Creates a new instance CustomParticleEmitter
  97814. */
  97815. constructor();
  97816. /**
  97817. * Called by the particle System when the direction is computed for the created particle.
  97818. * @param worldMatrix is the world matrix of the particle system
  97819. * @param directionToUpdate is the direction vector to update with the result
  97820. * @param particle is the particle we are computed the direction for
  97821. * @param isLocal defines if the direction should be set in local space
  97822. */
  97823. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97824. /**
  97825. * Called by the particle System when the position is computed for the created particle.
  97826. * @param worldMatrix is the world matrix of the particle system
  97827. * @param positionToUpdate is the position vector to update with the result
  97828. * @param particle is the particle we are computed the position for
  97829. * @param isLocal defines if the position should be set in local space
  97830. */
  97831. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97832. /**
  97833. * Clones the current emitter and returns a copy of it
  97834. * @returns the new emitter
  97835. */
  97836. clone(): CustomParticleEmitter;
  97837. /**
  97838. * Called by the GPUParticleSystem to setup the update shader
  97839. * @param effect defines the update shader
  97840. */
  97841. applyToShader(effect: Effect): void;
  97842. /**
  97843. * Returns a string to use to update the GPU particles update shader
  97844. * @returns a string containng the defines string
  97845. */
  97846. getEffectDefines(): string;
  97847. /**
  97848. * Returns the string "PointParticleEmitter"
  97849. * @returns a string containing the class name
  97850. */
  97851. getClassName(): string;
  97852. /**
  97853. * Serializes the particle system to a JSON object.
  97854. * @returns the JSON object
  97855. */
  97856. serialize(): any;
  97857. /**
  97858. * Parse properties from a JSON object
  97859. * @param serializationObject defines the JSON object
  97860. */
  97861. parse(serializationObject: any): void;
  97862. }
  97863. }
  97864. declare module BABYLON {
  97865. /**
  97866. * Particle emitter emitting particles from the inside of a box.
  97867. * It emits the particles randomly between 2 given directions.
  97868. */
  97869. export class MeshParticleEmitter implements IParticleEmitterType {
  97870. private _indices;
  97871. private _positions;
  97872. private _normals;
  97873. private _storedNormal;
  97874. private _mesh;
  97875. /**
  97876. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97877. */
  97878. direction1: Vector3;
  97879. /**
  97880. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97881. */
  97882. direction2: Vector3;
  97883. /**
  97884. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  97885. */
  97886. useMeshNormalsForDirection: boolean;
  97887. /** Defines the mesh to use as source */
  97888. get mesh(): Nullable<AbstractMesh>;
  97889. set mesh(value: Nullable<AbstractMesh>);
  97890. /**
  97891. * Creates a new instance MeshParticleEmitter
  97892. * @param mesh defines the mesh to use as source
  97893. */
  97894. constructor(mesh?: Nullable<AbstractMesh>);
  97895. /**
  97896. * Called by the particle System when the direction is computed for the created particle.
  97897. * @param worldMatrix is the world matrix of the particle system
  97898. * @param directionToUpdate is the direction vector to update with the result
  97899. * @param particle is the particle we are computed the direction for
  97900. * @param isLocal defines if the direction should be set in local space
  97901. */
  97902. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97903. /**
  97904. * Called by the particle System when the position is computed for the created particle.
  97905. * @param worldMatrix is the world matrix of the particle system
  97906. * @param positionToUpdate is the position vector to update with the result
  97907. * @param particle is the particle we are computed the position for
  97908. * @param isLocal defines if the position should be set in local space
  97909. */
  97910. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97911. /**
  97912. * Clones the current emitter and returns a copy of it
  97913. * @returns the new emitter
  97914. */
  97915. clone(): MeshParticleEmitter;
  97916. /**
  97917. * Called by the GPUParticleSystem to setup the update shader
  97918. * @param effect defines the update shader
  97919. */
  97920. applyToShader(effect: Effect): void;
  97921. /**
  97922. * Returns a string to use to update the GPU particles update shader
  97923. * @returns a string containng the defines string
  97924. */
  97925. getEffectDefines(): string;
  97926. /**
  97927. * Returns the string "BoxParticleEmitter"
  97928. * @returns a string containing the class name
  97929. */
  97930. getClassName(): string;
  97931. /**
  97932. * Serializes the particle system to a JSON object.
  97933. * @returns the JSON object
  97934. */
  97935. serialize(): any;
  97936. /**
  97937. * Parse properties from a JSON object
  97938. * @param serializationObject defines the JSON object
  97939. * @param scene defines the hosting scene
  97940. */
  97941. parse(serializationObject: any, scene: Nullable<Scene>): void;
  97942. }
  97943. }
  97944. declare module BABYLON {
  97945. /**
  97946. * Interface representing a particle system in Babylon.js.
  97947. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  97948. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  97949. */
  97950. export interface IParticleSystem {
  97951. /**
  97952. * List of animations used by the particle system.
  97953. */
  97954. animations: Animation[];
  97955. /**
  97956. * The id of the Particle system.
  97957. */
  97958. id: string;
  97959. /**
  97960. * The name of the Particle system.
  97961. */
  97962. name: string;
  97963. /**
  97964. * The emitter represents the Mesh or position we are attaching the particle system to.
  97965. */
  97966. emitter: Nullable<AbstractMesh | Vector3>;
  97967. /**
  97968. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  97969. */
  97970. isBillboardBased: boolean;
  97971. /**
  97972. * The rendering group used by the Particle system to chose when to render.
  97973. */
  97974. renderingGroupId: number;
  97975. /**
  97976. * The layer mask we are rendering the particles through.
  97977. */
  97978. layerMask: number;
  97979. /**
  97980. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  97981. */
  97982. updateSpeed: number;
  97983. /**
  97984. * The amount of time the particle system is running (depends of the overall update speed).
  97985. */
  97986. targetStopDuration: number;
  97987. /**
  97988. * The texture used to render each particle. (this can be a spritesheet)
  97989. */
  97990. particleTexture: Nullable<BaseTexture>;
  97991. /**
  97992. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  97993. */
  97994. blendMode: number;
  97995. /**
  97996. * Minimum life time of emitting particles.
  97997. */
  97998. minLifeTime: number;
  97999. /**
  98000. * Maximum life time of emitting particles.
  98001. */
  98002. maxLifeTime: number;
  98003. /**
  98004. * Minimum Size of emitting particles.
  98005. */
  98006. minSize: number;
  98007. /**
  98008. * Maximum Size of emitting particles.
  98009. */
  98010. maxSize: number;
  98011. /**
  98012. * Minimum scale of emitting particles on X axis.
  98013. */
  98014. minScaleX: number;
  98015. /**
  98016. * Maximum scale of emitting particles on X axis.
  98017. */
  98018. maxScaleX: number;
  98019. /**
  98020. * Minimum scale of emitting particles on Y axis.
  98021. */
  98022. minScaleY: number;
  98023. /**
  98024. * Maximum scale of emitting particles on Y axis.
  98025. */
  98026. maxScaleY: number;
  98027. /**
  98028. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  98029. */
  98030. color1: Color4;
  98031. /**
  98032. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  98033. */
  98034. color2: Color4;
  98035. /**
  98036. * Color the particle will have at the end of its lifetime.
  98037. */
  98038. colorDead: Color4;
  98039. /**
  98040. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  98041. */
  98042. emitRate: number;
  98043. /**
  98044. * You can use gravity if you want to give an orientation to your particles.
  98045. */
  98046. gravity: Vector3;
  98047. /**
  98048. * Minimum power of emitting particles.
  98049. */
  98050. minEmitPower: number;
  98051. /**
  98052. * Maximum power of emitting particles.
  98053. */
  98054. maxEmitPower: number;
  98055. /**
  98056. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  98057. */
  98058. minAngularSpeed: number;
  98059. /**
  98060. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  98061. */
  98062. maxAngularSpeed: number;
  98063. /**
  98064. * Gets or sets the minimal initial rotation in radians.
  98065. */
  98066. minInitialRotation: number;
  98067. /**
  98068. * Gets or sets the maximal initial rotation in radians.
  98069. */
  98070. maxInitialRotation: number;
  98071. /**
  98072. * The particle emitter type defines the emitter used by the particle system.
  98073. * It can be for example box, sphere, or cone...
  98074. */
  98075. particleEmitterType: Nullable<IParticleEmitterType>;
  98076. /**
  98077. * Defines the delay in milliseconds before starting the system (0 by default)
  98078. */
  98079. startDelay: number;
  98080. /**
  98081. * 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
  98082. */
  98083. preWarmCycles: number;
  98084. /**
  98085. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  98086. */
  98087. preWarmStepOffset: number;
  98088. /**
  98089. * 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)
  98090. */
  98091. spriteCellChangeSpeed: number;
  98092. /**
  98093. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  98094. */
  98095. startSpriteCellID: number;
  98096. /**
  98097. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  98098. */
  98099. endSpriteCellID: number;
  98100. /**
  98101. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  98102. */
  98103. spriteCellWidth: number;
  98104. /**
  98105. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  98106. */
  98107. spriteCellHeight: number;
  98108. /**
  98109. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  98110. */
  98111. spriteRandomStartCell: boolean;
  98112. /**
  98113. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  98114. */
  98115. isAnimationSheetEnabled: boolean;
  98116. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  98117. translationPivot: Vector2;
  98118. /**
  98119. * Gets or sets a texture used to add random noise to particle positions
  98120. */
  98121. noiseTexture: Nullable<BaseTexture>;
  98122. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  98123. noiseStrength: Vector3;
  98124. /**
  98125. * Gets or sets the billboard mode to use when isBillboardBased = true.
  98126. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  98127. */
  98128. billboardMode: number;
  98129. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  98130. limitVelocityDamping: number;
  98131. /**
  98132. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  98133. */
  98134. beginAnimationOnStart: boolean;
  98135. /**
  98136. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  98137. */
  98138. beginAnimationFrom: number;
  98139. /**
  98140. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  98141. */
  98142. beginAnimationTo: number;
  98143. /**
  98144. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  98145. */
  98146. beginAnimationLoop: boolean;
  98147. /**
  98148. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  98149. */
  98150. disposeOnStop: boolean;
  98151. /**
  98152. * Specifies if the particles are updated in emitter local space or world space
  98153. */
  98154. isLocal: boolean;
  98155. /** Snippet ID if the particle system was created from the snippet server */
  98156. snippetId: string;
  98157. /** Gets or sets a matrix to use to compute projection */
  98158. defaultProjectionMatrix: Matrix;
  98159. /**
  98160. * Gets the maximum number of particles active at the same time.
  98161. * @returns The max number of active particles.
  98162. */
  98163. getCapacity(): number;
  98164. /**
  98165. * Gets the number of particles active at the same time.
  98166. * @returns The number of active particles.
  98167. */
  98168. getActiveCount(): number;
  98169. /**
  98170. * Gets if the system has been started. (Note: this will still be true after stop is called)
  98171. * @returns True if it has been started, otherwise false.
  98172. */
  98173. isStarted(): boolean;
  98174. /**
  98175. * Animates the particle system for this frame.
  98176. */
  98177. animate(): void;
  98178. /**
  98179. * Renders the particle system in its current state.
  98180. * @returns the current number of particles
  98181. */
  98182. render(): number;
  98183. /**
  98184. * Dispose the particle system and frees its associated resources.
  98185. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  98186. */
  98187. dispose(disposeTexture?: boolean): void;
  98188. /**
  98189. * An event triggered when the system is disposed
  98190. */
  98191. onDisposeObservable: Observable<IParticleSystem>;
  98192. /**
  98193. * An event triggered when the system is stopped
  98194. */
  98195. onStoppedObservable: Observable<IParticleSystem>;
  98196. /**
  98197. * Clones the particle system.
  98198. * @param name The name of the cloned object
  98199. * @param newEmitter The new emitter to use
  98200. * @returns the cloned particle system
  98201. */
  98202. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  98203. /**
  98204. * Serializes the particle system to a JSON object
  98205. * @param serializeTexture defines if the texture must be serialized as well
  98206. * @returns the JSON object
  98207. */
  98208. serialize(serializeTexture: boolean): any;
  98209. /**
  98210. * Rebuild the particle system
  98211. */
  98212. rebuild(): void;
  98213. /** Force the system to rebuild all gradients that need to be resync */
  98214. forceRefreshGradients(): void;
  98215. /**
  98216. * Starts the particle system and begins to emit
  98217. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  98218. */
  98219. start(delay?: number): void;
  98220. /**
  98221. * Stops the particle system.
  98222. */
  98223. stop(): void;
  98224. /**
  98225. * Remove all active particles
  98226. */
  98227. reset(): void;
  98228. /**
  98229. * Gets a boolean indicating that the system is stopping
  98230. * @returns true if the system is currently stopping
  98231. */
  98232. isStopping(): boolean;
  98233. /**
  98234. * Is this system ready to be used/rendered
  98235. * @return true if the system is ready
  98236. */
  98237. isReady(): boolean;
  98238. /**
  98239. * Returns the string "ParticleSystem"
  98240. * @returns a string containing the class name
  98241. */
  98242. getClassName(): string;
  98243. /**
  98244. * Gets the custom effect used to render the particles
  98245. * @param blendMode Blend mode for which the effect should be retrieved
  98246. * @returns The effect
  98247. */
  98248. getCustomEffect(blendMode: number): Nullable<Effect>;
  98249. /**
  98250. * Sets the custom effect used to render the particles
  98251. * @param effect The effect to set
  98252. * @param blendMode Blend mode for which the effect should be set
  98253. */
  98254. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  98255. /**
  98256. * Fill the defines array according to the current settings of the particle system
  98257. * @param defines Array to be updated
  98258. * @param blendMode blend mode to take into account when updating the array
  98259. */
  98260. fillDefines(defines: Array<string>, blendMode: number): void;
  98261. /**
  98262. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  98263. * @param uniforms Uniforms array to fill
  98264. * @param attributes Attributes array to fill
  98265. * @param samplers Samplers array to fill
  98266. */
  98267. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  98268. /**
  98269. * Observable that will be called just before the particles are drawn
  98270. */
  98271. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  98272. /**
  98273. * Gets the name of the particle vertex shader
  98274. */
  98275. vertexShaderName: string;
  98276. /**
  98277. * Adds a new color gradient
  98278. * @param gradient defines the gradient to use (between 0 and 1)
  98279. * @param color1 defines the color to affect to the specified gradient
  98280. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  98281. * @returns the current particle system
  98282. */
  98283. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  98284. /**
  98285. * Remove a specific color gradient
  98286. * @param gradient defines the gradient to remove
  98287. * @returns the current particle system
  98288. */
  98289. removeColorGradient(gradient: number): IParticleSystem;
  98290. /**
  98291. * Adds a new size gradient
  98292. * @param gradient defines the gradient to use (between 0 and 1)
  98293. * @param factor defines the size factor to affect to the specified gradient
  98294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98295. * @returns the current particle system
  98296. */
  98297. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98298. /**
  98299. * Remove a specific size gradient
  98300. * @param gradient defines the gradient to remove
  98301. * @returns the current particle system
  98302. */
  98303. removeSizeGradient(gradient: number): IParticleSystem;
  98304. /**
  98305. * Gets the current list of color gradients.
  98306. * You must use addColorGradient and removeColorGradient to udpate this list
  98307. * @returns the list of color gradients
  98308. */
  98309. getColorGradients(): Nullable<Array<ColorGradient>>;
  98310. /**
  98311. * Gets the current list of size gradients.
  98312. * You must use addSizeGradient and removeSizeGradient to udpate this list
  98313. * @returns the list of size gradients
  98314. */
  98315. getSizeGradients(): Nullable<Array<FactorGradient>>;
  98316. /**
  98317. * Gets the current list of angular speed gradients.
  98318. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  98319. * @returns the list of angular speed gradients
  98320. */
  98321. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  98322. /**
  98323. * Adds a new angular speed gradient
  98324. * @param gradient defines the gradient to use (between 0 and 1)
  98325. * @param factor defines the angular speed to affect to the specified gradient
  98326. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98327. * @returns the current particle system
  98328. */
  98329. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98330. /**
  98331. * Remove a specific angular speed gradient
  98332. * @param gradient defines the gradient to remove
  98333. * @returns the current particle system
  98334. */
  98335. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  98336. /**
  98337. * Gets the current list of velocity gradients.
  98338. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  98339. * @returns the list of velocity gradients
  98340. */
  98341. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  98342. /**
  98343. * Adds a new velocity gradient
  98344. * @param gradient defines the gradient to use (between 0 and 1)
  98345. * @param factor defines the velocity to affect to the specified gradient
  98346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98347. * @returns the current particle system
  98348. */
  98349. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98350. /**
  98351. * Remove a specific velocity gradient
  98352. * @param gradient defines the gradient to remove
  98353. * @returns the current particle system
  98354. */
  98355. removeVelocityGradient(gradient: number): IParticleSystem;
  98356. /**
  98357. * Gets the current list of limit velocity gradients.
  98358. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  98359. * @returns the list of limit velocity gradients
  98360. */
  98361. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  98362. /**
  98363. * Adds a new limit velocity gradient
  98364. * @param gradient defines the gradient to use (between 0 and 1)
  98365. * @param factor defines the limit velocity to affect to the specified gradient
  98366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98367. * @returns the current particle system
  98368. */
  98369. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98370. /**
  98371. * Remove a specific limit velocity gradient
  98372. * @param gradient defines the gradient to remove
  98373. * @returns the current particle system
  98374. */
  98375. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  98376. /**
  98377. * Adds a new drag gradient
  98378. * @param gradient defines the gradient to use (between 0 and 1)
  98379. * @param factor defines the drag to affect to the specified gradient
  98380. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98381. * @returns the current particle system
  98382. */
  98383. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98384. /**
  98385. * Remove a specific drag gradient
  98386. * @param gradient defines the gradient to remove
  98387. * @returns the current particle system
  98388. */
  98389. removeDragGradient(gradient: number): IParticleSystem;
  98390. /**
  98391. * Gets the current list of drag gradients.
  98392. * You must use addDragGradient and removeDragGradient to udpate this list
  98393. * @returns the list of drag gradients
  98394. */
  98395. getDragGradients(): Nullable<Array<FactorGradient>>;
  98396. /**
  98397. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  98398. * @param gradient defines the gradient to use (between 0 and 1)
  98399. * @param factor defines the emit rate to affect to the specified gradient
  98400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98401. * @returns the current particle system
  98402. */
  98403. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98404. /**
  98405. * Remove a specific emit rate gradient
  98406. * @param gradient defines the gradient to remove
  98407. * @returns the current particle system
  98408. */
  98409. removeEmitRateGradient(gradient: number): IParticleSystem;
  98410. /**
  98411. * Gets the current list of emit rate gradients.
  98412. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  98413. * @returns the list of emit rate gradients
  98414. */
  98415. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  98416. /**
  98417. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  98418. * @param gradient defines the gradient to use (between 0 and 1)
  98419. * @param factor defines the start size to affect to the specified gradient
  98420. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98421. * @returns the current particle system
  98422. */
  98423. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98424. /**
  98425. * Remove a specific start size gradient
  98426. * @param gradient defines the gradient to remove
  98427. * @returns the current particle system
  98428. */
  98429. removeStartSizeGradient(gradient: number): IParticleSystem;
  98430. /**
  98431. * Gets the current list of start size gradients.
  98432. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  98433. * @returns the list of start size gradients
  98434. */
  98435. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  98436. /**
  98437. * Adds a new life time gradient
  98438. * @param gradient defines the gradient to use (between 0 and 1)
  98439. * @param factor defines the life time factor to affect to the specified gradient
  98440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98441. * @returns the current particle system
  98442. */
  98443. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98444. /**
  98445. * Remove a specific life time gradient
  98446. * @param gradient defines the gradient to remove
  98447. * @returns the current particle system
  98448. */
  98449. removeLifeTimeGradient(gradient: number): IParticleSystem;
  98450. /**
  98451. * Gets the current list of life time gradients.
  98452. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  98453. * @returns the list of life time gradients
  98454. */
  98455. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  98456. /**
  98457. * Gets the current list of color gradients.
  98458. * You must use addColorGradient and removeColorGradient to udpate this list
  98459. * @returns the list of color gradients
  98460. */
  98461. getColorGradients(): Nullable<Array<ColorGradient>>;
  98462. /**
  98463. * Adds a new ramp gradient used to remap particle colors
  98464. * @param gradient defines the gradient to use (between 0 and 1)
  98465. * @param color defines the color to affect to the specified gradient
  98466. * @returns the current particle system
  98467. */
  98468. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  98469. /**
  98470. * Gets the current list of ramp gradients.
  98471. * You must use addRampGradient and removeRampGradient to udpate this list
  98472. * @returns the list of ramp gradients
  98473. */
  98474. getRampGradients(): Nullable<Array<Color3Gradient>>;
  98475. /** Gets or sets a boolean indicating that ramp gradients must be used
  98476. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  98477. */
  98478. useRampGradients: boolean;
  98479. /**
  98480. * Adds a new color remap gradient
  98481. * @param gradient defines the gradient to use (between 0 and 1)
  98482. * @param min defines the color remap minimal range
  98483. * @param max defines the color remap maximal range
  98484. * @returns the current particle system
  98485. */
  98486. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  98487. /**
  98488. * Gets the current list of color remap gradients.
  98489. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  98490. * @returns the list of color remap gradients
  98491. */
  98492. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  98493. /**
  98494. * Adds a new alpha remap gradient
  98495. * @param gradient defines the gradient to use (between 0 and 1)
  98496. * @param min defines the alpha remap minimal range
  98497. * @param max defines the alpha remap maximal range
  98498. * @returns the current particle system
  98499. */
  98500. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  98501. /**
  98502. * Gets the current list of alpha remap gradients.
  98503. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  98504. * @returns the list of alpha remap gradients
  98505. */
  98506. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  98507. /**
  98508. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  98509. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  98510. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  98511. * @returns the emitter
  98512. */
  98513. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  98514. /**
  98515. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  98516. * @param radius The radius of the hemisphere to emit from
  98517. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  98518. * @returns the emitter
  98519. */
  98520. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  98521. /**
  98522. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  98523. * @param radius The radius of the sphere to emit from
  98524. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  98525. * @returns the emitter
  98526. */
  98527. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  98528. /**
  98529. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  98530. * @param radius The radius of the sphere to emit from
  98531. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  98532. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  98533. * @returns the emitter
  98534. */
  98535. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  98536. /**
  98537. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  98538. * @param radius The radius of the emission cylinder
  98539. * @param height The height of the emission cylinder
  98540. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  98541. * @param directionRandomizer How much to randomize the particle direction [0-1]
  98542. * @returns the emitter
  98543. */
  98544. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  98545. /**
  98546. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  98547. * @param radius The radius of the cylinder to emit from
  98548. * @param height The height of the emission cylinder
  98549. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  98550. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  98551. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  98552. * @returns the emitter
  98553. */
  98554. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  98555. /**
  98556. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  98557. * @param radius The radius of the cone to emit from
  98558. * @param angle The base angle of the cone
  98559. * @returns the emitter
  98560. */
  98561. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  98562. /**
  98563. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  98564. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  98565. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  98566. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  98567. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  98568. * @returns the emitter
  98569. */
  98570. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  98571. /**
  98572. * Get hosting scene
  98573. * @returns the scene
  98574. */
  98575. getScene(): Nullable<Scene>;
  98576. }
  98577. }
  98578. declare module BABYLON {
  98579. /**
  98580. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  98581. */
  98582. export class ColorSplitterBlock extends NodeMaterialBlock {
  98583. /**
  98584. * Create a new ColorSplitterBlock
  98585. * @param name defines the block name
  98586. */
  98587. constructor(name: string);
  98588. /**
  98589. * Gets the current class name
  98590. * @returns the class name
  98591. */
  98592. getClassName(): string;
  98593. /**
  98594. * Gets the rgba component (input)
  98595. */
  98596. get rgba(): NodeMaterialConnectionPoint;
  98597. /**
  98598. * Gets the rgb component (input)
  98599. */
  98600. get rgbIn(): NodeMaterialConnectionPoint;
  98601. /**
  98602. * Gets the rgb component (output)
  98603. */
  98604. get rgbOut(): NodeMaterialConnectionPoint;
  98605. /**
  98606. * Gets the r component (output)
  98607. */
  98608. get r(): NodeMaterialConnectionPoint;
  98609. /**
  98610. * Gets the g component (output)
  98611. */
  98612. get g(): NodeMaterialConnectionPoint;
  98613. /**
  98614. * Gets the b component (output)
  98615. */
  98616. get b(): NodeMaterialConnectionPoint;
  98617. /**
  98618. * Gets the a component (output)
  98619. */
  98620. get a(): NodeMaterialConnectionPoint;
  98621. protected _inputRename(name: string): string;
  98622. protected _outputRename(name: string): string;
  98623. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98624. }
  98625. }
  98626. declare module BABYLON {
  98627. /**
  98628. * Operations supported by the Trigonometry block
  98629. */
  98630. export enum TrigonometryBlockOperations {
  98631. /** Cos */
  98632. Cos = 0,
  98633. /** Sin */
  98634. Sin = 1,
  98635. /** Abs */
  98636. Abs = 2,
  98637. /** Exp */
  98638. Exp = 3,
  98639. /** Exp2 */
  98640. Exp2 = 4,
  98641. /** Round */
  98642. Round = 5,
  98643. /** Floor */
  98644. Floor = 6,
  98645. /** Ceiling */
  98646. Ceiling = 7,
  98647. /** Square root */
  98648. Sqrt = 8,
  98649. /** Log */
  98650. Log = 9,
  98651. /** Tangent */
  98652. Tan = 10,
  98653. /** Arc tangent */
  98654. ArcTan = 11,
  98655. /** Arc cosinus */
  98656. ArcCos = 12,
  98657. /** Arc sinus */
  98658. ArcSin = 13,
  98659. /** Fraction */
  98660. Fract = 14,
  98661. /** Sign */
  98662. Sign = 15,
  98663. /** To radians (from degrees) */
  98664. Radians = 16,
  98665. /** To degrees (from radians) */
  98666. Degrees = 17
  98667. }
  98668. /**
  98669. * Block used to apply trigonometry operation to floats
  98670. */
  98671. export class TrigonometryBlock extends NodeMaterialBlock {
  98672. /**
  98673. * Gets or sets the operation applied by the block
  98674. */
  98675. operation: TrigonometryBlockOperations;
  98676. /**
  98677. * Creates a new TrigonometryBlock
  98678. * @param name defines the block name
  98679. */
  98680. constructor(name: string);
  98681. /**
  98682. * Gets the current class name
  98683. * @returns the class name
  98684. */
  98685. getClassName(): string;
  98686. /**
  98687. * Gets the input component
  98688. */
  98689. get input(): NodeMaterialConnectionPoint;
  98690. /**
  98691. * Gets the output component
  98692. */
  98693. get output(): NodeMaterialConnectionPoint;
  98694. protected _buildBlock(state: NodeMaterialBuildState): this;
  98695. serialize(): any;
  98696. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98697. protected _dumpPropertiesCode(): string;
  98698. }
  98699. }
  98700. declare module BABYLON {
  98701. /**
  98702. * Interface used to configure the node material editor
  98703. */
  98704. export interface INodeMaterialEditorOptions {
  98705. /** Define the URl to load node editor script */
  98706. editorURL?: string;
  98707. }
  98708. /** @hidden */
  98709. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98710. NORMAL: boolean;
  98711. TANGENT: boolean;
  98712. UV1: boolean;
  98713. /** BONES */
  98714. NUM_BONE_INFLUENCERS: number;
  98715. BonesPerMesh: number;
  98716. BONETEXTURE: boolean;
  98717. /** MORPH TARGETS */
  98718. MORPHTARGETS: boolean;
  98719. MORPHTARGETS_NORMAL: boolean;
  98720. MORPHTARGETS_TANGENT: boolean;
  98721. MORPHTARGETS_UV: boolean;
  98722. NUM_MORPH_INFLUENCERS: number;
  98723. /** IMAGE PROCESSING */
  98724. IMAGEPROCESSING: boolean;
  98725. VIGNETTE: boolean;
  98726. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98727. VIGNETTEBLENDMODEOPAQUE: boolean;
  98728. TONEMAPPING: boolean;
  98729. TONEMAPPING_ACES: boolean;
  98730. CONTRAST: boolean;
  98731. EXPOSURE: boolean;
  98732. COLORCURVES: boolean;
  98733. COLORGRADING: boolean;
  98734. COLORGRADING3D: boolean;
  98735. SAMPLER3DGREENDEPTH: boolean;
  98736. SAMPLER3DBGRMAP: boolean;
  98737. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98738. /** MISC. */
  98739. BUMPDIRECTUV: number;
  98740. constructor();
  98741. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  98742. }
  98743. /**
  98744. * Class used to configure NodeMaterial
  98745. */
  98746. export interface INodeMaterialOptions {
  98747. /**
  98748. * Defines if blocks should emit comments
  98749. */
  98750. emitComments: boolean;
  98751. }
  98752. /**
  98753. * Class used to create a node based material built by assembling shader blocks
  98754. */
  98755. export class NodeMaterial extends PushMaterial {
  98756. private static _BuildIdGenerator;
  98757. private _options;
  98758. private _vertexCompilationState;
  98759. private _fragmentCompilationState;
  98760. private _sharedData;
  98761. private _buildId;
  98762. private _buildWasSuccessful;
  98763. private _cachedWorldViewMatrix;
  98764. private _cachedWorldViewProjectionMatrix;
  98765. private _optimizers;
  98766. private _animationFrame;
  98767. /** Define the Url to load node editor script */
  98768. static EditorURL: string;
  98769. /** Define the Url to load snippets */
  98770. static SnippetUrl: string;
  98771. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  98772. static IgnoreTexturesAtLoadTime: boolean;
  98773. private BJSNODEMATERIALEDITOR;
  98774. /** Get the inspector from bundle or global */
  98775. private _getGlobalNodeMaterialEditor;
  98776. /**
  98777. * Snippet ID if the material was created from the snippet server
  98778. */
  98779. snippetId: string;
  98780. /**
  98781. * Gets or sets data used by visual editor
  98782. * @see https://nme.babylonjs.com
  98783. */
  98784. editorData: any;
  98785. /**
  98786. * 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)
  98787. */
  98788. ignoreAlpha: boolean;
  98789. /**
  98790. * Defines the maximum number of lights that can be used in the material
  98791. */
  98792. maxSimultaneousLights: number;
  98793. /**
  98794. * Observable raised when the material is built
  98795. */
  98796. onBuildObservable: Observable<NodeMaterial>;
  98797. /**
  98798. * Gets or sets the root nodes of the material vertex shader
  98799. */
  98800. _vertexOutputNodes: NodeMaterialBlock[];
  98801. /**
  98802. * Gets or sets the root nodes of the material fragment (pixel) shader
  98803. */
  98804. _fragmentOutputNodes: NodeMaterialBlock[];
  98805. /** Gets or sets options to control the node material overall behavior */
  98806. get options(): INodeMaterialOptions;
  98807. set options(options: INodeMaterialOptions);
  98808. /**
  98809. * Default configuration related to image processing available in the standard Material.
  98810. */
  98811. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98812. /**
  98813. * Gets the image processing configuration used either in this material.
  98814. */
  98815. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  98816. /**
  98817. * Sets the Default image processing configuration used either in the this material.
  98818. *
  98819. * If sets to null, the scene one is in use.
  98820. */
  98821. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  98822. /**
  98823. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  98824. */
  98825. attachedBlocks: NodeMaterialBlock[];
  98826. /**
  98827. * Specifies the mode of the node material
  98828. * @hidden
  98829. */
  98830. _mode: NodeMaterialModes;
  98831. /**
  98832. * Gets the mode property
  98833. */
  98834. get mode(): NodeMaterialModes;
  98835. /**
  98836. * A free comment about the material
  98837. */
  98838. comment: string;
  98839. /**
  98840. * Create a new node based material
  98841. * @param name defines the material name
  98842. * @param scene defines the hosting scene
  98843. * @param options defines creation option
  98844. */
  98845. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  98846. /**
  98847. * Gets the current class name of the material e.g. "NodeMaterial"
  98848. * @returns the class name
  98849. */
  98850. getClassName(): string;
  98851. /**
  98852. * Keep track of the image processing observer to allow dispose and replace.
  98853. */
  98854. private _imageProcessingObserver;
  98855. /**
  98856. * Attaches a new image processing configuration to the Standard Material.
  98857. * @param configuration
  98858. */
  98859. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98860. /**
  98861. * Get a block by its name
  98862. * @param name defines the name of the block to retrieve
  98863. * @returns the required block or null if not found
  98864. */
  98865. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  98866. /**
  98867. * Get a block by its name
  98868. * @param predicate defines the predicate used to find the good candidate
  98869. * @returns the required block or null if not found
  98870. */
  98871. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  98872. /**
  98873. * Get an input block by its name
  98874. * @param predicate defines the predicate used to find the good candidate
  98875. * @returns the required input block or null if not found
  98876. */
  98877. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  98878. /**
  98879. * Gets the list of input blocks attached to this material
  98880. * @returns an array of InputBlocks
  98881. */
  98882. getInputBlocks(): InputBlock[];
  98883. /**
  98884. * Adds a new optimizer to the list of optimizers
  98885. * @param optimizer defines the optimizers to add
  98886. * @returns the current material
  98887. */
  98888. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  98889. /**
  98890. * Remove an optimizer from the list of optimizers
  98891. * @param optimizer defines the optimizers to remove
  98892. * @returns the current material
  98893. */
  98894. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  98895. /**
  98896. * Add a new block to the list of output nodes
  98897. * @param node defines the node to add
  98898. * @returns the current material
  98899. */
  98900. addOutputNode(node: NodeMaterialBlock): this;
  98901. /**
  98902. * Remove a block from the list of root nodes
  98903. * @param node defines the node to remove
  98904. * @returns the current material
  98905. */
  98906. removeOutputNode(node: NodeMaterialBlock): this;
  98907. private _addVertexOutputNode;
  98908. private _removeVertexOutputNode;
  98909. private _addFragmentOutputNode;
  98910. private _removeFragmentOutputNode;
  98911. /**
  98912. * Specifies if the material will require alpha blending
  98913. * @returns a boolean specifying if alpha blending is needed
  98914. */
  98915. needAlphaBlending(): boolean;
  98916. /**
  98917. * Specifies if this material should be rendered in alpha test mode
  98918. * @returns a boolean specifying if an alpha test is needed.
  98919. */
  98920. needAlphaTesting(): boolean;
  98921. private _initializeBlock;
  98922. private _resetDualBlocks;
  98923. /**
  98924. * Remove a block from the current node material
  98925. * @param block defines the block to remove
  98926. */
  98927. removeBlock(block: NodeMaterialBlock): void;
  98928. /**
  98929. * Build the material and generates the inner effect
  98930. * @param verbose defines if the build should log activity
  98931. */
  98932. build(verbose?: boolean): void;
  98933. /**
  98934. * Runs an otpimization phase to try to improve the shader code
  98935. */
  98936. optimize(): void;
  98937. private _prepareDefinesForAttributes;
  98938. /**
  98939. * Create a post process from the material
  98940. * @param camera The camera to apply the render pass to.
  98941. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  98942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  98943. * @param engine The engine which the post process will be applied. (default: current engine)
  98944. * @param reusable If the post process can be reused on the same frame. (default: false)
  98945. * @param textureType Type of textures used when performing the post process. (default: 0)
  98946. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  98947. * @returns the post process created
  98948. */
  98949. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  98950. /**
  98951. * Create the post process effect from the material
  98952. * @param postProcess The post process to create the effect for
  98953. */
  98954. createEffectForPostProcess(postProcess: PostProcess): void;
  98955. private _createEffectForPostProcess;
  98956. /**
  98957. * Create a new procedural texture based on this node material
  98958. * @param size defines the size of the texture
  98959. * @param scene defines the hosting scene
  98960. * @returns the new procedural texture attached to this node material
  98961. */
  98962. createProceduralTexture(size: number | {
  98963. width: number;
  98964. height: number;
  98965. layers?: number;
  98966. }, scene: Scene): Nullable<ProceduralTexture>;
  98967. private _createEffectForParticles;
  98968. private _checkInternals;
  98969. /**
  98970. * Create the effect to be used as the custom effect for a particle system
  98971. * @param particleSystem Particle system to create the effect for
  98972. * @param onCompiled defines a function to call when the effect creation is successful
  98973. * @param onError defines a function to call when the effect creation has failed
  98974. */
  98975. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  98976. private _processDefines;
  98977. /**
  98978. * Get if the submesh is ready to be used and all its information available.
  98979. * Child classes can use it to update shaders
  98980. * @param mesh defines the mesh to check
  98981. * @param subMesh defines which submesh to check
  98982. * @param useInstances specifies that instances should be used
  98983. * @returns a boolean indicating that the submesh is ready or not
  98984. */
  98985. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98986. /**
  98987. * Get a string representing the shaders built by the current node graph
  98988. */
  98989. get compiledShaders(): string;
  98990. /**
  98991. * Binds the world matrix to the material
  98992. * @param world defines the world transformation matrix
  98993. */
  98994. bindOnlyWorldMatrix(world: Matrix): void;
  98995. /**
  98996. * Binds the submesh to this material by preparing the effect and shader to draw
  98997. * @param world defines the world transformation matrix
  98998. * @param mesh defines the mesh containing the submesh
  98999. * @param subMesh defines the submesh to bind the material to
  99000. */
  99001. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99002. /**
  99003. * Gets the active textures from the material
  99004. * @returns an array of textures
  99005. */
  99006. getActiveTextures(): BaseTexture[];
  99007. /**
  99008. * Gets the list of texture blocks
  99009. * @returns an array of texture blocks
  99010. */
  99011. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99012. /**
  99013. * Specifies if the material uses a texture
  99014. * @param texture defines the texture to check against the material
  99015. * @returns a boolean specifying if the material uses the texture
  99016. */
  99017. hasTexture(texture: BaseTexture): boolean;
  99018. /**
  99019. * Disposes the material
  99020. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99021. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99022. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  99023. */
  99024. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  99025. /** Creates the node editor window. */
  99026. private _createNodeEditor;
  99027. /**
  99028. * Launch the node material editor
  99029. * @param config Define the configuration of the editor
  99030. * @return a promise fulfilled when the node editor is visible
  99031. */
  99032. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  99033. /**
  99034. * Clear the current material
  99035. */
  99036. clear(): void;
  99037. /**
  99038. * Clear the current material and set it to a default state
  99039. */
  99040. setToDefault(): void;
  99041. /**
  99042. * Clear the current material and set it to a default state for post process
  99043. */
  99044. setToDefaultPostProcess(): void;
  99045. /**
  99046. * Clear the current material and set it to a default state for procedural texture
  99047. */
  99048. setToDefaultProceduralTexture(): void;
  99049. /**
  99050. * Clear the current material and set it to a default state for particle
  99051. */
  99052. setToDefaultParticle(): void;
  99053. /**
  99054. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  99055. * @param url defines the url to load from
  99056. * @returns a promise that will fullfil when the material is fully loaded
  99057. */
  99058. loadAsync(url: string): Promise<void>;
  99059. private _gatherBlocks;
  99060. /**
  99061. * Generate a string containing the code declaration required to create an equivalent of this material
  99062. * @returns a string
  99063. */
  99064. generateCode(): string;
  99065. /**
  99066. * Serializes this material in a JSON representation
  99067. * @returns the serialized material object
  99068. */
  99069. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  99070. private _restoreConnections;
  99071. /**
  99072. * Clear the current graph and load a new one from a serialization object
  99073. * @param source defines the JSON representation of the material
  99074. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99075. * @param merge defines whether or not the source must be merged or replace the current content
  99076. */
  99077. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  99078. /**
  99079. * Makes a duplicate of the current material.
  99080. * @param name - name to use for the new material.
  99081. */
  99082. clone(name: string): NodeMaterial;
  99083. /**
  99084. * Creates a node material from parsed material data
  99085. * @param source defines the JSON representation of the material
  99086. * @param scene defines the hosting scene
  99087. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99088. * @returns a new node material
  99089. */
  99090. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  99091. /**
  99092. * Creates a node material from a snippet saved in a remote file
  99093. * @param name defines the name of the material to create
  99094. * @param url defines the url to load from
  99095. * @param scene defines the hosting scene
  99096. * @returns a promise that will resolve to the new node material
  99097. */
  99098. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  99099. /**
  99100. * Creates a node material from a snippet saved by the node material editor
  99101. * @param snippetId defines the snippet to load
  99102. * @param scene defines the hosting scene
  99103. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99104. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  99105. * @returns a promise that will resolve to the new node material
  99106. */
  99107. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  99108. /**
  99109. * Creates a new node material set to default basic configuration
  99110. * @param name defines the name of the material
  99111. * @param scene defines the hosting scene
  99112. * @returns a new NodeMaterial
  99113. */
  99114. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  99115. }
  99116. }
  99117. declare module BABYLON {
  99118. interface ThinEngine {
  99119. /**
  99120. * Unbind a list of render target textures from the webGL context
  99121. * This is used only when drawBuffer extension or webGL2 are active
  99122. * @param textures defines the render target textures to unbind
  99123. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  99124. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  99125. */
  99126. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  99127. /**
  99128. * Create a multi render target texture
  99129. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  99130. * @param size defines the size of the texture
  99131. * @param options defines the creation options
  99132. * @returns the cube texture as an InternalTexture
  99133. */
  99134. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  99135. /**
  99136. * Update the sample count for a given multiple render target texture
  99137. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  99138. * @param textures defines the textures to update
  99139. * @param samples defines the sample count to set
  99140. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  99141. */
  99142. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  99143. /**
  99144. * Select a subsets of attachments to draw to.
  99145. * @param attachments gl attachments
  99146. */
  99147. bindAttachments(attachments: number[]): void;
  99148. /**
  99149. * Creates a layout object to draw/clear on specific textures in a MRT
  99150. * @param textureStatus textureStatus[i] indicates if the i-th is active
  99151. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  99152. */
  99153. buildTextureLayout(textureStatus: boolean[]): number[];
  99154. /**
  99155. * Restores the webgl state to only draw on the main color attachment
  99156. */
  99157. restoreSingleAttachment(): void;
  99158. }
  99159. }
  99160. declare module BABYLON {
  99161. /**
  99162. * Creation options of the multi render target texture.
  99163. */
  99164. export interface IMultiRenderTargetOptions {
  99165. /**
  99166. * Define if the texture needs to create mip maps after render.
  99167. */
  99168. generateMipMaps?: boolean;
  99169. /**
  99170. * Define the types of all the draw buffers we want to create
  99171. */
  99172. types?: number[];
  99173. /**
  99174. * Define the sampling modes of all the draw buffers we want to create
  99175. */
  99176. samplingModes?: number[];
  99177. /**
  99178. * Define if a depth buffer is required
  99179. */
  99180. generateDepthBuffer?: boolean;
  99181. /**
  99182. * Define if a stencil buffer is required
  99183. */
  99184. generateStencilBuffer?: boolean;
  99185. /**
  99186. * Define if a depth texture is required instead of a depth buffer
  99187. */
  99188. generateDepthTexture?: boolean;
  99189. /**
  99190. * Define the number of desired draw buffers
  99191. */
  99192. textureCount?: number;
  99193. /**
  99194. * Define if aspect ratio should be adapted to the texture or stay the scene one
  99195. */
  99196. doNotChangeAspectRatio?: boolean;
  99197. /**
  99198. * Define the default type of the buffers we are creating
  99199. */
  99200. defaultType?: number;
  99201. }
  99202. /**
  99203. * A multi render target, like a render target provides the ability to render to a texture.
  99204. * Unlike the render target, it can render to several draw buffers in one draw.
  99205. * This is specially interesting in deferred rendering or for any effects requiring more than
  99206. * just one color from a single pass.
  99207. */
  99208. export class MultiRenderTarget extends RenderTargetTexture {
  99209. private _internalTextures;
  99210. private _textures;
  99211. private _multiRenderTargetOptions;
  99212. private _count;
  99213. /**
  99214. * Get if draw buffers are currently supported by the used hardware and browser.
  99215. */
  99216. get isSupported(): boolean;
  99217. /**
  99218. * Get the list of textures generated by the multi render target.
  99219. */
  99220. get textures(): Texture[];
  99221. /**
  99222. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  99223. */
  99224. get count(): number;
  99225. /**
  99226. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  99227. */
  99228. get depthTexture(): Texture;
  99229. /**
  99230. * Set the wrapping mode on U of all the textures we are rendering to.
  99231. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  99232. */
  99233. set wrapU(wrap: number);
  99234. /**
  99235. * Set the wrapping mode on V of all the textures we are rendering to.
  99236. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  99237. */
  99238. set wrapV(wrap: number);
  99239. /**
  99240. * Instantiate a new multi render target texture.
  99241. * A multi render target, like a render target provides the ability to render to a texture.
  99242. * Unlike the render target, it can render to several draw buffers in one draw.
  99243. * This is specially interesting in deferred rendering or for any effects requiring more than
  99244. * just one color from a single pass.
  99245. * @param name Define the name of the texture
  99246. * @param size Define the size of the buffers to render to
  99247. * @param count Define the number of target we are rendering into
  99248. * @param scene Define the scene the texture belongs to
  99249. * @param options Define the options used to create the multi render target
  99250. */
  99251. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  99252. private _initTypes;
  99253. /** @hidden */
  99254. _rebuild(forceFullRebuild?: boolean): void;
  99255. private _createInternalTextures;
  99256. private _createTextures;
  99257. /**
  99258. * Replaces a texture within the MRT.
  99259. * @param texture The new texture to insert in the MRT
  99260. * @param index The index of the texture to replace
  99261. */
  99262. replaceTexture(texture: Texture, index: number): void;
  99263. /**
  99264. * Define the number of samples used if MSAA is enabled.
  99265. */
  99266. get samples(): number;
  99267. set samples(value: number);
  99268. /**
  99269. * Resize all the textures in the multi render target.
  99270. * Be careful as it will recreate all the data in the new texture.
  99271. * @param size Define the new size
  99272. */
  99273. resize(size: any): void;
  99274. /**
  99275. * Changes the number of render targets in this MRT
  99276. * Be careful as it will recreate all the data in the new texture.
  99277. * @param count new texture count
  99278. * @param options Specifies texture types and sampling modes for new textures
  99279. */
  99280. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  99281. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  99282. /**
  99283. * Dispose the render targets and their associated resources
  99284. */
  99285. dispose(): void;
  99286. /**
  99287. * Release all the underlying texture used as draw buffers.
  99288. */
  99289. releaseInternalTextures(): void;
  99290. }
  99291. }
  99292. declare module BABYLON {
  99293. /** @hidden */
  99294. export var imageProcessingPixelShader: {
  99295. name: string;
  99296. shader: string;
  99297. };
  99298. }
  99299. declare module BABYLON {
  99300. /**
  99301. * ImageProcessingPostProcess
  99302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99303. */
  99304. export class ImageProcessingPostProcess extends PostProcess {
  99305. /**
  99306. * Default configuration related to image processing available in the PBR Material.
  99307. */
  99308. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99309. /**
  99310. * Gets the image processing configuration used either in this material.
  99311. */
  99312. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99313. /**
  99314. * Sets the Default image processing configuration used either in the this material.
  99315. *
  99316. * If sets to null, the scene one is in use.
  99317. */
  99318. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99319. /**
  99320. * Keep track of the image processing observer to allow dispose and replace.
  99321. */
  99322. private _imageProcessingObserver;
  99323. /**
  99324. * Attaches a new image processing configuration to the PBR Material.
  99325. * @param configuration
  99326. */
  99327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99328. /**
  99329. * If the post process is supported.
  99330. */
  99331. get isSupported(): boolean;
  99332. /**
  99333. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99334. */
  99335. get colorCurves(): Nullable<ColorCurves>;
  99336. /**
  99337. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99338. */
  99339. set colorCurves(value: Nullable<ColorCurves>);
  99340. /**
  99341. * Gets wether the color curves effect is enabled.
  99342. */
  99343. get colorCurvesEnabled(): boolean;
  99344. /**
  99345. * Sets wether the color curves effect is enabled.
  99346. */
  99347. set colorCurvesEnabled(value: boolean);
  99348. /**
  99349. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99350. */
  99351. get colorGradingTexture(): Nullable<BaseTexture>;
  99352. /**
  99353. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99354. */
  99355. set colorGradingTexture(value: Nullable<BaseTexture>);
  99356. /**
  99357. * Gets wether the color grading effect is enabled.
  99358. */
  99359. get colorGradingEnabled(): boolean;
  99360. /**
  99361. * Gets wether the color grading effect is enabled.
  99362. */
  99363. set colorGradingEnabled(value: boolean);
  99364. /**
  99365. * Gets exposure used in the effect.
  99366. */
  99367. get exposure(): number;
  99368. /**
  99369. * Sets exposure used in the effect.
  99370. */
  99371. set exposure(value: number);
  99372. /**
  99373. * Gets wether tonemapping is enabled or not.
  99374. */
  99375. get toneMappingEnabled(): boolean;
  99376. /**
  99377. * Sets wether tonemapping is enabled or not
  99378. */
  99379. set toneMappingEnabled(value: boolean);
  99380. /**
  99381. * Gets the type of tone mapping effect.
  99382. */
  99383. get toneMappingType(): number;
  99384. /**
  99385. * Sets the type of tone mapping effect.
  99386. */
  99387. set toneMappingType(value: number);
  99388. /**
  99389. * Gets contrast used in the effect.
  99390. */
  99391. get contrast(): number;
  99392. /**
  99393. * Sets contrast used in the effect.
  99394. */
  99395. set contrast(value: number);
  99396. /**
  99397. * Gets Vignette stretch size.
  99398. */
  99399. get vignetteStretch(): number;
  99400. /**
  99401. * Sets Vignette stretch size.
  99402. */
  99403. set vignetteStretch(value: number);
  99404. /**
  99405. * Gets Vignette centre X Offset.
  99406. */
  99407. get vignetteCentreX(): number;
  99408. /**
  99409. * Sets Vignette centre X Offset.
  99410. */
  99411. set vignetteCentreX(value: number);
  99412. /**
  99413. * Gets Vignette centre Y Offset.
  99414. */
  99415. get vignetteCentreY(): number;
  99416. /**
  99417. * Sets Vignette centre Y Offset.
  99418. */
  99419. set vignetteCentreY(value: number);
  99420. /**
  99421. * Gets Vignette weight or intensity of the vignette effect.
  99422. */
  99423. get vignetteWeight(): number;
  99424. /**
  99425. * Sets Vignette weight or intensity of the vignette effect.
  99426. */
  99427. set vignetteWeight(value: number);
  99428. /**
  99429. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99430. * if vignetteEnabled is set to true.
  99431. */
  99432. get vignetteColor(): Color4;
  99433. /**
  99434. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99435. * if vignetteEnabled is set to true.
  99436. */
  99437. set vignetteColor(value: Color4);
  99438. /**
  99439. * Gets Camera field of view used by the Vignette effect.
  99440. */
  99441. get vignetteCameraFov(): number;
  99442. /**
  99443. * Sets Camera field of view used by the Vignette effect.
  99444. */
  99445. set vignetteCameraFov(value: number);
  99446. /**
  99447. * Gets the vignette blend mode allowing different kind of effect.
  99448. */
  99449. get vignetteBlendMode(): number;
  99450. /**
  99451. * Sets the vignette blend mode allowing different kind of effect.
  99452. */
  99453. set vignetteBlendMode(value: number);
  99454. /**
  99455. * Gets wether the vignette effect is enabled.
  99456. */
  99457. get vignetteEnabled(): boolean;
  99458. /**
  99459. * Sets wether the vignette effect is enabled.
  99460. */
  99461. set vignetteEnabled(value: boolean);
  99462. private _fromLinearSpace;
  99463. /**
  99464. * Gets wether the input of the processing is in Gamma or Linear Space.
  99465. */
  99466. get fromLinearSpace(): boolean;
  99467. /**
  99468. * Sets wether the input of the processing is in Gamma or Linear Space.
  99469. */
  99470. set fromLinearSpace(value: boolean);
  99471. /**
  99472. * Defines cache preventing GC.
  99473. */
  99474. private _defines;
  99475. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99476. /**
  99477. * "ImageProcessingPostProcess"
  99478. * @returns "ImageProcessingPostProcess"
  99479. */
  99480. getClassName(): string;
  99481. /**
  99482. * @hidden
  99483. */
  99484. _updateParameters(): void;
  99485. dispose(camera?: Camera): void;
  99486. }
  99487. }
  99488. declare module BABYLON {
  99489. /**
  99490. * Interface for defining prepass effects in the prepass post-process pipeline
  99491. */
  99492. export interface PrePassEffectConfiguration {
  99493. /**
  99494. * Name of the effect
  99495. */
  99496. name: string;
  99497. /**
  99498. * Post process to attach for this effect
  99499. */
  99500. postProcess?: PostProcess;
  99501. /**
  99502. * Textures required in the MRT
  99503. */
  99504. texturesRequired: number[];
  99505. /**
  99506. * Is the effect enabled
  99507. */
  99508. enabled: boolean;
  99509. /**
  99510. * Disposes the effect configuration
  99511. */
  99512. dispose?: () => void;
  99513. /**
  99514. * Creates the associated post process
  99515. */
  99516. createPostProcess?: () => PostProcess;
  99517. }
  99518. }
  99519. declare module BABYLON {
  99520. /**
  99521. * Options to be used when creating a FresnelParameters.
  99522. */
  99523. export type IFresnelParametersCreationOptions = {
  99524. /**
  99525. * Define the color used on edges (grazing angle)
  99526. */
  99527. leftColor?: Color3;
  99528. /**
  99529. * Define the color used on center
  99530. */
  99531. rightColor?: Color3;
  99532. /**
  99533. * Define bias applied to computed fresnel term
  99534. */
  99535. bias?: number;
  99536. /**
  99537. * Defined the power exponent applied to fresnel term
  99538. */
  99539. power?: number;
  99540. /**
  99541. * Define if the fresnel effect is enable or not.
  99542. */
  99543. isEnabled?: boolean;
  99544. };
  99545. /**
  99546. * Serialized format for FresnelParameters.
  99547. */
  99548. export type IFresnelParametersSerialized = {
  99549. /**
  99550. * Define the color used on edges (grazing angle) [as an array]
  99551. */
  99552. leftColor: number[];
  99553. /**
  99554. * Define the color used on center [as an array]
  99555. */
  99556. rightColor: number[];
  99557. /**
  99558. * Define bias applied to computed fresnel term
  99559. */
  99560. bias: number;
  99561. /**
  99562. * Defined the power exponent applied to fresnel term
  99563. */
  99564. power?: number;
  99565. /**
  99566. * Define if the fresnel effect is enable or not.
  99567. */
  99568. isEnabled: boolean;
  99569. };
  99570. /**
  99571. * This represents all the required information to add a fresnel effect on a material:
  99572. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99573. */
  99574. export class FresnelParameters {
  99575. private _isEnabled;
  99576. /**
  99577. * Define if the fresnel effect is enable or not.
  99578. */
  99579. get isEnabled(): boolean;
  99580. set isEnabled(value: boolean);
  99581. /**
  99582. * Define the color used on edges (grazing angle)
  99583. */
  99584. leftColor: Color3;
  99585. /**
  99586. * Define the color used on center
  99587. */
  99588. rightColor: Color3;
  99589. /**
  99590. * Define bias applied to computed fresnel term
  99591. */
  99592. bias: number;
  99593. /**
  99594. * Defined the power exponent applied to fresnel term
  99595. */
  99596. power: number;
  99597. /**
  99598. * Creates a new FresnelParameters object.
  99599. *
  99600. * @param options provide your own settings to optionally to override defaults
  99601. */
  99602. constructor(options?: IFresnelParametersCreationOptions);
  99603. /**
  99604. * Clones the current fresnel and its valuues
  99605. * @returns a clone fresnel configuration
  99606. */
  99607. clone(): FresnelParameters;
  99608. /**
  99609. * Determines equality between FresnelParameters objects
  99610. * @param otherFresnelParameters defines the second operand
  99611. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  99612. */
  99613. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  99614. /**
  99615. * Serializes the current fresnel parameters to a JSON representation.
  99616. * @return the JSON serialization
  99617. */
  99618. serialize(): IFresnelParametersSerialized;
  99619. /**
  99620. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99621. * @param parsedFresnelParameters Define the JSON representation
  99622. * @returns the parsed parameters
  99623. */
  99624. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  99625. }
  99626. }
  99627. declare module BABYLON {
  99628. /**
  99629. * This groups all the flags used to control the materials channel.
  99630. */
  99631. export class MaterialFlags {
  99632. private static _DiffuseTextureEnabled;
  99633. /**
  99634. * Are diffuse textures enabled in the application.
  99635. */
  99636. static get DiffuseTextureEnabled(): boolean;
  99637. static set DiffuseTextureEnabled(value: boolean);
  99638. private static _DetailTextureEnabled;
  99639. /**
  99640. * Are detail textures enabled in the application.
  99641. */
  99642. static get DetailTextureEnabled(): boolean;
  99643. static set DetailTextureEnabled(value: boolean);
  99644. private static _AmbientTextureEnabled;
  99645. /**
  99646. * Are ambient textures enabled in the application.
  99647. */
  99648. static get AmbientTextureEnabled(): boolean;
  99649. static set AmbientTextureEnabled(value: boolean);
  99650. private static _OpacityTextureEnabled;
  99651. /**
  99652. * Are opacity textures enabled in the application.
  99653. */
  99654. static get OpacityTextureEnabled(): boolean;
  99655. static set OpacityTextureEnabled(value: boolean);
  99656. private static _ReflectionTextureEnabled;
  99657. /**
  99658. * Are reflection textures enabled in the application.
  99659. */
  99660. static get ReflectionTextureEnabled(): boolean;
  99661. static set ReflectionTextureEnabled(value: boolean);
  99662. private static _EmissiveTextureEnabled;
  99663. /**
  99664. * Are emissive textures enabled in the application.
  99665. */
  99666. static get EmissiveTextureEnabled(): boolean;
  99667. static set EmissiveTextureEnabled(value: boolean);
  99668. private static _SpecularTextureEnabled;
  99669. /**
  99670. * Are specular textures enabled in the application.
  99671. */
  99672. static get SpecularTextureEnabled(): boolean;
  99673. static set SpecularTextureEnabled(value: boolean);
  99674. private static _BumpTextureEnabled;
  99675. /**
  99676. * Are bump textures enabled in the application.
  99677. */
  99678. static get BumpTextureEnabled(): boolean;
  99679. static set BumpTextureEnabled(value: boolean);
  99680. private static _LightmapTextureEnabled;
  99681. /**
  99682. * Are lightmap textures enabled in the application.
  99683. */
  99684. static get LightmapTextureEnabled(): boolean;
  99685. static set LightmapTextureEnabled(value: boolean);
  99686. private static _RefractionTextureEnabled;
  99687. /**
  99688. * Are refraction textures enabled in the application.
  99689. */
  99690. static get RefractionTextureEnabled(): boolean;
  99691. static set RefractionTextureEnabled(value: boolean);
  99692. private static _ColorGradingTextureEnabled;
  99693. /**
  99694. * Are color grading textures enabled in the application.
  99695. */
  99696. static get ColorGradingTextureEnabled(): boolean;
  99697. static set ColorGradingTextureEnabled(value: boolean);
  99698. private static _FresnelEnabled;
  99699. /**
  99700. * Are fresnels enabled in the application.
  99701. */
  99702. static get FresnelEnabled(): boolean;
  99703. static set FresnelEnabled(value: boolean);
  99704. private static _ClearCoatTextureEnabled;
  99705. /**
  99706. * Are clear coat textures enabled in the application.
  99707. */
  99708. static get ClearCoatTextureEnabled(): boolean;
  99709. static set ClearCoatTextureEnabled(value: boolean);
  99710. private static _ClearCoatBumpTextureEnabled;
  99711. /**
  99712. * Are clear coat bump textures enabled in the application.
  99713. */
  99714. static get ClearCoatBumpTextureEnabled(): boolean;
  99715. static set ClearCoatBumpTextureEnabled(value: boolean);
  99716. private static _ClearCoatTintTextureEnabled;
  99717. /**
  99718. * Are clear coat tint textures enabled in the application.
  99719. */
  99720. static get ClearCoatTintTextureEnabled(): boolean;
  99721. static set ClearCoatTintTextureEnabled(value: boolean);
  99722. private static _SheenTextureEnabled;
  99723. /**
  99724. * Are sheen textures enabled in the application.
  99725. */
  99726. static get SheenTextureEnabled(): boolean;
  99727. static set SheenTextureEnabled(value: boolean);
  99728. private static _AnisotropicTextureEnabled;
  99729. /**
  99730. * Are anisotropic textures enabled in the application.
  99731. */
  99732. static get AnisotropicTextureEnabled(): boolean;
  99733. static set AnisotropicTextureEnabled(value: boolean);
  99734. private static _ThicknessTextureEnabled;
  99735. /**
  99736. * Are thickness textures enabled in the application.
  99737. */
  99738. static get ThicknessTextureEnabled(): boolean;
  99739. static set ThicknessTextureEnabled(value: boolean);
  99740. }
  99741. }
  99742. declare module BABYLON {
  99743. /** @hidden */
  99744. export var defaultFragmentDeclaration: {
  99745. name: string;
  99746. shader: string;
  99747. };
  99748. }
  99749. declare module BABYLON {
  99750. /** @hidden */
  99751. export var defaultUboDeclaration: {
  99752. name: string;
  99753. shader: string;
  99754. };
  99755. }
  99756. declare module BABYLON {
  99757. /** @hidden */
  99758. export var prePassDeclaration: {
  99759. name: string;
  99760. shader: string;
  99761. };
  99762. }
  99763. declare module BABYLON {
  99764. /** @hidden */
  99765. export var lightFragmentDeclaration: {
  99766. name: string;
  99767. shader: string;
  99768. };
  99769. }
  99770. declare module BABYLON {
  99771. /** @hidden */
  99772. export var lightUboDeclaration: {
  99773. name: string;
  99774. shader: string;
  99775. };
  99776. }
  99777. declare module BABYLON {
  99778. /** @hidden */
  99779. export var lightsFragmentFunctions: {
  99780. name: string;
  99781. shader: string;
  99782. };
  99783. }
  99784. declare module BABYLON {
  99785. /** @hidden */
  99786. export var shadowsFragmentFunctions: {
  99787. name: string;
  99788. shader: string;
  99789. };
  99790. }
  99791. declare module BABYLON {
  99792. /** @hidden */
  99793. export var fresnelFunction: {
  99794. name: string;
  99795. shader: string;
  99796. };
  99797. }
  99798. declare module BABYLON {
  99799. /** @hidden */
  99800. export var bumpFragmentMainFunctions: {
  99801. name: string;
  99802. shader: string;
  99803. };
  99804. }
  99805. declare module BABYLON {
  99806. /** @hidden */
  99807. export var bumpFragmentFunctions: {
  99808. name: string;
  99809. shader: string;
  99810. };
  99811. }
  99812. declare module BABYLON {
  99813. /** @hidden */
  99814. export var logDepthDeclaration: {
  99815. name: string;
  99816. shader: string;
  99817. };
  99818. }
  99819. declare module BABYLON {
  99820. /** @hidden */
  99821. export var fogFragmentDeclaration: {
  99822. name: string;
  99823. shader: string;
  99824. };
  99825. }
  99826. declare module BABYLON {
  99827. /** @hidden */
  99828. export var bumpFragment: {
  99829. name: string;
  99830. shader: string;
  99831. };
  99832. }
  99833. declare module BABYLON {
  99834. /** @hidden */
  99835. export var depthPrePass: {
  99836. name: string;
  99837. shader: string;
  99838. };
  99839. }
  99840. declare module BABYLON {
  99841. /** @hidden */
  99842. export var lightFragment: {
  99843. name: string;
  99844. shader: string;
  99845. };
  99846. }
  99847. declare module BABYLON {
  99848. /** @hidden */
  99849. export var logDepthFragment: {
  99850. name: string;
  99851. shader: string;
  99852. };
  99853. }
  99854. declare module BABYLON {
  99855. /** @hidden */
  99856. export var fogFragment: {
  99857. name: string;
  99858. shader: string;
  99859. };
  99860. }
  99861. declare module BABYLON {
  99862. /** @hidden */
  99863. export var defaultPixelShader: {
  99864. name: string;
  99865. shader: string;
  99866. };
  99867. }
  99868. declare module BABYLON {
  99869. /** @hidden */
  99870. export var defaultVertexDeclaration: {
  99871. name: string;
  99872. shader: string;
  99873. };
  99874. }
  99875. declare module BABYLON {
  99876. /** @hidden */
  99877. export var bonesDeclaration: {
  99878. name: string;
  99879. shader: string;
  99880. };
  99881. }
  99882. declare module BABYLON {
  99883. /** @hidden */
  99884. export var instancesDeclaration: {
  99885. name: string;
  99886. shader: string;
  99887. };
  99888. }
  99889. declare module BABYLON {
  99890. /** @hidden */
  99891. export var prePassVertexDeclaration: {
  99892. name: string;
  99893. shader: string;
  99894. };
  99895. }
  99896. declare module BABYLON {
  99897. /** @hidden */
  99898. export var bumpVertexDeclaration: {
  99899. name: string;
  99900. shader: string;
  99901. };
  99902. }
  99903. declare module BABYLON {
  99904. /** @hidden */
  99905. export var fogVertexDeclaration: {
  99906. name: string;
  99907. shader: string;
  99908. };
  99909. }
  99910. declare module BABYLON {
  99911. /** @hidden */
  99912. export var morphTargetsVertexGlobalDeclaration: {
  99913. name: string;
  99914. shader: string;
  99915. };
  99916. }
  99917. declare module BABYLON {
  99918. /** @hidden */
  99919. export var morphTargetsVertexDeclaration: {
  99920. name: string;
  99921. shader: string;
  99922. };
  99923. }
  99924. declare module BABYLON {
  99925. /** @hidden */
  99926. export var morphTargetsVertex: {
  99927. name: string;
  99928. shader: string;
  99929. };
  99930. }
  99931. declare module BABYLON {
  99932. /** @hidden */
  99933. export var instancesVertex: {
  99934. name: string;
  99935. shader: string;
  99936. };
  99937. }
  99938. declare module BABYLON {
  99939. /** @hidden */
  99940. export var bonesVertex: {
  99941. name: string;
  99942. shader: string;
  99943. };
  99944. }
  99945. declare module BABYLON {
  99946. /** @hidden */
  99947. export var prePassVertex: {
  99948. name: string;
  99949. shader: string;
  99950. };
  99951. }
  99952. declare module BABYLON {
  99953. /** @hidden */
  99954. export var bumpVertex: {
  99955. name: string;
  99956. shader: string;
  99957. };
  99958. }
  99959. declare module BABYLON {
  99960. /** @hidden */
  99961. export var fogVertex: {
  99962. name: string;
  99963. shader: string;
  99964. };
  99965. }
  99966. declare module BABYLON {
  99967. /** @hidden */
  99968. export var shadowsVertex: {
  99969. name: string;
  99970. shader: string;
  99971. };
  99972. }
  99973. declare module BABYLON {
  99974. /** @hidden */
  99975. export var pointCloudVertex: {
  99976. name: string;
  99977. shader: string;
  99978. };
  99979. }
  99980. declare module BABYLON {
  99981. /** @hidden */
  99982. export var logDepthVertex: {
  99983. name: string;
  99984. shader: string;
  99985. };
  99986. }
  99987. declare module BABYLON {
  99988. /** @hidden */
  99989. export var defaultVertexShader: {
  99990. name: string;
  99991. shader: string;
  99992. };
  99993. }
  99994. declare module BABYLON {
  99995. /**
  99996. * @hidden
  99997. */
  99998. export interface IMaterialDetailMapDefines {
  99999. DETAIL: boolean;
  100000. DETAILDIRECTUV: number;
  100001. DETAIL_NORMALBLENDMETHOD: number;
  100002. /** @hidden */
  100003. _areTexturesDirty: boolean;
  100004. }
  100005. /**
  100006. * Define the code related to the detail map parameters of a material
  100007. *
  100008. * Inspired from:
  100009. * 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
  100010. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  100011. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  100012. */
  100013. export class DetailMapConfiguration {
  100014. private _texture;
  100015. /**
  100016. * The detail texture of the material.
  100017. */
  100018. texture: Nullable<BaseTexture>;
  100019. /**
  100020. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  100021. * Bigger values mean stronger blending
  100022. */
  100023. diffuseBlendLevel: number;
  100024. /**
  100025. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  100026. * Bigger values mean stronger blending. Only used with PBR materials
  100027. */
  100028. roughnessBlendLevel: number;
  100029. /**
  100030. * Defines how strong the bump effect from the detail map is
  100031. * Bigger values mean stronger effect
  100032. */
  100033. bumpLevel: number;
  100034. private _normalBlendMethod;
  100035. /**
  100036. * The method used to blend the bump and detail normals together
  100037. */
  100038. normalBlendMethod: number;
  100039. private _isEnabled;
  100040. /**
  100041. * Enable or disable the detail map on this material
  100042. */
  100043. isEnabled: boolean;
  100044. /** @hidden */
  100045. private _internalMarkAllSubMeshesAsTexturesDirty;
  100046. /** @hidden */
  100047. _markAllSubMeshesAsTexturesDirty(): void;
  100048. /**
  100049. * Instantiate a new detail map
  100050. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100051. */
  100052. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100053. /**
  100054. * Gets whether the submesh is ready to be used or not.
  100055. * @param defines the list of "defines" to update.
  100056. * @param scene defines the scene the material belongs to.
  100057. * @returns - boolean indicating that the submesh is ready or not.
  100058. */
  100059. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  100060. /**
  100061. * Update the defines for detail map usage
  100062. * @param defines the list of "defines" to update.
  100063. * @param scene defines the scene the material belongs to.
  100064. */
  100065. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  100066. /**
  100067. * Binds the material data.
  100068. * @param uniformBuffer defines the Uniform buffer to fill in.
  100069. * @param scene defines the scene the material belongs to.
  100070. * @param isFrozen defines whether the material is frozen or not.
  100071. */
  100072. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100073. /**
  100074. * Checks to see if a texture is used in the material.
  100075. * @param texture - Base texture to use.
  100076. * @returns - Boolean specifying if a texture is used in the material.
  100077. */
  100078. hasTexture(texture: BaseTexture): boolean;
  100079. /**
  100080. * Returns an array of the actively used textures.
  100081. * @param activeTextures Array of BaseTextures
  100082. */
  100083. getActiveTextures(activeTextures: BaseTexture[]): void;
  100084. /**
  100085. * Returns the animatable textures.
  100086. * @param animatables Array of animatable textures.
  100087. */
  100088. getAnimatables(animatables: IAnimatable[]): void;
  100089. /**
  100090. * Disposes the resources of the material.
  100091. * @param forceDisposeTextures - Forces the disposal of all textures.
  100092. */
  100093. dispose(forceDisposeTextures?: boolean): void;
  100094. /**
  100095. * Get the current class name useful for serialization or dynamic coding.
  100096. * @returns "DetailMap"
  100097. */
  100098. getClassName(): string;
  100099. /**
  100100. * Add the required uniforms to the current list.
  100101. * @param uniforms defines the current uniform list.
  100102. */
  100103. static AddUniforms(uniforms: string[]): void;
  100104. /**
  100105. * Add the required samplers to the current list.
  100106. * @param samplers defines the current sampler list.
  100107. */
  100108. static AddSamplers(samplers: string[]): void;
  100109. /**
  100110. * Add the required uniforms to the current buffer.
  100111. * @param uniformBuffer defines the current uniform buffer.
  100112. */
  100113. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100114. /**
  100115. * Makes a duplicate of the current instance into another one.
  100116. * @param detailMap define the instance where to copy the info
  100117. */
  100118. copyTo(detailMap: DetailMapConfiguration): void;
  100119. /**
  100120. * Serializes this detail map instance
  100121. * @returns - An object with the serialized instance.
  100122. */
  100123. serialize(): any;
  100124. /**
  100125. * Parses a detail map setting from a serialized object.
  100126. * @param source - Serialized object.
  100127. * @param scene Defines the scene we are parsing for
  100128. * @param rootUrl Defines the rootUrl to load from
  100129. */
  100130. parse(source: any, scene: Scene, rootUrl: string): void;
  100131. }
  100132. }
  100133. declare module BABYLON {
  100134. /** @hidden */
  100135. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  100136. MAINUV1: boolean;
  100137. MAINUV2: boolean;
  100138. DIFFUSE: boolean;
  100139. DIFFUSEDIRECTUV: number;
  100140. DETAIL: boolean;
  100141. DETAILDIRECTUV: number;
  100142. DETAIL_NORMALBLENDMETHOD: number;
  100143. AMBIENT: boolean;
  100144. AMBIENTDIRECTUV: number;
  100145. OPACITY: boolean;
  100146. OPACITYDIRECTUV: number;
  100147. OPACITYRGB: boolean;
  100148. REFLECTION: boolean;
  100149. EMISSIVE: boolean;
  100150. EMISSIVEDIRECTUV: number;
  100151. SPECULAR: boolean;
  100152. SPECULARDIRECTUV: number;
  100153. BUMP: boolean;
  100154. BUMPDIRECTUV: number;
  100155. PARALLAX: boolean;
  100156. PARALLAXOCCLUSION: boolean;
  100157. SPECULAROVERALPHA: boolean;
  100158. CLIPPLANE: boolean;
  100159. CLIPPLANE2: boolean;
  100160. CLIPPLANE3: boolean;
  100161. CLIPPLANE4: boolean;
  100162. CLIPPLANE5: boolean;
  100163. CLIPPLANE6: boolean;
  100164. ALPHATEST: boolean;
  100165. DEPTHPREPASS: boolean;
  100166. ALPHAFROMDIFFUSE: boolean;
  100167. POINTSIZE: boolean;
  100168. FOG: boolean;
  100169. SPECULARTERM: boolean;
  100170. DIFFUSEFRESNEL: boolean;
  100171. OPACITYFRESNEL: boolean;
  100172. REFLECTIONFRESNEL: boolean;
  100173. REFRACTIONFRESNEL: boolean;
  100174. EMISSIVEFRESNEL: boolean;
  100175. FRESNEL: boolean;
  100176. NORMAL: boolean;
  100177. UV1: boolean;
  100178. UV2: boolean;
  100179. VERTEXCOLOR: boolean;
  100180. VERTEXALPHA: boolean;
  100181. NUM_BONE_INFLUENCERS: number;
  100182. BonesPerMesh: number;
  100183. BONETEXTURE: boolean;
  100184. BONES_VELOCITY_ENABLED: boolean;
  100185. INSTANCES: boolean;
  100186. THIN_INSTANCES: boolean;
  100187. GLOSSINESS: boolean;
  100188. ROUGHNESS: boolean;
  100189. EMISSIVEASILLUMINATION: boolean;
  100190. LINKEMISSIVEWITHDIFFUSE: boolean;
  100191. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100192. LIGHTMAP: boolean;
  100193. LIGHTMAPDIRECTUV: number;
  100194. OBJECTSPACE_NORMALMAP: boolean;
  100195. USELIGHTMAPASSHADOWMAP: boolean;
  100196. REFLECTIONMAP_3D: boolean;
  100197. REFLECTIONMAP_SPHERICAL: boolean;
  100198. REFLECTIONMAP_PLANAR: boolean;
  100199. REFLECTIONMAP_CUBIC: boolean;
  100200. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100201. REFLECTIONMAP_PROJECTION: boolean;
  100202. REFLECTIONMAP_SKYBOX: boolean;
  100203. REFLECTIONMAP_EXPLICIT: boolean;
  100204. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100205. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100206. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100207. INVERTCUBICMAP: boolean;
  100208. LOGARITHMICDEPTH: boolean;
  100209. REFRACTION: boolean;
  100210. REFRACTIONMAP_3D: boolean;
  100211. REFLECTIONOVERALPHA: boolean;
  100212. TWOSIDEDLIGHTING: boolean;
  100213. SHADOWFLOAT: boolean;
  100214. MORPHTARGETS: boolean;
  100215. MORPHTARGETS_NORMAL: boolean;
  100216. MORPHTARGETS_TANGENT: boolean;
  100217. MORPHTARGETS_UV: boolean;
  100218. NUM_MORPH_INFLUENCERS: number;
  100219. NONUNIFORMSCALING: boolean;
  100220. PREMULTIPLYALPHA: boolean;
  100221. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100222. ALPHABLEND: boolean;
  100223. PREPASS: boolean;
  100224. PREPASS_IRRADIANCE: boolean;
  100225. PREPASS_IRRADIANCE_INDEX: number;
  100226. PREPASS_ALBEDO: boolean;
  100227. PREPASS_ALBEDO_INDEX: number;
  100228. PREPASS_DEPTHNORMAL: boolean;
  100229. PREPASS_DEPTHNORMAL_INDEX: number;
  100230. PREPASS_POSITION: boolean;
  100231. PREPASS_POSITION_INDEX: number;
  100232. PREPASS_VELOCITY: boolean;
  100233. PREPASS_VELOCITY_INDEX: number;
  100234. PREPASS_REFLECTIVITY: boolean;
  100235. PREPASS_REFLECTIVITY_INDEX: number;
  100236. SCENE_MRT_COUNT: number;
  100237. RGBDLIGHTMAP: boolean;
  100238. RGBDREFLECTION: boolean;
  100239. RGBDREFRACTION: boolean;
  100240. IMAGEPROCESSING: boolean;
  100241. VIGNETTE: boolean;
  100242. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100243. VIGNETTEBLENDMODEOPAQUE: boolean;
  100244. TONEMAPPING: boolean;
  100245. TONEMAPPING_ACES: boolean;
  100246. CONTRAST: boolean;
  100247. COLORCURVES: boolean;
  100248. COLORGRADING: boolean;
  100249. COLORGRADING3D: boolean;
  100250. SAMPLER3DGREENDEPTH: boolean;
  100251. SAMPLER3DBGRMAP: boolean;
  100252. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100253. MULTIVIEW: boolean;
  100254. /**
  100255. * If the reflection texture on this material is in linear color space
  100256. * @hidden
  100257. */
  100258. IS_REFLECTION_LINEAR: boolean;
  100259. /**
  100260. * If the refraction texture on this material is in linear color space
  100261. * @hidden
  100262. */
  100263. IS_REFRACTION_LINEAR: boolean;
  100264. EXPOSURE: boolean;
  100265. constructor();
  100266. setReflectionMode(modeToEnable: string): void;
  100267. }
  100268. /**
  100269. * This is the default material used in Babylon. It is the best trade off between quality
  100270. * and performances.
  100271. * @see https://doc.babylonjs.com/babylon101/materials
  100272. */
  100273. export class StandardMaterial extends PushMaterial {
  100274. private _diffuseTexture;
  100275. /**
  100276. * The basic texture of the material as viewed under a light.
  100277. */
  100278. diffuseTexture: Nullable<BaseTexture>;
  100279. private _ambientTexture;
  100280. /**
  100281. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100282. */
  100283. ambientTexture: Nullable<BaseTexture>;
  100284. private _opacityTexture;
  100285. /**
  100286. * Define the transparency of the material from a texture.
  100287. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  100288. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  100289. */
  100290. opacityTexture: Nullable<BaseTexture>;
  100291. private _reflectionTexture;
  100292. /**
  100293. * Define the texture used to display the reflection.
  100294. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100295. */
  100296. reflectionTexture: Nullable<BaseTexture>;
  100297. private _emissiveTexture;
  100298. /**
  100299. * Define texture of the material as if self lit.
  100300. * This will be mixed in the final result even in the absence of light.
  100301. */
  100302. emissiveTexture: Nullable<BaseTexture>;
  100303. private _specularTexture;
  100304. /**
  100305. * Define how the color and intensity of the highlight given by the light in the material.
  100306. */
  100307. specularTexture: Nullable<BaseTexture>;
  100308. private _bumpTexture;
  100309. /**
  100310. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  100311. * 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.
  100312. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  100313. */
  100314. bumpTexture: Nullable<BaseTexture>;
  100315. private _lightmapTexture;
  100316. /**
  100317. * Complex lighting can be computationally expensive to compute at runtime.
  100318. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  100319. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  100320. */
  100321. lightmapTexture: Nullable<BaseTexture>;
  100322. private _refractionTexture;
  100323. /**
  100324. * Define the texture used to display the refraction.
  100325. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100326. */
  100327. refractionTexture: Nullable<BaseTexture>;
  100328. /**
  100329. * The color of the material lit by the environmental background lighting.
  100330. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  100331. */
  100332. ambientColor: Color3;
  100333. /**
  100334. * The basic color of the material as viewed under a light.
  100335. */
  100336. diffuseColor: Color3;
  100337. /**
  100338. * Define how the color and intensity of the highlight given by the light in the material.
  100339. */
  100340. specularColor: Color3;
  100341. /**
  100342. * Define the color of the material as if self lit.
  100343. * This will be mixed in the final result even in the absence of light.
  100344. */
  100345. emissiveColor: Color3;
  100346. /**
  100347. * Defines how sharp are the highlights in the material.
  100348. * The bigger the value the sharper giving a more glossy feeling to the result.
  100349. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  100350. */
  100351. specularPower: number;
  100352. private _useAlphaFromDiffuseTexture;
  100353. /**
  100354. * Does the transparency come from the diffuse texture alpha channel.
  100355. */
  100356. useAlphaFromDiffuseTexture: boolean;
  100357. private _useEmissiveAsIllumination;
  100358. /**
  100359. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  100360. */
  100361. useEmissiveAsIllumination: boolean;
  100362. private _linkEmissiveWithDiffuse;
  100363. /**
  100364. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  100365. * the emissive level when the final color is close to one.
  100366. */
  100367. linkEmissiveWithDiffuse: boolean;
  100368. private _useSpecularOverAlpha;
  100369. /**
  100370. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  100371. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100372. */
  100373. useSpecularOverAlpha: boolean;
  100374. private _useReflectionOverAlpha;
  100375. /**
  100376. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100377. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100378. */
  100379. useReflectionOverAlpha: boolean;
  100380. private _disableLighting;
  100381. /**
  100382. * Does lights from the scene impacts this material.
  100383. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  100384. */
  100385. disableLighting: boolean;
  100386. private _useObjectSpaceNormalMap;
  100387. /**
  100388. * Allows using an object space normal map (instead of tangent space).
  100389. */
  100390. useObjectSpaceNormalMap: boolean;
  100391. private _useParallax;
  100392. /**
  100393. * Is parallax enabled or not.
  100394. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  100395. */
  100396. useParallax: boolean;
  100397. private _useParallaxOcclusion;
  100398. /**
  100399. * Is parallax occlusion enabled or not.
  100400. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  100401. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  100402. */
  100403. useParallaxOcclusion: boolean;
  100404. /**
  100405. * 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.
  100406. */
  100407. parallaxScaleBias: number;
  100408. private _roughness;
  100409. /**
  100410. * Helps to define how blurry the reflections should appears in the material.
  100411. */
  100412. roughness: number;
  100413. /**
  100414. * In case of refraction, define the value of the index of refraction.
  100415. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100416. */
  100417. indexOfRefraction: number;
  100418. /**
  100419. * Invert the refraction texture alongside the y axis.
  100420. * It can be useful with procedural textures or probe for instance.
  100421. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100422. */
  100423. invertRefractionY: boolean;
  100424. /**
  100425. * Defines the alpha limits in alpha test mode.
  100426. */
  100427. alphaCutOff: number;
  100428. private _useLightmapAsShadowmap;
  100429. /**
  100430. * In case of light mapping, define whether the map contains light or shadow informations.
  100431. */
  100432. useLightmapAsShadowmap: boolean;
  100433. private _diffuseFresnelParameters;
  100434. /**
  100435. * Define the diffuse fresnel parameters of the material.
  100436. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100437. */
  100438. diffuseFresnelParameters: FresnelParameters;
  100439. private _opacityFresnelParameters;
  100440. /**
  100441. * Define the opacity fresnel parameters of the material.
  100442. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100443. */
  100444. opacityFresnelParameters: FresnelParameters;
  100445. private _reflectionFresnelParameters;
  100446. /**
  100447. * Define the reflection fresnel parameters of the material.
  100448. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100449. */
  100450. reflectionFresnelParameters: FresnelParameters;
  100451. private _refractionFresnelParameters;
  100452. /**
  100453. * Define the refraction fresnel parameters of the material.
  100454. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100455. */
  100456. refractionFresnelParameters: FresnelParameters;
  100457. private _emissiveFresnelParameters;
  100458. /**
  100459. * Define the emissive fresnel parameters of the material.
  100460. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100461. */
  100462. emissiveFresnelParameters: FresnelParameters;
  100463. private _useReflectionFresnelFromSpecular;
  100464. /**
  100465. * If true automatically deducts the fresnels values from the material specularity.
  100466. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100467. */
  100468. useReflectionFresnelFromSpecular: boolean;
  100469. private _useGlossinessFromSpecularMapAlpha;
  100470. /**
  100471. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  100472. */
  100473. useGlossinessFromSpecularMapAlpha: boolean;
  100474. private _maxSimultaneousLights;
  100475. /**
  100476. * Defines the maximum number of lights that can be used in the material
  100477. */
  100478. maxSimultaneousLights: number;
  100479. private _invertNormalMapX;
  100480. /**
  100481. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100482. */
  100483. invertNormalMapX: boolean;
  100484. private _invertNormalMapY;
  100485. /**
  100486. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100487. */
  100488. invertNormalMapY: boolean;
  100489. private _twoSidedLighting;
  100490. /**
  100491. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100492. */
  100493. twoSidedLighting: boolean;
  100494. /**
  100495. * Default configuration related to image processing available in the standard Material.
  100496. */
  100497. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100498. /**
  100499. * Gets the image processing configuration used either in this material.
  100500. */
  100501. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100502. /**
  100503. * Sets the Default image processing configuration used either in the this material.
  100504. *
  100505. * If sets to null, the scene one is in use.
  100506. */
  100507. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100508. /**
  100509. * Keep track of the image processing observer to allow dispose and replace.
  100510. */
  100511. private _imageProcessingObserver;
  100512. /**
  100513. * Attaches a new image processing configuration to the Standard Material.
  100514. * @param configuration
  100515. */
  100516. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100517. /**
  100518. * Defines additionnal PrePass parameters for the material.
  100519. */
  100520. readonly prePassConfiguration: PrePassConfiguration;
  100521. /**
  100522. * Gets wether the color curves effect is enabled.
  100523. */
  100524. get cameraColorCurvesEnabled(): boolean;
  100525. /**
  100526. * Sets wether the color curves effect is enabled.
  100527. */
  100528. set cameraColorCurvesEnabled(value: boolean);
  100529. /**
  100530. * Gets wether the color grading effect is enabled.
  100531. */
  100532. get cameraColorGradingEnabled(): boolean;
  100533. /**
  100534. * Gets wether the color grading effect is enabled.
  100535. */
  100536. set cameraColorGradingEnabled(value: boolean);
  100537. /**
  100538. * Gets wether tonemapping is enabled or not.
  100539. */
  100540. get cameraToneMappingEnabled(): boolean;
  100541. /**
  100542. * Sets wether tonemapping is enabled or not
  100543. */
  100544. set cameraToneMappingEnabled(value: boolean);
  100545. /**
  100546. * The camera exposure used on this material.
  100547. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100548. * This corresponds to a photographic exposure.
  100549. */
  100550. get cameraExposure(): number;
  100551. /**
  100552. * The camera exposure used on this material.
  100553. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100554. * This corresponds to a photographic exposure.
  100555. */
  100556. set cameraExposure(value: number);
  100557. /**
  100558. * Gets The camera contrast used on this material.
  100559. */
  100560. get cameraContrast(): number;
  100561. /**
  100562. * Sets The camera contrast used on this material.
  100563. */
  100564. set cameraContrast(value: number);
  100565. /**
  100566. * Gets the Color Grading 2D Lookup Texture.
  100567. */
  100568. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100569. /**
  100570. * Sets the Color Grading 2D Lookup Texture.
  100571. */
  100572. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100573. /**
  100574. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100575. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100576. * 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;
  100577. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100578. */
  100579. get cameraColorCurves(): Nullable<ColorCurves>;
  100580. /**
  100581. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100582. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100583. * 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;
  100584. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100585. */
  100586. set cameraColorCurves(value: Nullable<ColorCurves>);
  100587. /**
  100588. * Can this material render to several textures at once
  100589. */
  100590. get canRenderToMRT(): boolean;
  100591. /**
  100592. * Defines the detail map parameters for the material.
  100593. */
  100594. readonly detailMap: DetailMapConfiguration;
  100595. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100596. protected _worldViewProjectionMatrix: Matrix;
  100597. protected _globalAmbientColor: Color3;
  100598. protected _useLogarithmicDepth: boolean;
  100599. protected _rebuildInParallel: boolean;
  100600. /**
  100601. * Instantiates a new standard material.
  100602. * This is the default material used in Babylon. It is the best trade off between quality
  100603. * and performances.
  100604. * @see https://doc.babylonjs.com/babylon101/materials
  100605. * @param name Define the name of the material in the scene
  100606. * @param scene Define the scene the material belong to
  100607. */
  100608. constructor(name: string, scene: Scene);
  100609. /**
  100610. * Gets a boolean indicating that current material needs to register RTT
  100611. */
  100612. get hasRenderTargetTextures(): boolean;
  100613. /**
  100614. * Gets the current class name of the material e.g. "StandardMaterial"
  100615. * Mainly use in serialization.
  100616. * @returns the class name
  100617. */
  100618. getClassName(): string;
  100619. /**
  100620. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100621. * You can try switching to logarithmic depth.
  100622. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100623. */
  100624. get useLogarithmicDepth(): boolean;
  100625. set useLogarithmicDepth(value: boolean);
  100626. /**
  100627. * Specifies if the material will require alpha blending
  100628. * @returns a boolean specifying if alpha blending is needed
  100629. */
  100630. needAlphaBlending(): boolean;
  100631. /**
  100632. * Specifies if this material should be rendered in alpha test mode
  100633. * @returns a boolean specifying if an alpha test is needed.
  100634. */
  100635. needAlphaTesting(): boolean;
  100636. /**
  100637. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  100638. */
  100639. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100640. /**
  100641. * Specifies whether or not there is a usable alpha channel for transparency.
  100642. */
  100643. protected _hasAlphaChannel(): boolean;
  100644. /**
  100645. * Get the texture used for alpha test purpose.
  100646. * @returns the diffuse texture in case of the standard material.
  100647. */
  100648. getAlphaTestTexture(): Nullable<BaseTexture>;
  100649. /**
  100650. * Get if the submesh is ready to be used and all its information available.
  100651. * Child classes can use it to update shaders
  100652. * @param mesh defines the mesh to check
  100653. * @param subMesh defines which submesh to check
  100654. * @param useInstances specifies that instances should be used
  100655. * @returns a boolean indicating that the submesh is ready or not
  100656. */
  100657. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100658. /**
  100659. * Builds the material UBO layouts.
  100660. * Used internally during the effect preparation.
  100661. */
  100662. buildUniformLayout(): void;
  100663. /**
  100664. * Unbinds the material from the mesh
  100665. */
  100666. unbind(): void;
  100667. /**
  100668. * Binds the submesh to this material by preparing the effect and shader to draw
  100669. * @param world defines the world transformation matrix
  100670. * @param mesh defines the mesh containing the submesh
  100671. * @param subMesh defines the submesh to bind the material to
  100672. */
  100673. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100674. /**
  100675. * Get the list of animatables in the material.
  100676. * @returns the list of animatables object used in the material
  100677. */
  100678. getAnimatables(): IAnimatable[];
  100679. /**
  100680. * Gets the active textures from the material
  100681. * @returns an array of textures
  100682. */
  100683. getActiveTextures(): BaseTexture[];
  100684. /**
  100685. * Specifies if the material uses a texture
  100686. * @param texture defines the texture to check against the material
  100687. * @returns a boolean specifying if the material uses the texture
  100688. */
  100689. hasTexture(texture: BaseTexture): boolean;
  100690. /**
  100691. * Disposes the material
  100692. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100693. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100694. */
  100695. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100696. /**
  100697. * Makes a duplicate of the material, and gives it a new name
  100698. * @param name defines the new name for the duplicated material
  100699. * @returns the cloned material
  100700. */
  100701. clone(name: string): StandardMaterial;
  100702. /**
  100703. * Serializes this material in a JSON representation
  100704. * @returns the serialized material object
  100705. */
  100706. serialize(): any;
  100707. /**
  100708. * Creates a standard material from parsed material data
  100709. * @param source defines the JSON representation of the material
  100710. * @param scene defines the hosting scene
  100711. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100712. * @returns a new standard material
  100713. */
  100714. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100715. /**
  100716. * Are diffuse textures enabled in the application.
  100717. */
  100718. static get DiffuseTextureEnabled(): boolean;
  100719. static set DiffuseTextureEnabled(value: boolean);
  100720. /**
  100721. * Are detail textures enabled in the application.
  100722. */
  100723. static get DetailTextureEnabled(): boolean;
  100724. static set DetailTextureEnabled(value: boolean);
  100725. /**
  100726. * Are ambient textures enabled in the application.
  100727. */
  100728. static get AmbientTextureEnabled(): boolean;
  100729. static set AmbientTextureEnabled(value: boolean);
  100730. /**
  100731. * Are opacity textures enabled in the application.
  100732. */
  100733. static get OpacityTextureEnabled(): boolean;
  100734. static set OpacityTextureEnabled(value: boolean);
  100735. /**
  100736. * Are reflection textures enabled in the application.
  100737. */
  100738. static get ReflectionTextureEnabled(): boolean;
  100739. static set ReflectionTextureEnabled(value: boolean);
  100740. /**
  100741. * Are emissive textures enabled in the application.
  100742. */
  100743. static get EmissiveTextureEnabled(): boolean;
  100744. static set EmissiveTextureEnabled(value: boolean);
  100745. /**
  100746. * Are specular textures enabled in the application.
  100747. */
  100748. static get SpecularTextureEnabled(): boolean;
  100749. static set SpecularTextureEnabled(value: boolean);
  100750. /**
  100751. * Are bump textures enabled in the application.
  100752. */
  100753. static get BumpTextureEnabled(): boolean;
  100754. static set BumpTextureEnabled(value: boolean);
  100755. /**
  100756. * Are lightmap textures enabled in the application.
  100757. */
  100758. static get LightmapTextureEnabled(): boolean;
  100759. static set LightmapTextureEnabled(value: boolean);
  100760. /**
  100761. * Are refraction textures enabled in the application.
  100762. */
  100763. static get RefractionTextureEnabled(): boolean;
  100764. static set RefractionTextureEnabled(value: boolean);
  100765. /**
  100766. * Are color grading textures enabled in the application.
  100767. */
  100768. static get ColorGradingTextureEnabled(): boolean;
  100769. static set ColorGradingTextureEnabled(value: boolean);
  100770. /**
  100771. * Are fresnels enabled in the application.
  100772. */
  100773. static get FresnelEnabled(): boolean;
  100774. static set FresnelEnabled(value: boolean);
  100775. }
  100776. }
  100777. declare module BABYLON {
  100778. /** @hidden */
  100779. export var rgbdDecodePixelShader: {
  100780. name: string;
  100781. shader: string;
  100782. };
  100783. }
  100784. declare module BABYLON {
  100785. /**
  100786. * Class used to host RGBD texture specific utilities
  100787. */
  100788. export class RGBDTextureTools {
  100789. /**
  100790. * Expand the RGBD Texture from RGBD to Half Float if possible.
  100791. * @param texture the texture to expand.
  100792. */
  100793. static ExpandRGBDTexture(texture: Texture): void;
  100794. }
  100795. }
  100796. declare module BABYLON {
  100797. /**
  100798. * Class used to host texture specific utilities
  100799. */
  100800. export class BRDFTextureTools {
  100801. /**
  100802. * Prevents texture cache collision
  100803. */
  100804. private static _instanceNumber;
  100805. /**
  100806. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100807. * @param scene defines the hosting scene
  100808. * @returns the environment BRDF texture
  100809. */
  100810. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100811. private static _environmentBRDFBase64Texture;
  100812. }
  100813. }
  100814. declare module BABYLON {
  100815. /**
  100816. * @hidden
  100817. */
  100818. export interface IMaterialClearCoatDefines {
  100819. CLEARCOAT: boolean;
  100820. CLEARCOAT_DEFAULTIOR: boolean;
  100821. CLEARCOAT_TEXTURE: boolean;
  100822. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  100823. CLEARCOAT_TEXTUREDIRECTUV: number;
  100824. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  100825. CLEARCOAT_BUMP: boolean;
  100826. CLEARCOAT_BUMPDIRECTUV: number;
  100827. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  100828. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  100829. CLEARCOAT_REMAP_F0: boolean;
  100830. CLEARCOAT_TINT: boolean;
  100831. CLEARCOAT_TINT_TEXTURE: boolean;
  100832. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100833. /** @hidden */
  100834. _areTexturesDirty: boolean;
  100835. }
  100836. /**
  100837. * Define the code related to the clear coat parameters of the pbr material.
  100838. */
  100839. export class PBRClearCoatConfiguration {
  100840. /**
  100841. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100842. * The default fits with a polyurethane material.
  100843. * @hidden
  100844. */
  100845. static readonly _DefaultIndexOfRefraction: number;
  100846. private _isEnabled;
  100847. /**
  100848. * Defines if the clear coat is enabled in the material.
  100849. */
  100850. isEnabled: boolean;
  100851. /**
  100852. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100853. */
  100854. intensity: number;
  100855. /**
  100856. * Defines the clear coat layer roughness.
  100857. */
  100858. roughness: number;
  100859. private _indexOfRefraction;
  100860. /**
  100861. * Defines the index of refraction of the clear coat.
  100862. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100863. * The default fits with a polyurethane material.
  100864. * Changing the default value is more performance intensive.
  100865. */
  100866. indexOfRefraction: number;
  100867. private _texture;
  100868. /**
  100869. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  100870. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  100871. * if textureRoughness is not empty, else no texture roughness is used
  100872. */
  100873. texture: Nullable<BaseTexture>;
  100874. private _useRoughnessFromMainTexture;
  100875. /**
  100876. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  100877. * If false, the green channel from textureRoughness is used for roughness
  100878. */
  100879. useRoughnessFromMainTexture: boolean;
  100880. private _textureRoughness;
  100881. /**
  100882. * Stores the clear coat roughness in a texture (green channel)
  100883. * Not used if useRoughnessFromMainTexture is true
  100884. */
  100885. textureRoughness: Nullable<BaseTexture>;
  100886. private _remapF0OnInterfaceChange;
  100887. /**
  100888. * Defines if the F0 value should be remapped to account for the interface change in the material.
  100889. */
  100890. remapF0OnInterfaceChange: boolean;
  100891. private _bumpTexture;
  100892. /**
  100893. * Define the clear coat specific bump texture.
  100894. */
  100895. bumpTexture: Nullable<BaseTexture>;
  100896. private _isTintEnabled;
  100897. /**
  100898. * Defines if the clear coat tint is enabled in the material.
  100899. */
  100900. isTintEnabled: boolean;
  100901. /**
  100902. * Defines the clear coat tint of the material.
  100903. * This is only use if tint is enabled
  100904. */
  100905. tintColor: Color3;
  100906. /**
  100907. * Defines the distance at which the tint color should be found in the
  100908. * clear coat media.
  100909. * This is only use if tint is enabled
  100910. */
  100911. tintColorAtDistance: number;
  100912. /**
  100913. * Defines the clear coat layer thickness.
  100914. * This is only use if tint is enabled
  100915. */
  100916. tintThickness: number;
  100917. private _tintTexture;
  100918. /**
  100919. * Stores the clear tint values in a texture.
  100920. * rgb is tint
  100921. * a is a thickness factor
  100922. */
  100923. tintTexture: Nullable<BaseTexture>;
  100924. /** @hidden */
  100925. private _internalMarkAllSubMeshesAsTexturesDirty;
  100926. /** @hidden */
  100927. _markAllSubMeshesAsTexturesDirty(): void;
  100928. /**
  100929. * Instantiate a new istance of clear coat configuration.
  100930. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100931. */
  100932. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100933. /**
  100934. * Gets wehter the submesh is ready to be used or not.
  100935. * @param defines the list of "defines" to update.
  100936. * @param scene defines the scene the material belongs to.
  100937. * @param engine defines the engine the material belongs to.
  100938. * @param disableBumpMap defines wether the material disables bump or not.
  100939. * @returns - boolean indicating that the submesh is ready or not.
  100940. */
  100941. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  100942. /**
  100943. * Checks to see if a texture is used in the material.
  100944. * @param defines the list of "defines" to update.
  100945. * @param scene defines the scene to the material belongs to.
  100946. */
  100947. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  100948. /**
  100949. * Binds the material data.
  100950. * @param uniformBuffer defines the Uniform buffer to fill in.
  100951. * @param scene defines the scene the material belongs to.
  100952. * @param engine defines the engine the material belongs to.
  100953. * @param disableBumpMap defines wether the material disables bump or not.
  100954. * @param isFrozen defines wether the material is frozen or not.
  100955. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  100956. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  100957. * @param subMesh the submesh to bind data for
  100958. */
  100959. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  100960. /**
  100961. * Checks to see if a texture is used in the material.
  100962. * @param texture - Base texture to use.
  100963. * @returns - Boolean specifying if a texture is used in the material.
  100964. */
  100965. hasTexture(texture: BaseTexture): boolean;
  100966. /**
  100967. * Returns an array of the actively used textures.
  100968. * @param activeTextures Array of BaseTextures
  100969. */
  100970. getActiveTextures(activeTextures: BaseTexture[]): void;
  100971. /**
  100972. * Returns the animatable textures.
  100973. * @param animatables Array of animatable textures.
  100974. */
  100975. getAnimatables(animatables: IAnimatable[]): void;
  100976. /**
  100977. * Disposes the resources of the material.
  100978. * @param forceDisposeTextures - Forces the disposal of all textures.
  100979. */
  100980. dispose(forceDisposeTextures?: boolean): void;
  100981. /**
  100982. * Get the current class name of the texture useful for serialization or dynamic coding.
  100983. * @returns "PBRClearCoatConfiguration"
  100984. */
  100985. getClassName(): string;
  100986. /**
  100987. * Add fallbacks to the effect fallbacks list.
  100988. * @param defines defines the Base texture to use.
  100989. * @param fallbacks defines the current fallback list.
  100990. * @param currentRank defines the current fallback rank.
  100991. * @returns the new fallback rank.
  100992. */
  100993. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  100994. /**
  100995. * Add the required uniforms to the current list.
  100996. * @param uniforms defines the current uniform list.
  100997. */
  100998. static AddUniforms(uniforms: string[]): void;
  100999. /**
  101000. * Add the required samplers to the current list.
  101001. * @param samplers defines the current sampler list.
  101002. */
  101003. static AddSamplers(samplers: string[]): void;
  101004. /**
  101005. * Add the required uniforms to the current buffer.
  101006. * @param uniformBuffer defines the current uniform buffer.
  101007. */
  101008. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101009. /**
  101010. * Makes a duplicate of the current configuration into another one.
  101011. * @param clearCoatConfiguration define the config where to copy the info
  101012. */
  101013. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  101014. /**
  101015. * Serializes this clear coat configuration.
  101016. * @returns - An object with the serialized config.
  101017. */
  101018. serialize(): any;
  101019. /**
  101020. * Parses a anisotropy Configuration from a serialized object.
  101021. * @param source - Serialized object.
  101022. * @param scene Defines the scene we are parsing for
  101023. * @param rootUrl Defines the rootUrl to load from
  101024. */
  101025. parse(source: any, scene: Scene, rootUrl: string): void;
  101026. }
  101027. }
  101028. declare module BABYLON {
  101029. /**
  101030. * @hidden
  101031. */
  101032. export interface IMaterialAnisotropicDefines {
  101033. ANISOTROPIC: boolean;
  101034. ANISOTROPIC_TEXTURE: boolean;
  101035. ANISOTROPIC_TEXTUREDIRECTUV: number;
  101036. MAINUV1: boolean;
  101037. _areTexturesDirty: boolean;
  101038. _needUVs: boolean;
  101039. }
  101040. /**
  101041. * Define the code related to the anisotropic parameters of the pbr material.
  101042. */
  101043. export class PBRAnisotropicConfiguration {
  101044. private _isEnabled;
  101045. /**
  101046. * Defines if the anisotropy is enabled in the material.
  101047. */
  101048. isEnabled: boolean;
  101049. /**
  101050. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  101051. */
  101052. intensity: number;
  101053. /**
  101054. * Defines if the effect is along the tangents, bitangents or in between.
  101055. * By default, the effect is "strectching" the highlights along the tangents.
  101056. */
  101057. direction: Vector2;
  101058. private _texture;
  101059. /**
  101060. * Stores the anisotropy values in a texture.
  101061. * rg is direction (like normal from -1 to 1)
  101062. * b is a intensity
  101063. */
  101064. texture: Nullable<BaseTexture>;
  101065. /** @hidden */
  101066. private _internalMarkAllSubMeshesAsTexturesDirty;
  101067. /** @hidden */
  101068. _markAllSubMeshesAsTexturesDirty(): void;
  101069. /**
  101070. * Instantiate a new istance of anisotropy configuration.
  101071. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101072. */
  101073. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101074. /**
  101075. * Specifies that the submesh is ready to be used.
  101076. * @param defines the list of "defines" to update.
  101077. * @param scene defines the scene the material belongs to.
  101078. * @returns - boolean indicating that the submesh is ready or not.
  101079. */
  101080. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  101081. /**
  101082. * Checks to see if a texture is used in the material.
  101083. * @param defines the list of "defines" to update.
  101084. * @param mesh the mesh we are preparing the defines for.
  101085. * @param scene defines the scene the material belongs to.
  101086. */
  101087. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  101088. /**
  101089. * Binds the material data.
  101090. * @param uniformBuffer defines the Uniform buffer to fill in.
  101091. * @param scene defines the scene the material belongs to.
  101092. * @param isFrozen defines wether the material is frozen or not.
  101093. */
  101094. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101095. /**
  101096. * Checks to see if a texture is used in the material.
  101097. * @param texture - Base texture to use.
  101098. * @returns - Boolean specifying if a texture is used in the material.
  101099. */
  101100. hasTexture(texture: BaseTexture): boolean;
  101101. /**
  101102. * Returns an array of the actively used textures.
  101103. * @param activeTextures Array of BaseTextures
  101104. */
  101105. getActiveTextures(activeTextures: BaseTexture[]): void;
  101106. /**
  101107. * Returns the animatable textures.
  101108. * @param animatables Array of animatable textures.
  101109. */
  101110. getAnimatables(animatables: IAnimatable[]): void;
  101111. /**
  101112. * Disposes the resources of the material.
  101113. * @param forceDisposeTextures - Forces the disposal of all textures.
  101114. */
  101115. dispose(forceDisposeTextures?: boolean): void;
  101116. /**
  101117. * Get the current class name of the texture useful for serialization or dynamic coding.
  101118. * @returns "PBRAnisotropicConfiguration"
  101119. */
  101120. getClassName(): string;
  101121. /**
  101122. * Add fallbacks to the effect fallbacks list.
  101123. * @param defines defines the Base texture to use.
  101124. * @param fallbacks defines the current fallback list.
  101125. * @param currentRank defines the current fallback rank.
  101126. * @returns the new fallback rank.
  101127. */
  101128. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101129. /**
  101130. * Add the required uniforms to the current list.
  101131. * @param uniforms defines the current uniform list.
  101132. */
  101133. static AddUniforms(uniforms: string[]): void;
  101134. /**
  101135. * Add the required uniforms to the current buffer.
  101136. * @param uniformBuffer defines the current uniform buffer.
  101137. */
  101138. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101139. /**
  101140. * Add the required samplers to the current list.
  101141. * @param samplers defines the current sampler list.
  101142. */
  101143. static AddSamplers(samplers: string[]): void;
  101144. /**
  101145. * Makes a duplicate of the current configuration into another one.
  101146. * @param anisotropicConfiguration define the config where to copy the info
  101147. */
  101148. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  101149. /**
  101150. * Serializes this anisotropy configuration.
  101151. * @returns - An object with the serialized config.
  101152. */
  101153. serialize(): any;
  101154. /**
  101155. * Parses a anisotropy Configuration from a serialized object.
  101156. * @param source - Serialized object.
  101157. * @param scene Defines the scene we are parsing for
  101158. * @param rootUrl Defines the rootUrl to load from
  101159. */
  101160. parse(source: any, scene: Scene, rootUrl: string): void;
  101161. }
  101162. }
  101163. declare module BABYLON {
  101164. /**
  101165. * @hidden
  101166. */
  101167. export interface IMaterialBRDFDefines {
  101168. BRDF_V_HEIGHT_CORRELATED: boolean;
  101169. MS_BRDF_ENERGY_CONSERVATION: boolean;
  101170. SPHERICAL_HARMONICS: boolean;
  101171. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  101172. /** @hidden */
  101173. _areMiscDirty: boolean;
  101174. }
  101175. /**
  101176. * Define the code related to the BRDF parameters of the pbr material.
  101177. */
  101178. export class PBRBRDFConfiguration {
  101179. /**
  101180. * Default value used for the energy conservation.
  101181. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  101182. */
  101183. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  101184. /**
  101185. * Default value used for the Smith Visibility Height Correlated mode.
  101186. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  101187. */
  101188. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  101189. /**
  101190. * Default value used for the IBL diffuse part.
  101191. * This can help switching back to the polynomials mode globally which is a tiny bit
  101192. * less GPU intensive at the drawback of a lower quality.
  101193. */
  101194. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  101195. /**
  101196. * Default value used for activating energy conservation for the specular workflow.
  101197. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  101198. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  101199. */
  101200. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  101201. private _useEnergyConservation;
  101202. /**
  101203. * Defines if the material uses energy conservation.
  101204. */
  101205. useEnergyConservation: boolean;
  101206. private _useSmithVisibilityHeightCorrelated;
  101207. /**
  101208. * LEGACY Mode set to false
  101209. * Defines if the material uses height smith correlated visibility term.
  101210. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  101211. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101212. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  101213. * Not relying on height correlated will also disable energy conservation.
  101214. */
  101215. useSmithVisibilityHeightCorrelated: boolean;
  101216. private _useSphericalHarmonics;
  101217. /**
  101218. * LEGACY Mode set to false
  101219. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  101220. * diffuse part of the IBL.
  101221. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  101222. * to the ground truth.
  101223. */
  101224. useSphericalHarmonics: boolean;
  101225. private _useSpecularGlossinessInputEnergyConservation;
  101226. /**
  101227. * Defines if the material uses energy conservation, when the specular workflow is active.
  101228. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  101229. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  101230. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  101231. */
  101232. useSpecularGlossinessInputEnergyConservation: boolean;
  101233. /** @hidden */
  101234. private _internalMarkAllSubMeshesAsMiscDirty;
  101235. /** @hidden */
  101236. _markAllSubMeshesAsMiscDirty(): void;
  101237. /**
  101238. * Instantiate a new istance of clear coat configuration.
  101239. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  101240. */
  101241. constructor(markAllSubMeshesAsMiscDirty: () => void);
  101242. /**
  101243. * Checks to see if a texture is used in the material.
  101244. * @param defines the list of "defines" to update.
  101245. */
  101246. prepareDefines(defines: IMaterialBRDFDefines): void;
  101247. /**
  101248. * Get the current class name of the texture useful for serialization or dynamic coding.
  101249. * @returns "PBRClearCoatConfiguration"
  101250. */
  101251. getClassName(): string;
  101252. /**
  101253. * Makes a duplicate of the current configuration into another one.
  101254. * @param brdfConfiguration define the config where to copy the info
  101255. */
  101256. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  101257. /**
  101258. * Serializes this BRDF configuration.
  101259. * @returns - An object with the serialized config.
  101260. */
  101261. serialize(): any;
  101262. /**
  101263. * Parses a anisotropy Configuration from a serialized object.
  101264. * @param source - Serialized object.
  101265. * @param scene Defines the scene we are parsing for
  101266. * @param rootUrl Defines the rootUrl to load from
  101267. */
  101268. parse(source: any, scene: Scene, rootUrl: string): void;
  101269. }
  101270. }
  101271. declare module BABYLON {
  101272. /**
  101273. * @hidden
  101274. */
  101275. export interface IMaterialSheenDefines {
  101276. SHEEN: boolean;
  101277. SHEEN_TEXTURE: boolean;
  101278. SHEEN_TEXTURE_ROUGHNESS: boolean;
  101279. SHEEN_TEXTUREDIRECTUV: number;
  101280. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  101281. SHEEN_LINKWITHALBEDO: boolean;
  101282. SHEEN_ROUGHNESS: boolean;
  101283. SHEEN_ALBEDOSCALING: boolean;
  101284. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  101285. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  101286. /** @hidden */
  101287. _areTexturesDirty: boolean;
  101288. }
  101289. /**
  101290. * Define the code related to the Sheen parameters of the pbr material.
  101291. */
  101292. export class PBRSheenConfiguration {
  101293. private _isEnabled;
  101294. /**
  101295. * Defines if the material uses sheen.
  101296. */
  101297. isEnabled: boolean;
  101298. private _linkSheenWithAlbedo;
  101299. /**
  101300. * Defines if the sheen is linked to the sheen color.
  101301. */
  101302. linkSheenWithAlbedo: boolean;
  101303. /**
  101304. * Defines the sheen intensity.
  101305. */
  101306. intensity: number;
  101307. /**
  101308. * Defines the sheen color.
  101309. */
  101310. color: Color3;
  101311. private _texture;
  101312. /**
  101313. * Stores the sheen tint values in a texture.
  101314. * rgb is tint
  101315. * 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)
  101316. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  101317. */
  101318. texture: Nullable<BaseTexture>;
  101319. private _useRoughnessFromMainTexture;
  101320. /**
  101321. * Indicates that the alpha channel of the texture property will be used for roughness.
  101322. * Has no effect if the roughness (and texture!) property is not defined
  101323. */
  101324. useRoughnessFromMainTexture: boolean;
  101325. private _roughness;
  101326. /**
  101327. * Defines the sheen roughness.
  101328. * It is not taken into account if linkSheenWithAlbedo is true.
  101329. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  101330. */
  101331. roughness: Nullable<number>;
  101332. private _textureRoughness;
  101333. /**
  101334. * Stores the sheen roughness in a texture.
  101335. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  101336. */
  101337. textureRoughness: Nullable<BaseTexture>;
  101338. private _albedoScaling;
  101339. /**
  101340. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  101341. * It allows the strength of the sheen effect to not depend on the base color of the material,
  101342. * making it easier to setup and tweak the effect
  101343. */
  101344. albedoScaling: boolean;
  101345. /** @hidden */
  101346. private _internalMarkAllSubMeshesAsTexturesDirty;
  101347. /** @hidden */
  101348. _markAllSubMeshesAsTexturesDirty(): void;
  101349. /**
  101350. * Instantiate a new istance of clear coat configuration.
  101351. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101352. */
  101353. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101354. /**
  101355. * Specifies that the submesh is ready to be used.
  101356. * @param defines the list of "defines" to update.
  101357. * @param scene defines the scene the material belongs to.
  101358. * @returns - boolean indicating that the submesh is ready or not.
  101359. */
  101360. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  101361. /**
  101362. * Checks to see if a texture is used in the material.
  101363. * @param defines the list of "defines" to update.
  101364. * @param scene defines the scene the material belongs to.
  101365. */
  101366. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  101367. /**
  101368. * Binds the material data.
  101369. * @param uniformBuffer defines the Uniform buffer to fill in.
  101370. * @param scene defines the scene the material belongs to.
  101371. * @param isFrozen defines wether the material is frozen or not.
  101372. * @param subMesh the submesh to bind data for
  101373. */
  101374. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  101375. /**
  101376. * Checks to see if a texture is used in the material.
  101377. * @param texture - Base texture to use.
  101378. * @returns - Boolean specifying if a texture is used in the material.
  101379. */
  101380. hasTexture(texture: BaseTexture): boolean;
  101381. /**
  101382. * Returns an array of the actively used textures.
  101383. * @param activeTextures Array of BaseTextures
  101384. */
  101385. getActiveTextures(activeTextures: BaseTexture[]): void;
  101386. /**
  101387. * Returns the animatable textures.
  101388. * @param animatables Array of animatable textures.
  101389. */
  101390. getAnimatables(animatables: IAnimatable[]): void;
  101391. /**
  101392. * Disposes the resources of the material.
  101393. * @param forceDisposeTextures - Forces the disposal of all textures.
  101394. */
  101395. dispose(forceDisposeTextures?: boolean): void;
  101396. /**
  101397. * Get the current class name of the texture useful for serialization or dynamic coding.
  101398. * @returns "PBRSheenConfiguration"
  101399. */
  101400. getClassName(): string;
  101401. /**
  101402. * Add fallbacks to the effect fallbacks list.
  101403. * @param defines defines the Base texture to use.
  101404. * @param fallbacks defines the current fallback list.
  101405. * @param currentRank defines the current fallback rank.
  101406. * @returns the new fallback rank.
  101407. */
  101408. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101409. /**
  101410. * Add the required uniforms to the current list.
  101411. * @param uniforms defines the current uniform list.
  101412. */
  101413. static AddUniforms(uniforms: string[]): void;
  101414. /**
  101415. * Add the required uniforms to the current buffer.
  101416. * @param uniformBuffer defines the current uniform buffer.
  101417. */
  101418. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101419. /**
  101420. * Add the required samplers to the current list.
  101421. * @param samplers defines the current sampler list.
  101422. */
  101423. static AddSamplers(samplers: string[]): void;
  101424. /**
  101425. * Makes a duplicate of the current configuration into another one.
  101426. * @param sheenConfiguration define the config where to copy the info
  101427. */
  101428. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  101429. /**
  101430. * Serializes this BRDF configuration.
  101431. * @returns - An object with the serialized config.
  101432. */
  101433. serialize(): any;
  101434. /**
  101435. * Parses a anisotropy Configuration from a serialized object.
  101436. * @param source - Serialized object.
  101437. * @param scene Defines the scene we are parsing for
  101438. * @param rootUrl Defines the rootUrl to load from
  101439. */
  101440. parse(source: any, scene: Scene, rootUrl: string): void;
  101441. }
  101442. }
  101443. declare module BABYLON {
  101444. /**
  101445. * @hidden
  101446. */
  101447. export interface IMaterialSubSurfaceDefines {
  101448. SUBSURFACE: boolean;
  101449. SS_REFRACTION: boolean;
  101450. SS_TRANSLUCENCY: boolean;
  101451. SS_SCATTERING: boolean;
  101452. SS_THICKNESSANDMASK_TEXTURE: boolean;
  101453. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  101454. SS_REFRACTIONMAP_3D: boolean;
  101455. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  101456. SS_LODINREFRACTIONALPHA: boolean;
  101457. SS_GAMMAREFRACTION: boolean;
  101458. SS_RGBDREFRACTION: boolean;
  101459. SS_LINEARSPECULARREFRACTION: boolean;
  101460. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  101461. SS_ALBEDOFORREFRACTIONTINT: boolean;
  101462. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  101463. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  101464. /** @hidden */
  101465. _areTexturesDirty: boolean;
  101466. }
  101467. /**
  101468. * Define the code related to the sub surface parameters of the pbr material.
  101469. */
  101470. export class PBRSubSurfaceConfiguration {
  101471. private _isRefractionEnabled;
  101472. /**
  101473. * Defines if the refraction is enabled in the material.
  101474. */
  101475. isRefractionEnabled: boolean;
  101476. private _isTranslucencyEnabled;
  101477. /**
  101478. * Defines if the translucency is enabled in the material.
  101479. */
  101480. isTranslucencyEnabled: boolean;
  101481. private _isScatteringEnabled;
  101482. /**
  101483. * Defines if the sub surface scattering is enabled in the material.
  101484. */
  101485. isScatteringEnabled: boolean;
  101486. private _scatteringDiffusionProfileIndex;
  101487. /**
  101488. * Diffusion profile for subsurface scattering.
  101489. * Useful for better scattering in the skins or foliages.
  101490. */
  101491. get scatteringDiffusionProfile(): Nullable<Color3>;
  101492. set scatteringDiffusionProfile(c: Nullable<Color3>);
  101493. /**
  101494. * Defines the refraction intensity of the material.
  101495. * The refraction when enabled replaces the Diffuse part of the material.
  101496. * The intensity helps transitionning between diffuse and refraction.
  101497. */
  101498. refractionIntensity: number;
  101499. /**
  101500. * Defines the translucency intensity of the material.
  101501. * When translucency has been enabled, this defines how much of the "translucency"
  101502. * is addded to the diffuse part of the material.
  101503. */
  101504. translucencyIntensity: number;
  101505. /**
  101506. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  101507. */
  101508. useAlbedoToTintRefraction: boolean;
  101509. private _thicknessTexture;
  101510. /**
  101511. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  101512. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  101513. * 0 would mean minimumThickness
  101514. * 1 would mean maximumThickness
  101515. * The other channels might be use as a mask to vary the different effects intensity.
  101516. */
  101517. thicknessTexture: Nullable<BaseTexture>;
  101518. private _refractionTexture;
  101519. /**
  101520. * Defines the texture to use for refraction.
  101521. */
  101522. refractionTexture: Nullable<BaseTexture>;
  101523. private _indexOfRefraction;
  101524. /**
  101525. * Index of refraction of the material base layer.
  101526. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  101527. *
  101528. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  101529. *
  101530. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  101531. */
  101532. indexOfRefraction: number;
  101533. private _volumeIndexOfRefraction;
  101534. /**
  101535. * Index of refraction of the material's volume.
  101536. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  101537. *
  101538. * This ONLY impacts refraction. If not provided or given a non-valid value,
  101539. * the volume will use the same IOR as the surface.
  101540. */
  101541. get volumeIndexOfRefraction(): number;
  101542. set volumeIndexOfRefraction(value: number);
  101543. private _invertRefractionY;
  101544. /**
  101545. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101546. */
  101547. invertRefractionY: boolean;
  101548. private _linkRefractionWithTransparency;
  101549. /**
  101550. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101551. * Materials half opaque for instance using refraction could benefit from this control.
  101552. */
  101553. linkRefractionWithTransparency: boolean;
  101554. /**
  101555. * Defines the minimum thickness stored in the thickness map.
  101556. * If no thickness map is defined, this value will be used to simulate thickness.
  101557. */
  101558. minimumThickness: number;
  101559. /**
  101560. * Defines the maximum thickness stored in the thickness map.
  101561. */
  101562. maximumThickness: number;
  101563. /**
  101564. * Defines the volume tint of the material.
  101565. * This is used for both translucency and scattering.
  101566. */
  101567. tintColor: Color3;
  101568. /**
  101569. * Defines the distance at which the tint color should be found in the media.
  101570. * This is used for refraction only.
  101571. */
  101572. tintColorAtDistance: number;
  101573. /**
  101574. * Defines how far each channel transmit through the media.
  101575. * It is defined as a color to simplify it selection.
  101576. */
  101577. diffusionDistance: Color3;
  101578. private _useMaskFromThicknessTexture;
  101579. /**
  101580. * Stores the intensity of the different subsurface effects in the thickness texture.
  101581. * * the green channel is the translucency intensity.
  101582. * * the blue channel is the scattering intensity.
  101583. * * the alpha channel is the refraction intensity.
  101584. */
  101585. useMaskFromThicknessTexture: boolean;
  101586. private _scene;
  101587. private _useMaskFromThicknessTextureGltf;
  101588. /**
  101589. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  101590. * matches the channel-packing that is used by glTF.
  101591. * * the red channel is the transmission/translucency intensity.
  101592. * * the green channel is the thickness.
  101593. */
  101594. useMaskFromThicknessTextureGltf: boolean;
  101595. /** @hidden */
  101596. private _internalMarkAllSubMeshesAsTexturesDirty;
  101597. private _internalMarkScenePrePassDirty;
  101598. /** @hidden */
  101599. _markAllSubMeshesAsTexturesDirty(): void;
  101600. /** @hidden */
  101601. _markScenePrePassDirty(): void;
  101602. /**
  101603. * Instantiate a new istance of sub surface configuration.
  101604. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101605. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  101606. * @param scene The scene
  101607. */
  101608. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  101609. /**
  101610. * Gets wehter the submesh is ready to be used or not.
  101611. * @param defines the list of "defines" to update.
  101612. * @param scene defines the scene the material belongs to.
  101613. * @returns - boolean indicating that the submesh is ready or not.
  101614. */
  101615. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  101616. /**
  101617. * Checks to see if a texture is used in the material.
  101618. * @param defines the list of "defines" to update.
  101619. * @param scene defines the scene to the material belongs to.
  101620. */
  101621. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  101622. /**
  101623. * Binds the material data.
  101624. * @param uniformBuffer defines the Uniform buffer to fill in.
  101625. * @param scene defines the scene the material belongs to.
  101626. * @param engine defines the engine the material belongs to.
  101627. * @param isFrozen defines whether the material is frozen or not.
  101628. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  101629. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  101630. */
  101631. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  101632. /**
  101633. * Unbinds the material from the mesh.
  101634. * @param activeEffect defines the effect that should be unbound from.
  101635. * @returns true if unbound, otherwise false
  101636. */
  101637. unbind(activeEffect: Effect): boolean;
  101638. /**
  101639. * Returns the texture used for refraction or null if none is used.
  101640. * @param scene defines the scene the material belongs to.
  101641. * @returns - Refraction texture if present. If no refraction texture and refraction
  101642. * is linked with transparency, returns environment texture. Otherwise, returns null.
  101643. */
  101644. private _getRefractionTexture;
  101645. /**
  101646. * Returns true if alpha blending should be disabled.
  101647. */
  101648. get disableAlphaBlending(): boolean;
  101649. /**
  101650. * Fills the list of render target textures.
  101651. * @param renderTargets the list of render targets to update
  101652. */
  101653. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  101654. /**
  101655. * Checks to see if a texture is used in the material.
  101656. * @param texture - Base texture to use.
  101657. * @returns - Boolean specifying if a texture is used in the material.
  101658. */
  101659. hasTexture(texture: BaseTexture): boolean;
  101660. /**
  101661. * Gets a boolean indicating that current material needs to register RTT
  101662. * @returns true if this uses a render target otherwise false.
  101663. */
  101664. hasRenderTargetTextures(): boolean;
  101665. /**
  101666. * Returns an array of the actively used textures.
  101667. * @param activeTextures Array of BaseTextures
  101668. */
  101669. getActiveTextures(activeTextures: BaseTexture[]): void;
  101670. /**
  101671. * Returns the animatable textures.
  101672. * @param animatables Array of animatable textures.
  101673. */
  101674. getAnimatables(animatables: IAnimatable[]): void;
  101675. /**
  101676. * Disposes the resources of the material.
  101677. * @param forceDisposeTextures - Forces the disposal of all textures.
  101678. */
  101679. dispose(forceDisposeTextures?: boolean): void;
  101680. /**
  101681. * Get the current class name of the texture useful for serialization or dynamic coding.
  101682. * @returns "PBRSubSurfaceConfiguration"
  101683. */
  101684. getClassName(): string;
  101685. /**
  101686. * Add fallbacks to the effect fallbacks list.
  101687. * @param defines defines the Base texture to use.
  101688. * @param fallbacks defines the current fallback list.
  101689. * @param currentRank defines the current fallback rank.
  101690. * @returns the new fallback rank.
  101691. */
  101692. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101693. /**
  101694. * Add the required uniforms to the current list.
  101695. * @param uniforms defines the current uniform list.
  101696. */
  101697. static AddUniforms(uniforms: string[]): void;
  101698. /**
  101699. * Add the required samplers to the current list.
  101700. * @param samplers defines the current sampler list.
  101701. */
  101702. static AddSamplers(samplers: string[]): void;
  101703. /**
  101704. * Add the required uniforms to the current buffer.
  101705. * @param uniformBuffer defines the current uniform buffer.
  101706. */
  101707. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101708. /**
  101709. * Makes a duplicate of the current configuration into another one.
  101710. * @param configuration define the config where to copy the info
  101711. */
  101712. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  101713. /**
  101714. * Serializes this Sub Surface configuration.
  101715. * @returns - An object with the serialized config.
  101716. */
  101717. serialize(): any;
  101718. /**
  101719. * Parses a anisotropy Configuration from a serialized object.
  101720. * @param source - Serialized object.
  101721. * @param scene Defines the scene we are parsing for
  101722. * @param rootUrl Defines the rootUrl to load from
  101723. */
  101724. parse(source: any, scene: Scene, rootUrl: string): void;
  101725. }
  101726. }
  101727. declare module BABYLON {
  101728. /**
  101729. * Class representing spherical harmonics coefficients to the 3rd degree
  101730. */
  101731. export class SphericalHarmonics {
  101732. /**
  101733. * Defines whether or not the harmonics have been prescaled for rendering.
  101734. */
  101735. preScaled: boolean;
  101736. /**
  101737. * The l0,0 coefficients of the spherical harmonics
  101738. */
  101739. l00: Vector3;
  101740. /**
  101741. * The l1,-1 coefficients of the spherical harmonics
  101742. */
  101743. l1_1: Vector3;
  101744. /**
  101745. * The l1,0 coefficients of the spherical harmonics
  101746. */
  101747. l10: Vector3;
  101748. /**
  101749. * The l1,1 coefficients of the spherical harmonics
  101750. */
  101751. l11: Vector3;
  101752. /**
  101753. * The l2,-2 coefficients of the spherical harmonics
  101754. */
  101755. l2_2: Vector3;
  101756. /**
  101757. * The l2,-1 coefficients of the spherical harmonics
  101758. */
  101759. l2_1: Vector3;
  101760. /**
  101761. * The l2,0 coefficients of the spherical harmonics
  101762. */
  101763. l20: Vector3;
  101764. /**
  101765. * The l2,1 coefficients of the spherical harmonics
  101766. */
  101767. l21: Vector3;
  101768. /**
  101769. * The l2,2 coefficients of the spherical harmonics
  101770. */
  101771. l22: Vector3;
  101772. /**
  101773. * Adds a light to the spherical harmonics
  101774. * @param direction the direction of the light
  101775. * @param color the color of the light
  101776. * @param deltaSolidAngle the delta solid angle of the light
  101777. */
  101778. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  101779. /**
  101780. * Scales the spherical harmonics by the given amount
  101781. * @param scale the amount to scale
  101782. */
  101783. scaleInPlace(scale: number): void;
  101784. /**
  101785. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  101786. *
  101787. * ```
  101788. * E_lm = A_l * L_lm
  101789. * ```
  101790. *
  101791. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  101792. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  101793. * the scaling factors are given in equation 9.
  101794. */
  101795. convertIncidentRadianceToIrradiance(): void;
  101796. /**
  101797. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  101798. *
  101799. * ```
  101800. * L = (1/pi) * E * rho
  101801. * ```
  101802. *
  101803. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  101804. */
  101805. convertIrradianceToLambertianRadiance(): void;
  101806. /**
  101807. * Integrates the reconstruction coefficients directly in to the SH preventing further
  101808. * required operations at run time.
  101809. *
  101810. * This is simply done by scaling back the SH with Ylm constants parameter.
  101811. * The trigonometric part being applied by the shader at run time.
  101812. */
  101813. preScaleForRendering(): void;
  101814. /**
  101815. * Constructs a spherical harmonics from an array.
  101816. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  101817. * @returns the spherical harmonics
  101818. */
  101819. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  101820. /**
  101821. * Gets the spherical harmonics from polynomial
  101822. * @param polynomial the spherical polynomial
  101823. * @returns the spherical harmonics
  101824. */
  101825. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  101826. }
  101827. /**
  101828. * Class representing spherical polynomial coefficients to the 3rd degree
  101829. */
  101830. export class SphericalPolynomial {
  101831. private _harmonics;
  101832. /**
  101833. * The spherical harmonics used to create the polynomials.
  101834. */
  101835. get preScaledHarmonics(): SphericalHarmonics;
  101836. /**
  101837. * The x coefficients of the spherical polynomial
  101838. */
  101839. x: Vector3;
  101840. /**
  101841. * The y coefficients of the spherical polynomial
  101842. */
  101843. y: Vector3;
  101844. /**
  101845. * The z coefficients of the spherical polynomial
  101846. */
  101847. z: Vector3;
  101848. /**
  101849. * The xx coefficients of the spherical polynomial
  101850. */
  101851. xx: Vector3;
  101852. /**
  101853. * The yy coefficients of the spherical polynomial
  101854. */
  101855. yy: Vector3;
  101856. /**
  101857. * The zz coefficients of the spherical polynomial
  101858. */
  101859. zz: Vector3;
  101860. /**
  101861. * The xy coefficients of the spherical polynomial
  101862. */
  101863. xy: Vector3;
  101864. /**
  101865. * The yz coefficients of the spherical polynomial
  101866. */
  101867. yz: Vector3;
  101868. /**
  101869. * The zx coefficients of the spherical polynomial
  101870. */
  101871. zx: Vector3;
  101872. /**
  101873. * Adds an ambient color to the spherical polynomial
  101874. * @param color the color to add
  101875. */
  101876. addAmbient(color: Color3): void;
  101877. /**
  101878. * Scales the spherical polynomial by the given amount
  101879. * @param scale the amount to scale
  101880. */
  101881. scaleInPlace(scale: number): void;
  101882. /**
  101883. * Gets the spherical polynomial from harmonics
  101884. * @param harmonics the spherical harmonics
  101885. * @returns the spherical polynomial
  101886. */
  101887. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  101888. /**
  101889. * Constructs a spherical polynomial from an array.
  101890. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  101891. * @returns the spherical polynomial
  101892. */
  101893. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  101894. }
  101895. }
  101896. declare module BABYLON {
  101897. /**
  101898. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  101899. */
  101900. export interface CubeMapInfo {
  101901. /**
  101902. * The pixel array for the front face.
  101903. * This is stored in format, left to right, up to down format.
  101904. */
  101905. front: Nullable<ArrayBufferView>;
  101906. /**
  101907. * The pixel array for the back face.
  101908. * This is stored in format, left to right, up to down format.
  101909. */
  101910. back: Nullable<ArrayBufferView>;
  101911. /**
  101912. * The pixel array for the left face.
  101913. * This is stored in format, left to right, up to down format.
  101914. */
  101915. left: Nullable<ArrayBufferView>;
  101916. /**
  101917. * The pixel array for the right face.
  101918. * This is stored in format, left to right, up to down format.
  101919. */
  101920. right: Nullable<ArrayBufferView>;
  101921. /**
  101922. * The pixel array for the up face.
  101923. * This is stored in format, left to right, up to down format.
  101924. */
  101925. up: Nullable<ArrayBufferView>;
  101926. /**
  101927. * The pixel array for the down face.
  101928. * This is stored in format, left to right, up to down format.
  101929. */
  101930. down: Nullable<ArrayBufferView>;
  101931. /**
  101932. * The size of the cubemap stored.
  101933. *
  101934. * Each faces will be size * size pixels.
  101935. */
  101936. size: number;
  101937. /**
  101938. * The format of the texture.
  101939. *
  101940. * RGBA, RGB.
  101941. */
  101942. format: number;
  101943. /**
  101944. * The type of the texture data.
  101945. *
  101946. * UNSIGNED_INT, FLOAT.
  101947. */
  101948. type: number;
  101949. /**
  101950. * Specifies whether the texture is in gamma space.
  101951. */
  101952. gammaSpace: boolean;
  101953. }
  101954. /**
  101955. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  101956. */
  101957. export class PanoramaToCubeMapTools {
  101958. private static FACE_LEFT;
  101959. private static FACE_RIGHT;
  101960. private static FACE_FRONT;
  101961. private static FACE_BACK;
  101962. private static FACE_DOWN;
  101963. private static FACE_UP;
  101964. /**
  101965. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  101966. *
  101967. * @param float32Array The source data.
  101968. * @param inputWidth The width of the input panorama.
  101969. * @param inputHeight The height of the input panorama.
  101970. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  101971. * @return The cubemap data
  101972. */
  101973. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  101974. private static CreateCubemapTexture;
  101975. private static CalcProjectionSpherical;
  101976. }
  101977. }
  101978. declare module BABYLON {
  101979. /**
  101980. * Helper class dealing with the extraction of spherical polynomial dataArray
  101981. * from a cube map.
  101982. */
  101983. export class CubeMapToSphericalPolynomialTools {
  101984. private static FileFaces;
  101985. /**
  101986. * Converts a texture to the according Spherical Polynomial data.
  101987. * This extracts the first 3 orders only as they are the only one used in the lighting.
  101988. *
  101989. * @param texture The texture to extract the information from.
  101990. * @return The Spherical Polynomial data.
  101991. */
  101992. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  101993. /**
  101994. * Converts a cubemap to the according Spherical Polynomial data.
  101995. * This extracts the first 3 orders only as they are the only one used in the lighting.
  101996. *
  101997. * @param cubeInfo The Cube map to extract the information from.
  101998. * @return The Spherical Polynomial data.
  101999. */
  102000. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  102001. }
  102002. }
  102003. declare module BABYLON {
  102004. interface BaseTexture {
  102005. /**
  102006. * Get the polynomial representation of the texture data.
  102007. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  102008. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  102009. */
  102010. sphericalPolynomial: Nullable<SphericalPolynomial>;
  102011. }
  102012. }
  102013. declare module BABYLON {
  102014. /** @hidden */
  102015. export var pbrFragmentDeclaration: {
  102016. name: string;
  102017. shader: string;
  102018. };
  102019. }
  102020. declare module BABYLON {
  102021. /** @hidden */
  102022. export var pbrUboDeclaration: {
  102023. name: string;
  102024. shader: string;
  102025. };
  102026. }
  102027. declare module BABYLON {
  102028. /** @hidden */
  102029. export var pbrFragmentExtraDeclaration: {
  102030. name: string;
  102031. shader: string;
  102032. };
  102033. }
  102034. declare module BABYLON {
  102035. /** @hidden */
  102036. export var pbrFragmentSamplersDeclaration: {
  102037. name: string;
  102038. shader: string;
  102039. };
  102040. }
  102041. declare module BABYLON {
  102042. /** @hidden */
  102043. export var subSurfaceScatteringFunctions: {
  102044. name: string;
  102045. shader: string;
  102046. };
  102047. }
  102048. declare module BABYLON {
  102049. /** @hidden */
  102050. export var importanceSampling: {
  102051. name: string;
  102052. shader: string;
  102053. };
  102054. }
  102055. declare module BABYLON {
  102056. /** @hidden */
  102057. export var pbrHelperFunctions: {
  102058. name: string;
  102059. shader: string;
  102060. };
  102061. }
  102062. declare module BABYLON {
  102063. /** @hidden */
  102064. export var harmonicsFunctions: {
  102065. name: string;
  102066. shader: string;
  102067. };
  102068. }
  102069. declare module BABYLON {
  102070. /** @hidden */
  102071. export var pbrDirectLightingSetupFunctions: {
  102072. name: string;
  102073. shader: string;
  102074. };
  102075. }
  102076. declare module BABYLON {
  102077. /** @hidden */
  102078. export var pbrDirectLightingFalloffFunctions: {
  102079. name: string;
  102080. shader: string;
  102081. };
  102082. }
  102083. declare module BABYLON {
  102084. /** @hidden */
  102085. export var pbrBRDFFunctions: {
  102086. name: string;
  102087. shader: string;
  102088. };
  102089. }
  102090. declare module BABYLON {
  102091. /** @hidden */
  102092. export var hdrFilteringFunctions: {
  102093. name: string;
  102094. shader: string;
  102095. };
  102096. }
  102097. declare module BABYLON {
  102098. /** @hidden */
  102099. export var pbrDirectLightingFunctions: {
  102100. name: string;
  102101. shader: string;
  102102. };
  102103. }
  102104. declare module BABYLON {
  102105. /** @hidden */
  102106. export var pbrIBLFunctions: {
  102107. name: string;
  102108. shader: string;
  102109. };
  102110. }
  102111. declare module BABYLON {
  102112. /** @hidden */
  102113. export var pbrBlockAlbedoOpacity: {
  102114. name: string;
  102115. shader: string;
  102116. };
  102117. }
  102118. declare module BABYLON {
  102119. /** @hidden */
  102120. export var pbrBlockReflectivity: {
  102121. name: string;
  102122. shader: string;
  102123. };
  102124. }
  102125. declare module BABYLON {
  102126. /** @hidden */
  102127. export var pbrBlockAmbientOcclusion: {
  102128. name: string;
  102129. shader: string;
  102130. };
  102131. }
  102132. declare module BABYLON {
  102133. /** @hidden */
  102134. export var pbrBlockAlphaFresnel: {
  102135. name: string;
  102136. shader: string;
  102137. };
  102138. }
  102139. declare module BABYLON {
  102140. /** @hidden */
  102141. export var pbrBlockAnisotropic: {
  102142. name: string;
  102143. shader: string;
  102144. };
  102145. }
  102146. declare module BABYLON {
  102147. /** @hidden */
  102148. export var pbrBlockReflection: {
  102149. name: string;
  102150. shader: string;
  102151. };
  102152. }
  102153. declare module BABYLON {
  102154. /** @hidden */
  102155. export var pbrBlockSheen: {
  102156. name: string;
  102157. shader: string;
  102158. };
  102159. }
  102160. declare module BABYLON {
  102161. /** @hidden */
  102162. export var pbrBlockClearcoat: {
  102163. name: string;
  102164. shader: string;
  102165. };
  102166. }
  102167. declare module BABYLON {
  102168. /** @hidden */
  102169. export var pbrBlockSubSurface: {
  102170. name: string;
  102171. shader: string;
  102172. };
  102173. }
  102174. declare module BABYLON {
  102175. /** @hidden */
  102176. export var pbrBlockNormalGeometric: {
  102177. name: string;
  102178. shader: string;
  102179. };
  102180. }
  102181. declare module BABYLON {
  102182. /** @hidden */
  102183. export var pbrBlockNormalFinal: {
  102184. name: string;
  102185. shader: string;
  102186. };
  102187. }
  102188. declare module BABYLON {
  102189. /** @hidden */
  102190. export var pbrBlockLightmapInit: {
  102191. name: string;
  102192. shader: string;
  102193. };
  102194. }
  102195. declare module BABYLON {
  102196. /** @hidden */
  102197. export var pbrBlockGeometryInfo: {
  102198. name: string;
  102199. shader: string;
  102200. };
  102201. }
  102202. declare module BABYLON {
  102203. /** @hidden */
  102204. export var pbrBlockReflectance0: {
  102205. name: string;
  102206. shader: string;
  102207. };
  102208. }
  102209. declare module BABYLON {
  102210. /** @hidden */
  102211. export var pbrBlockReflectance: {
  102212. name: string;
  102213. shader: string;
  102214. };
  102215. }
  102216. declare module BABYLON {
  102217. /** @hidden */
  102218. export var pbrBlockDirectLighting: {
  102219. name: string;
  102220. shader: string;
  102221. };
  102222. }
  102223. declare module BABYLON {
  102224. /** @hidden */
  102225. export var pbrBlockFinalLitComponents: {
  102226. name: string;
  102227. shader: string;
  102228. };
  102229. }
  102230. declare module BABYLON {
  102231. /** @hidden */
  102232. export var pbrBlockFinalUnlitComponents: {
  102233. name: string;
  102234. shader: string;
  102235. };
  102236. }
  102237. declare module BABYLON {
  102238. /** @hidden */
  102239. export var pbrBlockFinalColorComposition: {
  102240. name: string;
  102241. shader: string;
  102242. };
  102243. }
  102244. declare module BABYLON {
  102245. /** @hidden */
  102246. export var pbrBlockImageProcessing: {
  102247. name: string;
  102248. shader: string;
  102249. };
  102250. }
  102251. declare module BABYLON {
  102252. /** @hidden */
  102253. export var pbrDebug: {
  102254. name: string;
  102255. shader: string;
  102256. };
  102257. }
  102258. declare module BABYLON {
  102259. /** @hidden */
  102260. export var pbrPixelShader: {
  102261. name: string;
  102262. shader: string;
  102263. };
  102264. }
  102265. declare module BABYLON {
  102266. /** @hidden */
  102267. export var pbrVertexDeclaration: {
  102268. name: string;
  102269. shader: string;
  102270. };
  102271. }
  102272. declare module BABYLON {
  102273. /** @hidden */
  102274. export var pbrVertexShader: {
  102275. name: string;
  102276. shader: string;
  102277. };
  102278. }
  102279. declare module BABYLON {
  102280. /**
  102281. * Manages the defines for the PBR Material.
  102282. * @hidden
  102283. */
  102284. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  102285. PBR: boolean;
  102286. NUM_SAMPLES: string;
  102287. REALTIME_FILTERING: boolean;
  102288. MAINUV1: boolean;
  102289. MAINUV2: boolean;
  102290. UV1: boolean;
  102291. UV2: boolean;
  102292. ALBEDO: boolean;
  102293. GAMMAALBEDO: boolean;
  102294. ALBEDODIRECTUV: number;
  102295. VERTEXCOLOR: boolean;
  102296. DETAIL: boolean;
  102297. DETAILDIRECTUV: number;
  102298. DETAIL_NORMALBLENDMETHOD: number;
  102299. AMBIENT: boolean;
  102300. AMBIENTDIRECTUV: number;
  102301. AMBIENTINGRAYSCALE: boolean;
  102302. OPACITY: boolean;
  102303. VERTEXALPHA: boolean;
  102304. OPACITYDIRECTUV: number;
  102305. OPACITYRGB: boolean;
  102306. ALPHATEST: boolean;
  102307. DEPTHPREPASS: boolean;
  102308. ALPHABLEND: boolean;
  102309. ALPHAFROMALBEDO: boolean;
  102310. ALPHATESTVALUE: string;
  102311. SPECULAROVERALPHA: boolean;
  102312. RADIANCEOVERALPHA: boolean;
  102313. ALPHAFRESNEL: boolean;
  102314. LINEARALPHAFRESNEL: boolean;
  102315. PREMULTIPLYALPHA: boolean;
  102316. EMISSIVE: boolean;
  102317. EMISSIVEDIRECTUV: number;
  102318. REFLECTIVITY: boolean;
  102319. REFLECTIVITYDIRECTUV: number;
  102320. SPECULARTERM: boolean;
  102321. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  102322. MICROSURFACEAUTOMATIC: boolean;
  102323. LODBASEDMICROSFURACE: boolean;
  102324. MICROSURFACEMAP: boolean;
  102325. MICROSURFACEMAPDIRECTUV: number;
  102326. METALLICWORKFLOW: boolean;
  102327. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  102328. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  102329. METALLNESSSTOREINMETALMAPBLUE: boolean;
  102330. AOSTOREINMETALMAPRED: boolean;
  102331. METALLIC_REFLECTANCE: boolean;
  102332. METALLIC_REFLECTANCEDIRECTUV: number;
  102333. ENVIRONMENTBRDF: boolean;
  102334. ENVIRONMENTBRDF_RGBD: boolean;
  102335. NORMAL: boolean;
  102336. TANGENT: boolean;
  102337. BUMP: boolean;
  102338. BUMPDIRECTUV: number;
  102339. OBJECTSPACE_NORMALMAP: boolean;
  102340. PARALLAX: boolean;
  102341. PARALLAXOCCLUSION: boolean;
  102342. NORMALXYSCALE: boolean;
  102343. LIGHTMAP: boolean;
  102344. LIGHTMAPDIRECTUV: number;
  102345. USELIGHTMAPASSHADOWMAP: boolean;
  102346. GAMMALIGHTMAP: boolean;
  102347. RGBDLIGHTMAP: boolean;
  102348. REFLECTION: boolean;
  102349. REFLECTIONMAP_3D: boolean;
  102350. REFLECTIONMAP_SPHERICAL: boolean;
  102351. REFLECTIONMAP_PLANAR: boolean;
  102352. REFLECTIONMAP_CUBIC: boolean;
  102353. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102354. REFLECTIONMAP_PROJECTION: boolean;
  102355. REFLECTIONMAP_SKYBOX: boolean;
  102356. REFLECTIONMAP_EXPLICIT: boolean;
  102357. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102358. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102359. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102360. INVERTCUBICMAP: boolean;
  102361. USESPHERICALFROMREFLECTIONMAP: boolean;
  102362. USEIRRADIANCEMAP: boolean;
  102363. SPHERICAL_HARMONICS: boolean;
  102364. USESPHERICALINVERTEX: boolean;
  102365. REFLECTIONMAP_OPPOSITEZ: boolean;
  102366. LODINREFLECTIONALPHA: boolean;
  102367. GAMMAREFLECTION: boolean;
  102368. RGBDREFLECTION: boolean;
  102369. LINEARSPECULARREFLECTION: boolean;
  102370. RADIANCEOCCLUSION: boolean;
  102371. HORIZONOCCLUSION: boolean;
  102372. INSTANCES: boolean;
  102373. THIN_INSTANCES: boolean;
  102374. PREPASS: boolean;
  102375. PREPASS_IRRADIANCE: boolean;
  102376. PREPASS_IRRADIANCE_INDEX: number;
  102377. PREPASS_ALBEDO: boolean;
  102378. PREPASS_ALBEDO_INDEX: number;
  102379. PREPASS_DEPTHNORMAL: boolean;
  102380. PREPASS_DEPTHNORMAL_INDEX: number;
  102381. PREPASS_POSITION: boolean;
  102382. PREPASS_POSITION_INDEX: number;
  102383. PREPASS_VELOCITY: boolean;
  102384. PREPASS_VELOCITY_INDEX: number;
  102385. PREPASS_REFLECTIVITY: boolean;
  102386. PREPASS_REFLECTIVITY_INDEX: number;
  102387. SCENE_MRT_COUNT: number;
  102388. NUM_BONE_INFLUENCERS: number;
  102389. BonesPerMesh: number;
  102390. BONETEXTURE: boolean;
  102391. BONES_VELOCITY_ENABLED: boolean;
  102392. NONUNIFORMSCALING: boolean;
  102393. MORPHTARGETS: boolean;
  102394. MORPHTARGETS_NORMAL: boolean;
  102395. MORPHTARGETS_TANGENT: boolean;
  102396. MORPHTARGETS_UV: boolean;
  102397. NUM_MORPH_INFLUENCERS: number;
  102398. IMAGEPROCESSING: boolean;
  102399. VIGNETTE: boolean;
  102400. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102401. VIGNETTEBLENDMODEOPAQUE: boolean;
  102402. TONEMAPPING: boolean;
  102403. TONEMAPPING_ACES: boolean;
  102404. CONTRAST: boolean;
  102405. COLORCURVES: boolean;
  102406. COLORGRADING: boolean;
  102407. COLORGRADING3D: boolean;
  102408. SAMPLER3DGREENDEPTH: boolean;
  102409. SAMPLER3DBGRMAP: boolean;
  102410. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102411. EXPOSURE: boolean;
  102412. MULTIVIEW: boolean;
  102413. USEPHYSICALLIGHTFALLOFF: boolean;
  102414. USEGLTFLIGHTFALLOFF: boolean;
  102415. TWOSIDEDLIGHTING: boolean;
  102416. SHADOWFLOAT: boolean;
  102417. CLIPPLANE: boolean;
  102418. CLIPPLANE2: boolean;
  102419. CLIPPLANE3: boolean;
  102420. CLIPPLANE4: boolean;
  102421. CLIPPLANE5: boolean;
  102422. CLIPPLANE6: boolean;
  102423. POINTSIZE: boolean;
  102424. FOG: boolean;
  102425. LOGARITHMICDEPTH: boolean;
  102426. FORCENORMALFORWARD: boolean;
  102427. SPECULARAA: boolean;
  102428. CLEARCOAT: boolean;
  102429. CLEARCOAT_DEFAULTIOR: boolean;
  102430. CLEARCOAT_TEXTURE: boolean;
  102431. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  102432. CLEARCOAT_TEXTUREDIRECTUV: number;
  102433. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  102434. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  102435. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  102436. CLEARCOAT_BUMP: boolean;
  102437. CLEARCOAT_BUMPDIRECTUV: number;
  102438. CLEARCOAT_REMAP_F0: boolean;
  102439. CLEARCOAT_TINT: boolean;
  102440. CLEARCOAT_TINT_TEXTURE: boolean;
  102441. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  102442. ANISOTROPIC: boolean;
  102443. ANISOTROPIC_TEXTURE: boolean;
  102444. ANISOTROPIC_TEXTUREDIRECTUV: number;
  102445. BRDF_V_HEIGHT_CORRELATED: boolean;
  102446. MS_BRDF_ENERGY_CONSERVATION: boolean;
  102447. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  102448. SHEEN: boolean;
  102449. SHEEN_TEXTURE: boolean;
  102450. SHEEN_TEXTURE_ROUGHNESS: boolean;
  102451. SHEEN_TEXTUREDIRECTUV: number;
  102452. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  102453. SHEEN_LINKWITHALBEDO: boolean;
  102454. SHEEN_ROUGHNESS: boolean;
  102455. SHEEN_ALBEDOSCALING: boolean;
  102456. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  102457. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  102458. SUBSURFACE: boolean;
  102459. SS_REFRACTION: boolean;
  102460. SS_TRANSLUCENCY: boolean;
  102461. SS_SCATTERING: boolean;
  102462. SS_THICKNESSANDMASK_TEXTURE: boolean;
  102463. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  102464. SS_REFRACTIONMAP_3D: boolean;
  102465. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  102466. SS_LODINREFRACTIONALPHA: boolean;
  102467. SS_GAMMAREFRACTION: boolean;
  102468. SS_RGBDREFRACTION: boolean;
  102469. SS_LINEARSPECULARREFRACTION: boolean;
  102470. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  102471. SS_ALBEDOFORREFRACTIONTINT: boolean;
  102472. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  102473. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  102474. UNLIT: boolean;
  102475. DEBUGMODE: number;
  102476. /**
  102477. * Initializes the PBR Material defines.
  102478. */
  102479. constructor();
  102480. /**
  102481. * Resets the PBR Material defines.
  102482. */
  102483. reset(): void;
  102484. }
  102485. /**
  102486. * The Physically based material base class of BJS.
  102487. *
  102488. * This offers the main features of a standard PBR material.
  102489. * For more information, please refer to the documentation :
  102490. * https://doc.babylonjs.com/how_to/physically_based_rendering
  102491. */
  102492. export abstract class PBRBaseMaterial extends PushMaterial {
  102493. /**
  102494. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102495. */
  102496. static readonly PBRMATERIAL_OPAQUE: number;
  102497. /**
  102498. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102499. */
  102500. static readonly PBRMATERIAL_ALPHATEST: number;
  102501. /**
  102502. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102503. */
  102504. static readonly PBRMATERIAL_ALPHABLEND: number;
  102505. /**
  102506. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102507. * They are also discarded below the alpha cutoff threshold to improve performances.
  102508. */
  102509. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102510. /**
  102511. * Defines the default value of how much AO map is occluding the analytical lights
  102512. * (point spot...).
  102513. */
  102514. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102515. /**
  102516. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  102517. */
  102518. static readonly LIGHTFALLOFF_PHYSICAL: number;
  102519. /**
  102520. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  102521. * to enhance interoperability with other engines.
  102522. */
  102523. static readonly LIGHTFALLOFF_GLTF: number;
  102524. /**
  102525. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  102526. * to enhance interoperability with other materials.
  102527. */
  102528. static readonly LIGHTFALLOFF_STANDARD: number;
  102529. /**
  102530. * Intensity of the direct lights e.g. the four lights available in your scene.
  102531. * This impacts both the direct diffuse and specular highlights.
  102532. */
  102533. protected _directIntensity: number;
  102534. /**
  102535. * Intensity of the emissive part of the material.
  102536. * This helps controlling the emissive effect without modifying the emissive color.
  102537. */
  102538. protected _emissiveIntensity: number;
  102539. /**
  102540. * Intensity of the environment e.g. how much the environment will light the object
  102541. * either through harmonics for rough material or through the refelction for shiny ones.
  102542. */
  102543. protected _environmentIntensity: number;
  102544. /**
  102545. * This is a special control allowing the reduction of the specular highlights coming from the
  102546. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102547. */
  102548. protected _specularIntensity: number;
  102549. /**
  102550. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  102551. */
  102552. private _lightingInfos;
  102553. /**
  102554. * Debug Control allowing disabling the bump map on this material.
  102555. */
  102556. protected _disableBumpMap: boolean;
  102557. /**
  102558. * AKA Diffuse Texture in standard nomenclature.
  102559. */
  102560. protected _albedoTexture: Nullable<BaseTexture>;
  102561. /**
  102562. * AKA Occlusion Texture in other nomenclature.
  102563. */
  102564. protected _ambientTexture: Nullable<BaseTexture>;
  102565. /**
  102566. * AKA Occlusion Texture Intensity in other nomenclature.
  102567. */
  102568. protected _ambientTextureStrength: number;
  102569. /**
  102570. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102571. * 1 means it completely occludes it
  102572. * 0 mean it has no impact
  102573. */
  102574. protected _ambientTextureImpactOnAnalyticalLights: number;
  102575. /**
  102576. * Stores the alpha values in a texture.
  102577. */
  102578. protected _opacityTexture: Nullable<BaseTexture>;
  102579. /**
  102580. * Stores the reflection values in a texture.
  102581. */
  102582. protected _reflectionTexture: Nullable<BaseTexture>;
  102583. /**
  102584. * Stores the emissive values in a texture.
  102585. */
  102586. protected _emissiveTexture: Nullable<BaseTexture>;
  102587. /**
  102588. * AKA Specular texture in other nomenclature.
  102589. */
  102590. protected _reflectivityTexture: Nullable<BaseTexture>;
  102591. /**
  102592. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102593. */
  102594. protected _metallicTexture: Nullable<BaseTexture>;
  102595. /**
  102596. * Specifies the metallic scalar of the metallic/roughness workflow.
  102597. * Can also be used to scale the metalness values of the metallic texture.
  102598. */
  102599. protected _metallic: Nullable<number>;
  102600. /**
  102601. * Specifies the roughness scalar of the metallic/roughness workflow.
  102602. * Can also be used to scale the roughness values of the metallic texture.
  102603. */
  102604. protected _roughness: Nullable<number>;
  102605. /**
  102606. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  102607. * By default the indexOfrefraction is used to compute F0;
  102608. *
  102609. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  102610. *
  102611. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  102612. * F90 = metallicReflectanceColor;
  102613. */
  102614. protected _metallicF0Factor: number;
  102615. /**
  102616. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  102617. * By default the F90 is always 1;
  102618. *
  102619. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  102620. *
  102621. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  102622. * F90 = metallicReflectanceColor;
  102623. */
  102624. protected _metallicReflectanceColor: Color3;
  102625. /**
  102626. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  102627. * This is multiply against the scalar values defined in the material.
  102628. */
  102629. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  102630. /**
  102631. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102632. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102633. */
  102634. protected _microSurfaceTexture: Nullable<BaseTexture>;
  102635. /**
  102636. * Stores surface normal data used to displace a mesh in a texture.
  102637. */
  102638. protected _bumpTexture: Nullable<BaseTexture>;
  102639. /**
  102640. * Stores the pre-calculated light information of a mesh in a texture.
  102641. */
  102642. protected _lightmapTexture: Nullable<BaseTexture>;
  102643. /**
  102644. * The color of a material in ambient lighting.
  102645. */
  102646. protected _ambientColor: Color3;
  102647. /**
  102648. * AKA Diffuse Color in other nomenclature.
  102649. */
  102650. protected _albedoColor: Color3;
  102651. /**
  102652. * AKA Specular Color in other nomenclature.
  102653. */
  102654. protected _reflectivityColor: Color3;
  102655. /**
  102656. * The color applied when light is reflected from a material.
  102657. */
  102658. protected _reflectionColor: Color3;
  102659. /**
  102660. * The color applied when light is emitted from a material.
  102661. */
  102662. protected _emissiveColor: Color3;
  102663. /**
  102664. * AKA Glossiness in other nomenclature.
  102665. */
  102666. protected _microSurface: number;
  102667. /**
  102668. * Specifies that the material will use the light map as a show map.
  102669. */
  102670. protected _useLightmapAsShadowmap: boolean;
  102671. /**
  102672. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102673. * makes the reflect vector face the model (under horizon).
  102674. */
  102675. protected _useHorizonOcclusion: boolean;
  102676. /**
  102677. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102678. * too much the area relying on ambient texture to define their ambient occlusion.
  102679. */
  102680. protected _useRadianceOcclusion: boolean;
  102681. /**
  102682. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102683. */
  102684. protected _useAlphaFromAlbedoTexture: boolean;
  102685. /**
  102686. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  102687. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102688. */
  102689. protected _useSpecularOverAlpha: boolean;
  102690. /**
  102691. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102692. */
  102693. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102694. /**
  102695. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102696. */
  102697. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  102698. /**
  102699. * Specifies if the metallic texture contains the roughness information in its green channel.
  102700. */
  102701. protected _useRoughnessFromMetallicTextureGreen: boolean;
  102702. /**
  102703. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102704. */
  102705. protected _useMetallnessFromMetallicTextureBlue: boolean;
  102706. /**
  102707. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102708. */
  102709. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  102710. /**
  102711. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102712. */
  102713. protected _useAmbientInGrayScale: boolean;
  102714. /**
  102715. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102716. * The material will try to infer what glossiness each pixel should be.
  102717. */
  102718. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  102719. /**
  102720. * Defines the falloff type used in this material.
  102721. * It by default is Physical.
  102722. */
  102723. protected _lightFalloff: number;
  102724. /**
  102725. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102726. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102727. */
  102728. protected _useRadianceOverAlpha: boolean;
  102729. /**
  102730. * Allows using an object space normal map (instead of tangent space).
  102731. */
  102732. protected _useObjectSpaceNormalMap: boolean;
  102733. /**
  102734. * Allows using the bump map in parallax mode.
  102735. */
  102736. protected _useParallax: boolean;
  102737. /**
  102738. * Allows using the bump map in parallax occlusion mode.
  102739. */
  102740. protected _useParallaxOcclusion: boolean;
  102741. /**
  102742. * Controls the scale bias of the parallax mode.
  102743. */
  102744. protected _parallaxScaleBias: number;
  102745. /**
  102746. * If sets to true, disables all the lights affecting the material.
  102747. */
  102748. protected _disableLighting: boolean;
  102749. /**
  102750. * Number of Simultaneous lights allowed on the material.
  102751. */
  102752. protected _maxSimultaneousLights: number;
  102753. /**
  102754. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102755. */
  102756. protected _invertNormalMapX: boolean;
  102757. /**
  102758. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102759. */
  102760. protected _invertNormalMapY: boolean;
  102761. /**
  102762. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102763. */
  102764. protected _twoSidedLighting: boolean;
  102765. /**
  102766. * Defines the alpha limits in alpha test mode.
  102767. */
  102768. protected _alphaCutOff: number;
  102769. /**
  102770. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102771. */
  102772. protected _forceAlphaTest: boolean;
  102773. /**
  102774. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102775. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102776. */
  102777. protected _useAlphaFresnel: boolean;
  102778. /**
  102779. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102780. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102781. */
  102782. protected _useLinearAlphaFresnel: boolean;
  102783. /**
  102784. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  102785. * from cos thetav and roughness:
  102786. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  102787. */
  102788. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  102789. /**
  102790. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102791. */
  102792. protected _forceIrradianceInFragment: boolean;
  102793. private _realTimeFiltering;
  102794. /**
  102795. * Enables realtime filtering on the texture.
  102796. */
  102797. get realTimeFiltering(): boolean;
  102798. set realTimeFiltering(b: boolean);
  102799. private _realTimeFilteringQuality;
  102800. /**
  102801. * Quality switch for realtime filtering
  102802. */
  102803. get realTimeFilteringQuality(): number;
  102804. set realTimeFilteringQuality(n: number);
  102805. /**
  102806. * Can this material render to several textures at once
  102807. */
  102808. get canRenderToMRT(): boolean;
  102809. /**
  102810. * Force normal to face away from face.
  102811. */
  102812. protected _forceNormalForward: boolean;
  102813. /**
  102814. * Enables specular anti aliasing in the PBR shader.
  102815. * It will both interacts on the Geometry for analytical and IBL lighting.
  102816. * It also prefilter the roughness map based on the bump values.
  102817. */
  102818. protected _enableSpecularAntiAliasing: boolean;
  102819. /**
  102820. * Default configuration related to image processing available in the PBR Material.
  102821. */
  102822. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102823. /**
  102824. * Keep track of the image processing observer to allow dispose and replace.
  102825. */
  102826. private _imageProcessingObserver;
  102827. /**
  102828. * Attaches a new image processing configuration to the PBR Material.
  102829. * @param configuration
  102830. */
  102831. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102832. /**
  102833. * Stores the available render targets.
  102834. */
  102835. private _renderTargets;
  102836. /**
  102837. * Sets the global ambient color for the material used in lighting calculations.
  102838. */
  102839. private _globalAmbientColor;
  102840. /**
  102841. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  102842. */
  102843. private _useLogarithmicDepth;
  102844. /**
  102845. * If set to true, no lighting calculations will be applied.
  102846. */
  102847. private _unlit;
  102848. private _debugMode;
  102849. /**
  102850. * @hidden
  102851. * This is reserved for the inspector.
  102852. * Defines the material debug mode.
  102853. * It helps seeing only some components of the material while troubleshooting.
  102854. */
  102855. debugMode: number;
  102856. /**
  102857. * @hidden
  102858. * This is reserved for the inspector.
  102859. * Specify from where on screen the debug mode should start.
  102860. * The value goes from -1 (full screen) to 1 (not visible)
  102861. * It helps with side by side comparison against the final render
  102862. * This defaults to -1
  102863. */
  102864. private debugLimit;
  102865. /**
  102866. * @hidden
  102867. * This is reserved for the inspector.
  102868. * As the default viewing range might not be enough (if the ambient is really small for instance)
  102869. * You can use the factor to better multiply the final value.
  102870. */
  102871. private debugFactor;
  102872. /**
  102873. * Defines the clear coat layer parameters for the material.
  102874. */
  102875. readonly clearCoat: PBRClearCoatConfiguration;
  102876. /**
  102877. * Defines the anisotropic parameters for the material.
  102878. */
  102879. readonly anisotropy: PBRAnisotropicConfiguration;
  102880. /**
  102881. * Defines the BRDF parameters for the material.
  102882. */
  102883. readonly brdf: PBRBRDFConfiguration;
  102884. /**
  102885. * Defines the Sheen parameters for the material.
  102886. */
  102887. readonly sheen: PBRSheenConfiguration;
  102888. /**
  102889. * Defines the SubSurface parameters for the material.
  102890. */
  102891. readonly subSurface: PBRSubSurfaceConfiguration;
  102892. /**
  102893. * Defines additionnal PrePass parameters for the material.
  102894. */
  102895. readonly prePassConfiguration: PrePassConfiguration;
  102896. /**
  102897. * Defines the detail map parameters for the material.
  102898. */
  102899. readonly detailMap: DetailMapConfiguration;
  102900. protected _rebuildInParallel: boolean;
  102901. /**
  102902. * Instantiates a new PBRMaterial instance.
  102903. *
  102904. * @param name The material name
  102905. * @param scene The scene the material will be use in.
  102906. */
  102907. constructor(name: string, scene: Scene);
  102908. /**
  102909. * Gets a boolean indicating that current material needs to register RTT
  102910. */
  102911. get hasRenderTargetTextures(): boolean;
  102912. /**
  102913. * Gets the name of the material class.
  102914. */
  102915. getClassName(): string;
  102916. /**
  102917. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102918. */
  102919. get useLogarithmicDepth(): boolean;
  102920. /**
  102921. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102922. */
  102923. set useLogarithmicDepth(value: boolean);
  102924. /**
  102925. * Returns true if alpha blending should be disabled.
  102926. */
  102927. protected get _disableAlphaBlending(): boolean;
  102928. /**
  102929. * Specifies whether or not this material should be rendered in alpha blend mode.
  102930. */
  102931. needAlphaBlending(): boolean;
  102932. /**
  102933. * Specifies whether or not this material should be rendered in alpha test mode.
  102934. */
  102935. needAlphaTesting(): boolean;
  102936. /**
  102937. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  102938. */
  102939. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  102940. /**
  102941. * Specifies whether or not there is a usable alpha channel for transparency.
  102942. */
  102943. protected _hasAlphaChannel(): boolean;
  102944. /**
  102945. * Gets the texture used for the alpha test.
  102946. */
  102947. getAlphaTestTexture(): Nullable<BaseTexture>;
  102948. /**
  102949. * Specifies that the submesh is ready to be used.
  102950. * @param mesh - BJS mesh.
  102951. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  102952. * @param useInstances - Specifies that instances should be used.
  102953. * @returns - boolean indicating that the submesh is ready or not.
  102954. */
  102955. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102956. /**
  102957. * Specifies if the material uses metallic roughness workflow.
  102958. * @returns boolean specifiying if the material uses metallic roughness workflow.
  102959. */
  102960. isMetallicWorkflow(): boolean;
  102961. private _prepareEffect;
  102962. private _prepareDefines;
  102963. /**
  102964. * Force shader compilation
  102965. */
  102966. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  102967. /**
  102968. * Initializes the uniform buffer layout for the shader.
  102969. */
  102970. buildUniformLayout(): void;
  102971. /**
  102972. * Unbinds the material from the mesh
  102973. */
  102974. unbind(): void;
  102975. /**
  102976. * Binds the submesh data.
  102977. * @param world - The world matrix.
  102978. * @param mesh - The BJS mesh.
  102979. * @param subMesh - A submesh of the BJS mesh.
  102980. */
  102981. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102982. /**
  102983. * Returns the animatable textures.
  102984. * @returns - Array of animatable textures.
  102985. */
  102986. getAnimatables(): IAnimatable[];
  102987. /**
  102988. * Returns the texture used for reflections.
  102989. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  102990. */
  102991. private _getReflectionTexture;
  102992. /**
  102993. * Returns an array of the actively used textures.
  102994. * @returns - Array of BaseTextures
  102995. */
  102996. getActiveTextures(): BaseTexture[];
  102997. /**
  102998. * Checks to see if a texture is used in the material.
  102999. * @param texture - Base texture to use.
  103000. * @returns - Boolean specifying if a texture is used in the material.
  103001. */
  103002. hasTexture(texture: BaseTexture): boolean;
  103003. /**
  103004. * Sets the required values to the prepass renderer.
  103005. * @param prePassRenderer defines the prepass renderer to setup
  103006. */
  103007. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  103008. /**
  103009. * Disposes the resources of the material.
  103010. * @param forceDisposeEffect - Forces the disposal of effects.
  103011. * @param forceDisposeTextures - Forces the disposal of all textures.
  103012. */
  103013. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103014. }
  103015. }
  103016. declare module BABYLON {
  103017. /**
  103018. * The Physically based material of BJS.
  103019. *
  103020. * This offers the main features of a standard PBR material.
  103021. * For more information, please refer to the documentation :
  103022. * https://doc.babylonjs.com/how_to/physically_based_rendering
  103023. */
  103024. export class PBRMaterial extends PBRBaseMaterial {
  103025. /**
  103026. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103027. */
  103028. static readonly PBRMATERIAL_OPAQUE: number;
  103029. /**
  103030. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103031. */
  103032. static readonly PBRMATERIAL_ALPHATEST: number;
  103033. /**
  103034. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103035. */
  103036. static readonly PBRMATERIAL_ALPHABLEND: number;
  103037. /**
  103038. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103039. * They are also discarded below the alpha cutoff threshold to improve performances.
  103040. */
  103041. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  103042. /**
  103043. * Defines the default value of how much AO map is occluding the analytical lights
  103044. * (point spot...).
  103045. */
  103046. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  103047. /**
  103048. * Intensity of the direct lights e.g. the four lights available in your scene.
  103049. * This impacts both the direct diffuse and specular highlights.
  103050. */
  103051. directIntensity: number;
  103052. /**
  103053. * Intensity of the emissive part of the material.
  103054. * This helps controlling the emissive effect without modifying the emissive color.
  103055. */
  103056. emissiveIntensity: number;
  103057. /**
  103058. * Intensity of the environment e.g. how much the environment will light the object
  103059. * either through harmonics for rough material or through the refelction for shiny ones.
  103060. */
  103061. environmentIntensity: number;
  103062. /**
  103063. * This is a special control allowing the reduction of the specular highlights coming from the
  103064. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  103065. */
  103066. specularIntensity: number;
  103067. /**
  103068. * Debug Control allowing disabling the bump map on this material.
  103069. */
  103070. disableBumpMap: boolean;
  103071. /**
  103072. * AKA Diffuse Texture in standard nomenclature.
  103073. */
  103074. albedoTexture: BaseTexture;
  103075. /**
  103076. * AKA Occlusion Texture in other nomenclature.
  103077. */
  103078. ambientTexture: BaseTexture;
  103079. /**
  103080. * AKA Occlusion Texture Intensity in other nomenclature.
  103081. */
  103082. ambientTextureStrength: number;
  103083. /**
  103084. * Defines how much the AO map is occluding the analytical lights (point spot...).
  103085. * 1 means it completely occludes it
  103086. * 0 mean it has no impact
  103087. */
  103088. ambientTextureImpactOnAnalyticalLights: number;
  103089. /**
  103090. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  103091. */
  103092. opacityTexture: BaseTexture;
  103093. /**
  103094. * Stores the reflection values in a texture.
  103095. */
  103096. reflectionTexture: Nullable<BaseTexture>;
  103097. /**
  103098. * Stores the emissive values in a texture.
  103099. */
  103100. emissiveTexture: BaseTexture;
  103101. /**
  103102. * AKA Specular texture in other nomenclature.
  103103. */
  103104. reflectivityTexture: BaseTexture;
  103105. /**
  103106. * Used to switch from specular/glossiness to metallic/roughness workflow.
  103107. */
  103108. metallicTexture: BaseTexture;
  103109. /**
  103110. * Specifies the metallic scalar of the metallic/roughness workflow.
  103111. * Can also be used to scale the metalness values of the metallic texture.
  103112. */
  103113. metallic: Nullable<number>;
  103114. /**
  103115. * Specifies the roughness scalar of the metallic/roughness workflow.
  103116. * Can also be used to scale the roughness values of the metallic texture.
  103117. */
  103118. roughness: Nullable<number>;
  103119. /**
  103120. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  103121. * By default the indexOfrefraction is used to compute F0;
  103122. *
  103123. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  103124. *
  103125. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  103126. * F90 = metallicReflectanceColor;
  103127. */
  103128. metallicF0Factor: number;
  103129. /**
  103130. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  103131. * By default the F90 is always 1;
  103132. *
  103133. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  103134. *
  103135. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  103136. * F90 = metallicReflectanceColor;
  103137. */
  103138. metallicReflectanceColor: Color3;
  103139. /**
  103140. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  103141. * This is multiply against the scalar values defined in the material.
  103142. */
  103143. metallicReflectanceTexture: Nullable<BaseTexture>;
  103144. /**
  103145. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  103146. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  103147. */
  103148. microSurfaceTexture: BaseTexture;
  103149. /**
  103150. * Stores surface normal data used to displace a mesh in a texture.
  103151. */
  103152. bumpTexture: BaseTexture;
  103153. /**
  103154. * Stores the pre-calculated light information of a mesh in a texture.
  103155. */
  103156. lightmapTexture: BaseTexture;
  103157. /**
  103158. * Stores the refracted light information in a texture.
  103159. */
  103160. get refractionTexture(): Nullable<BaseTexture>;
  103161. set refractionTexture(value: Nullable<BaseTexture>);
  103162. /**
  103163. * The color of a material in ambient lighting.
  103164. */
  103165. ambientColor: Color3;
  103166. /**
  103167. * AKA Diffuse Color in other nomenclature.
  103168. */
  103169. albedoColor: Color3;
  103170. /**
  103171. * AKA Specular Color in other nomenclature.
  103172. */
  103173. reflectivityColor: Color3;
  103174. /**
  103175. * The color reflected from the material.
  103176. */
  103177. reflectionColor: Color3;
  103178. /**
  103179. * The color emitted from the material.
  103180. */
  103181. emissiveColor: Color3;
  103182. /**
  103183. * AKA Glossiness in other nomenclature.
  103184. */
  103185. microSurface: number;
  103186. /**
  103187. * Index of refraction of the material base layer.
  103188. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  103189. *
  103190. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  103191. *
  103192. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  103193. */
  103194. get indexOfRefraction(): number;
  103195. set indexOfRefraction(value: number);
  103196. /**
  103197. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103198. */
  103199. get invertRefractionY(): boolean;
  103200. set invertRefractionY(value: boolean);
  103201. /**
  103202. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103203. * Materials half opaque for instance using refraction could benefit from this control.
  103204. */
  103205. get linkRefractionWithTransparency(): boolean;
  103206. set linkRefractionWithTransparency(value: boolean);
  103207. /**
  103208. * If true, the light map contains occlusion information instead of lighting info.
  103209. */
  103210. useLightmapAsShadowmap: boolean;
  103211. /**
  103212. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  103213. */
  103214. useAlphaFromAlbedoTexture: boolean;
  103215. /**
  103216. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103217. */
  103218. forceAlphaTest: boolean;
  103219. /**
  103220. * Defines the alpha limits in alpha test mode.
  103221. */
  103222. alphaCutOff: number;
  103223. /**
  103224. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103225. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103226. */
  103227. useSpecularOverAlpha: boolean;
  103228. /**
  103229. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  103230. */
  103231. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  103232. /**
  103233. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  103234. */
  103235. useRoughnessFromMetallicTextureAlpha: boolean;
  103236. /**
  103237. * Specifies if the metallic texture contains the roughness information in its green channel.
  103238. */
  103239. useRoughnessFromMetallicTextureGreen: boolean;
  103240. /**
  103241. * Specifies if the metallic texture contains the metallness information in its blue channel.
  103242. */
  103243. useMetallnessFromMetallicTextureBlue: boolean;
  103244. /**
  103245. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  103246. */
  103247. useAmbientOcclusionFromMetallicTextureRed: boolean;
  103248. /**
  103249. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  103250. */
  103251. useAmbientInGrayScale: boolean;
  103252. /**
  103253. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  103254. * The material will try to infer what glossiness each pixel should be.
  103255. */
  103256. useAutoMicroSurfaceFromReflectivityMap: boolean;
  103257. /**
  103258. * BJS is using an harcoded light falloff based on a manually sets up range.
  103259. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103260. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103261. */
  103262. get usePhysicalLightFalloff(): boolean;
  103263. /**
  103264. * BJS is using an harcoded light falloff based on a manually sets up range.
  103265. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103266. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103267. */
  103268. set usePhysicalLightFalloff(value: boolean);
  103269. /**
  103270. * In order to support the falloff compatibility with gltf, a special mode has been added
  103271. * to reproduce the gltf light falloff.
  103272. */
  103273. get useGLTFLightFalloff(): boolean;
  103274. /**
  103275. * In order to support the falloff compatibility with gltf, a special mode has been added
  103276. * to reproduce the gltf light falloff.
  103277. */
  103278. set useGLTFLightFalloff(value: boolean);
  103279. /**
  103280. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103281. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103282. */
  103283. useRadianceOverAlpha: boolean;
  103284. /**
  103285. * Allows using an object space normal map (instead of tangent space).
  103286. */
  103287. useObjectSpaceNormalMap: boolean;
  103288. /**
  103289. * Allows using the bump map in parallax mode.
  103290. */
  103291. useParallax: boolean;
  103292. /**
  103293. * Allows using the bump map in parallax occlusion mode.
  103294. */
  103295. useParallaxOcclusion: boolean;
  103296. /**
  103297. * Controls the scale bias of the parallax mode.
  103298. */
  103299. parallaxScaleBias: number;
  103300. /**
  103301. * If sets to true, disables all the lights affecting the material.
  103302. */
  103303. disableLighting: boolean;
  103304. /**
  103305. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  103306. */
  103307. forceIrradianceInFragment: boolean;
  103308. /**
  103309. * Number of Simultaneous lights allowed on the material.
  103310. */
  103311. maxSimultaneousLights: number;
  103312. /**
  103313. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103314. */
  103315. invertNormalMapX: boolean;
  103316. /**
  103317. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103318. */
  103319. invertNormalMapY: boolean;
  103320. /**
  103321. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103322. */
  103323. twoSidedLighting: boolean;
  103324. /**
  103325. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103326. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  103327. */
  103328. useAlphaFresnel: boolean;
  103329. /**
  103330. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103331. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  103332. */
  103333. useLinearAlphaFresnel: boolean;
  103334. /**
  103335. * Let user defines the brdf lookup texture used for IBL.
  103336. * A default 8bit version is embedded but you could point at :
  103337. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  103338. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103339. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  103340. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103341. */
  103342. environmentBRDFTexture: Nullable<BaseTexture>;
  103343. /**
  103344. * Force normal to face away from face.
  103345. */
  103346. forceNormalForward: boolean;
  103347. /**
  103348. * Enables specular anti aliasing in the PBR shader.
  103349. * It will both interacts on the Geometry for analytical and IBL lighting.
  103350. * It also prefilter the roughness map based on the bump values.
  103351. */
  103352. enableSpecularAntiAliasing: boolean;
  103353. /**
  103354. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  103355. * makes the reflect vector face the model (under horizon).
  103356. */
  103357. useHorizonOcclusion: boolean;
  103358. /**
  103359. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  103360. * too much the area relying on ambient texture to define their ambient occlusion.
  103361. */
  103362. useRadianceOcclusion: boolean;
  103363. /**
  103364. * If set to true, no lighting calculations will be applied.
  103365. */
  103366. unlit: boolean;
  103367. /**
  103368. * Gets the image processing configuration used either in this material.
  103369. */
  103370. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103371. /**
  103372. * Sets the Default image processing configuration used either in the this material.
  103373. *
  103374. * If sets to null, the scene one is in use.
  103375. */
  103376. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103377. /**
  103378. * Gets wether the color curves effect is enabled.
  103379. */
  103380. get cameraColorCurvesEnabled(): boolean;
  103381. /**
  103382. * Sets wether the color curves effect is enabled.
  103383. */
  103384. set cameraColorCurvesEnabled(value: boolean);
  103385. /**
  103386. * Gets wether the color grading effect is enabled.
  103387. */
  103388. get cameraColorGradingEnabled(): boolean;
  103389. /**
  103390. * Gets wether the color grading effect is enabled.
  103391. */
  103392. set cameraColorGradingEnabled(value: boolean);
  103393. /**
  103394. * Gets wether tonemapping is enabled or not.
  103395. */
  103396. get cameraToneMappingEnabled(): boolean;
  103397. /**
  103398. * Sets wether tonemapping is enabled or not
  103399. */
  103400. set cameraToneMappingEnabled(value: boolean);
  103401. /**
  103402. * The camera exposure used on this material.
  103403. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103404. * This corresponds to a photographic exposure.
  103405. */
  103406. get cameraExposure(): number;
  103407. /**
  103408. * The camera exposure used on this material.
  103409. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103410. * This corresponds to a photographic exposure.
  103411. */
  103412. set cameraExposure(value: number);
  103413. /**
  103414. * Gets The camera contrast used on this material.
  103415. */
  103416. get cameraContrast(): number;
  103417. /**
  103418. * Sets The camera contrast used on this material.
  103419. */
  103420. set cameraContrast(value: number);
  103421. /**
  103422. * Gets the Color Grading 2D Lookup Texture.
  103423. */
  103424. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  103425. /**
  103426. * Sets the Color Grading 2D Lookup Texture.
  103427. */
  103428. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  103429. /**
  103430. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103431. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103432. * 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;
  103433. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103434. */
  103435. get cameraColorCurves(): Nullable<ColorCurves>;
  103436. /**
  103437. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103438. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103439. * 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;
  103440. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103441. */
  103442. set cameraColorCurves(value: Nullable<ColorCurves>);
  103443. /**
  103444. * Instantiates a new PBRMaterial instance.
  103445. *
  103446. * @param name The material name
  103447. * @param scene The scene the material will be use in.
  103448. */
  103449. constructor(name: string, scene: Scene);
  103450. /**
  103451. * Returns the name of this material class.
  103452. */
  103453. getClassName(): string;
  103454. /**
  103455. * Makes a duplicate of the current material.
  103456. * @param name - name to use for the new material.
  103457. */
  103458. clone(name: string): PBRMaterial;
  103459. /**
  103460. * Serializes this PBR Material.
  103461. * @returns - An object with the serialized material.
  103462. */
  103463. serialize(): any;
  103464. /**
  103465. * Parses a PBR Material from a serialized object.
  103466. * @param source - Serialized object.
  103467. * @param scene - BJS scene instance.
  103468. * @param rootUrl - url for the scene object
  103469. * @returns - PBRMaterial
  103470. */
  103471. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  103472. }
  103473. }
  103474. declare module BABYLON {
  103475. /** @hidden */
  103476. export var mrtFragmentDeclaration: {
  103477. name: string;
  103478. shader: string;
  103479. };
  103480. }
  103481. declare module BABYLON {
  103482. /** @hidden */
  103483. export var geometryPixelShader: {
  103484. name: string;
  103485. shader: string;
  103486. };
  103487. }
  103488. declare module BABYLON {
  103489. /** @hidden */
  103490. export var geometryVertexShader: {
  103491. name: string;
  103492. shader: string;
  103493. };
  103494. }
  103495. declare module BABYLON {
  103496. /** @hidden */
  103497. interface ISavedTransformationMatrix {
  103498. world: Matrix;
  103499. viewProjection: Matrix;
  103500. }
  103501. /**
  103502. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  103503. */
  103504. export class GeometryBufferRenderer {
  103505. /**
  103506. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  103507. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  103508. */
  103509. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  103510. /**
  103511. * Constant used to retrieve the position texture index in the G-Buffer textures array
  103512. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  103513. */
  103514. static readonly POSITION_TEXTURE_TYPE: number;
  103515. /**
  103516. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  103517. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  103518. */
  103519. static readonly VELOCITY_TEXTURE_TYPE: number;
  103520. /**
  103521. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  103522. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  103523. */
  103524. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  103525. /**
  103526. * Dictionary used to store the previous transformation matrices of each rendered mesh
  103527. * in order to compute objects velocities when enableVelocity is set to "true"
  103528. * @hidden
  103529. */
  103530. _previousTransformationMatrices: {
  103531. [index: number]: ISavedTransformationMatrix;
  103532. };
  103533. /**
  103534. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  103535. * in order to compute objects velocities when enableVelocity is set to "true"
  103536. * @hidden
  103537. */
  103538. _previousBonesTransformationMatrices: {
  103539. [index: number]: Float32Array;
  103540. };
  103541. /**
  103542. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  103543. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  103544. */
  103545. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  103546. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  103547. renderTransparentMeshes: boolean;
  103548. private _scene;
  103549. private _resizeObserver;
  103550. private _multiRenderTarget;
  103551. private _ratio;
  103552. private _enablePosition;
  103553. private _enableVelocity;
  103554. private _enableReflectivity;
  103555. private _positionIndex;
  103556. private _velocityIndex;
  103557. private _reflectivityIndex;
  103558. private _depthNormalIndex;
  103559. private _linkedWithPrePass;
  103560. private _prePassRenderer;
  103561. private _attachments;
  103562. protected _effect: Effect;
  103563. protected _cachedDefines: string;
  103564. /**
  103565. * @hidden
  103566. * Sets up internal structures to share outputs with PrePassRenderer
  103567. * This method should only be called by the PrePassRenderer itself
  103568. */
  103569. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  103570. /**
  103571. * @hidden
  103572. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  103573. * This method should only be called by the PrePassRenderer itself
  103574. */
  103575. _unlinkPrePassRenderer(): void;
  103576. /**
  103577. * @hidden
  103578. * Resets the geometry buffer layout
  103579. */
  103580. _resetLayout(): void;
  103581. /**
  103582. * @hidden
  103583. * Replaces a texture in the geometry buffer renderer
  103584. * Useful when linking textures of the prepass renderer
  103585. */
  103586. _forceTextureType(geometryBufferType: number, index: number): void;
  103587. /**
  103588. * @hidden
  103589. * Sets texture attachments
  103590. * Useful when linking textures of the prepass renderer
  103591. */
  103592. _setAttachments(attachments: number[]): void;
  103593. /**
  103594. * @hidden
  103595. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  103596. * Useful when linking textures of the prepass renderer
  103597. */
  103598. _linkInternalTexture(internalTexture: InternalTexture): void;
  103599. /**
  103600. * Gets the render list (meshes to be rendered) used in the G buffer.
  103601. */
  103602. get renderList(): Nullable<AbstractMesh[]>;
  103603. /**
  103604. * Set the render list (meshes to be rendered) used in the G buffer.
  103605. */
  103606. set renderList(meshes: Nullable<AbstractMesh[]>);
  103607. /**
  103608. * Gets wether or not G buffer are supported by the running hardware.
  103609. * This requires draw buffer supports
  103610. */
  103611. get isSupported(): boolean;
  103612. /**
  103613. * Returns the index of the given texture type in the G-Buffer textures array
  103614. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  103615. * @returns the index of the given texture type in the G-Buffer textures array
  103616. */
  103617. getTextureIndex(textureType: number): number;
  103618. /**
  103619. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  103620. */
  103621. get enablePosition(): boolean;
  103622. /**
  103623. * Sets whether or not objects positions are enabled for the G buffer.
  103624. */
  103625. set enablePosition(enable: boolean);
  103626. /**
  103627. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  103628. */
  103629. get enableVelocity(): boolean;
  103630. /**
  103631. * Sets wether or not objects velocities are enabled for the G buffer.
  103632. */
  103633. set enableVelocity(enable: boolean);
  103634. /**
  103635. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  103636. */
  103637. get enableReflectivity(): boolean;
  103638. /**
  103639. * Sets wether or not objects roughness are enabled for the G buffer.
  103640. */
  103641. set enableReflectivity(enable: boolean);
  103642. /**
  103643. * Gets the scene associated with the buffer.
  103644. */
  103645. get scene(): Scene;
  103646. /**
  103647. * Gets the ratio used by the buffer during its creation.
  103648. * How big is the buffer related to the main canvas.
  103649. */
  103650. get ratio(): number;
  103651. /** @hidden */
  103652. static _SceneComponentInitialization: (scene: Scene) => void;
  103653. /**
  103654. * Creates a new G Buffer for the scene
  103655. * @param scene The scene the buffer belongs to
  103656. * @param ratio How big is the buffer related to the main canvas.
  103657. */
  103658. constructor(scene: Scene, ratio?: number);
  103659. /**
  103660. * Checks wether everything is ready to render a submesh to the G buffer.
  103661. * @param subMesh the submesh to check readiness for
  103662. * @param useInstances is the mesh drawn using instance or not
  103663. * @returns true if ready otherwise false
  103664. */
  103665. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103666. /**
  103667. * Gets the current underlying G Buffer.
  103668. * @returns the buffer
  103669. */
  103670. getGBuffer(): MultiRenderTarget;
  103671. /**
  103672. * Gets the number of samples used to render the buffer (anti aliasing).
  103673. */
  103674. get samples(): number;
  103675. /**
  103676. * Sets the number of samples used to render the buffer (anti aliasing).
  103677. */
  103678. set samples(value: number);
  103679. /**
  103680. * Disposes the renderer and frees up associated resources.
  103681. */
  103682. dispose(): void;
  103683. private _assignRenderTargetIndices;
  103684. protected _createRenderTargets(): void;
  103685. private _copyBonesTransformationMatrices;
  103686. }
  103687. }
  103688. declare module BABYLON {
  103689. /**
  103690. * Renders a pre pass of the scene
  103691. * This means every mesh in the scene will be rendered to a render target texture
  103692. * And then this texture will be composited to the rendering canvas with post processes
  103693. * It is necessary for effects like subsurface scattering or deferred shading
  103694. */
  103695. export class PrePassRenderer {
  103696. /** @hidden */
  103697. static _SceneComponentInitialization: (scene: Scene) => void;
  103698. private _textureFormats;
  103699. /**
  103700. * To save performance, we can excluded skinned meshes from the prepass
  103701. */
  103702. excludedSkinnedMesh: AbstractMesh[];
  103703. /**
  103704. * Force material to be excluded from the prepass
  103705. * Can be useful when `useGeometryBufferFallback` is set to `true`
  103706. * and you don't want a material to show in the effect.
  103707. */
  103708. excludedMaterials: Material[];
  103709. private _textureIndices;
  103710. private _scene;
  103711. private _engine;
  103712. private _isDirty;
  103713. /**
  103714. * Number of textures in the multi render target texture where the scene is directly rendered
  103715. */
  103716. mrtCount: number;
  103717. /**
  103718. * The render target where the scene is directly rendered
  103719. */
  103720. prePassRT: MultiRenderTarget;
  103721. private _multiRenderAttachments;
  103722. private _defaultAttachments;
  103723. private _clearAttachments;
  103724. private _postProcesses;
  103725. private readonly _clearColor;
  103726. /**
  103727. * Image processing post process for composition
  103728. */
  103729. imageProcessingPostProcess: ImageProcessingPostProcess;
  103730. /**
  103731. * Configuration for prepass effects
  103732. */
  103733. private _effectConfigurations;
  103734. private _mrtFormats;
  103735. private _mrtLayout;
  103736. private _enabled;
  103737. /**
  103738. * Indicates if the prepass is enabled
  103739. */
  103740. get enabled(): boolean;
  103741. /**
  103742. * How many samples are used for MSAA of the scene render target
  103743. */
  103744. get samples(): number;
  103745. set samples(n: number);
  103746. private _geometryBuffer;
  103747. private _useGeometryBufferFallback;
  103748. /**
  103749. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  103750. */
  103751. get useGeometryBufferFallback(): boolean;
  103752. set useGeometryBufferFallback(value: boolean);
  103753. /**
  103754. * Instanciates a prepass renderer
  103755. * @param scene The scene
  103756. */
  103757. constructor(scene: Scene);
  103758. private _initializeAttachments;
  103759. private _createCompositionEffect;
  103760. /**
  103761. * Indicates if rendering a prepass is supported
  103762. */
  103763. get isSupported(): boolean;
  103764. /**
  103765. * Sets the proper output textures to draw in the engine.
  103766. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103767. * @param subMesh Submesh on which the effect is applied
  103768. */
  103769. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  103770. /**
  103771. * @hidden
  103772. */
  103773. _beforeCameraDraw(): void;
  103774. /**
  103775. * @hidden
  103776. */
  103777. _afterCameraDraw(): void;
  103778. private _checkRTSize;
  103779. private _bindFrameBuffer;
  103780. /**
  103781. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103782. */
  103783. clear(): void;
  103784. private _setState;
  103785. private _updateGeometryBufferLayout;
  103786. /**
  103787. * Adds an effect configuration to the prepass.
  103788. * If an effect has already been added, it won't add it twice and will return the configuration
  103789. * already present.
  103790. * @param cfg the effect configuration
  103791. * @return the effect configuration now used by the prepass
  103792. */
  103793. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  103794. /**
  103795. * Returns the index of a texture in the multi render target texture array.
  103796. * @param type Texture type
  103797. * @return The index
  103798. */
  103799. getIndex(type: number): number;
  103800. private _enable;
  103801. private _disable;
  103802. private _resetLayout;
  103803. private _resetPostProcessChain;
  103804. private _bindPostProcessChain;
  103805. /**
  103806. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103807. */
  103808. markAsDirty(): void;
  103809. /**
  103810. * Enables a texture on the MultiRenderTarget for prepass
  103811. */
  103812. private _enableTextures;
  103813. private _update;
  103814. private _markAllMaterialsAsPrePassDirty;
  103815. /**
  103816. * Disposes the prepass renderer.
  103817. */
  103818. dispose(): void;
  103819. }
  103820. }
  103821. declare module BABYLON {
  103822. /**
  103823. * Size options for a post process
  103824. */
  103825. export type PostProcessOptions = {
  103826. width: number;
  103827. height: number;
  103828. };
  103829. /**
  103830. * PostProcess can be used to apply a shader to a texture after it has been rendered
  103831. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103832. */
  103833. export class PostProcess {
  103834. /**
  103835. * Gets or sets the unique id of the post process
  103836. */
  103837. uniqueId: number;
  103838. /** Name of the PostProcess. */
  103839. name: string;
  103840. /**
  103841. * Width of the texture to apply the post process on
  103842. */
  103843. width: number;
  103844. /**
  103845. * Height of the texture to apply the post process on
  103846. */
  103847. height: number;
  103848. /**
  103849. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  103850. */
  103851. nodeMaterialSource: Nullable<NodeMaterial>;
  103852. /**
  103853. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  103854. * @hidden
  103855. */
  103856. _outputTexture: Nullable<InternalTexture>;
  103857. /**
  103858. * Sampling mode used by the shader
  103859. * See https://doc.babylonjs.com/classes/3.1/texture
  103860. */
  103861. renderTargetSamplingMode: number;
  103862. /**
  103863. * Clear color to use when screen clearing
  103864. */
  103865. clearColor: Color4;
  103866. /**
  103867. * If the buffer needs to be cleared before applying the post process. (default: true)
  103868. * Should be set to false if shader will overwrite all previous pixels.
  103869. */
  103870. autoClear: boolean;
  103871. /**
  103872. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  103873. */
  103874. alphaMode: number;
  103875. /**
  103876. * Sets the setAlphaBlendConstants of the babylon engine
  103877. */
  103878. alphaConstants: Color4;
  103879. /**
  103880. * Animations to be used for the post processing
  103881. */
  103882. animations: Animation[];
  103883. /**
  103884. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  103885. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  103886. */
  103887. enablePixelPerfectMode: boolean;
  103888. /**
  103889. * Force the postprocess to be applied without taking in account viewport
  103890. */
  103891. forceFullscreenViewport: boolean;
  103892. /**
  103893. * List of inspectable custom properties (used by the Inspector)
  103894. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103895. */
  103896. inspectableCustomProperties: IInspectable[];
  103897. /**
  103898. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  103899. *
  103900. * | Value | Type | Description |
  103901. * | ----- | ----------------------------------- | ----------- |
  103902. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  103903. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  103904. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  103905. *
  103906. */
  103907. scaleMode: number;
  103908. /**
  103909. * Force textures to be a power of two (default: false)
  103910. */
  103911. alwaysForcePOT: boolean;
  103912. private _samples;
  103913. /**
  103914. * Number of sample textures (default: 1)
  103915. */
  103916. get samples(): number;
  103917. set samples(n: number);
  103918. /**
  103919. * Modify the scale of the post process to be the same as the viewport (default: false)
  103920. */
  103921. adaptScaleToCurrentViewport: boolean;
  103922. private _camera;
  103923. protected _scene: Scene;
  103924. private _engine;
  103925. private _options;
  103926. private _reusable;
  103927. private _textureType;
  103928. private _textureFormat;
  103929. /**
  103930. * Smart array of input and output textures for the post process.
  103931. * @hidden
  103932. */
  103933. _textures: SmartArray<InternalTexture>;
  103934. /**
  103935. * The index in _textures that corresponds to the output texture.
  103936. * @hidden
  103937. */
  103938. _currentRenderTextureInd: number;
  103939. private _effect;
  103940. private _samplers;
  103941. private _fragmentUrl;
  103942. private _vertexUrl;
  103943. private _parameters;
  103944. private _scaleRatio;
  103945. protected _indexParameters: any;
  103946. private _shareOutputWithPostProcess;
  103947. private _texelSize;
  103948. private _forcedOutputTexture;
  103949. /**
  103950. * Prepass configuration in case this post process needs a texture from prepass
  103951. * @hidden
  103952. */
  103953. _prePassEffectConfiguration: PrePassEffectConfiguration;
  103954. /**
  103955. * Returns the fragment url or shader name used in the post process.
  103956. * @returns the fragment url or name in the shader store.
  103957. */
  103958. getEffectName(): string;
  103959. /**
  103960. * An event triggered when the postprocess is activated.
  103961. */
  103962. onActivateObservable: Observable<Camera>;
  103963. private _onActivateObserver;
  103964. /**
  103965. * A function that is added to the onActivateObservable
  103966. */
  103967. set onActivate(callback: Nullable<(camera: Camera) => void>);
  103968. /**
  103969. * An event triggered when the postprocess changes its size.
  103970. */
  103971. onSizeChangedObservable: Observable<PostProcess>;
  103972. private _onSizeChangedObserver;
  103973. /**
  103974. * A function that is added to the onSizeChangedObservable
  103975. */
  103976. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  103977. /**
  103978. * An event triggered when the postprocess applies its effect.
  103979. */
  103980. onApplyObservable: Observable<Effect>;
  103981. private _onApplyObserver;
  103982. /**
  103983. * A function that is added to the onApplyObservable
  103984. */
  103985. set onApply(callback: (effect: Effect) => void);
  103986. /**
  103987. * An event triggered before rendering the postprocess
  103988. */
  103989. onBeforeRenderObservable: Observable<Effect>;
  103990. private _onBeforeRenderObserver;
  103991. /**
  103992. * A function that is added to the onBeforeRenderObservable
  103993. */
  103994. set onBeforeRender(callback: (effect: Effect) => void);
  103995. /**
  103996. * An event triggered after rendering the postprocess
  103997. */
  103998. onAfterRenderObservable: Observable<Effect>;
  103999. private _onAfterRenderObserver;
  104000. /**
  104001. * A function that is added to the onAfterRenderObservable
  104002. */
  104003. set onAfterRender(callback: (efect: Effect) => void);
  104004. /**
  104005. * 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
  104006. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  104007. */
  104008. get inputTexture(): InternalTexture;
  104009. set inputTexture(value: InternalTexture);
  104010. /**
  104011. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  104012. * the only way to unset it is to use this function to restore its internal state
  104013. */
  104014. restoreDefaultInputTexture(): void;
  104015. /**
  104016. * Gets the camera which post process is applied to.
  104017. * @returns The camera the post process is applied to.
  104018. */
  104019. getCamera(): Camera;
  104020. /**
  104021. * Gets the texel size of the postprocess.
  104022. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  104023. */
  104024. get texelSize(): Vector2;
  104025. /**
  104026. * Creates a new instance PostProcess
  104027. * @param name The name of the PostProcess.
  104028. * @param fragmentUrl The url of the fragment shader to be used.
  104029. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  104030. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  104031. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104032. * @param camera The camera to apply the render pass to.
  104033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104034. * @param engine The engine which the post process will be applied. (default: current engine)
  104035. * @param reusable If the post process can be reused on the same frame. (default: false)
  104036. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  104037. * @param textureType Type of textures used when performing the post process. (default: 0)
  104038. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  104039. * @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
  104040. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  104041. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  104042. */
  104043. 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);
  104044. /**
  104045. * Gets a string identifying the name of the class
  104046. * @returns "PostProcess" string
  104047. */
  104048. getClassName(): string;
  104049. /**
  104050. * Gets the engine which this post process belongs to.
  104051. * @returns The engine the post process was enabled with.
  104052. */
  104053. getEngine(): Engine;
  104054. /**
  104055. * The effect that is created when initializing the post process.
  104056. * @returns The created effect corresponding the the postprocess.
  104057. */
  104058. getEffect(): Effect;
  104059. /**
  104060. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  104061. * @param postProcess The post process to share the output with.
  104062. * @returns This post process.
  104063. */
  104064. shareOutputWith(postProcess: PostProcess): PostProcess;
  104065. /**
  104066. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  104067. * This should be called if the post process that shares output with this post process is disabled/disposed.
  104068. */
  104069. useOwnOutput(): void;
  104070. /**
  104071. * Updates the effect with the current post process compile time values and recompiles the shader.
  104072. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104073. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104074. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104075. * @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
  104076. * @param onCompiled Called when the shader has been compiled.
  104077. * @param onError Called if there is an error when compiling a shader.
  104078. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  104079. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  104080. */
  104081. 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;
  104082. /**
  104083. * The post process is reusable if it can be used multiple times within one frame.
  104084. * @returns If the post process is reusable
  104085. */
  104086. isReusable(): boolean;
  104087. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  104088. markTextureDirty(): void;
  104089. /**
  104090. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  104091. * 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.
  104092. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  104093. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  104094. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  104095. * @returns The target texture that was bound to be written to.
  104096. */
  104097. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  104098. /**
  104099. * If the post process is supported.
  104100. */
  104101. get isSupported(): boolean;
  104102. /**
  104103. * The aspect ratio of the output texture.
  104104. */
  104105. get aspectRatio(): number;
  104106. /**
  104107. * Get a value indicating if the post-process is ready to be used
  104108. * @returns true if the post-process is ready (shader is compiled)
  104109. */
  104110. isReady(): boolean;
  104111. /**
  104112. * Binds all textures and uniforms to the shader, this will be run on every pass.
  104113. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  104114. */
  104115. apply(): Nullable<Effect>;
  104116. private _disposeTextures;
  104117. /**
  104118. * Sets the required values to the prepass renderer.
  104119. * @param prePassRenderer defines the prepass renderer to setup.
  104120. * @returns true if the pre pass is needed.
  104121. */
  104122. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104123. /**
  104124. * Disposes the post process.
  104125. * @param camera The camera to dispose the post process on.
  104126. */
  104127. dispose(camera?: Camera): void;
  104128. /**
  104129. * Serializes the particle system to a JSON object
  104130. * @returns the JSON object
  104131. */
  104132. serialize(): any;
  104133. /**
  104134. * Creates a material from parsed material data
  104135. * @param parsedPostProcess defines parsed post process data
  104136. * @param scene defines the hosting scene
  104137. * @param rootUrl defines the root URL to use to load textures
  104138. * @returns a new post process
  104139. */
  104140. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  104141. }
  104142. }
  104143. declare module BABYLON {
  104144. /** @hidden */
  104145. export var kernelBlurVaryingDeclaration: {
  104146. name: string;
  104147. shader: string;
  104148. };
  104149. }
  104150. declare module BABYLON {
  104151. /** @hidden */
  104152. export var packingFunctions: {
  104153. name: string;
  104154. shader: string;
  104155. };
  104156. }
  104157. declare module BABYLON {
  104158. /** @hidden */
  104159. export var kernelBlurFragment: {
  104160. name: string;
  104161. shader: string;
  104162. };
  104163. }
  104164. declare module BABYLON {
  104165. /** @hidden */
  104166. export var kernelBlurFragment2: {
  104167. name: string;
  104168. shader: string;
  104169. };
  104170. }
  104171. declare module BABYLON {
  104172. /** @hidden */
  104173. export var kernelBlurPixelShader: {
  104174. name: string;
  104175. shader: string;
  104176. };
  104177. }
  104178. declare module BABYLON {
  104179. /** @hidden */
  104180. export var kernelBlurVertex: {
  104181. name: string;
  104182. shader: string;
  104183. };
  104184. }
  104185. declare module BABYLON {
  104186. /** @hidden */
  104187. export var kernelBlurVertexShader: {
  104188. name: string;
  104189. shader: string;
  104190. };
  104191. }
  104192. declare module BABYLON {
  104193. /**
  104194. * The Blur Post Process which blurs an image based on a kernel and direction.
  104195. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  104196. */
  104197. export class BlurPostProcess extends PostProcess {
  104198. private blockCompilation;
  104199. protected _kernel: number;
  104200. protected _idealKernel: number;
  104201. protected _packedFloat: boolean;
  104202. private _staticDefines;
  104203. /** The direction in which to blur the image. */
  104204. direction: Vector2;
  104205. /**
  104206. * Sets the length in pixels of the blur sample region
  104207. */
  104208. set kernel(v: number);
  104209. /**
  104210. * Gets the length in pixels of the blur sample region
  104211. */
  104212. get kernel(): number;
  104213. /**
  104214. * Sets wether or not the blur needs to unpack/repack floats
  104215. */
  104216. set packedFloat(v: boolean);
  104217. /**
  104218. * Gets wether or not the blur is unpacking/repacking floats
  104219. */
  104220. get packedFloat(): boolean;
  104221. /**
  104222. * Gets a string identifying the name of the class
  104223. * @returns "BlurPostProcess" string
  104224. */
  104225. getClassName(): string;
  104226. /**
  104227. * Creates a new instance BlurPostProcess
  104228. * @param name The name of the effect.
  104229. * @param direction The direction in which to blur the image.
  104230. * @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.
  104231. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104232. * @param camera The camera to apply the render pass to.
  104233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104234. * @param engine The engine which the post process will be applied. (default: current engine)
  104235. * @param reusable If the post process can be reused on the same frame. (default: false)
  104236. * @param textureType Type of textures used when performing the post process. (default: 0)
  104237. * @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)
  104238. */
  104239. 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);
  104240. /**
  104241. * Updates the effect with the current post process compile time values and recompiles the shader.
  104242. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104243. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104244. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104245. * @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
  104246. * @param onCompiled Called when the shader has been compiled.
  104247. * @param onError Called if there is an error when compiling a shader.
  104248. */
  104249. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104250. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104251. /**
  104252. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  104253. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  104254. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  104255. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  104256. * The gaps between physical kernels are compensated for in the weighting of the samples
  104257. * @param idealKernel Ideal blur kernel.
  104258. * @return Nearest best kernel.
  104259. */
  104260. protected _nearestBestKernel(idealKernel: number): number;
  104261. /**
  104262. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  104263. * @param x The point on the Gaussian distribution to sample.
  104264. * @return the value of the Gaussian function at x.
  104265. */
  104266. protected _gaussianWeight(x: number): number;
  104267. /**
  104268. * Generates a string that can be used as a floating point number in GLSL.
  104269. * @param x Value to print.
  104270. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  104271. * @return GLSL float string.
  104272. */
  104273. protected _glslFloat(x: number, decimalFigures?: number): string;
  104274. /** @hidden */
  104275. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  104276. }
  104277. }
  104278. declare module BABYLON {
  104279. /**
  104280. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104281. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104282. * You can then easily use it as a reflectionTexture on a flat surface.
  104283. * In case the surface is not a plane, please consider relying on reflection probes.
  104284. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104285. */
  104286. export class MirrorTexture extends RenderTargetTexture {
  104287. private scene;
  104288. /**
  104289. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  104290. * 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.
  104291. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104292. */
  104293. mirrorPlane: Plane;
  104294. /**
  104295. * Define the blur ratio used to blur the reflection if needed.
  104296. */
  104297. set blurRatio(value: number);
  104298. get blurRatio(): number;
  104299. /**
  104300. * Define the adaptive blur kernel used to blur the reflection if needed.
  104301. * This will autocompute the closest best match for the `blurKernel`
  104302. */
  104303. set adaptiveBlurKernel(value: number);
  104304. /**
  104305. * Define the blur kernel used to blur the reflection if needed.
  104306. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104307. */
  104308. set blurKernel(value: number);
  104309. /**
  104310. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  104311. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104312. */
  104313. set blurKernelX(value: number);
  104314. get blurKernelX(): number;
  104315. /**
  104316. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  104317. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104318. */
  104319. set blurKernelY(value: number);
  104320. get blurKernelY(): number;
  104321. private _autoComputeBlurKernel;
  104322. protected _onRatioRescale(): void;
  104323. private _updateGammaSpace;
  104324. private _imageProcessingConfigChangeObserver;
  104325. private _transformMatrix;
  104326. private _mirrorMatrix;
  104327. private _savedViewMatrix;
  104328. private _blurX;
  104329. private _blurY;
  104330. private _adaptiveBlurKernel;
  104331. private _blurKernelX;
  104332. private _blurKernelY;
  104333. private _blurRatio;
  104334. /**
  104335. * Instantiates a Mirror Texture.
  104336. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104337. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104338. * You can then easily use it as a reflectionTexture on a flat surface.
  104339. * In case the surface is not a plane, please consider relying on reflection probes.
  104340. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104341. * @param name
  104342. * @param size
  104343. * @param scene
  104344. * @param generateMipMaps
  104345. * @param type
  104346. * @param samplingMode
  104347. * @param generateDepthBuffer
  104348. */
  104349. constructor(name: string, size: number | {
  104350. width: number;
  104351. height: number;
  104352. } | {
  104353. ratio: number;
  104354. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  104355. private _preparePostProcesses;
  104356. /**
  104357. * Clone the mirror texture.
  104358. * @returns the cloned texture
  104359. */
  104360. clone(): MirrorTexture;
  104361. /**
  104362. * Serialize the texture to a JSON representation you could use in Parse later on
  104363. * @returns the serialized JSON representation
  104364. */
  104365. serialize(): any;
  104366. /**
  104367. * Dispose the texture and release its associated resources.
  104368. */
  104369. dispose(): void;
  104370. }
  104371. }
  104372. declare module BABYLON {
  104373. /**
  104374. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104375. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104376. */
  104377. export class Texture extends BaseTexture {
  104378. /**
  104379. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  104380. */
  104381. static SerializeBuffers: boolean;
  104382. /**
  104383. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  104384. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  104385. */
  104386. static ForceSerializeBuffers: boolean;
  104387. /** @hidden */
  104388. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  104389. /** @hidden */
  104390. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  104391. /** @hidden */
  104392. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  104393. /** nearest is mag = nearest and min = nearest and mip = linear */
  104394. static readonly NEAREST_SAMPLINGMODE: number;
  104395. /** nearest is mag = nearest and min = nearest and mip = linear */
  104396. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  104397. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104398. static readonly BILINEAR_SAMPLINGMODE: number;
  104399. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104400. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  104401. /** Trilinear is mag = linear and min = linear and mip = linear */
  104402. static readonly TRILINEAR_SAMPLINGMODE: number;
  104403. /** Trilinear is mag = linear and min = linear and mip = linear */
  104404. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  104405. /** mag = nearest and min = nearest and mip = nearest */
  104406. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  104407. /** mag = nearest and min = linear and mip = nearest */
  104408. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  104409. /** mag = nearest and min = linear and mip = linear */
  104410. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  104411. /** mag = nearest and min = linear and mip = none */
  104412. static readonly NEAREST_LINEAR: number;
  104413. /** mag = nearest and min = nearest and mip = none */
  104414. static readonly NEAREST_NEAREST: number;
  104415. /** mag = linear and min = nearest and mip = nearest */
  104416. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  104417. /** mag = linear and min = nearest and mip = linear */
  104418. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  104419. /** mag = linear and min = linear and mip = none */
  104420. static readonly LINEAR_LINEAR: number;
  104421. /** mag = linear and min = nearest and mip = none */
  104422. static readonly LINEAR_NEAREST: number;
  104423. /** Explicit coordinates mode */
  104424. static readonly EXPLICIT_MODE: number;
  104425. /** Spherical coordinates mode */
  104426. static readonly SPHERICAL_MODE: number;
  104427. /** Planar coordinates mode */
  104428. static readonly PLANAR_MODE: number;
  104429. /** Cubic coordinates mode */
  104430. static readonly CUBIC_MODE: number;
  104431. /** Projection coordinates mode */
  104432. static readonly PROJECTION_MODE: number;
  104433. /** Inverse Cubic coordinates mode */
  104434. static readonly SKYBOX_MODE: number;
  104435. /** Inverse Cubic coordinates mode */
  104436. static readonly INVCUBIC_MODE: number;
  104437. /** Equirectangular coordinates mode */
  104438. static readonly EQUIRECTANGULAR_MODE: number;
  104439. /** Equirectangular Fixed coordinates mode */
  104440. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  104441. /** Equirectangular Fixed Mirrored coordinates mode */
  104442. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  104443. /** Texture is not repeating outside of 0..1 UVs */
  104444. static readonly CLAMP_ADDRESSMODE: number;
  104445. /** Texture is repeating outside of 0..1 UVs */
  104446. static readonly WRAP_ADDRESSMODE: number;
  104447. /** Texture is repeating and mirrored */
  104448. static readonly MIRROR_ADDRESSMODE: number;
  104449. /**
  104450. * 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
  104451. */
  104452. static UseSerializedUrlIfAny: boolean;
  104453. /**
  104454. * Define the url of the texture.
  104455. */
  104456. url: Nullable<string>;
  104457. /**
  104458. * Define an offset on the texture to offset the u coordinates of the UVs
  104459. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104460. */
  104461. uOffset: number;
  104462. /**
  104463. * Define an offset on the texture to offset the v coordinates of the UVs
  104464. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104465. */
  104466. vOffset: number;
  104467. /**
  104468. * Define an offset on the texture to scale the u coordinates of the UVs
  104469. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104470. */
  104471. uScale: number;
  104472. /**
  104473. * Define an offset on the texture to scale the v coordinates of the UVs
  104474. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104475. */
  104476. vScale: number;
  104477. /**
  104478. * Define an offset on the texture to rotate around the u coordinates of the UVs
  104479. * @see https://doc.babylonjs.com/how_to/more_materials
  104480. */
  104481. uAng: number;
  104482. /**
  104483. * Define an offset on the texture to rotate around the v coordinates of the UVs
  104484. * @see https://doc.babylonjs.com/how_to/more_materials
  104485. */
  104486. vAng: number;
  104487. /**
  104488. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  104489. * @see https://doc.babylonjs.com/how_to/more_materials
  104490. */
  104491. wAng: number;
  104492. /**
  104493. * Defines the center of rotation (U)
  104494. */
  104495. uRotationCenter: number;
  104496. /**
  104497. * Defines the center of rotation (V)
  104498. */
  104499. vRotationCenter: number;
  104500. /**
  104501. * Defines the center of rotation (W)
  104502. */
  104503. wRotationCenter: number;
  104504. /**
  104505. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  104506. */
  104507. homogeneousRotationInUVTransform: boolean;
  104508. /**
  104509. * Are mip maps generated for this texture or not.
  104510. */
  104511. get noMipmap(): boolean;
  104512. /**
  104513. * List of inspectable custom properties (used by the Inspector)
  104514. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104515. */
  104516. inspectableCustomProperties: Nullable<IInspectable[]>;
  104517. private _noMipmap;
  104518. /** @hidden */
  104519. _invertY: boolean;
  104520. private _rowGenerationMatrix;
  104521. private _cachedTextureMatrix;
  104522. private _projectionModeMatrix;
  104523. private _t0;
  104524. private _t1;
  104525. private _t2;
  104526. private _cachedUOffset;
  104527. private _cachedVOffset;
  104528. private _cachedUScale;
  104529. private _cachedVScale;
  104530. private _cachedUAng;
  104531. private _cachedVAng;
  104532. private _cachedWAng;
  104533. private _cachedProjectionMatrixId;
  104534. private _cachedURotationCenter;
  104535. private _cachedVRotationCenter;
  104536. private _cachedWRotationCenter;
  104537. private _cachedHomogeneousRotationInUVTransform;
  104538. private _cachedCoordinatesMode;
  104539. /** @hidden */
  104540. protected _initialSamplingMode: number;
  104541. /** @hidden */
  104542. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  104543. private _deleteBuffer;
  104544. protected _format: Nullable<number>;
  104545. private _delayedOnLoad;
  104546. private _delayedOnError;
  104547. private _mimeType?;
  104548. private _loaderOptions?;
  104549. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  104550. get mimeType(): string | undefined;
  104551. /**
  104552. * Observable triggered once the texture has been loaded.
  104553. */
  104554. onLoadObservable: Observable<Texture>;
  104555. protected _isBlocking: boolean;
  104556. /**
  104557. * Is the texture preventing material to render while loading.
  104558. * If false, a default texture will be used instead of the loading one during the preparation step.
  104559. */
  104560. set isBlocking(value: boolean);
  104561. get isBlocking(): boolean;
  104562. /**
  104563. * Get the current sampling mode associated with the texture.
  104564. */
  104565. get samplingMode(): number;
  104566. /**
  104567. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  104568. */
  104569. get invertY(): boolean;
  104570. /**
  104571. * Instantiates a new texture.
  104572. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104573. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104574. * @param url defines the url of the picture to load as a texture
  104575. * @param sceneOrEngine defines the scene or engine the texture will belong to
  104576. * @param noMipmap defines if the texture will require mip maps or not
  104577. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  104578. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104579. * @param onLoad defines a callback triggered when the texture has been loaded
  104580. * @param onError defines a callback triggered when an error occurred during the loading session
  104581. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  104582. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  104583. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104584. * @param mimeType defines an optional mime type information
  104585. * @param loaderOptions options to be passed to the loader
  104586. */
  104587. 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);
  104588. /**
  104589. * Update the url (and optional buffer) of this texture if url was null during construction.
  104590. * @param url the url of the texture
  104591. * @param buffer the buffer of the texture (defaults to null)
  104592. * @param onLoad callback called when the texture is loaded (defaults to null)
  104593. */
  104594. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  104595. /**
  104596. * Finish the loading sequence of a texture flagged as delayed load.
  104597. * @hidden
  104598. */
  104599. delayLoad(): void;
  104600. private _prepareRowForTextureGeneration;
  104601. /**
  104602. * Checks if the texture has the same transform matrix than another texture
  104603. * @param texture texture to check against
  104604. * @returns true if the transforms are the same, else false
  104605. */
  104606. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  104607. /**
  104608. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  104609. * @returns the transform matrix of the texture.
  104610. */
  104611. getTextureMatrix(uBase?: number): Matrix;
  104612. /**
  104613. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  104614. * @returns The reflection texture transform
  104615. */
  104616. getReflectionTextureMatrix(): Matrix;
  104617. /**
  104618. * Clones the texture.
  104619. * @returns the cloned texture
  104620. */
  104621. clone(): Texture;
  104622. /**
  104623. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104624. * @returns The JSON representation of the texture
  104625. */
  104626. serialize(): any;
  104627. /**
  104628. * Get the current class name of the texture useful for serialization or dynamic coding.
  104629. * @returns "Texture"
  104630. */
  104631. getClassName(): string;
  104632. /**
  104633. * Dispose the texture and release its associated resources.
  104634. */
  104635. dispose(): void;
  104636. /**
  104637. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  104638. * @param parsedTexture Define the JSON representation of the texture
  104639. * @param scene Define the scene the parsed texture should be instantiated in
  104640. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104641. * @returns The parsed texture if successful
  104642. */
  104643. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  104644. /**
  104645. * Creates a texture from its base 64 representation.
  104646. * @param data Define the base64 payload without the data: prefix
  104647. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104648. * @param scene Define the scene the texture should belong to
  104649. * @param noMipmap Forces the texture to not create mip map information if true
  104650. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104651. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104652. * @param onLoad define a callback triggered when the texture has been loaded
  104653. * @param onError define a callback triggered when an error occurred during the loading session
  104654. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104655. * @returns the created texture
  104656. */
  104657. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  104658. /**
  104659. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  104660. * @param data Define the base64 payload without the data: prefix
  104661. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104662. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  104663. * @param scene Define the scene the texture should belong to
  104664. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  104665. * @param noMipmap Forces the texture to not create mip map information if true
  104666. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104667. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104668. * @param onLoad define a callback triggered when the texture has been loaded
  104669. * @param onError define a callback triggered when an error occurred during the loading session
  104670. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104671. * @returns the created texture
  104672. */
  104673. 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;
  104674. }
  104675. }
  104676. declare module BABYLON {
  104677. /**
  104678. * ThinSprite Class used to represent a thin sprite
  104679. * This is the base class for sprites but can also directly be used with ThinEngine
  104680. * @see https://doc.babylonjs.com/babylon101/sprites
  104681. */
  104682. export class ThinSprite {
  104683. /** Gets or sets the cell index in the sprite sheet */
  104684. cellIndex: number;
  104685. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  104686. cellRef: string;
  104687. /** Gets or sets the current world position */
  104688. position: IVector3Like;
  104689. /** Gets or sets the main color */
  104690. color: IColor4Like;
  104691. /** Gets or sets the width */
  104692. width: number;
  104693. /** Gets or sets the height */
  104694. height: number;
  104695. /** Gets or sets rotation angle */
  104696. angle: number;
  104697. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  104698. invertU: boolean;
  104699. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  104700. invertV: boolean;
  104701. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  104702. isVisible: boolean;
  104703. /**
  104704. * Returns a boolean indicating if the animation is started
  104705. */
  104706. get animationStarted(): boolean;
  104707. /** Gets the initial key for the animation (setting it will restart the animation) */
  104708. get fromIndex(): number;
  104709. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  104710. get toIndex(): number;
  104711. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  104712. get loopAnimation(): boolean;
  104713. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  104714. get delay(): number;
  104715. /** @hidden */
  104716. _xOffset: number;
  104717. /** @hidden */
  104718. _yOffset: number;
  104719. /** @hidden */
  104720. _xSize: number;
  104721. /** @hidden */
  104722. _ySize: number;
  104723. private _animationStarted;
  104724. protected _loopAnimation: boolean;
  104725. protected _fromIndex: number;
  104726. protected _toIndex: number;
  104727. protected _delay: number;
  104728. private _direction;
  104729. private _time;
  104730. private _onBaseAnimationEnd;
  104731. /**
  104732. * Creates a new Thin Sprite
  104733. */
  104734. constructor();
  104735. /**
  104736. * Starts an animation
  104737. * @param from defines the initial key
  104738. * @param to defines the end key
  104739. * @param loop defines if the animation must loop
  104740. * @param delay defines the start delay (in ms)
  104741. * @param onAnimationEnd defines a callback for when the animation ends
  104742. */
  104743. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  104744. /** Stops current animation (if any) */
  104745. stopAnimation(): void;
  104746. /** @hidden */
  104747. _animate(deltaTime: number): void;
  104748. }
  104749. }
  104750. declare module BABYLON {
  104751. /** @hidden */
  104752. export var imageProcessingCompatibility: {
  104753. name: string;
  104754. shader: string;
  104755. };
  104756. }
  104757. declare module BABYLON {
  104758. /** @hidden */
  104759. export var spritesPixelShader: {
  104760. name: string;
  104761. shader: string;
  104762. };
  104763. }
  104764. declare module BABYLON {
  104765. /** @hidden */
  104766. export var spritesVertexShader: {
  104767. name: string;
  104768. shader: string;
  104769. };
  104770. }
  104771. declare module BABYLON {
  104772. /**
  104773. * Class used to render sprites.
  104774. *
  104775. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  104776. */
  104777. export class SpriteRenderer {
  104778. /**
  104779. * Defines the texture of the spritesheet
  104780. */
  104781. texture: Nullable<ThinTexture>;
  104782. /**
  104783. * Defines the default width of a cell in the spritesheet
  104784. */
  104785. cellWidth: number;
  104786. /**
  104787. * Defines the default height of a cell in the spritesheet
  104788. */
  104789. cellHeight: number;
  104790. /**
  104791. * Blend mode use to render the particle, it can be any of
  104792. * the static Constants.ALPHA_x properties provided in this class.
  104793. * Default value is Constants.ALPHA_COMBINE
  104794. */
  104795. blendMode: number;
  104796. /**
  104797. * Gets or sets a boolean indicating if alpha mode is automatically
  104798. * reset.
  104799. */
  104800. autoResetAlpha: boolean;
  104801. /**
  104802. * Disables writing to the depth buffer when rendering the sprites.
  104803. * It can be handy to disable depth writing when using textures without alpha channel
  104804. * and setting some specific blend modes.
  104805. */
  104806. disableDepthWrite: boolean;
  104807. /**
  104808. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  104809. */
  104810. fogEnabled: boolean;
  104811. /**
  104812. * Gets the capacity of the manager
  104813. */
  104814. get capacity(): number;
  104815. private readonly _engine;
  104816. private readonly _useVAO;
  104817. private readonly _useInstancing;
  104818. private readonly _scene;
  104819. private readonly _capacity;
  104820. private readonly _epsilon;
  104821. private _vertexBufferSize;
  104822. private _vertexData;
  104823. private _buffer;
  104824. private _vertexBuffers;
  104825. private _spriteBuffer;
  104826. private _indexBuffer;
  104827. private _effectBase;
  104828. private _effectFog;
  104829. private _vertexArrayObject;
  104830. /**
  104831. * Creates a new sprite Renderer
  104832. * @param engine defines the engine the renderer works with
  104833. * @param capacity defines the maximum allowed number of sprites
  104834. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  104835. * @param scene defines the hosting scene
  104836. */
  104837. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  104838. /**
  104839. * Render all child sprites
  104840. * @param sprites defines the list of sprites to render
  104841. * @param deltaTime defines the time since last frame
  104842. * @param viewMatrix defines the viewMatrix to use to render the sprites
  104843. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  104844. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  104845. */
  104846. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  104847. private _appendSpriteVertex;
  104848. /**
  104849. * Release associated resources
  104850. */
  104851. dispose(): void;
  104852. }
  104853. }
  104854. declare module BABYLON {
  104855. /**
  104856. * Defines the minimum interface to fullfil in order to be a sprite manager.
  104857. */
  104858. export interface ISpriteManager extends IDisposable {
  104859. /**
  104860. * Gets manager's name
  104861. */
  104862. name: string;
  104863. /**
  104864. * Restricts the camera to viewing objects with the same layerMask.
  104865. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  104866. */
  104867. layerMask: number;
  104868. /**
  104869. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  104870. */
  104871. isPickable: boolean;
  104872. /**
  104873. * Gets the hosting scene
  104874. */
  104875. scene: Scene;
  104876. /**
  104877. * Specifies the rendering group id for this mesh (0 by default)
  104878. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  104879. */
  104880. renderingGroupId: number;
  104881. /**
  104882. * Defines the list of sprites managed by the manager.
  104883. */
  104884. sprites: Array<Sprite>;
  104885. /**
  104886. * Gets or sets the spritesheet texture
  104887. */
  104888. texture: Texture;
  104889. /** Defines the default width of a cell in the spritesheet */
  104890. cellWidth: number;
  104891. /** Defines the default height of a cell in the spritesheet */
  104892. cellHeight: number;
  104893. /**
  104894. * Tests the intersection of a sprite with a specific ray.
  104895. * @param ray The ray we are sending to test the collision
  104896. * @param camera The camera space we are sending rays in
  104897. * @param predicate A predicate allowing excluding sprites from the list of object to test
  104898. * @param fastCheck defines if the first intersection will be used (and not the closest)
  104899. * @returns picking info or null.
  104900. */
  104901. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  104902. /**
  104903. * Intersects the sprites with a ray
  104904. * @param ray defines the ray to intersect with
  104905. * @param camera defines the current active camera
  104906. * @param predicate defines a predicate used to select candidate sprites
  104907. * @returns null if no hit or a PickingInfo array
  104908. */
  104909. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  104910. /**
  104911. * Renders the list of sprites on screen.
  104912. */
  104913. render(): void;
  104914. }
  104915. /**
  104916. * Class used to manage multiple sprites on the same spritesheet
  104917. * @see https://doc.babylonjs.com/babylon101/sprites
  104918. */
  104919. export class SpriteManager implements ISpriteManager {
  104920. /** defines the manager's name */
  104921. name: string;
  104922. /** Define the Url to load snippets */
  104923. static SnippetUrl: string;
  104924. /** Snippet ID if the manager was created from the snippet server */
  104925. snippetId: string;
  104926. /** Gets the list of sprites */
  104927. sprites: Sprite[];
  104928. /** Gets or sets the rendering group id (0 by default) */
  104929. renderingGroupId: number;
  104930. /** Gets or sets camera layer mask */
  104931. layerMask: number;
  104932. /** Gets or sets a boolean indicating if the sprites are pickable */
  104933. isPickable: boolean;
  104934. /**
  104935. * An event triggered when the manager is disposed.
  104936. */
  104937. onDisposeObservable: Observable<SpriteManager>;
  104938. /**
  104939. * Callback called when the manager is disposed
  104940. */
  104941. set onDispose(callback: () => void);
  104942. /**
  104943. * Gets or sets the unique id of the sprite
  104944. */
  104945. uniqueId: number;
  104946. /**
  104947. * Gets the array of sprites
  104948. */
  104949. get children(): Sprite[];
  104950. /**
  104951. * Gets the hosting scene
  104952. */
  104953. get scene(): Scene;
  104954. /**
  104955. * Gets the capacity of the manager
  104956. */
  104957. get capacity(): number;
  104958. /**
  104959. * Gets or sets the spritesheet texture
  104960. */
  104961. get texture(): Texture;
  104962. set texture(value: Texture);
  104963. /** Defines the default width of a cell in the spritesheet */
  104964. get cellWidth(): number;
  104965. set cellWidth(value: number);
  104966. /** Defines the default height of a cell in the spritesheet */
  104967. get cellHeight(): number;
  104968. set cellHeight(value: number);
  104969. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  104970. get fogEnabled(): boolean;
  104971. set fogEnabled(value: boolean);
  104972. /**
  104973. * Blend mode use to render the particle, it can be any of
  104974. * the static Constants.ALPHA_x properties provided in this class.
  104975. * Default value is Constants.ALPHA_COMBINE
  104976. */
  104977. get blendMode(): number;
  104978. set blendMode(blendMode: number);
  104979. /** Disables writing to the depth buffer when rendering the sprites.
  104980. * It can be handy to disable depth writing when using textures without alpha channel
  104981. * and setting some specific blend modes.
  104982. */
  104983. disableDepthWrite: boolean;
  104984. private _spriteRenderer;
  104985. /** Associative array from JSON sprite data file */
  104986. private _cellData;
  104987. /** Array of sprite names from JSON sprite data file */
  104988. private _spriteMap;
  104989. /** True when packed cell data from JSON file is ready*/
  104990. private _packedAndReady;
  104991. private _textureContent;
  104992. private _onDisposeObserver;
  104993. private _fromPacked;
  104994. private _scene;
  104995. /**
  104996. * Creates a new sprite manager
  104997. * @param name defines the manager's name
  104998. * @param imgUrl defines the sprite sheet url
  104999. * @param capacity defines the maximum allowed number of sprites
  105000. * @param cellSize defines the size of a sprite cell
  105001. * @param scene defines the hosting scene
  105002. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  105003. * @param samplingMode defines the smapling mode to use with spritesheet
  105004. * @param fromPacked set to false; do not alter
  105005. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  105006. */
  105007. constructor(
  105008. /** defines the manager's name */
  105009. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  105010. /**
  105011. * Returns the string "SpriteManager"
  105012. * @returns "SpriteManager"
  105013. */
  105014. getClassName(): string;
  105015. private _makePacked;
  105016. private _checkTextureAlpha;
  105017. /**
  105018. * Intersects the sprites with a ray
  105019. * @param ray defines the ray to intersect with
  105020. * @param camera defines the current active camera
  105021. * @param predicate defines a predicate used to select candidate sprites
  105022. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  105023. * @returns null if no hit or a PickingInfo
  105024. */
  105025. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  105026. /**
  105027. * Intersects the sprites with a ray
  105028. * @param ray defines the ray to intersect with
  105029. * @param camera defines the current active camera
  105030. * @param predicate defines a predicate used to select candidate sprites
  105031. * @returns null if no hit or a PickingInfo array
  105032. */
  105033. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  105034. /**
  105035. * Render all child sprites
  105036. */
  105037. render(): void;
  105038. private _customUpdate;
  105039. /**
  105040. * Release associated resources
  105041. */
  105042. dispose(): void;
  105043. /**
  105044. * Serializes the sprite manager to a JSON object
  105045. * @param serializeTexture defines if the texture must be serialized as well
  105046. * @returns the JSON object
  105047. */
  105048. serialize(serializeTexture?: boolean): any;
  105049. /**
  105050. * Parses a JSON object to create a new sprite manager.
  105051. * @param parsedManager The JSON object to parse
  105052. * @param scene The scene to create the sprite managerin
  105053. * @param rootUrl The root url to use to load external dependencies like texture
  105054. * @returns the new sprite manager
  105055. */
  105056. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  105057. /**
  105058. * Creates a sprite manager from a snippet saved in a remote file
  105059. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  105060. * @param url defines the url to load from
  105061. * @param scene defines the hosting scene
  105062. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105063. * @returns a promise that will resolve to the new sprite manager
  105064. */
  105065. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  105066. /**
  105067. * Creates a sprite manager from a snippet saved by the sprite editor
  105068. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  105069. * @param scene defines the hosting scene
  105070. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105071. * @returns a promise that will resolve to the new sprite manager
  105072. */
  105073. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  105074. }
  105075. }
  105076. declare module BABYLON {
  105077. /**
  105078. * Class used to represent a sprite
  105079. * @see https://doc.babylonjs.com/babylon101/sprites
  105080. */
  105081. export class Sprite extends ThinSprite implements IAnimatable {
  105082. /** defines the name */
  105083. name: string;
  105084. /** Gets or sets the current world position */
  105085. position: Vector3;
  105086. /** Gets or sets the main color */
  105087. color: Color4;
  105088. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  105089. disposeWhenFinishedAnimating: boolean;
  105090. /** Gets the list of attached animations */
  105091. animations: Nullable<Array<Animation>>;
  105092. /** Gets or sets a boolean indicating if the sprite can be picked */
  105093. isPickable: boolean;
  105094. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  105095. useAlphaForPicking: boolean;
  105096. /**
  105097. * Gets or sets the associated action manager
  105098. */
  105099. actionManager: Nullable<ActionManager>;
  105100. /**
  105101. * An event triggered when the control has been disposed
  105102. */
  105103. onDisposeObservable: Observable<Sprite>;
  105104. private _manager;
  105105. private _onAnimationEnd;
  105106. /**
  105107. * Gets or sets the sprite size
  105108. */
  105109. get size(): number;
  105110. set size(value: number);
  105111. /**
  105112. * Gets or sets the unique id of the sprite
  105113. */
  105114. uniqueId: number;
  105115. /**
  105116. * Gets the manager of this sprite
  105117. */
  105118. get manager(): ISpriteManager;
  105119. /**
  105120. * Creates a new Sprite
  105121. * @param name defines the name
  105122. * @param manager defines the manager
  105123. */
  105124. constructor(
  105125. /** defines the name */
  105126. name: string, manager: ISpriteManager);
  105127. /**
  105128. * Returns the string "Sprite"
  105129. * @returns "Sprite"
  105130. */
  105131. getClassName(): string;
  105132. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  105133. get fromIndex(): number;
  105134. set fromIndex(value: number);
  105135. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  105136. get toIndex(): number;
  105137. set toIndex(value: number);
  105138. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  105139. get loopAnimation(): boolean;
  105140. set loopAnimation(value: boolean);
  105141. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  105142. get delay(): number;
  105143. set delay(value: number);
  105144. /**
  105145. * Starts an animation
  105146. * @param from defines the initial key
  105147. * @param to defines the end key
  105148. * @param loop defines if the animation must loop
  105149. * @param delay defines the start delay (in ms)
  105150. * @param onAnimationEnd defines a callback to call when animation ends
  105151. */
  105152. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  105153. private _endAnimation;
  105154. /** Release associated resources */
  105155. dispose(): void;
  105156. /**
  105157. * Serializes the sprite to a JSON object
  105158. * @returns the JSON object
  105159. */
  105160. serialize(): any;
  105161. /**
  105162. * Parses a JSON object to create a new sprite
  105163. * @param parsedSprite The JSON object to parse
  105164. * @param manager defines the hosting manager
  105165. * @returns the new sprite
  105166. */
  105167. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  105168. }
  105169. }
  105170. declare module BABYLON {
  105171. /**
  105172. * Information about the result of picking within a scene
  105173. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  105174. */
  105175. export class PickingInfo {
  105176. /** @hidden */
  105177. _pickingUnavailable: boolean;
  105178. /**
  105179. * If the pick collided with an object
  105180. */
  105181. hit: boolean;
  105182. /**
  105183. * Distance away where the pick collided
  105184. */
  105185. distance: number;
  105186. /**
  105187. * The location of pick collision
  105188. */
  105189. pickedPoint: Nullable<Vector3>;
  105190. /**
  105191. * The mesh corresponding the the pick collision
  105192. */
  105193. pickedMesh: Nullable<AbstractMesh>;
  105194. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  105195. bu: number;
  105196. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  105197. bv: number;
  105198. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  105199. faceId: number;
  105200. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  105201. subMeshFaceId: number;
  105202. /** Id of the the submesh that was picked */
  105203. subMeshId: number;
  105204. /** If a sprite was picked, this will be the sprite the pick collided with */
  105205. pickedSprite: Nullable<Sprite>;
  105206. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  105207. thinInstanceIndex: number;
  105208. /**
  105209. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  105210. */
  105211. originMesh: Nullable<AbstractMesh>;
  105212. /**
  105213. * The ray that was used to perform the picking.
  105214. */
  105215. ray: Nullable<Ray>;
  105216. /**
  105217. * Gets the normal correspodning to the face the pick collided with
  105218. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  105219. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  105220. * @returns The normal correspodning to the face the pick collided with
  105221. */
  105222. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  105223. /**
  105224. * Gets the texture coordinates of where the pick occured
  105225. * @returns the vector containing the coordnates of the texture
  105226. */
  105227. getTextureCoordinates(): Nullable<Vector2>;
  105228. }
  105229. }
  105230. declare module BABYLON {
  105231. /**
  105232. * Gather the list of pointer event types as constants.
  105233. */
  105234. export class PointerEventTypes {
  105235. /**
  105236. * 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.
  105237. */
  105238. static readonly POINTERDOWN: number;
  105239. /**
  105240. * The pointerup event is fired when a pointer is no longer active.
  105241. */
  105242. static readonly POINTERUP: number;
  105243. /**
  105244. * The pointermove event is fired when a pointer changes coordinates.
  105245. */
  105246. static readonly POINTERMOVE: number;
  105247. /**
  105248. * The pointerwheel event is fired when a mouse wheel has been rotated.
  105249. */
  105250. static readonly POINTERWHEEL: number;
  105251. /**
  105252. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  105253. */
  105254. static readonly POINTERPICK: number;
  105255. /**
  105256. * The pointertap event is fired when a the object has been touched and released without drag.
  105257. */
  105258. static readonly POINTERTAP: number;
  105259. /**
  105260. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  105261. */
  105262. static readonly POINTERDOUBLETAP: number;
  105263. }
  105264. /**
  105265. * Base class of pointer info types.
  105266. */
  105267. export class PointerInfoBase {
  105268. /**
  105269. * Defines the type of event (PointerEventTypes)
  105270. */
  105271. type: number;
  105272. /**
  105273. * Defines the related dom event
  105274. */
  105275. event: PointerEvent | MouseWheelEvent;
  105276. /**
  105277. * Instantiates the base class of pointers info.
  105278. * @param type Defines the type of event (PointerEventTypes)
  105279. * @param event Defines the related dom event
  105280. */
  105281. constructor(
  105282. /**
  105283. * Defines the type of event (PointerEventTypes)
  105284. */
  105285. type: number,
  105286. /**
  105287. * Defines the related dom event
  105288. */
  105289. event: PointerEvent | MouseWheelEvent);
  105290. }
  105291. /**
  105292. * This class is used to store pointer related info for the onPrePointerObservable event.
  105293. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  105294. */
  105295. export class PointerInfoPre extends PointerInfoBase {
  105296. /**
  105297. * Ray from a pointer if availible (eg. 6dof controller)
  105298. */
  105299. ray: Nullable<Ray>;
  105300. /**
  105301. * Defines the local position of the pointer on the canvas.
  105302. */
  105303. localPosition: Vector2;
  105304. /**
  105305. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  105306. */
  105307. skipOnPointerObservable: boolean;
  105308. /**
  105309. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  105310. * @param type Defines the type of event (PointerEventTypes)
  105311. * @param event Defines the related dom event
  105312. * @param localX Defines the local x coordinates of the pointer when the event occured
  105313. * @param localY Defines the local y coordinates of the pointer when the event occured
  105314. */
  105315. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  105316. }
  105317. /**
  105318. * This type contains all the data related to a pointer event in Babylon.js.
  105319. * 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.
  105320. */
  105321. export class PointerInfo extends PointerInfoBase {
  105322. /**
  105323. * Defines the picking info associated to the info (if any)\
  105324. */
  105325. pickInfo: Nullable<PickingInfo>;
  105326. /**
  105327. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  105328. * @param type Defines the type of event (PointerEventTypes)
  105329. * @param event Defines the related dom event
  105330. * @param pickInfo Defines the picking info associated to the info (if any)\
  105331. */
  105332. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  105333. /**
  105334. * Defines the picking info associated to the info (if any)\
  105335. */
  105336. pickInfo: Nullable<PickingInfo>);
  105337. }
  105338. /**
  105339. * Data relating to a touch event on the screen.
  105340. */
  105341. export interface PointerTouch {
  105342. /**
  105343. * X coordinate of touch.
  105344. */
  105345. x: number;
  105346. /**
  105347. * Y coordinate of touch.
  105348. */
  105349. y: number;
  105350. /**
  105351. * Id of touch. Unique for each finger.
  105352. */
  105353. pointerId: number;
  105354. /**
  105355. * Event type passed from DOM.
  105356. */
  105357. type: any;
  105358. }
  105359. }
  105360. declare module BABYLON {
  105361. /**
  105362. * Manage the mouse inputs to control the movement of a free camera.
  105363. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105364. */
  105365. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  105366. /**
  105367. * Define if touch is enabled in the mouse input
  105368. */
  105369. touchEnabled: boolean;
  105370. /**
  105371. * Defines the camera the input is attached to.
  105372. */
  105373. camera: FreeCamera;
  105374. /**
  105375. * Defines the buttons associated with the input to handle camera move.
  105376. */
  105377. buttons: number[];
  105378. /**
  105379. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  105380. */
  105381. angularSensibility: number;
  105382. private _pointerInput;
  105383. private _onMouseMove;
  105384. private _observer;
  105385. private previousPosition;
  105386. /**
  105387. * Observable for when a pointer move event occurs containing the move offset
  105388. */
  105389. onPointerMovedObservable: Observable<{
  105390. offsetX: number;
  105391. offsetY: number;
  105392. }>;
  105393. /**
  105394. * @hidden
  105395. * If the camera should be rotated automatically based on pointer movement
  105396. */
  105397. _allowCameraRotation: boolean;
  105398. /**
  105399. * Manage the mouse inputs to control the movement of a free camera.
  105400. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105401. * @param touchEnabled Defines if touch is enabled or not
  105402. */
  105403. constructor(
  105404. /**
  105405. * Define if touch is enabled in the mouse input
  105406. */
  105407. touchEnabled?: boolean);
  105408. /**
  105409. * Attach the input controls to a specific dom element to get the input from.
  105410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105411. */
  105412. attachControl(noPreventDefault?: boolean): void;
  105413. /**
  105414. * Called on JS contextmenu event.
  105415. * Override this method to provide functionality.
  105416. */
  105417. protected onContextMenu(evt: PointerEvent): void;
  105418. /**
  105419. * Detach the current controls from the specified dom element.
  105420. */
  105421. detachControl(): void;
  105422. /**
  105423. * Gets the class name of the current intput.
  105424. * @returns the class name
  105425. */
  105426. getClassName(): string;
  105427. /**
  105428. * Get the friendly name associated with the input class.
  105429. * @returns the input friendly name
  105430. */
  105431. getSimpleName(): string;
  105432. }
  105433. }
  105434. declare module BABYLON {
  105435. /**
  105436. * Base class for mouse wheel input..
  105437. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  105438. * for example usage.
  105439. */
  105440. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  105441. /**
  105442. * Defines the camera the input is attached to.
  105443. */
  105444. abstract camera: Camera;
  105445. /**
  105446. * How fast is the camera moves in relation to X axis mouseWheel events.
  105447. * Use negative value to reverse direction.
  105448. */
  105449. wheelPrecisionX: number;
  105450. /**
  105451. * How fast is the camera moves in relation to Y axis mouseWheel events.
  105452. * Use negative value to reverse direction.
  105453. */
  105454. wheelPrecisionY: number;
  105455. /**
  105456. * How fast is the camera moves in relation to Z axis mouseWheel events.
  105457. * Use negative value to reverse direction.
  105458. */
  105459. wheelPrecisionZ: number;
  105460. /**
  105461. * Observable for when a mouse wheel move event occurs.
  105462. */
  105463. onChangedObservable: Observable<{
  105464. wheelDeltaX: number;
  105465. wheelDeltaY: number;
  105466. wheelDeltaZ: number;
  105467. }>;
  105468. private _wheel;
  105469. private _observer;
  105470. /**
  105471. * Attach the input controls to a specific dom element to get the input from.
  105472. * @param noPreventDefault Defines whether event caught by the controls
  105473. * should call preventdefault().
  105474. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105475. */
  105476. attachControl(noPreventDefault?: boolean): void;
  105477. /**
  105478. * Detach the current controls from the specified dom element.
  105479. */
  105480. detachControl(): void;
  105481. /**
  105482. * Called for each rendered frame.
  105483. */
  105484. checkInputs(): void;
  105485. /**
  105486. * Gets the class name of the current intput.
  105487. * @returns the class name
  105488. */
  105489. getClassName(): string;
  105490. /**
  105491. * Get the friendly name associated with the input class.
  105492. * @returns the input friendly name
  105493. */
  105494. getSimpleName(): string;
  105495. /**
  105496. * Incremental value of multiple mouse wheel movements of the X axis.
  105497. * Should be zero-ed when read.
  105498. */
  105499. protected _wheelDeltaX: number;
  105500. /**
  105501. * Incremental value of multiple mouse wheel movements of the Y axis.
  105502. * Should be zero-ed when read.
  105503. */
  105504. protected _wheelDeltaY: number;
  105505. /**
  105506. * Incremental value of multiple mouse wheel movements of the Z axis.
  105507. * Should be zero-ed when read.
  105508. */
  105509. protected _wheelDeltaZ: number;
  105510. /**
  105511. * Firefox uses a different scheme to report scroll distances to other
  105512. * browsers. Rather than use complicated methods to calculate the exact
  105513. * multiple we need to apply, let's just cheat and use a constant.
  105514. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  105515. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  105516. */
  105517. private readonly _ffMultiplier;
  105518. /**
  105519. * Different event attributes for wheel data fall into a few set ranges.
  105520. * Some relevant but dated date here:
  105521. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  105522. */
  105523. private readonly _normalize;
  105524. }
  105525. }
  105526. declare module BABYLON {
  105527. /**
  105528. * Manage the mouse wheel inputs to control a free camera.
  105529. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105530. */
  105531. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  105532. /**
  105533. * Defines the camera the input is attached to.
  105534. */
  105535. camera: FreeCamera;
  105536. /**
  105537. * Gets the class name of the current input.
  105538. * @returns the class name
  105539. */
  105540. getClassName(): string;
  105541. /**
  105542. * Set which movement axis (relative to camera's orientation) the mouse
  105543. * wheel's X axis controls.
  105544. * @param axis The axis to be moved. Set null to clear.
  105545. */
  105546. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  105547. /**
  105548. * Get the configured movement axis (relative to camera's orientation) the
  105549. * mouse wheel's X axis controls.
  105550. * @returns The configured axis or null if none.
  105551. */
  105552. get wheelXMoveRelative(): Nullable<Coordinate>;
  105553. /**
  105554. * Set which movement axis (relative to camera's orientation) the mouse
  105555. * wheel's Y axis controls.
  105556. * @param axis The axis to be moved. Set null to clear.
  105557. */
  105558. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  105559. /**
  105560. * Get the configured movement axis (relative to camera's orientation) the
  105561. * mouse wheel's Y axis controls.
  105562. * @returns The configured axis or null if none.
  105563. */
  105564. get wheelYMoveRelative(): Nullable<Coordinate>;
  105565. /**
  105566. * Set which movement axis (relative to camera's orientation) the mouse
  105567. * wheel's Z axis controls.
  105568. * @param axis The axis to be moved. Set null to clear.
  105569. */
  105570. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  105571. /**
  105572. * Get the configured movement axis (relative to camera's orientation) the
  105573. * mouse wheel's Z axis controls.
  105574. * @returns The configured axis or null if none.
  105575. */
  105576. get wheelZMoveRelative(): Nullable<Coordinate>;
  105577. /**
  105578. * Set which rotation axis (relative to camera's orientation) the mouse
  105579. * wheel's X axis controls.
  105580. * @param axis The axis to be moved. Set null to clear.
  105581. */
  105582. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  105583. /**
  105584. * Get the configured rotation axis (relative to camera's orientation) the
  105585. * mouse wheel's X axis controls.
  105586. * @returns The configured axis or null if none.
  105587. */
  105588. get wheelXRotateRelative(): Nullable<Coordinate>;
  105589. /**
  105590. * Set which rotation axis (relative to camera's orientation) the mouse
  105591. * wheel's Y axis controls.
  105592. * @param axis The axis to be moved. Set null to clear.
  105593. */
  105594. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  105595. /**
  105596. * Get the configured rotation axis (relative to camera's orientation) the
  105597. * mouse wheel's Y axis controls.
  105598. * @returns The configured axis or null if none.
  105599. */
  105600. get wheelYRotateRelative(): Nullable<Coordinate>;
  105601. /**
  105602. * Set which rotation axis (relative to camera's orientation) the mouse
  105603. * wheel's Z axis controls.
  105604. * @param axis The axis to be moved. Set null to clear.
  105605. */
  105606. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  105607. /**
  105608. * Get the configured rotation axis (relative to camera's orientation) the
  105609. * mouse wheel's Z axis controls.
  105610. * @returns The configured axis or null if none.
  105611. */
  105612. get wheelZRotateRelative(): Nullable<Coordinate>;
  105613. /**
  105614. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  105615. * controls.
  105616. * @param axis The axis to be moved. Set null to clear.
  105617. */
  105618. set wheelXMoveScene(axis: Nullable<Coordinate>);
  105619. /**
  105620. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105621. * X axis controls.
  105622. * @returns The configured axis or null if none.
  105623. */
  105624. get wheelXMoveScene(): Nullable<Coordinate>;
  105625. /**
  105626. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  105627. * controls.
  105628. * @param axis The axis to be moved. Set null to clear.
  105629. */
  105630. set wheelYMoveScene(axis: Nullable<Coordinate>);
  105631. /**
  105632. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105633. * Y axis controls.
  105634. * @returns The configured axis or null if none.
  105635. */
  105636. get wheelYMoveScene(): Nullable<Coordinate>;
  105637. /**
  105638. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  105639. * controls.
  105640. * @param axis The axis to be moved. Set null to clear.
  105641. */
  105642. set wheelZMoveScene(axis: Nullable<Coordinate>);
  105643. /**
  105644. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105645. * Z axis controls.
  105646. * @returns The configured axis or null if none.
  105647. */
  105648. get wheelZMoveScene(): Nullable<Coordinate>;
  105649. /**
  105650. * Called for each rendered frame.
  105651. */
  105652. checkInputs(): void;
  105653. private _moveRelative;
  105654. private _rotateRelative;
  105655. private _moveScene;
  105656. /**
  105657. * These are set to the desired default behaviour.
  105658. */
  105659. private _wheelXAction;
  105660. private _wheelXActionCoordinate;
  105661. private _wheelYAction;
  105662. private _wheelYActionCoordinate;
  105663. private _wheelZAction;
  105664. private _wheelZActionCoordinate;
  105665. /**
  105666. * Update the camera according to any configured properties for the 3
  105667. * mouse-wheel axis.
  105668. */
  105669. private _updateCamera;
  105670. }
  105671. }
  105672. declare module BABYLON {
  105673. /**
  105674. * Manage the touch inputs to control the movement of a free camera.
  105675. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105676. */
  105677. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  105678. /**
  105679. * Define if mouse events can be treated as touch events
  105680. */
  105681. allowMouse: boolean;
  105682. /**
  105683. * Defines the camera the input is attached to.
  105684. */
  105685. camera: FreeCamera;
  105686. /**
  105687. * Defines the touch sensibility for rotation.
  105688. * The higher the faster.
  105689. */
  105690. touchAngularSensibility: number;
  105691. /**
  105692. * Defines the touch sensibility for move.
  105693. * The higher the faster.
  105694. */
  105695. touchMoveSensibility: number;
  105696. private _offsetX;
  105697. private _offsetY;
  105698. private _pointerPressed;
  105699. private _pointerInput?;
  105700. private _observer;
  105701. private _onLostFocus;
  105702. /**
  105703. * Manage the touch inputs to control the movement of a free camera.
  105704. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105705. * @param allowMouse Defines if mouse events can be treated as touch events
  105706. */
  105707. constructor(
  105708. /**
  105709. * Define if mouse events can be treated as touch events
  105710. */
  105711. allowMouse?: boolean);
  105712. /**
  105713. * Attach the input controls to a specific dom element to get the input from.
  105714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105715. */
  105716. attachControl(noPreventDefault?: boolean): void;
  105717. /**
  105718. * Detach the current controls from the specified dom element.
  105719. */
  105720. detachControl(): void;
  105721. /**
  105722. * Update the current camera state depending on the inputs that have been used this frame.
  105723. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105724. */
  105725. checkInputs(): void;
  105726. /**
  105727. * Gets the class name of the current intput.
  105728. * @returns the class name
  105729. */
  105730. getClassName(): string;
  105731. /**
  105732. * Get the friendly name associated with the input class.
  105733. * @returns the input friendly name
  105734. */
  105735. getSimpleName(): string;
  105736. }
  105737. }
  105738. declare module BABYLON {
  105739. /**
  105740. * Default Inputs manager for the FreeCamera.
  105741. * It groups all the default supported inputs for ease of use.
  105742. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105743. */
  105744. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  105745. /**
  105746. * @hidden
  105747. */
  105748. _mouseInput: Nullable<FreeCameraMouseInput>;
  105749. /**
  105750. * @hidden
  105751. */
  105752. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  105753. /**
  105754. * Instantiates a new FreeCameraInputsManager.
  105755. * @param camera Defines the camera the inputs belong to
  105756. */
  105757. constructor(camera: FreeCamera);
  105758. /**
  105759. * Add keyboard input support to the input manager.
  105760. * @returns the current input manager
  105761. */
  105762. addKeyboard(): FreeCameraInputsManager;
  105763. /**
  105764. * Add mouse input support to the input manager.
  105765. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  105766. * @returns the current input manager
  105767. */
  105768. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  105769. /**
  105770. * Removes the mouse input support from the manager
  105771. * @returns the current input manager
  105772. */
  105773. removeMouse(): FreeCameraInputsManager;
  105774. /**
  105775. * Add mouse wheel input support to the input manager.
  105776. * @returns the current input manager
  105777. */
  105778. addMouseWheel(): FreeCameraInputsManager;
  105779. /**
  105780. * Removes the mouse wheel input support from the manager
  105781. * @returns the current input manager
  105782. */
  105783. removeMouseWheel(): FreeCameraInputsManager;
  105784. /**
  105785. * Add touch input support to the input manager.
  105786. * @returns the current input manager
  105787. */
  105788. addTouch(): FreeCameraInputsManager;
  105789. /**
  105790. * Remove all attached input methods from a camera
  105791. */
  105792. clear(): void;
  105793. }
  105794. }
  105795. declare module BABYLON {
  105796. /**
  105797. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105798. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  105799. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  105800. */
  105801. export class FreeCamera extends TargetCamera {
  105802. /**
  105803. * Define the collision ellipsoid of the camera.
  105804. * This is helpful to simulate a camera body like the player body around the camera
  105805. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105806. */
  105807. ellipsoid: Vector3;
  105808. /**
  105809. * Define an offset for the position of the ellipsoid around the camera.
  105810. * This can be helpful to determine the center of the body near the gravity center of the body
  105811. * instead of its head.
  105812. */
  105813. ellipsoidOffset: Vector3;
  105814. /**
  105815. * Enable or disable collisions of the camera with the rest of the scene objects.
  105816. */
  105817. checkCollisions: boolean;
  105818. /**
  105819. * Enable or disable gravity on the camera.
  105820. */
  105821. applyGravity: boolean;
  105822. /**
  105823. * Define the input manager associated to the camera.
  105824. */
  105825. inputs: FreeCameraInputsManager;
  105826. /**
  105827. * Gets the input sensibility for a mouse input. (default is 2000.0)
  105828. * Higher values reduce sensitivity.
  105829. */
  105830. get angularSensibility(): number;
  105831. /**
  105832. * Sets the input sensibility for a mouse input. (default is 2000.0)
  105833. * Higher values reduce sensitivity.
  105834. */
  105835. set angularSensibility(value: number);
  105836. /**
  105837. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  105838. */
  105839. get keysUp(): number[];
  105840. set keysUp(value: number[]);
  105841. /**
  105842. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  105843. */
  105844. get keysUpward(): number[];
  105845. set keysUpward(value: number[]);
  105846. /**
  105847. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  105848. */
  105849. get keysDown(): number[];
  105850. set keysDown(value: number[]);
  105851. /**
  105852. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  105853. */
  105854. get keysDownward(): number[];
  105855. set keysDownward(value: number[]);
  105856. /**
  105857. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  105858. */
  105859. get keysLeft(): number[];
  105860. set keysLeft(value: number[]);
  105861. /**
  105862. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  105863. */
  105864. get keysRight(): number[];
  105865. set keysRight(value: number[]);
  105866. /**
  105867. * Event raised when the camera collide with a mesh in the scene.
  105868. */
  105869. onCollide: (collidedMesh: AbstractMesh) => void;
  105870. private _collider;
  105871. private _needMoveForGravity;
  105872. private _oldPosition;
  105873. private _diffPosition;
  105874. private _newPosition;
  105875. /** @hidden */
  105876. _localDirection: Vector3;
  105877. /** @hidden */
  105878. _transformedDirection: Vector3;
  105879. /**
  105880. * Instantiates a Free Camera.
  105881. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105882. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  105883. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  105884. * @param name Define the name of the camera in the scene
  105885. * @param position Define the start position of the camera in the scene
  105886. * @param scene Define the scene the camera belongs to
  105887. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  105888. */
  105889. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  105890. /**
  105891. * Attach the input controls to a specific dom element to get the input from.
  105892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105893. */
  105894. attachControl(noPreventDefault?: boolean): void;
  105895. /**
  105896. * Attach the input controls to a specific dom element to get the input from.
  105897. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  105898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105899. * BACK COMPAT SIGNATURE ONLY.
  105900. */
  105901. attachControl(ignored: any, noPreventDefault?: boolean): void;
  105902. /**
  105903. * Detach the current controls from the specified dom element.
  105904. */
  105905. detachControl(): void;
  105906. /**
  105907. * Detach the current controls from the specified dom element.
  105908. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  105909. */
  105910. detachControl(ignored: any): void;
  105911. private _collisionMask;
  105912. /**
  105913. * Define a collision mask to limit the list of object the camera can collide with
  105914. */
  105915. get collisionMask(): number;
  105916. set collisionMask(mask: number);
  105917. /** @hidden */
  105918. _collideWithWorld(displacement: Vector3): void;
  105919. private _onCollisionPositionChange;
  105920. /** @hidden */
  105921. _checkInputs(): void;
  105922. /** @hidden */
  105923. _decideIfNeedsToMove(): boolean;
  105924. /** @hidden */
  105925. _updatePosition(): void;
  105926. /**
  105927. * Destroy the camera and release the current resources hold by it.
  105928. */
  105929. dispose(): void;
  105930. /**
  105931. * Gets the current object class name.
  105932. * @return the class name
  105933. */
  105934. getClassName(): string;
  105935. }
  105936. }
  105937. declare module BABYLON {
  105938. /**
  105939. * Represents a gamepad control stick position
  105940. */
  105941. export class StickValues {
  105942. /**
  105943. * The x component of the control stick
  105944. */
  105945. x: number;
  105946. /**
  105947. * The y component of the control stick
  105948. */
  105949. y: number;
  105950. /**
  105951. * Initializes the gamepad x and y control stick values
  105952. * @param x The x component of the gamepad control stick value
  105953. * @param y The y component of the gamepad control stick value
  105954. */
  105955. constructor(
  105956. /**
  105957. * The x component of the control stick
  105958. */
  105959. x: number,
  105960. /**
  105961. * The y component of the control stick
  105962. */
  105963. y: number);
  105964. }
  105965. /**
  105966. * An interface which manages callbacks for gamepad button changes
  105967. */
  105968. export interface GamepadButtonChanges {
  105969. /**
  105970. * Called when a gamepad has been changed
  105971. */
  105972. changed: boolean;
  105973. /**
  105974. * Called when a gamepad press event has been triggered
  105975. */
  105976. pressChanged: boolean;
  105977. /**
  105978. * Called when a touch event has been triggered
  105979. */
  105980. touchChanged: boolean;
  105981. /**
  105982. * Called when a value has changed
  105983. */
  105984. valueChanged: boolean;
  105985. }
  105986. /**
  105987. * Represents a gamepad
  105988. */
  105989. export class Gamepad {
  105990. /**
  105991. * The id of the gamepad
  105992. */
  105993. id: string;
  105994. /**
  105995. * The index of the gamepad
  105996. */
  105997. index: number;
  105998. /**
  105999. * The browser gamepad
  106000. */
  106001. browserGamepad: any;
  106002. /**
  106003. * Specifies what type of gamepad this represents
  106004. */
  106005. type: number;
  106006. private _leftStick;
  106007. private _rightStick;
  106008. /** @hidden */
  106009. _isConnected: boolean;
  106010. private _leftStickAxisX;
  106011. private _leftStickAxisY;
  106012. private _rightStickAxisX;
  106013. private _rightStickAxisY;
  106014. /**
  106015. * Triggered when the left control stick has been changed
  106016. */
  106017. private _onleftstickchanged;
  106018. /**
  106019. * Triggered when the right control stick has been changed
  106020. */
  106021. private _onrightstickchanged;
  106022. /**
  106023. * Represents a gamepad controller
  106024. */
  106025. static GAMEPAD: number;
  106026. /**
  106027. * Represents a generic controller
  106028. */
  106029. static GENERIC: number;
  106030. /**
  106031. * Represents an XBox controller
  106032. */
  106033. static XBOX: number;
  106034. /**
  106035. * Represents a pose-enabled controller
  106036. */
  106037. static POSE_ENABLED: number;
  106038. /**
  106039. * Represents an Dual Shock controller
  106040. */
  106041. static DUALSHOCK: number;
  106042. /**
  106043. * Specifies whether the left control stick should be Y-inverted
  106044. */
  106045. protected _invertLeftStickY: boolean;
  106046. /**
  106047. * Specifies if the gamepad has been connected
  106048. */
  106049. get isConnected(): boolean;
  106050. /**
  106051. * Initializes the gamepad
  106052. * @param id The id of the gamepad
  106053. * @param index The index of the gamepad
  106054. * @param browserGamepad The browser gamepad
  106055. * @param leftStickX The x component of the left joystick
  106056. * @param leftStickY The y component of the left joystick
  106057. * @param rightStickX The x component of the right joystick
  106058. * @param rightStickY The y component of the right joystick
  106059. */
  106060. constructor(
  106061. /**
  106062. * The id of the gamepad
  106063. */
  106064. id: string,
  106065. /**
  106066. * The index of the gamepad
  106067. */
  106068. index: number,
  106069. /**
  106070. * The browser gamepad
  106071. */
  106072. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  106073. /**
  106074. * Callback triggered when the left joystick has changed
  106075. * @param callback
  106076. */
  106077. onleftstickchanged(callback: (values: StickValues) => void): void;
  106078. /**
  106079. * Callback triggered when the right joystick has changed
  106080. * @param callback
  106081. */
  106082. onrightstickchanged(callback: (values: StickValues) => void): void;
  106083. /**
  106084. * Gets the left joystick
  106085. */
  106086. get leftStick(): StickValues;
  106087. /**
  106088. * Sets the left joystick values
  106089. */
  106090. set leftStick(newValues: StickValues);
  106091. /**
  106092. * Gets the right joystick
  106093. */
  106094. get rightStick(): StickValues;
  106095. /**
  106096. * Sets the right joystick value
  106097. */
  106098. set rightStick(newValues: StickValues);
  106099. /**
  106100. * Updates the gamepad joystick positions
  106101. */
  106102. update(): void;
  106103. /**
  106104. * Disposes the gamepad
  106105. */
  106106. dispose(): void;
  106107. }
  106108. /**
  106109. * Represents a generic gamepad
  106110. */
  106111. export class GenericPad extends Gamepad {
  106112. private _buttons;
  106113. private _onbuttondown;
  106114. private _onbuttonup;
  106115. /**
  106116. * Observable triggered when a button has been pressed
  106117. */
  106118. onButtonDownObservable: Observable<number>;
  106119. /**
  106120. * Observable triggered when a button has been released
  106121. */
  106122. onButtonUpObservable: Observable<number>;
  106123. /**
  106124. * Callback triggered when a button has been pressed
  106125. * @param callback Called when a button has been pressed
  106126. */
  106127. onbuttondown(callback: (buttonPressed: number) => void): void;
  106128. /**
  106129. * Callback triggered when a button has been released
  106130. * @param callback Called when a button has been released
  106131. */
  106132. onbuttonup(callback: (buttonReleased: number) => void): void;
  106133. /**
  106134. * Initializes the generic gamepad
  106135. * @param id The id of the generic gamepad
  106136. * @param index The index of the generic gamepad
  106137. * @param browserGamepad The browser gamepad
  106138. */
  106139. constructor(id: string, index: number, browserGamepad: any);
  106140. private _setButtonValue;
  106141. /**
  106142. * Updates the generic gamepad
  106143. */
  106144. update(): void;
  106145. /**
  106146. * Disposes the generic gamepad
  106147. */
  106148. dispose(): void;
  106149. }
  106150. }
  106151. declare module BABYLON {
  106152. /**
  106153. * Defines a runtime animation
  106154. */
  106155. export class RuntimeAnimation {
  106156. private _events;
  106157. /**
  106158. * The current frame of the runtime animation
  106159. */
  106160. private _currentFrame;
  106161. /**
  106162. * The animation used by the runtime animation
  106163. */
  106164. private _animation;
  106165. /**
  106166. * The target of the runtime animation
  106167. */
  106168. private _target;
  106169. /**
  106170. * The initiating animatable
  106171. */
  106172. private _host;
  106173. /**
  106174. * The original value of the runtime animation
  106175. */
  106176. private _originalValue;
  106177. /**
  106178. * The original blend value of the runtime animation
  106179. */
  106180. private _originalBlendValue;
  106181. /**
  106182. * The offsets cache of the runtime animation
  106183. */
  106184. private _offsetsCache;
  106185. /**
  106186. * The high limits cache of the runtime animation
  106187. */
  106188. private _highLimitsCache;
  106189. /**
  106190. * Specifies if the runtime animation has been stopped
  106191. */
  106192. private _stopped;
  106193. /**
  106194. * The blending factor of the runtime animation
  106195. */
  106196. private _blendingFactor;
  106197. /**
  106198. * The BabylonJS scene
  106199. */
  106200. private _scene;
  106201. /**
  106202. * The current value of the runtime animation
  106203. */
  106204. private _currentValue;
  106205. /** @hidden */
  106206. _animationState: _IAnimationState;
  106207. /**
  106208. * The active target of the runtime animation
  106209. */
  106210. private _activeTargets;
  106211. private _currentActiveTarget;
  106212. private _directTarget;
  106213. /**
  106214. * The target path of the runtime animation
  106215. */
  106216. private _targetPath;
  106217. /**
  106218. * The weight of the runtime animation
  106219. */
  106220. private _weight;
  106221. /**
  106222. * The ratio offset of the runtime animation
  106223. */
  106224. private _ratioOffset;
  106225. /**
  106226. * The previous delay of the runtime animation
  106227. */
  106228. private _previousDelay;
  106229. /**
  106230. * The previous ratio of the runtime animation
  106231. */
  106232. private _previousRatio;
  106233. private _enableBlending;
  106234. private _keys;
  106235. private _minFrame;
  106236. private _maxFrame;
  106237. private _minValue;
  106238. private _maxValue;
  106239. private _targetIsArray;
  106240. /**
  106241. * Gets the current frame of the runtime animation
  106242. */
  106243. get currentFrame(): number;
  106244. /**
  106245. * Gets the weight of the runtime animation
  106246. */
  106247. get weight(): number;
  106248. /**
  106249. * Gets the current value of the runtime animation
  106250. */
  106251. get currentValue(): any;
  106252. /**
  106253. * Gets the target path of the runtime animation
  106254. */
  106255. get targetPath(): string;
  106256. /**
  106257. * Gets the actual target of the runtime animation
  106258. */
  106259. get target(): any;
  106260. /**
  106261. * Gets the additive state of the runtime animation
  106262. */
  106263. get isAdditive(): boolean;
  106264. /** @hidden */
  106265. _onLoop: () => void;
  106266. /**
  106267. * Create a new RuntimeAnimation object
  106268. * @param target defines the target of the animation
  106269. * @param animation defines the source animation object
  106270. * @param scene defines the hosting scene
  106271. * @param host defines the initiating Animatable
  106272. */
  106273. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  106274. private _preparePath;
  106275. /**
  106276. * Gets the animation from the runtime animation
  106277. */
  106278. get animation(): Animation;
  106279. /**
  106280. * Resets the runtime animation to the beginning
  106281. * @param restoreOriginal defines whether to restore the target property to the original value
  106282. */
  106283. reset(restoreOriginal?: boolean): void;
  106284. /**
  106285. * Specifies if the runtime animation is stopped
  106286. * @returns Boolean specifying if the runtime animation is stopped
  106287. */
  106288. isStopped(): boolean;
  106289. /**
  106290. * Disposes of the runtime animation
  106291. */
  106292. dispose(): void;
  106293. /**
  106294. * Apply the interpolated value to the target
  106295. * @param currentValue defines the value computed by the animation
  106296. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  106297. */
  106298. setValue(currentValue: any, weight: number): void;
  106299. private _getOriginalValues;
  106300. private _setValue;
  106301. /**
  106302. * Gets the loop pmode of the runtime animation
  106303. * @returns Loop Mode
  106304. */
  106305. private _getCorrectLoopMode;
  106306. /**
  106307. * Move the current animation to a given frame
  106308. * @param frame defines the frame to move to
  106309. */
  106310. goToFrame(frame: number): void;
  106311. /**
  106312. * @hidden Internal use only
  106313. */
  106314. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  106315. /**
  106316. * Execute the current animation
  106317. * @param delay defines the delay to add to the current frame
  106318. * @param from defines the lower bound of the animation range
  106319. * @param to defines the upper bound of the animation range
  106320. * @param loop defines if the current animation must loop
  106321. * @param speedRatio defines the current speed ratio
  106322. * @param weight defines the weight of the animation (default is -1 so no weight)
  106323. * @param onLoop optional callback called when animation loops
  106324. * @returns a boolean indicating if the animation is running
  106325. */
  106326. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  106327. }
  106328. }
  106329. declare module BABYLON {
  106330. /**
  106331. * Class used to store an actual running animation
  106332. */
  106333. export class Animatable {
  106334. /** defines the target object */
  106335. target: any;
  106336. /** defines the starting frame number (default is 0) */
  106337. fromFrame: number;
  106338. /** defines the ending frame number (default is 100) */
  106339. toFrame: number;
  106340. /** defines if the animation must loop (default is false) */
  106341. loopAnimation: boolean;
  106342. /** defines a callback to call when animation ends if it is not looping */
  106343. onAnimationEnd?: (() => void) | null | undefined;
  106344. /** defines a callback to call when animation loops */
  106345. onAnimationLoop?: (() => void) | null | undefined;
  106346. /** defines whether the animation should be evaluated additively */
  106347. isAdditive: boolean;
  106348. private _localDelayOffset;
  106349. private _pausedDelay;
  106350. private _runtimeAnimations;
  106351. private _paused;
  106352. private _scene;
  106353. private _speedRatio;
  106354. private _weight;
  106355. private _syncRoot;
  106356. /**
  106357. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  106358. * This will only apply for non looping animation (default is true)
  106359. */
  106360. disposeOnEnd: boolean;
  106361. /**
  106362. * Gets a boolean indicating if the animation has started
  106363. */
  106364. animationStarted: boolean;
  106365. /**
  106366. * Observer raised when the animation ends
  106367. */
  106368. onAnimationEndObservable: Observable<Animatable>;
  106369. /**
  106370. * Observer raised when the animation loops
  106371. */
  106372. onAnimationLoopObservable: Observable<Animatable>;
  106373. /**
  106374. * Gets the root Animatable used to synchronize and normalize animations
  106375. */
  106376. get syncRoot(): Nullable<Animatable>;
  106377. /**
  106378. * Gets the current frame of the first RuntimeAnimation
  106379. * Used to synchronize Animatables
  106380. */
  106381. get masterFrame(): number;
  106382. /**
  106383. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  106384. */
  106385. get weight(): number;
  106386. set weight(value: number);
  106387. /**
  106388. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  106389. */
  106390. get speedRatio(): number;
  106391. set speedRatio(value: number);
  106392. /**
  106393. * Creates a new Animatable
  106394. * @param scene defines the hosting scene
  106395. * @param target defines the target object
  106396. * @param fromFrame defines the starting frame number (default is 0)
  106397. * @param toFrame defines the ending frame number (default is 100)
  106398. * @param loopAnimation defines if the animation must loop (default is false)
  106399. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  106400. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  106401. * @param animations defines a group of animation to add to the new Animatable
  106402. * @param onAnimationLoop defines a callback to call when animation loops
  106403. * @param isAdditive defines whether the animation should be evaluated additively
  106404. */
  106405. constructor(scene: Scene,
  106406. /** defines the target object */
  106407. target: any,
  106408. /** defines the starting frame number (default is 0) */
  106409. fromFrame?: number,
  106410. /** defines the ending frame number (default is 100) */
  106411. toFrame?: number,
  106412. /** defines if the animation must loop (default is false) */
  106413. loopAnimation?: boolean, speedRatio?: number,
  106414. /** defines a callback to call when animation ends if it is not looping */
  106415. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  106416. /** defines a callback to call when animation loops */
  106417. onAnimationLoop?: (() => void) | null | undefined,
  106418. /** defines whether the animation should be evaluated additively */
  106419. isAdditive?: boolean);
  106420. /**
  106421. * Synchronize and normalize current Animatable with a source Animatable
  106422. * This is useful when using animation weights and when animations are not of the same length
  106423. * @param root defines the root Animatable to synchronize with
  106424. * @returns the current Animatable
  106425. */
  106426. syncWith(root: Animatable): Animatable;
  106427. /**
  106428. * Gets the list of runtime animations
  106429. * @returns an array of RuntimeAnimation
  106430. */
  106431. getAnimations(): RuntimeAnimation[];
  106432. /**
  106433. * Adds more animations to the current animatable
  106434. * @param target defines the target of the animations
  106435. * @param animations defines the new animations to add
  106436. */
  106437. appendAnimations(target: any, animations: Animation[]): void;
  106438. /**
  106439. * Gets the source animation for a specific property
  106440. * @param property defines the propertyu to look for
  106441. * @returns null or the source animation for the given property
  106442. */
  106443. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  106444. /**
  106445. * Gets the runtime animation for a specific property
  106446. * @param property defines the propertyu to look for
  106447. * @returns null or the runtime animation for the given property
  106448. */
  106449. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  106450. /**
  106451. * Resets the animatable to its original state
  106452. */
  106453. reset(): void;
  106454. /**
  106455. * Allows the animatable to blend with current running animations
  106456. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106457. * @param blendingSpeed defines the blending speed to use
  106458. */
  106459. enableBlending(blendingSpeed: number): void;
  106460. /**
  106461. * Disable animation blending
  106462. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106463. */
  106464. disableBlending(): void;
  106465. /**
  106466. * Jump directly to a given frame
  106467. * @param frame defines the frame to jump to
  106468. */
  106469. goToFrame(frame: number): void;
  106470. /**
  106471. * Pause the animation
  106472. */
  106473. pause(): void;
  106474. /**
  106475. * Restart the animation
  106476. */
  106477. restart(): void;
  106478. private _raiseOnAnimationEnd;
  106479. /**
  106480. * Stop and delete the current animation
  106481. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  106482. * @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)
  106483. */
  106484. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  106485. /**
  106486. * Wait asynchronously for the animation to end
  106487. * @returns a promise which will be fullfilled when the animation ends
  106488. */
  106489. waitAsync(): Promise<Animatable>;
  106490. /** @hidden */
  106491. _animate(delay: number): boolean;
  106492. }
  106493. interface Scene {
  106494. /** @hidden */
  106495. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  106496. /** @hidden */
  106497. _processLateAnimationBindingsForMatrices(holder: {
  106498. totalWeight: number;
  106499. totalAdditiveWeight: number;
  106500. animations: RuntimeAnimation[];
  106501. additiveAnimations: RuntimeAnimation[];
  106502. originalValue: Matrix;
  106503. }): any;
  106504. /** @hidden */
  106505. _processLateAnimationBindingsForQuaternions(holder: {
  106506. totalWeight: number;
  106507. totalAdditiveWeight: number;
  106508. animations: RuntimeAnimation[];
  106509. additiveAnimations: RuntimeAnimation[];
  106510. originalValue: Quaternion;
  106511. }, refQuaternion: Quaternion): Quaternion;
  106512. /** @hidden */
  106513. _processLateAnimationBindings(): void;
  106514. /**
  106515. * Will start the animation sequence of a given target
  106516. * @param target defines the target
  106517. * @param from defines from which frame should animation start
  106518. * @param to defines until which frame should animation run.
  106519. * @param weight defines the weight to apply to the animation (1.0 by default)
  106520. * @param loop defines if the animation loops
  106521. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106522. * @param onAnimationEnd defines the function to be executed when the animation ends
  106523. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106524. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  106525. * @param onAnimationLoop defines the callback to call when an animation loops
  106526. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106527. * @returns the animatable object created for this animation
  106528. */
  106529. 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;
  106530. /**
  106531. * Will start the animation sequence of a given target
  106532. * @param target defines the target
  106533. * @param from defines from which frame should animation start
  106534. * @param to defines until which frame should animation run.
  106535. * @param loop defines if the animation loops
  106536. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106537. * @param onAnimationEnd defines the function to be executed when the animation ends
  106538. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106539. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  106540. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  106541. * @param onAnimationLoop defines the callback to call when an animation loops
  106542. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106543. * @returns the animatable object created for this animation
  106544. */
  106545. 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;
  106546. /**
  106547. * Will start the animation sequence of a given target and its hierarchy
  106548. * @param target defines the target
  106549. * @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.
  106550. * @param from defines from which frame should animation start
  106551. * @param to defines until which frame should animation run.
  106552. * @param loop defines if the animation loops
  106553. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106554. * @param onAnimationEnd defines the function to be executed when the animation ends
  106555. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106556. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  106557. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  106558. * @param onAnimationLoop defines the callback to call when an animation loops
  106559. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106560. * @returns the list of created animatables
  106561. */
  106562. 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[];
  106563. /**
  106564. * Begin a new animation on a given node
  106565. * @param target defines the target where the animation will take place
  106566. * @param animations defines the list of animations to start
  106567. * @param from defines the initial value
  106568. * @param to defines the final value
  106569. * @param loop defines if you want animation to loop (off by default)
  106570. * @param speedRatio defines the speed ratio to apply to all animations
  106571. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  106572. * @param onAnimationLoop defines the callback to call when an animation loops
  106573. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106574. * @returns the list of created animatables
  106575. */
  106576. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  106577. /**
  106578. * Begin a new animation on a given node and its hierarchy
  106579. * @param target defines the root node where the animation will take place
  106580. * @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.
  106581. * @param animations defines the list of animations to start
  106582. * @param from defines the initial value
  106583. * @param to defines the final value
  106584. * @param loop defines if you want animation to loop (off by default)
  106585. * @param speedRatio defines the speed ratio to apply to all animations
  106586. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  106587. * @param onAnimationLoop defines the callback to call when an animation loops
  106588. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106589. * @returns the list of animatables created for all nodes
  106590. */
  106591. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  106592. /**
  106593. * Gets the animatable associated with a specific target
  106594. * @param target defines the target of the animatable
  106595. * @returns the required animatable if found
  106596. */
  106597. getAnimatableByTarget(target: any): Nullable<Animatable>;
  106598. /**
  106599. * Gets all animatables associated with a given target
  106600. * @param target defines the target to look animatables for
  106601. * @returns an array of Animatables
  106602. */
  106603. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  106604. /**
  106605. * Stops and removes all animations that have been applied to the scene
  106606. */
  106607. stopAllAnimations(): void;
  106608. /**
  106609. * Gets the current delta time used by animation engine
  106610. */
  106611. deltaTime: number;
  106612. }
  106613. interface Bone {
  106614. /**
  106615. * Copy an animation range from another bone
  106616. * @param source defines the source bone
  106617. * @param rangeName defines the range name to copy
  106618. * @param frameOffset defines the frame offset
  106619. * @param rescaleAsRequired defines if rescaling must be applied if required
  106620. * @param skelDimensionsRatio defines the scaling ratio
  106621. * @returns true if operation was successful
  106622. */
  106623. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  106624. }
  106625. }
  106626. declare module BABYLON {
  106627. /**
  106628. * Class used to override all child animations of a given target
  106629. */
  106630. export class AnimationPropertiesOverride {
  106631. /**
  106632. * Gets or sets a value indicating if animation blending must be used
  106633. */
  106634. enableBlending: boolean;
  106635. /**
  106636. * Gets or sets the blending speed to use when enableBlending is true
  106637. */
  106638. blendingSpeed: number;
  106639. /**
  106640. * Gets or sets the default loop mode to use
  106641. */
  106642. loopMode: number;
  106643. }
  106644. }
  106645. declare module BABYLON {
  106646. /**
  106647. * Class used to handle skinning animations
  106648. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  106649. */
  106650. export class Skeleton implements IAnimatable {
  106651. /** defines the skeleton name */
  106652. name: string;
  106653. /** defines the skeleton Id */
  106654. id: string;
  106655. /**
  106656. * Defines the list of child bones
  106657. */
  106658. bones: Bone[];
  106659. /**
  106660. * Defines an estimate of the dimension of the skeleton at rest
  106661. */
  106662. dimensionsAtRest: Vector3;
  106663. /**
  106664. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  106665. */
  106666. needInitialSkinMatrix: boolean;
  106667. /**
  106668. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  106669. */
  106670. overrideMesh: Nullable<AbstractMesh>;
  106671. /**
  106672. * Gets the list of animations attached to this skeleton
  106673. */
  106674. animations: Array<Animation>;
  106675. private _scene;
  106676. private _isDirty;
  106677. private _transformMatrices;
  106678. private _transformMatrixTexture;
  106679. private _meshesWithPoseMatrix;
  106680. private _animatables;
  106681. private _identity;
  106682. private _synchronizedWithMesh;
  106683. private _ranges;
  106684. private _lastAbsoluteTransformsUpdateId;
  106685. private _canUseTextureForBones;
  106686. private _uniqueId;
  106687. /** @hidden */
  106688. _numBonesWithLinkedTransformNode: number;
  106689. /** @hidden */
  106690. _hasWaitingData: Nullable<boolean>;
  106691. /** @hidden */
  106692. _waitingOverrideMeshId: Nullable<string>;
  106693. /**
  106694. * Specifies if the skeleton should be serialized
  106695. */
  106696. doNotSerialize: boolean;
  106697. private _useTextureToStoreBoneMatrices;
  106698. /**
  106699. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  106700. * Please note that this option is not available if the hardware does not support it
  106701. */
  106702. get useTextureToStoreBoneMatrices(): boolean;
  106703. set useTextureToStoreBoneMatrices(value: boolean);
  106704. private _animationPropertiesOverride;
  106705. /**
  106706. * Gets or sets the animation properties override
  106707. */
  106708. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106709. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106710. /**
  106711. * List of inspectable custom properties (used by the Inspector)
  106712. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  106713. */
  106714. inspectableCustomProperties: IInspectable[];
  106715. /**
  106716. * An observable triggered before computing the skeleton's matrices
  106717. */
  106718. onBeforeComputeObservable: Observable<Skeleton>;
  106719. /**
  106720. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  106721. */
  106722. get isUsingTextureForMatrices(): boolean;
  106723. /**
  106724. * Gets the unique ID of this skeleton
  106725. */
  106726. get uniqueId(): number;
  106727. /**
  106728. * Creates a new skeleton
  106729. * @param name defines the skeleton name
  106730. * @param id defines the skeleton Id
  106731. * @param scene defines the hosting scene
  106732. */
  106733. constructor(
  106734. /** defines the skeleton name */
  106735. name: string,
  106736. /** defines the skeleton Id */
  106737. id: string, scene: Scene);
  106738. /**
  106739. * Gets the current object class name.
  106740. * @return the class name
  106741. */
  106742. getClassName(): string;
  106743. /**
  106744. * Returns an array containing the root bones
  106745. * @returns an array containing the root bones
  106746. */
  106747. getChildren(): Array<Bone>;
  106748. /**
  106749. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  106750. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  106751. * @returns a Float32Array containing matrices data
  106752. */
  106753. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  106754. /**
  106755. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  106756. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  106757. * @returns a raw texture containing the data
  106758. */
  106759. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  106760. /**
  106761. * Gets the current hosting scene
  106762. * @returns a scene object
  106763. */
  106764. getScene(): Scene;
  106765. /**
  106766. * Gets a string representing the current skeleton data
  106767. * @param fullDetails defines a boolean indicating if we want a verbose version
  106768. * @returns a string representing the current skeleton data
  106769. */
  106770. toString(fullDetails?: boolean): string;
  106771. /**
  106772. * Get bone's index searching by name
  106773. * @param name defines bone's name to search for
  106774. * @return the indice of the bone. Returns -1 if not found
  106775. */
  106776. getBoneIndexByName(name: string): number;
  106777. /**
  106778. * Creater a new animation range
  106779. * @param name defines the name of the range
  106780. * @param from defines the start key
  106781. * @param to defines the end key
  106782. */
  106783. createAnimationRange(name: string, from: number, to: number): void;
  106784. /**
  106785. * Delete a specific animation range
  106786. * @param name defines the name of the range
  106787. * @param deleteFrames defines if frames must be removed as well
  106788. */
  106789. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  106790. /**
  106791. * Gets a specific animation range
  106792. * @param name defines the name of the range to look for
  106793. * @returns the requested animation range or null if not found
  106794. */
  106795. getAnimationRange(name: string): Nullable<AnimationRange>;
  106796. /**
  106797. * Gets the list of all animation ranges defined on this skeleton
  106798. * @returns an array
  106799. */
  106800. getAnimationRanges(): Nullable<AnimationRange>[];
  106801. /**
  106802. * Copy animation range from a source skeleton.
  106803. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  106804. * @param source defines the source skeleton
  106805. * @param name defines the name of the range to copy
  106806. * @param rescaleAsRequired defines if rescaling must be applied if required
  106807. * @returns true if operation was successful
  106808. */
  106809. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  106810. /**
  106811. * Forces the skeleton to go to rest pose
  106812. */
  106813. returnToRest(): void;
  106814. private _getHighestAnimationFrame;
  106815. /**
  106816. * Begin a specific animation range
  106817. * @param name defines the name of the range to start
  106818. * @param loop defines if looping must be turned on (false by default)
  106819. * @param speedRatio defines the speed ratio to apply (1 by default)
  106820. * @param onAnimationEnd defines a callback which will be called when animation will end
  106821. * @returns a new animatable
  106822. */
  106823. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  106824. /**
  106825. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  106826. * @param skeleton defines the Skeleton containing the animation range to convert
  106827. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  106828. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  106829. * @returns the original skeleton
  106830. */
  106831. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  106832. /** @hidden */
  106833. _markAsDirty(): void;
  106834. /** @hidden */
  106835. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  106836. /** @hidden */
  106837. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  106838. private _computeTransformMatrices;
  106839. /**
  106840. * Build all resources required to render a skeleton
  106841. */
  106842. prepare(): void;
  106843. /**
  106844. * Gets the list of animatables currently running for this skeleton
  106845. * @returns an array of animatables
  106846. */
  106847. getAnimatables(): IAnimatable[];
  106848. /**
  106849. * Clone the current skeleton
  106850. * @param name defines the name of the new skeleton
  106851. * @param id defines the id of the new skeleton
  106852. * @returns the new skeleton
  106853. */
  106854. clone(name: string, id?: string): Skeleton;
  106855. /**
  106856. * Enable animation blending for this skeleton
  106857. * @param blendingSpeed defines the blending speed to apply
  106858. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106859. */
  106860. enableBlending(blendingSpeed?: number): void;
  106861. /**
  106862. * Releases all resources associated with the current skeleton
  106863. */
  106864. dispose(): void;
  106865. /**
  106866. * Serialize the skeleton in a JSON object
  106867. * @returns a JSON object
  106868. */
  106869. serialize(): any;
  106870. /**
  106871. * Creates a new skeleton from serialized data
  106872. * @param parsedSkeleton defines the serialized data
  106873. * @param scene defines the hosting scene
  106874. * @returns a new skeleton
  106875. */
  106876. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  106877. /**
  106878. * Compute all node absolute transforms
  106879. * @param forceUpdate defines if computation must be done even if cache is up to date
  106880. */
  106881. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  106882. /**
  106883. * Gets the root pose matrix
  106884. * @returns a matrix
  106885. */
  106886. getPoseMatrix(): Nullable<Matrix>;
  106887. /**
  106888. * Sorts bones per internal index
  106889. */
  106890. sortBones(): void;
  106891. private _sortBones;
  106892. /**
  106893. * Set the current local matrix as the restPose for all bones in the skeleton.
  106894. */
  106895. setCurrentPoseAsRest(): void;
  106896. }
  106897. }
  106898. declare module BABYLON {
  106899. /**
  106900. * Class used to store bone information
  106901. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  106902. */
  106903. export class Bone extends Node {
  106904. /**
  106905. * defines the bone name
  106906. */
  106907. name: string;
  106908. private static _tmpVecs;
  106909. private static _tmpQuat;
  106910. private static _tmpMats;
  106911. /**
  106912. * Gets the list of child bones
  106913. */
  106914. children: Bone[];
  106915. /** Gets the animations associated with this bone */
  106916. animations: Animation[];
  106917. /**
  106918. * Gets or sets bone length
  106919. */
  106920. length: number;
  106921. /**
  106922. * @hidden Internal only
  106923. * Set this value to map this bone to a different index in the transform matrices
  106924. * Set this value to -1 to exclude the bone from the transform matrices
  106925. */
  106926. _index: Nullable<number>;
  106927. private _skeleton;
  106928. private _localMatrix;
  106929. private _restPose;
  106930. private _bindPose;
  106931. private _baseMatrix;
  106932. private _absoluteTransform;
  106933. private _invertedAbsoluteTransform;
  106934. private _parent;
  106935. private _scalingDeterminant;
  106936. private _worldTransform;
  106937. private _localScaling;
  106938. private _localRotation;
  106939. private _localPosition;
  106940. private _needToDecompose;
  106941. private _needToCompose;
  106942. /** @hidden */
  106943. _linkedTransformNode: Nullable<TransformNode>;
  106944. /** @hidden */
  106945. _waitingTransformNodeId: Nullable<string>;
  106946. /** @hidden */
  106947. get _matrix(): Matrix;
  106948. /** @hidden */
  106949. set _matrix(value: Matrix);
  106950. /**
  106951. * Create a new bone
  106952. * @param name defines the bone name
  106953. * @param skeleton defines the parent skeleton
  106954. * @param parentBone defines the parent (can be null if the bone is the root)
  106955. * @param localMatrix defines the local matrix
  106956. * @param restPose defines the rest pose matrix
  106957. * @param baseMatrix defines the base matrix
  106958. * @param index defines index of the bone in the hiearchy
  106959. */
  106960. constructor(
  106961. /**
  106962. * defines the bone name
  106963. */
  106964. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  106965. /**
  106966. * Gets the current object class name.
  106967. * @return the class name
  106968. */
  106969. getClassName(): string;
  106970. /**
  106971. * Gets the parent skeleton
  106972. * @returns a skeleton
  106973. */
  106974. getSkeleton(): Skeleton;
  106975. /**
  106976. * Gets parent bone
  106977. * @returns a bone or null if the bone is the root of the bone hierarchy
  106978. */
  106979. getParent(): Nullable<Bone>;
  106980. /**
  106981. * Returns an array containing the root bones
  106982. * @returns an array containing the root bones
  106983. */
  106984. getChildren(): Array<Bone>;
  106985. /**
  106986. * Gets the node index in matrix array generated for rendering
  106987. * @returns the node index
  106988. */
  106989. getIndex(): number;
  106990. /**
  106991. * Sets the parent bone
  106992. * @param parent defines the parent (can be null if the bone is the root)
  106993. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  106994. */
  106995. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  106996. /**
  106997. * Gets the local matrix
  106998. * @returns a matrix
  106999. */
  107000. getLocalMatrix(): Matrix;
  107001. /**
  107002. * Gets the base matrix (initial matrix which remains unchanged)
  107003. * @returns a matrix
  107004. */
  107005. getBaseMatrix(): Matrix;
  107006. /**
  107007. * Gets the rest pose matrix
  107008. * @returns a matrix
  107009. */
  107010. getRestPose(): Matrix;
  107011. /**
  107012. * Sets the rest pose matrix
  107013. * @param matrix the local-space rest pose to set for this bone
  107014. */
  107015. setRestPose(matrix: Matrix): void;
  107016. /**
  107017. * Gets the bind pose matrix
  107018. * @returns the bind pose matrix
  107019. */
  107020. getBindPose(): Matrix;
  107021. /**
  107022. * Sets the bind pose matrix
  107023. * @param matrix the local-space bind pose to set for this bone
  107024. */
  107025. setBindPose(matrix: Matrix): void;
  107026. /**
  107027. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  107028. */
  107029. getWorldMatrix(): Matrix;
  107030. /**
  107031. * Sets the local matrix to rest pose matrix
  107032. */
  107033. returnToRest(): void;
  107034. /**
  107035. * Gets the inverse of the absolute transform matrix.
  107036. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  107037. * @returns a matrix
  107038. */
  107039. getInvertedAbsoluteTransform(): Matrix;
  107040. /**
  107041. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  107042. * @returns a matrix
  107043. */
  107044. getAbsoluteTransform(): Matrix;
  107045. /**
  107046. * Links with the given transform node.
  107047. * The local matrix of this bone is copied from the transform node every frame.
  107048. * @param transformNode defines the transform node to link to
  107049. */
  107050. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  107051. /**
  107052. * Gets the node used to drive the bone's transformation
  107053. * @returns a transform node or null
  107054. */
  107055. getTransformNode(): Nullable<TransformNode>;
  107056. /** Gets or sets current position (in local space) */
  107057. get position(): Vector3;
  107058. set position(newPosition: Vector3);
  107059. /** Gets or sets current rotation (in local space) */
  107060. get rotation(): Vector3;
  107061. set rotation(newRotation: Vector3);
  107062. /** Gets or sets current rotation quaternion (in local space) */
  107063. get rotationQuaternion(): Quaternion;
  107064. set rotationQuaternion(newRotation: Quaternion);
  107065. /** Gets or sets current scaling (in local space) */
  107066. get scaling(): Vector3;
  107067. set scaling(newScaling: Vector3);
  107068. /**
  107069. * Gets the animation properties override
  107070. */
  107071. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  107072. private _decompose;
  107073. private _compose;
  107074. /**
  107075. * Update the base and local matrices
  107076. * @param matrix defines the new base or local matrix
  107077. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  107078. * @param updateLocalMatrix defines if the local matrix should be updated
  107079. */
  107080. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  107081. /** @hidden */
  107082. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  107083. /**
  107084. * Flag the bone as dirty (Forcing it to update everything)
  107085. */
  107086. markAsDirty(): void;
  107087. /** @hidden */
  107088. _markAsDirtyAndCompose(): void;
  107089. private _markAsDirtyAndDecompose;
  107090. /**
  107091. * Translate the bone in local or world space
  107092. * @param vec The amount to translate the bone
  107093. * @param space The space that the translation is in
  107094. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107095. */
  107096. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107097. /**
  107098. * Set the postion of the bone in local or world space
  107099. * @param position The position to set the bone
  107100. * @param space The space that the position is in
  107101. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107102. */
  107103. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107104. /**
  107105. * Set the absolute position of the bone (world space)
  107106. * @param position The position to set the bone
  107107. * @param mesh The mesh that this bone is attached to
  107108. */
  107109. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  107110. /**
  107111. * Scale the bone on the x, y and z axes (in local space)
  107112. * @param x The amount to scale the bone on the x axis
  107113. * @param y The amount to scale the bone on the y axis
  107114. * @param z The amount to scale the bone on the z axis
  107115. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  107116. */
  107117. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  107118. /**
  107119. * Set the bone scaling in local space
  107120. * @param scale defines the scaling vector
  107121. */
  107122. setScale(scale: Vector3): void;
  107123. /**
  107124. * Gets the current scaling in local space
  107125. * @returns the current scaling vector
  107126. */
  107127. getScale(): Vector3;
  107128. /**
  107129. * Gets the current scaling in local space and stores it in a target vector
  107130. * @param result defines the target vector
  107131. */
  107132. getScaleToRef(result: Vector3): void;
  107133. /**
  107134. * Set the yaw, pitch, and roll of the bone in local or world space
  107135. * @param yaw The rotation of the bone on the y axis
  107136. * @param pitch The rotation of the bone on the x axis
  107137. * @param roll The rotation of the bone on the z axis
  107138. * @param space The space that the axes of rotation are in
  107139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107140. */
  107141. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  107142. /**
  107143. * Add a rotation to the bone on an axis in local or world space
  107144. * @param axis The axis to rotate the bone on
  107145. * @param amount The amount to rotate the bone
  107146. * @param space The space that the axis is in
  107147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107148. */
  107149. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  107150. /**
  107151. * Set the rotation of the bone to a particular axis angle in local or world space
  107152. * @param axis The axis to rotate the bone on
  107153. * @param angle The angle that the bone should be rotated to
  107154. * @param space The space that the axis is in
  107155. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107156. */
  107157. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  107158. /**
  107159. * Set the euler rotation of the bone in local or world space
  107160. * @param rotation The euler rotation that the bone should be set to
  107161. * @param space The space that the rotation is in
  107162. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107163. */
  107164. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107165. /**
  107166. * Set the quaternion rotation of the bone in local or world space
  107167. * @param quat The quaternion rotation that the bone should be set to
  107168. * @param space The space that the rotation is in
  107169. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107170. */
  107171. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  107172. /**
  107173. * Set the rotation matrix of the bone in local or world space
  107174. * @param rotMat The rotation matrix that the bone should be set to
  107175. * @param space The space that the rotation is in
  107176. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107177. */
  107178. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  107179. private _rotateWithMatrix;
  107180. private _getNegativeRotationToRef;
  107181. /**
  107182. * Get the position of the bone in local or world space
  107183. * @param space The space that the returned position is in
  107184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107185. * @returns The position of the bone
  107186. */
  107187. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  107188. /**
  107189. * Copy the position of the bone to a vector3 in local or world space
  107190. * @param space The space that the returned position is in
  107191. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107192. * @param result The vector3 to copy the position to
  107193. */
  107194. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  107195. /**
  107196. * Get the absolute position of the bone (world space)
  107197. * @param mesh The mesh that this bone is attached to
  107198. * @returns The absolute position of the bone
  107199. */
  107200. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  107201. /**
  107202. * Copy the absolute position of the bone (world space) to the result param
  107203. * @param mesh The mesh that this bone is attached to
  107204. * @param result The vector3 to copy the absolute position to
  107205. */
  107206. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  107207. /**
  107208. * Compute the absolute transforms of this bone and its children
  107209. */
  107210. computeAbsoluteTransforms(): void;
  107211. /**
  107212. * Get the world direction from an axis that is in the local space of the bone
  107213. * @param localAxis The local direction that is used to compute the world direction
  107214. * @param mesh The mesh that this bone is attached to
  107215. * @returns The world direction
  107216. */
  107217. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107218. /**
  107219. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  107220. * @param localAxis The local direction that is used to compute the world direction
  107221. * @param mesh The mesh that this bone is attached to
  107222. * @param result The vector3 that the world direction will be copied to
  107223. */
  107224. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107225. /**
  107226. * Get the euler rotation of the bone in local or world space
  107227. * @param space The space that the rotation should be in
  107228. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107229. * @returns The euler rotation
  107230. */
  107231. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  107232. /**
  107233. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  107234. * @param space The space that the rotation should be in
  107235. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107236. * @param result The vector3 that the rotation should be copied to
  107237. */
  107238. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107239. /**
  107240. * Get the quaternion rotation of the bone in either local or world space
  107241. * @param space The space that the rotation should be in
  107242. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107243. * @returns The quaternion rotation
  107244. */
  107245. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  107246. /**
  107247. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  107248. * @param space The space that the rotation should be in
  107249. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107250. * @param result The quaternion that the rotation should be copied to
  107251. */
  107252. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  107253. /**
  107254. * Get the rotation matrix of the bone in local or world space
  107255. * @param space The space that the rotation should be in
  107256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107257. * @returns The rotation matrix
  107258. */
  107259. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  107260. /**
  107261. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  107262. * @param space The space that the rotation should be in
  107263. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107264. * @param result The quaternion that the rotation should be copied to
  107265. */
  107266. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  107267. /**
  107268. * Get the world position of a point that is in the local space of the bone
  107269. * @param position The local position
  107270. * @param mesh The mesh that this bone is attached to
  107271. * @returns The world position
  107272. */
  107273. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107274. /**
  107275. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  107276. * @param position The local position
  107277. * @param mesh The mesh that this bone is attached to
  107278. * @param result The vector3 that the world position should be copied to
  107279. */
  107280. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107281. /**
  107282. * Get the local position of a point that is in world space
  107283. * @param position The world position
  107284. * @param mesh The mesh that this bone is attached to
  107285. * @returns The local position
  107286. */
  107287. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107288. /**
  107289. * Get the local position of a point that is in world space and copy it to the result param
  107290. * @param position The world position
  107291. * @param mesh The mesh that this bone is attached to
  107292. * @param result The vector3 that the local position should be copied to
  107293. */
  107294. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107295. /**
  107296. * Set the current local matrix as the restPose for this bone.
  107297. */
  107298. setCurrentPoseAsRest(): void;
  107299. }
  107300. }
  107301. declare module BABYLON {
  107302. /**
  107303. * 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.
  107304. * @see https://doc.babylonjs.com/how_to/transformnode
  107305. */
  107306. export class TransformNode extends Node {
  107307. /**
  107308. * Object will not rotate to face the camera
  107309. */
  107310. static BILLBOARDMODE_NONE: number;
  107311. /**
  107312. * Object will rotate to face the camera but only on the x axis
  107313. */
  107314. static BILLBOARDMODE_X: number;
  107315. /**
  107316. * Object will rotate to face the camera but only on the y axis
  107317. */
  107318. static BILLBOARDMODE_Y: number;
  107319. /**
  107320. * Object will rotate to face the camera but only on the z axis
  107321. */
  107322. static BILLBOARDMODE_Z: number;
  107323. /**
  107324. * Object will rotate to face the camera
  107325. */
  107326. static BILLBOARDMODE_ALL: number;
  107327. /**
  107328. * Object will rotate to face the camera's position instead of orientation
  107329. */
  107330. static BILLBOARDMODE_USE_POSITION: number;
  107331. private static _TmpRotation;
  107332. private static _TmpScaling;
  107333. private static _TmpTranslation;
  107334. private _forward;
  107335. private _forwardInverted;
  107336. private _up;
  107337. private _right;
  107338. private _rightInverted;
  107339. private _position;
  107340. private _rotation;
  107341. private _rotationQuaternion;
  107342. protected _scaling: Vector3;
  107343. protected _isDirty: boolean;
  107344. private _transformToBoneReferal;
  107345. private _isAbsoluteSynced;
  107346. private _billboardMode;
  107347. /**
  107348. * Gets or sets the billboard mode. Default is 0.
  107349. *
  107350. * | Value | Type | Description |
  107351. * | --- | --- | --- |
  107352. * | 0 | BILLBOARDMODE_NONE | |
  107353. * | 1 | BILLBOARDMODE_X | |
  107354. * | 2 | BILLBOARDMODE_Y | |
  107355. * | 4 | BILLBOARDMODE_Z | |
  107356. * | 7 | BILLBOARDMODE_ALL | |
  107357. *
  107358. */
  107359. get billboardMode(): number;
  107360. set billboardMode(value: number);
  107361. private _preserveParentRotationForBillboard;
  107362. /**
  107363. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  107364. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  107365. */
  107366. get preserveParentRotationForBillboard(): boolean;
  107367. set preserveParentRotationForBillboard(value: boolean);
  107368. /**
  107369. * 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
  107370. */
  107371. scalingDeterminant: number;
  107372. private _infiniteDistance;
  107373. /**
  107374. * Gets or sets the distance of the object to max, often used by skybox
  107375. */
  107376. get infiniteDistance(): boolean;
  107377. set infiniteDistance(value: boolean);
  107378. /**
  107379. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  107380. * By default the system will update normals to compensate
  107381. */
  107382. ignoreNonUniformScaling: boolean;
  107383. /**
  107384. * 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
  107385. */
  107386. reIntegrateRotationIntoRotationQuaternion: boolean;
  107387. /** @hidden */
  107388. _poseMatrix: Nullable<Matrix>;
  107389. /** @hidden */
  107390. _localMatrix: Matrix;
  107391. private _usePivotMatrix;
  107392. private _absolutePosition;
  107393. private _absoluteScaling;
  107394. private _absoluteRotationQuaternion;
  107395. private _pivotMatrix;
  107396. private _pivotMatrixInverse;
  107397. /** @hidden */
  107398. _postMultiplyPivotMatrix: boolean;
  107399. protected _isWorldMatrixFrozen: boolean;
  107400. /** @hidden */
  107401. _indexInSceneTransformNodesArray: number;
  107402. /**
  107403. * An event triggered after the world matrix is updated
  107404. */
  107405. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  107406. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  107407. /**
  107408. * Gets a string identifying the name of the class
  107409. * @returns "TransformNode" string
  107410. */
  107411. getClassName(): string;
  107412. /**
  107413. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  107414. */
  107415. get position(): Vector3;
  107416. set position(newPosition: Vector3);
  107417. /**
  107418. * 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)).
  107419. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  107420. */
  107421. get rotation(): Vector3;
  107422. set rotation(newRotation: Vector3);
  107423. /**
  107424. * 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)).
  107425. */
  107426. get scaling(): Vector3;
  107427. set scaling(newScaling: Vector3);
  107428. /**
  107429. * 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).
  107430. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  107431. */
  107432. get rotationQuaternion(): Nullable<Quaternion>;
  107433. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  107434. /**
  107435. * The forward direction of that transform in world space.
  107436. */
  107437. get forward(): Vector3;
  107438. /**
  107439. * The up direction of that transform in world space.
  107440. */
  107441. get up(): Vector3;
  107442. /**
  107443. * The right direction of that transform in world space.
  107444. */
  107445. get right(): Vector3;
  107446. /**
  107447. * Copies the parameter passed Matrix into the mesh Pose matrix.
  107448. * @param matrix the matrix to copy the pose from
  107449. * @returns this TransformNode.
  107450. */
  107451. updatePoseMatrix(matrix: Matrix): TransformNode;
  107452. /**
  107453. * Returns the mesh Pose matrix.
  107454. * @returns the pose matrix
  107455. */
  107456. getPoseMatrix(): Matrix;
  107457. /** @hidden */
  107458. _isSynchronized(): boolean;
  107459. /** @hidden */
  107460. _initCache(): void;
  107461. /**
  107462. * Flag the transform node as dirty (Forcing it to update everything)
  107463. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  107464. * @returns this transform node
  107465. */
  107466. markAsDirty(property: string): TransformNode;
  107467. /**
  107468. * Returns the current mesh absolute position.
  107469. * Returns a Vector3.
  107470. */
  107471. get absolutePosition(): Vector3;
  107472. /**
  107473. * Returns the current mesh absolute scaling.
  107474. * Returns a Vector3.
  107475. */
  107476. get absoluteScaling(): Vector3;
  107477. /**
  107478. * Returns the current mesh absolute rotation.
  107479. * Returns a Quaternion.
  107480. */
  107481. get absoluteRotationQuaternion(): Quaternion;
  107482. /**
  107483. * Sets a new matrix to apply before all other transformation
  107484. * @param matrix defines the transform matrix
  107485. * @returns the current TransformNode
  107486. */
  107487. setPreTransformMatrix(matrix: Matrix): TransformNode;
  107488. /**
  107489. * Sets a new pivot matrix to the current node
  107490. * @param matrix defines the new pivot matrix to use
  107491. * @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
  107492. * @returns the current TransformNode
  107493. */
  107494. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  107495. /**
  107496. * Returns the mesh pivot matrix.
  107497. * Default : Identity.
  107498. * @returns the matrix
  107499. */
  107500. getPivotMatrix(): Matrix;
  107501. /**
  107502. * Instantiate (when possible) or clone that node with its hierarchy
  107503. * @param newParent defines the new parent to use for the instance (or clone)
  107504. * @param options defines options to configure how copy is done
  107505. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  107506. * @returns an instance (or a clone) of the current node with its hiearchy
  107507. */
  107508. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  107509. doNotInstantiate: boolean;
  107510. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  107511. /**
  107512. * Prevents the World matrix to be computed any longer
  107513. * @param newWorldMatrix defines an optional matrix to use as world matrix
  107514. * @returns the TransformNode.
  107515. */
  107516. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  107517. /**
  107518. * Allows back the World matrix computation.
  107519. * @returns the TransformNode.
  107520. */
  107521. unfreezeWorldMatrix(): this;
  107522. /**
  107523. * True if the World matrix has been frozen.
  107524. */
  107525. get isWorldMatrixFrozen(): boolean;
  107526. /**
  107527. * Retuns the mesh absolute position in the World.
  107528. * @returns a Vector3.
  107529. */
  107530. getAbsolutePosition(): Vector3;
  107531. /**
  107532. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  107533. * @param absolutePosition the absolute position to set
  107534. * @returns the TransformNode.
  107535. */
  107536. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107537. /**
  107538. * Sets the mesh position in its local space.
  107539. * @param vector3 the position to set in localspace
  107540. * @returns the TransformNode.
  107541. */
  107542. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  107543. /**
  107544. * Returns the mesh position in the local space from the current World matrix values.
  107545. * @returns a new Vector3.
  107546. */
  107547. getPositionExpressedInLocalSpace(): Vector3;
  107548. /**
  107549. * Translates the mesh along the passed Vector3 in its local space.
  107550. * @param vector3 the distance to translate in localspace
  107551. * @returns the TransformNode.
  107552. */
  107553. locallyTranslate(vector3: Vector3): TransformNode;
  107554. private static _lookAtVectorCache;
  107555. /**
  107556. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  107557. * @param targetPoint the position (must be in same space as current mesh) to look at
  107558. * @param yawCor optional yaw (y-axis) correction in radians
  107559. * @param pitchCor optional pitch (x-axis) correction in radians
  107560. * @param rollCor optional roll (z-axis) correction in radians
  107561. * @param space the choosen space of the target
  107562. * @returns the TransformNode.
  107563. */
  107564. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  107565. /**
  107566. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  107567. * This Vector3 is expressed in the World space.
  107568. * @param localAxis axis to rotate
  107569. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  107570. */
  107571. getDirection(localAxis: Vector3): Vector3;
  107572. /**
  107573. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  107574. * localAxis is expressed in the mesh local space.
  107575. * result is computed in the Wordl space from the mesh World matrix.
  107576. * @param localAxis axis to rotate
  107577. * @param result the resulting transformnode
  107578. * @returns this TransformNode.
  107579. */
  107580. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  107581. /**
  107582. * Sets this transform node rotation to the given local axis.
  107583. * @param localAxis the axis in local space
  107584. * @param yawCor optional yaw (y-axis) correction in radians
  107585. * @param pitchCor optional pitch (x-axis) correction in radians
  107586. * @param rollCor optional roll (z-axis) correction in radians
  107587. * @returns this TransformNode
  107588. */
  107589. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  107590. /**
  107591. * Sets a new pivot point to the current node
  107592. * @param point defines the new pivot point to use
  107593. * @param space defines if the point is in world or local space (local by default)
  107594. * @returns the current TransformNode
  107595. */
  107596. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  107597. /**
  107598. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  107599. * @returns the pivot point
  107600. */
  107601. getPivotPoint(): Vector3;
  107602. /**
  107603. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  107604. * @param result the vector3 to store the result
  107605. * @returns this TransformNode.
  107606. */
  107607. getPivotPointToRef(result: Vector3): TransformNode;
  107608. /**
  107609. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  107610. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  107611. */
  107612. getAbsolutePivotPoint(): Vector3;
  107613. /**
  107614. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  107615. * @param result vector3 to store the result
  107616. * @returns this TransformNode.
  107617. */
  107618. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  107619. /**
  107620. * Defines the passed node as the parent of the current node.
  107621. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  107622. * @see https://doc.babylonjs.com/how_to/parenting
  107623. * @param node the node ot set as the parent
  107624. * @returns this TransformNode.
  107625. */
  107626. setParent(node: Nullable<Node>): TransformNode;
  107627. private _nonUniformScaling;
  107628. /**
  107629. * True if the scaling property of this object is non uniform eg. (1,2,1)
  107630. */
  107631. get nonUniformScaling(): boolean;
  107632. /** @hidden */
  107633. _updateNonUniformScalingState(value: boolean): boolean;
  107634. /**
  107635. * Attach the current TransformNode to another TransformNode associated with a bone
  107636. * @param bone Bone affecting the TransformNode
  107637. * @param affectedTransformNode TransformNode associated with the bone
  107638. * @returns this object
  107639. */
  107640. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  107641. /**
  107642. * Detach the transform node if its associated with a bone
  107643. * @returns this object
  107644. */
  107645. detachFromBone(): TransformNode;
  107646. private static _rotationAxisCache;
  107647. /**
  107648. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  107649. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  107650. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  107651. * The passed axis is also normalized.
  107652. * @param axis the axis to rotate around
  107653. * @param amount the amount to rotate in radians
  107654. * @param space Space to rotate in (Default: local)
  107655. * @returns the TransformNode.
  107656. */
  107657. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107658. /**
  107659. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  107660. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  107661. * The passed axis is also normalized. .
  107662. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  107663. * @param point the point to rotate around
  107664. * @param axis the axis to rotate around
  107665. * @param amount the amount to rotate in radians
  107666. * @returns the TransformNode
  107667. */
  107668. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  107669. /**
  107670. * Translates the mesh along the axis vector for the passed distance in the given space.
  107671. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  107672. * @param axis the axis to translate in
  107673. * @param distance the distance to translate
  107674. * @param space Space to rotate in (Default: local)
  107675. * @returns the TransformNode.
  107676. */
  107677. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107678. /**
  107679. * Adds a rotation step to the mesh current rotation.
  107680. * x, y, z are Euler angles expressed in radians.
  107681. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  107682. * This means this rotation is made in the mesh local space only.
  107683. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  107684. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  107685. * ```javascript
  107686. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  107687. * ```
  107688. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  107689. * 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.
  107690. * @param x Rotation to add
  107691. * @param y Rotation to add
  107692. * @param z Rotation to add
  107693. * @returns the TransformNode.
  107694. */
  107695. addRotation(x: number, y: number, z: number): TransformNode;
  107696. /**
  107697. * @hidden
  107698. */
  107699. protected _getEffectiveParent(): Nullable<Node>;
  107700. /**
  107701. * Computes the world matrix of the node
  107702. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  107703. * @returns the world matrix
  107704. */
  107705. computeWorldMatrix(force?: boolean): Matrix;
  107706. /**
  107707. * Resets this nodeTransform's local matrix to Matrix.Identity().
  107708. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  107709. */
  107710. resetLocalMatrix(independentOfChildren?: boolean): void;
  107711. protected _afterComputeWorldMatrix(): void;
  107712. /**
  107713. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  107714. * @param func callback function to add
  107715. *
  107716. * @returns the TransformNode.
  107717. */
  107718. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  107719. /**
  107720. * Removes a registered callback function.
  107721. * @param func callback function to remove
  107722. * @returns the TransformNode.
  107723. */
  107724. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  107725. /**
  107726. * Gets the position of the current mesh in camera space
  107727. * @param camera defines the camera to use
  107728. * @returns a position
  107729. */
  107730. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  107731. /**
  107732. * Returns the distance from the mesh to the active camera
  107733. * @param camera defines the camera to use
  107734. * @returns the distance
  107735. */
  107736. getDistanceToCamera(camera?: Nullable<Camera>): number;
  107737. /**
  107738. * Clone the current transform node
  107739. * @param name Name of the new clone
  107740. * @param newParent New parent for the clone
  107741. * @param doNotCloneChildren Do not clone children hierarchy
  107742. * @returns the new transform node
  107743. */
  107744. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  107745. /**
  107746. * Serializes the objects information.
  107747. * @param currentSerializationObject defines the object to serialize in
  107748. * @returns the serialized object
  107749. */
  107750. serialize(currentSerializationObject?: any): any;
  107751. /**
  107752. * Returns a new TransformNode object parsed from the source provided.
  107753. * @param parsedTransformNode is the source.
  107754. * @param scene the scne the object belongs to
  107755. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  107756. * @returns a new TransformNode object parsed from the source provided.
  107757. */
  107758. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  107759. /**
  107760. * Get all child-transformNodes of this node
  107761. * @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
  107762. * @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
  107763. * @returns an array of TransformNode
  107764. */
  107765. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  107766. /**
  107767. * Releases resources associated with this transform node.
  107768. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107769. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107770. */
  107771. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107772. /**
  107773. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  107774. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  107775. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  107776. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  107777. * @returns the current mesh
  107778. */
  107779. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  107780. private _syncAbsoluteScalingAndRotation;
  107781. }
  107782. }
  107783. declare module BABYLON {
  107784. /**
  107785. * Defines the types of pose enabled controllers that are supported
  107786. */
  107787. export enum PoseEnabledControllerType {
  107788. /**
  107789. * HTC Vive
  107790. */
  107791. VIVE = 0,
  107792. /**
  107793. * Oculus Rift
  107794. */
  107795. OCULUS = 1,
  107796. /**
  107797. * Windows mixed reality
  107798. */
  107799. WINDOWS = 2,
  107800. /**
  107801. * Samsung gear VR
  107802. */
  107803. GEAR_VR = 3,
  107804. /**
  107805. * Google Daydream
  107806. */
  107807. DAYDREAM = 4,
  107808. /**
  107809. * Generic
  107810. */
  107811. GENERIC = 5
  107812. }
  107813. /**
  107814. * Defines the MutableGamepadButton interface for the state of a gamepad button
  107815. */
  107816. export interface MutableGamepadButton {
  107817. /**
  107818. * Value of the button/trigger
  107819. */
  107820. value: number;
  107821. /**
  107822. * If the button/trigger is currently touched
  107823. */
  107824. touched: boolean;
  107825. /**
  107826. * If the button/trigger is currently pressed
  107827. */
  107828. pressed: boolean;
  107829. }
  107830. /**
  107831. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  107832. * @hidden
  107833. */
  107834. export interface ExtendedGamepadButton extends GamepadButton {
  107835. /**
  107836. * If the button/trigger is currently pressed
  107837. */
  107838. readonly pressed: boolean;
  107839. /**
  107840. * If the button/trigger is currently touched
  107841. */
  107842. readonly touched: boolean;
  107843. /**
  107844. * Value of the button/trigger
  107845. */
  107846. readonly value: number;
  107847. }
  107848. /** @hidden */
  107849. export interface _GamePadFactory {
  107850. /**
  107851. * Returns whether or not the current gamepad can be created for this type of controller.
  107852. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  107853. * @returns true if it can be created, otherwise false
  107854. */
  107855. canCreate(gamepadInfo: any): boolean;
  107856. /**
  107857. * Creates a new instance of the Gamepad.
  107858. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  107859. * @returns the new gamepad instance
  107860. */
  107861. create(gamepadInfo: any): Gamepad;
  107862. }
  107863. /**
  107864. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  107865. */
  107866. export class PoseEnabledControllerHelper {
  107867. /** @hidden */
  107868. static _ControllerFactories: _GamePadFactory[];
  107869. /** @hidden */
  107870. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  107871. /**
  107872. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  107873. * @param vrGamepad the gamepad to initialized
  107874. * @returns a vr controller of the type the gamepad identified as
  107875. */
  107876. static InitiateController(vrGamepad: any): Gamepad;
  107877. }
  107878. /**
  107879. * Defines the PoseEnabledController object that contains state of a vr capable controller
  107880. */
  107881. export class PoseEnabledController extends Gamepad implements PoseControlled {
  107882. /**
  107883. * If the controller is used in a webXR session
  107884. */
  107885. isXR: boolean;
  107886. private _deviceRoomPosition;
  107887. private _deviceRoomRotationQuaternion;
  107888. /**
  107889. * The device position in babylon space
  107890. */
  107891. devicePosition: Vector3;
  107892. /**
  107893. * The device rotation in babylon space
  107894. */
  107895. deviceRotationQuaternion: Quaternion;
  107896. /**
  107897. * The scale factor of the device in babylon space
  107898. */
  107899. deviceScaleFactor: number;
  107900. /**
  107901. * (Likely devicePosition should be used instead) The device position in its room space
  107902. */
  107903. position: Vector3;
  107904. /**
  107905. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  107906. */
  107907. rotationQuaternion: Quaternion;
  107908. /**
  107909. * The type of controller (Eg. Windows mixed reality)
  107910. */
  107911. controllerType: PoseEnabledControllerType;
  107912. protected _calculatedPosition: Vector3;
  107913. private _calculatedRotation;
  107914. /**
  107915. * The raw pose from the device
  107916. */
  107917. rawPose: DevicePose;
  107918. private _trackPosition;
  107919. private _maxRotationDistFromHeadset;
  107920. private _draggedRoomRotation;
  107921. /**
  107922. * @hidden
  107923. */
  107924. _disableTrackPosition(fixedPosition: Vector3): void;
  107925. /**
  107926. * Internal, the mesh attached to the controller
  107927. * @hidden
  107928. */
  107929. _mesh: Nullable<AbstractMesh>;
  107930. private _poseControlledCamera;
  107931. private _leftHandSystemQuaternion;
  107932. /**
  107933. * Internal, matrix used to convert room space to babylon space
  107934. * @hidden
  107935. */
  107936. _deviceToWorld: Matrix;
  107937. /**
  107938. * Node to be used when casting a ray from the controller
  107939. * @hidden
  107940. */
  107941. _pointingPoseNode: Nullable<TransformNode>;
  107942. /**
  107943. * Name of the child mesh that can be used to cast a ray from the controller
  107944. */
  107945. static readonly POINTING_POSE: string;
  107946. /**
  107947. * Creates a new PoseEnabledController from a gamepad
  107948. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  107949. */
  107950. constructor(browserGamepad: any);
  107951. private _workingMatrix;
  107952. /**
  107953. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  107954. */
  107955. update(): void;
  107956. /**
  107957. * Updates only the pose device and mesh without doing any button event checking
  107958. */
  107959. protected _updatePoseAndMesh(): void;
  107960. /**
  107961. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  107962. * @param poseData raw pose fromthe device
  107963. */
  107964. updateFromDevice(poseData: DevicePose): void;
  107965. /**
  107966. * @hidden
  107967. */
  107968. _meshAttachedObservable: Observable<AbstractMesh>;
  107969. /**
  107970. * Attaches a mesh to the controller
  107971. * @param mesh the mesh to be attached
  107972. */
  107973. attachToMesh(mesh: AbstractMesh): void;
  107974. /**
  107975. * Attaches the controllers mesh to a camera
  107976. * @param camera the camera the mesh should be attached to
  107977. */
  107978. attachToPoseControlledCamera(camera: TargetCamera): void;
  107979. /**
  107980. * Disposes of the controller
  107981. */
  107982. dispose(): void;
  107983. /**
  107984. * The mesh that is attached to the controller
  107985. */
  107986. get mesh(): Nullable<AbstractMesh>;
  107987. /**
  107988. * Gets the ray of the controller in the direction the controller is pointing
  107989. * @param length the length the resulting ray should be
  107990. * @returns a ray in the direction the controller is pointing
  107991. */
  107992. getForwardRay(length?: number): Ray;
  107993. }
  107994. }
  107995. declare module BABYLON {
  107996. /**
  107997. * Defines the WebVRController object that represents controllers tracked in 3D space
  107998. */
  107999. export abstract class WebVRController extends PoseEnabledController {
  108000. /**
  108001. * Internal, the default controller model for the controller
  108002. */
  108003. protected _defaultModel: Nullable<AbstractMesh>;
  108004. /**
  108005. * Fired when the trigger state has changed
  108006. */
  108007. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  108008. /**
  108009. * Fired when the main button state has changed
  108010. */
  108011. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108012. /**
  108013. * Fired when the secondary button state has changed
  108014. */
  108015. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108016. /**
  108017. * Fired when the pad state has changed
  108018. */
  108019. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  108020. /**
  108021. * Fired when controllers stick values have changed
  108022. */
  108023. onPadValuesChangedObservable: Observable<StickValues>;
  108024. /**
  108025. * Array of button availible on the controller
  108026. */
  108027. protected _buttons: Array<MutableGamepadButton>;
  108028. private _onButtonStateChange;
  108029. /**
  108030. * Fired when a controller button's state has changed
  108031. * @param callback the callback containing the button that was modified
  108032. */
  108033. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  108034. /**
  108035. * X and Y axis corresponding to the controllers joystick
  108036. */
  108037. pad: StickValues;
  108038. /**
  108039. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  108040. */
  108041. hand: string;
  108042. /**
  108043. * The default controller model for the controller
  108044. */
  108045. get defaultModel(): Nullable<AbstractMesh>;
  108046. /**
  108047. * Creates a new WebVRController from a gamepad
  108048. * @param vrGamepad the gamepad that the WebVRController should be created from
  108049. */
  108050. constructor(vrGamepad: any);
  108051. /**
  108052. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  108053. */
  108054. update(): void;
  108055. /**
  108056. * Function to be called when a button is modified
  108057. */
  108058. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108059. /**
  108060. * Loads a mesh and attaches it to the controller
  108061. * @param scene the scene the mesh should be added to
  108062. * @param meshLoaded callback for when the mesh has been loaded
  108063. */
  108064. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108065. private _setButtonValue;
  108066. private _changes;
  108067. private _checkChanges;
  108068. /**
  108069. * Disposes of th webVRCOntroller
  108070. */
  108071. dispose(): void;
  108072. }
  108073. }
  108074. declare module BABYLON {
  108075. /**
  108076. * The HemisphericLight simulates the ambient environment light,
  108077. * so the passed direction is the light reflection direction, not the incoming direction.
  108078. */
  108079. export class HemisphericLight extends Light {
  108080. /**
  108081. * The groundColor is the light in the opposite direction to the one specified during creation.
  108082. * 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.
  108083. */
  108084. groundColor: Color3;
  108085. /**
  108086. * The light reflection direction, not the incoming direction.
  108087. */
  108088. direction: Vector3;
  108089. /**
  108090. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  108091. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  108092. * The HemisphericLight can't cast shadows.
  108093. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108094. * @param name The friendly name of the light
  108095. * @param direction The direction of the light reflection
  108096. * @param scene The scene the light belongs to
  108097. */
  108098. constructor(name: string, direction: Vector3, scene: Scene);
  108099. protected _buildUniformLayout(): void;
  108100. /**
  108101. * Returns the string "HemisphericLight".
  108102. * @return The class name
  108103. */
  108104. getClassName(): string;
  108105. /**
  108106. * Sets the HemisphericLight direction towards the passed target (Vector3).
  108107. * Returns the updated direction.
  108108. * @param target The target the direction should point to
  108109. * @return The computed direction
  108110. */
  108111. setDirectionToTarget(target: Vector3): Vector3;
  108112. /**
  108113. * Returns the shadow generator associated to the light.
  108114. * @returns Always null for hemispheric lights because it does not support shadows.
  108115. */
  108116. getShadowGenerator(): Nullable<IShadowGenerator>;
  108117. /**
  108118. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  108119. * @param effect The effect to update
  108120. * @param lightIndex The index of the light in the effect to update
  108121. * @returns The hemispheric light
  108122. */
  108123. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  108124. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  108125. /**
  108126. * Computes the world matrix of the node
  108127. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  108128. * @param useWasUpdatedFlag defines a reserved property
  108129. * @returns the world matrix
  108130. */
  108131. computeWorldMatrix(): Matrix;
  108132. /**
  108133. * Returns the integer 3.
  108134. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108135. */
  108136. getTypeID(): number;
  108137. /**
  108138. * Prepares the list of defines specific to the light type.
  108139. * @param defines the list of defines
  108140. * @param lightIndex defines the index of the light for the effect
  108141. */
  108142. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108143. }
  108144. }
  108145. declare module BABYLON {
  108146. /** @hidden */
  108147. export var vrMultiviewToSingleviewPixelShader: {
  108148. name: string;
  108149. shader: string;
  108150. };
  108151. }
  108152. declare module BABYLON {
  108153. /**
  108154. * Renders to multiple views with a single draw call
  108155. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  108156. */
  108157. export class MultiviewRenderTarget extends RenderTargetTexture {
  108158. /**
  108159. * Creates a multiview render target
  108160. * @param scene scene used with the render target
  108161. * @param size the size of the render target (used for each view)
  108162. */
  108163. constructor(scene: Scene, size?: number | {
  108164. width: number;
  108165. height: number;
  108166. } | {
  108167. ratio: number;
  108168. });
  108169. /**
  108170. * @hidden
  108171. * @param faceIndex the face index, if its a cube texture
  108172. */
  108173. _bindFrameBuffer(faceIndex?: number): void;
  108174. /**
  108175. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  108176. * @returns the view count
  108177. */
  108178. getViewCount(): number;
  108179. }
  108180. }
  108181. declare module BABYLON {
  108182. interface Engine {
  108183. /**
  108184. * Creates a new multiview render target
  108185. * @param width defines the width of the texture
  108186. * @param height defines the height of the texture
  108187. * @returns the created multiview texture
  108188. */
  108189. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  108190. /**
  108191. * Binds a multiview framebuffer to be drawn to
  108192. * @param multiviewTexture texture to bind
  108193. */
  108194. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  108195. }
  108196. interface Camera {
  108197. /**
  108198. * @hidden
  108199. * 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)
  108200. */
  108201. _useMultiviewToSingleView: boolean;
  108202. /**
  108203. * @hidden
  108204. * 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)
  108205. */
  108206. _multiviewTexture: Nullable<RenderTargetTexture>;
  108207. /**
  108208. * @hidden
  108209. * ensures the multiview texture of the camera exists and has the specified width/height
  108210. * @param width height to set on the multiview texture
  108211. * @param height width to set on the multiview texture
  108212. */
  108213. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  108214. }
  108215. interface Scene {
  108216. /** @hidden */
  108217. _transformMatrixR: Matrix;
  108218. /** @hidden */
  108219. _multiviewSceneUbo: Nullable<UniformBuffer>;
  108220. /** @hidden */
  108221. _createMultiviewUbo(): void;
  108222. /** @hidden */
  108223. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  108224. /** @hidden */
  108225. _renderMultiviewToSingleView(camera: Camera): void;
  108226. }
  108227. }
  108228. declare module BABYLON {
  108229. /**
  108230. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  108231. * This will not be used for webXR as it supports displaying texture arrays directly
  108232. */
  108233. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  108234. /**
  108235. * Gets a string identifying the name of the class
  108236. * @returns "VRMultiviewToSingleviewPostProcess" string
  108237. */
  108238. getClassName(): string;
  108239. /**
  108240. * Initializes a VRMultiviewToSingleview
  108241. * @param name name of the post process
  108242. * @param camera camera to be applied to
  108243. * @param scaleFactor scaling factor to the size of the output texture
  108244. */
  108245. constructor(name: string, camera: Camera, scaleFactor: number);
  108246. }
  108247. }
  108248. declare module BABYLON {
  108249. /**
  108250. * Interface used to define additional presentation attributes
  108251. */
  108252. export interface IVRPresentationAttributes {
  108253. /**
  108254. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  108255. */
  108256. highRefreshRate: boolean;
  108257. /**
  108258. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  108259. */
  108260. foveationLevel: number;
  108261. }
  108262. interface Engine {
  108263. /** @hidden */
  108264. _vrDisplay: any;
  108265. /** @hidden */
  108266. _vrSupported: boolean;
  108267. /** @hidden */
  108268. _oldSize: Size;
  108269. /** @hidden */
  108270. _oldHardwareScaleFactor: number;
  108271. /** @hidden */
  108272. _vrExclusivePointerMode: boolean;
  108273. /** @hidden */
  108274. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  108275. /** @hidden */
  108276. _onVRDisplayPointerRestricted: () => void;
  108277. /** @hidden */
  108278. _onVRDisplayPointerUnrestricted: () => void;
  108279. /** @hidden */
  108280. _onVrDisplayConnect: Nullable<(display: any) => void>;
  108281. /** @hidden */
  108282. _onVrDisplayDisconnect: Nullable<() => void>;
  108283. /** @hidden */
  108284. _onVrDisplayPresentChange: Nullable<() => void>;
  108285. /**
  108286. * Observable signaled when VR display mode changes
  108287. */
  108288. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  108289. /**
  108290. * Observable signaled when VR request present is complete
  108291. */
  108292. onVRRequestPresentComplete: Observable<boolean>;
  108293. /**
  108294. * Observable signaled when VR request present starts
  108295. */
  108296. onVRRequestPresentStart: Observable<Engine>;
  108297. /**
  108298. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  108299. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  108300. */
  108301. isInVRExclusivePointerMode: boolean;
  108302. /**
  108303. * Gets a boolean indicating if a webVR device was detected
  108304. * @returns true if a webVR device was detected
  108305. */
  108306. isVRDevicePresent(): boolean;
  108307. /**
  108308. * Gets the current webVR device
  108309. * @returns the current webVR device (or null)
  108310. */
  108311. getVRDevice(): any;
  108312. /**
  108313. * Initializes a webVR display and starts listening to display change events
  108314. * The onVRDisplayChangedObservable will be notified upon these changes
  108315. * @returns A promise containing a VRDisplay and if vr is supported
  108316. */
  108317. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  108318. /** @hidden */
  108319. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  108320. /**
  108321. * Gets or sets the presentation attributes used to configure VR rendering
  108322. */
  108323. vrPresentationAttributes?: IVRPresentationAttributes;
  108324. /**
  108325. * Call this function to switch to webVR mode
  108326. * Will do nothing if webVR is not supported or if there is no webVR device
  108327. * @param options the webvr options provided to the camera. mainly used for multiview
  108328. * @see https://doc.babylonjs.com/how_to/webvr_camera
  108329. */
  108330. enableVR(options: WebVROptions): void;
  108331. /** @hidden */
  108332. _onVRFullScreenTriggered(): void;
  108333. }
  108334. }
  108335. declare module BABYLON {
  108336. /**
  108337. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  108338. * IMPORTANT!! The data is right-hand data.
  108339. * @export
  108340. * @interface DevicePose
  108341. */
  108342. export interface DevicePose {
  108343. /**
  108344. * The position of the device, values in array are [x,y,z].
  108345. */
  108346. readonly position: Nullable<Float32Array>;
  108347. /**
  108348. * The linearVelocity of the device, values in array are [x,y,z].
  108349. */
  108350. readonly linearVelocity: Nullable<Float32Array>;
  108351. /**
  108352. * The linearAcceleration of the device, values in array are [x,y,z].
  108353. */
  108354. readonly linearAcceleration: Nullable<Float32Array>;
  108355. /**
  108356. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  108357. */
  108358. readonly orientation: Nullable<Float32Array>;
  108359. /**
  108360. * The angularVelocity of the device, values in array are [x,y,z].
  108361. */
  108362. readonly angularVelocity: Nullable<Float32Array>;
  108363. /**
  108364. * The angularAcceleration of the device, values in array are [x,y,z].
  108365. */
  108366. readonly angularAcceleration: Nullable<Float32Array>;
  108367. }
  108368. /**
  108369. * Interface representing a pose controlled object in Babylon.
  108370. * A pose controlled object has both regular pose values as well as pose values
  108371. * from an external device such as a VR head mounted display
  108372. */
  108373. export interface PoseControlled {
  108374. /**
  108375. * The position of the object in babylon space.
  108376. */
  108377. position: Vector3;
  108378. /**
  108379. * The rotation quaternion of the object in babylon space.
  108380. */
  108381. rotationQuaternion: Quaternion;
  108382. /**
  108383. * The position of the device in babylon space.
  108384. */
  108385. devicePosition?: Vector3;
  108386. /**
  108387. * The rotation quaternion of the device in babylon space.
  108388. */
  108389. deviceRotationQuaternion: Quaternion;
  108390. /**
  108391. * The raw pose coming from the device.
  108392. */
  108393. rawPose: Nullable<DevicePose>;
  108394. /**
  108395. * The scale of the device to be used when translating from device space to babylon space.
  108396. */
  108397. deviceScaleFactor: number;
  108398. /**
  108399. * Updates the poseControlled values based on the input device pose.
  108400. * @param poseData the pose data to update the object with
  108401. */
  108402. updateFromDevice(poseData: DevicePose): void;
  108403. }
  108404. /**
  108405. * Set of options to customize the webVRCamera
  108406. */
  108407. export interface WebVROptions {
  108408. /**
  108409. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  108410. */
  108411. trackPosition?: boolean;
  108412. /**
  108413. * Sets the scale of the vrDevice in babylon space. (default: 1)
  108414. */
  108415. positionScale?: number;
  108416. /**
  108417. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  108418. */
  108419. displayName?: string;
  108420. /**
  108421. * Should the native controller meshes be initialized. (default: true)
  108422. */
  108423. controllerMeshes?: boolean;
  108424. /**
  108425. * Creating a default HemiLight only on controllers. (default: true)
  108426. */
  108427. defaultLightingOnControllers?: boolean;
  108428. /**
  108429. * If you don't want to use the default VR button of the helper. (default: false)
  108430. */
  108431. useCustomVRButton?: boolean;
  108432. /**
  108433. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  108434. */
  108435. customVRButton?: HTMLButtonElement;
  108436. /**
  108437. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  108438. */
  108439. rayLength?: number;
  108440. /**
  108441. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  108442. */
  108443. defaultHeight?: number;
  108444. /**
  108445. * If multiview should be used if availible (default: false)
  108446. */
  108447. useMultiview?: boolean;
  108448. }
  108449. /**
  108450. * This represents a WebVR camera.
  108451. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  108452. * @example https://doc.babylonjs.com/how_to/webvr_camera
  108453. */
  108454. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  108455. private webVROptions;
  108456. /**
  108457. * @hidden
  108458. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  108459. */
  108460. _vrDevice: any;
  108461. /**
  108462. * The rawPose of the vrDevice.
  108463. */
  108464. rawPose: Nullable<DevicePose>;
  108465. private _onVREnabled;
  108466. private _specsVersion;
  108467. private _attached;
  108468. private _frameData;
  108469. protected _descendants: Array<Node>;
  108470. private _deviceRoomPosition;
  108471. /** @hidden */
  108472. _deviceRoomRotationQuaternion: Quaternion;
  108473. private _standingMatrix;
  108474. /**
  108475. * Represents device position in babylon space.
  108476. */
  108477. devicePosition: Vector3;
  108478. /**
  108479. * Represents device rotation in babylon space.
  108480. */
  108481. deviceRotationQuaternion: Quaternion;
  108482. /**
  108483. * The scale of the device to be used when translating from device space to babylon space.
  108484. */
  108485. deviceScaleFactor: number;
  108486. private _deviceToWorld;
  108487. private _worldToDevice;
  108488. /**
  108489. * References to the webVR controllers for the vrDevice.
  108490. */
  108491. controllers: Array<WebVRController>;
  108492. /**
  108493. * Emits an event when a controller is attached.
  108494. */
  108495. onControllersAttachedObservable: Observable<WebVRController[]>;
  108496. /**
  108497. * Emits an event when a controller's mesh has been loaded;
  108498. */
  108499. onControllerMeshLoadedObservable: Observable<WebVRController>;
  108500. /**
  108501. * Emits an event when the HMD's pose has been updated.
  108502. */
  108503. onPoseUpdatedFromDeviceObservable: Observable<any>;
  108504. private _poseSet;
  108505. /**
  108506. * If the rig cameras be used as parent instead of this camera.
  108507. */
  108508. rigParenting: boolean;
  108509. private _lightOnControllers;
  108510. private _defaultHeight?;
  108511. /**
  108512. * Instantiates a WebVRFreeCamera.
  108513. * @param name The name of the WebVRFreeCamera
  108514. * @param position The starting anchor position for the camera
  108515. * @param scene The scene the camera belongs to
  108516. * @param webVROptions a set of customizable options for the webVRCamera
  108517. */
  108518. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  108519. /**
  108520. * Gets the device distance from the ground in meters.
  108521. * @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.
  108522. */
  108523. deviceDistanceToRoomGround(): number;
  108524. /**
  108525. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  108526. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  108527. */
  108528. useStandingMatrix(callback?: (bool: boolean) => void): void;
  108529. /**
  108530. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  108531. * @returns A promise with a boolean set to if the standing matrix is supported.
  108532. */
  108533. useStandingMatrixAsync(): Promise<boolean>;
  108534. /**
  108535. * Disposes the camera
  108536. */
  108537. dispose(): void;
  108538. /**
  108539. * Gets a vrController by name.
  108540. * @param name The name of the controller to retreive
  108541. * @returns the controller matching the name specified or null if not found
  108542. */
  108543. getControllerByName(name: string): Nullable<WebVRController>;
  108544. private _leftController;
  108545. /**
  108546. * The controller corresponding to the users left hand.
  108547. */
  108548. get leftController(): Nullable<WebVRController>;
  108549. private _rightController;
  108550. /**
  108551. * The controller corresponding to the users right hand.
  108552. */
  108553. get rightController(): Nullable<WebVRController>;
  108554. /**
  108555. * Casts a ray forward from the vrCamera's gaze.
  108556. * @param length Length of the ray (default: 100)
  108557. * @returns the ray corresponding to the gaze
  108558. */
  108559. getForwardRay(length?: number): Ray;
  108560. /**
  108561. * @hidden
  108562. * Updates the camera based on device's frame data
  108563. */
  108564. _checkInputs(): void;
  108565. /**
  108566. * Updates the poseControlled values based on the input device pose.
  108567. * @param poseData Pose coming from the device
  108568. */
  108569. updateFromDevice(poseData: DevicePose): void;
  108570. private _detachIfAttached;
  108571. /**
  108572. * WebVR's attach control will start broadcasting frames to the device.
  108573. * Note that in certain browsers (chrome for example) this function must be called
  108574. * within a user-interaction callback. Example:
  108575. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  108576. *
  108577. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  108578. */
  108579. attachControl(noPreventDefault?: boolean): void;
  108580. /**
  108581. * Detach the current controls from the specified dom element.
  108582. */
  108583. detachControl(): void;
  108584. /**
  108585. * @returns the name of this class
  108586. */
  108587. getClassName(): string;
  108588. /**
  108589. * Calls resetPose on the vrDisplay
  108590. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  108591. */
  108592. resetToCurrentRotation(): void;
  108593. /**
  108594. * @hidden
  108595. * Updates the rig cameras (left and right eye)
  108596. */
  108597. _updateRigCameras(): void;
  108598. private _workingVector;
  108599. private _oneVector;
  108600. private _workingMatrix;
  108601. private updateCacheCalled;
  108602. private _correctPositionIfNotTrackPosition;
  108603. /**
  108604. * @hidden
  108605. * Updates the cached values of the camera
  108606. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  108607. */
  108608. _updateCache(ignoreParentClass?: boolean): void;
  108609. /**
  108610. * @hidden
  108611. * Get current device position in babylon world
  108612. */
  108613. _computeDevicePosition(): void;
  108614. /**
  108615. * Updates the current device position and rotation in the babylon world
  108616. */
  108617. update(): void;
  108618. /**
  108619. * @hidden
  108620. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  108621. * @returns an identity matrix
  108622. */
  108623. _getViewMatrix(): Matrix;
  108624. private _tmpMatrix;
  108625. /**
  108626. * This function is called by the two RIG cameras.
  108627. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  108628. * @hidden
  108629. */
  108630. _getWebVRViewMatrix(): Matrix;
  108631. /** @hidden */
  108632. _getWebVRProjectionMatrix(): Matrix;
  108633. private _onGamepadConnectedObserver;
  108634. private _onGamepadDisconnectedObserver;
  108635. private _updateCacheWhenTrackingDisabledObserver;
  108636. /**
  108637. * Initializes the controllers and their meshes
  108638. */
  108639. initControllers(): void;
  108640. }
  108641. }
  108642. declare module BABYLON {
  108643. /**
  108644. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  108645. *
  108646. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  108647. *
  108648. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  108649. */
  108650. export class MaterialHelper {
  108651. /**
  108652. * Bind the current view position to an effect.
  108653. * @param effect The effect to be bound
  108654. * @param scene The scene the eyes position is used from
  108655. * @param variableName name of the shader variable that will hold the eye position
  108656. */
  108657. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  108658. /**
  108659. * Helps preparing the defines values about the UVs in used in the effect.
  108660. * UVs are shared as much as we can accross channels in the shaders.
  108661. * @param texture The texture we are preparing the UVs for
  108662. * @param defines The defines to update
  108663. * @param key The channel key "diffuse", "specular"... used in the shader
  108664. */
  108665. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  108666. /**
  108667. * Binds a texture matrix value to its corrsponding uniform
  108668. * @param texture The texture to bind the matrix for
  108669. * @param uniformBuffer The uniform buffer receivin the data
  108670. * @param key The channel key "diffuse", "specular"... used in the shader
  108671. */
  108672. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  108673. /**
  108674. * Gets the current status of the fog (should it be enabled?)
  108675. * @param mesh defines the mesh to evaluate for fog support
  108676. * @param scene defines the hosting scene
  108677. * @returns true if fog must be enabled
  108678. */
  108679. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  108680. /**
  108681. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  108682. * @param mesh defines the current mesh
  108683. * @param scene defines the current scene
  108684. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  108685. * @param pointsCloud defines if point cloud rendering has to be turned on
  108686. * @param fogEnabled defines if fog has to be turned on
  108687. * @param alphaTest defines if alpha testing has to be turned on
  108688. * @param defines defines the current list of defines
  108689. */
  108690. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  108691. /**
  108692. * Helper used to prepare the list of defines associated with frame values for shader compilation
  108693. * @param scene defines the current scene
  108694. * @param engine defines the current engine
  108695. * @param defines specifies the list of active defines
  108696. * @param useInstances defines if instances have to be turned on
  108697. * @param useClipPlane defines if clip plane have to be turned on
  108698. * @param useInstances defines if instances have to be turned on
  108699. * @param useThinInstances defines if thin instances have to be turned on
  108700. */
  108701. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  108702. /**
  108703. * Prepares the defines for bones
  108704. * @param mesh The mesh containing the geometry data we will draw
  108705. * @param defines The defines to update
  108706. */
  108707. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  108708. /**
  108709. * Prepares the defines for morph targets
  108710. * @param mesh The mesh containing the geometry data we will draw
  108711. * @param defines The defines to update
  108712. */
  108713. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  108714. /**
  108715. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  108716. * @param mesh The mesh containing the geometry data we will draw
  108717. * @param defines The defines to update
  108718. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  108719. * @param useBones Precise whether bones should be used or not (override mesh info)
  108720. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  108721. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  108722. * @returns false if defines are considered not dirty and have not been checked
  108723. */
  108724. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  108725. /**
  108726. * Prepares the defines related to multiview
  108727. * @param scene The scene we are intending to draw
  108728. * @param defines The defines to update
  108729. */
  108730. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  108731. /**
  108732. * Prepares the defines related to the prepass
  108733. * @param scene The scene we are intending to draw
  108734. * @param defines The defines to update
  108735. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  108736. */
  108737. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  108738. /**
  108739. * Prepares the defines related to the light information passed in parameter
  108740. * @param scene The scene we are intending to draw
  108741. * @param mesh The mesh the effect is compiling for
  108742. * @param light The light the effect is compiling for
  108743. * @param lightIndex The index of the light
  108744. * @param defines The defines to update
  108745. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  108746. * @param state Defines the current state regarding what is needed (normals, etc...)
  108747. */
  108748. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  108749. needNormals: boolean;
  108750. needRebuild: boolean;
  108751. shadowEnabled: boolean;
  108752. specularEnabled: boolean;
  108753. lightmapMode: boolean;
  108754. }): void;
  108755. /**
  108756. * Prepares the defines related to the light information passed in parameter
  108757. * @param scene The scene we are intending to draw
  108758. * @param mesh The mesh the effect is compiling for
  108759. * @param defines The defines to update
  108760. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  108761. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  108762. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  108763. * @returns true if normals will be required for the rest of the effect
  108764. */
  108765. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  108766. /**
  108767. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  108768. * @param lightIndex defines the light index
  108769. * @param uniformsList The uniform list
  108770. * @param samplersList The sampler list
  108771. * @param projectedLightTexture defines if projected texture must be used
  108772. * @param uniformBuffersList defines an optional list of uniform buffers
  108773. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  108774. */
  108775. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  108776. /**
  108777. * Prepares the uniforms and samplers list to be used in the effect
  108778. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  108779. * @param samplersList The sampler list
  108780. * @param defines The defines helping in the list generation
  108781. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  108782. */
  108783. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  108784. /**
  108785. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  108786. * @param defines The defines to update while falling back
  108787. * @param fallbacks The authorized effect fallbacks
  108788. * @param maxSimultaneousLights The maximum number of lights allowed
  108789. * @param rank the current rank of the Effect
  108790. * @returns The newly affected rank
  108791. */
  108792. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  108793. private static _TmpMorphInfluencers;
  108794. /**
  108795. * Prepares the list of attributes required for morph targets according to the effect defines.
  108796. * @param attribs The current list of supported attribs
  108797. * @param mesh The mesh to prepare the morph targets attributes for
  108798. * @param influencers The number of influencers
  108799. */
  108800. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  108801. /**
  108802. * Prepares the list of attributes required for morph targets according to the effect defines.
  108803. * @param attribs The current list of supported attribs
  108804. * @param mesh The mesh to prepare the morph targets attributes for
  108805. * @param defines The current Defines of the effect
  108806. */
  108807. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  108808. /**
  108809. * Prepares the list of attributes required for bones according to the effect defines.
  108810. * @param attribs The current list of supported attribs
  108811. * @param mesh The mesh to prepare the bones attributes for
  108812. * @param defines The current Defines of the effect
  108813. * @param fallbacks The current efffect fallback strategy
  108814. */
  108815. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  108816. /**
  108817. * Check and prepare the list of attributes required for instances according to the effect defines.
  108818. * @param attribs The current list of supported attribs
  108819. * @param defines The current MaterialDefines of the effect
  108820. */
  108821. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  108822. /**
  108823. * Add the list of attributes required for instances to the attribs array.
  108824. * @param attribs The current list of supported attribs
  108825. */
  108826. static PushAttributesForInstances(attribs: string[]): void;
  108827. /**
  108828. * Binds the light information to the effect.
  108829. * @param light The light containing the generator
  108830. * @param effect The effect we are binding the data to
  108831. * @param lightIndex The light index in the effect used to render
  108832. */
  108833. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  108834. /**
  108835. * Binds the lights information from the scene to the effect for the given mesh.
  108836. * @param light Light to bind
  108837. * @param lightIndex Light index
  108838. * @param scene The scene where the light belongs to
  108839. * @param effect The effect we are binding the data to
  108840. * @param useSpecular Defines if specular is supported
  108841. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  108842. */
  108843. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  108844. /**
  108845. * Binds the lights information from the scene to the effect for the given mesh.
  108846. * @param scene The scene the lights belongs to
  108847. * @param mesh The mesh we are binding the information to render
  108848. * @param effect The effect we are binding the data to
  108849. * @param defines The generated defines for the effect
  108850. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  108851. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  108852. */
  108853. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  108854. private static _tempFogColor;
  108855. /**
  108856. * Binds the fog information from the scene to the effect for the given mesh.
  108857. * @param scene The scene the lights belongs to
  108858. * @param mesh The mesh we are binding the information to render
  108859. * @param effect The effect we are binding the data to
  108860. * @param linearSpace Defines if the fog effect is applied in linear space
  108861. */
  108862. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  108863. /**
  108864. * Binds the bones information from the mesh to the effect.
  108865. * @param mesh The mesh we are binding the information to render
  108866. * @param effect The effect we are binding the data to
  108867. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  108868. */
  108869. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  108870. private static _CopyBonesTransformationMatrices;
  108871. /**
  108872. * Binds the morph targets information from the mesh to the effect.
  108873. * @param abstractMesh The mesh we are binding the information to render
  108874. * @param effect The effect we are binding the data to
  108875. */
  108876. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  108877. /**
  108878. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  108879. * @param defines The generated defines used in the effect
  108880. * @param effect The effect we are binding the data to
  108881. * @param scene The scene we are willing to render with logarithmic scale for
  108882. */
  108883. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  108884. /**
  108885. * Binds the clip plane information from the scene to the effect.
  108886. * @param scene The scene the clip plane information are extracted from
  108887. * @param effect The effect we are binding the data to
  108888. */
  108889. static BindClipPlane(effect: Effect, scene: Scene): void;
  108890. }
  108891. }
  108892. declare module BABYLON {
  108893. /** @hidden */
  108894. export var bayerDitherFunctions: {
  108895. name: string;
  108896. shader: string;
  108897. };
  108898. }
  108899. declare module BABYLON {
  108900. /** @hidden */
  108901. export var shadowMapFragmentDeclaration: {
  108902. name: string;
  108903. shader: string;
  108904. };
  108905. }
  108906. declare module BABYLON {
  108907. /** @hidden */
  108908. export var shadowMapFragment: {
  108909. name: string;
  108910. shader: string;
  108911. };
  108912. }
  108913. declare module BABYLON {
  108914. /** @hidden */
  108915. export var shadowMapPixelShader: {
  108916. name: string;
  108917. shader: string;
  108918. };
  108919. }
  108920. declare module BABYLON {
  108921. /** @hidden */
  108922. export var shadowMapVertexDeclaration: {
  108923. name: string;
  108924. shader: string;
  108925. };
  108926. }
  108927. declare module BABYLON {
  108928. /** @hidden */
  108929. export var shadowMapVertexNormalBias: {
  108930. name: string;
  108931. shader: string;
  108932. };
  108933. }
  108934. declare module BABYLON {
  108935. /** @hidden */
  108936. export var shadowMapVertexMetric: {
  108937. name: string;
  108938. shader: string;
  108939. };
  108940. }
  108941. declare module BABYLON {
  108942. /** @hidden */
  108943. export var shadowMapVertexShader: {
  108944. name: string;
  108945. shader: string;
  108946. };
  108947. }
  108948. declare module BABYLON {
  108949. /** @hidden */
  108950. export var depthBoxBlurPixelShader: {
  108951. name: string;
  108952. shader: string;
  108953. };
  108954. }
  108955. declare module BABYLON {
  108956. /** @hidden */
  108957. export var shadowMapFragmentSoftTransparentShadow: {
  108958. name: string;
  108959. shader: string;
  108960. };
  108961. }
  108962. declare module BABYLON {
  108963. /**
  108964. * Creates an instance based on a source mesh.
  108965. */
  108966. export class InstancedMesh extends AbstractMesh {
  108967. private _sourceMesh;
  108968. private _currentLOD;
  108969. /** @hidden */
  108970. _indexInSourceMeshInstanceArray: number;
  108971. constructor(name: string, source: Mesh);
  108972. /**
  108973. * Returns the string "InstancedMesh".
  108974. */
  108975. getClassName(): string;
  108976. /** Gets the list of lights affecting that mesh */
  108977. get lightSources(): Light[];
  108978. _resyncLightSources(): void;
  108979. _resyncLightSource(light: Light): void;
  108980. _removeLightSource(light: Light, dispose: boolean): void;
  108981. /**
  108982. * If the source mesh receives shadows
  108983. */
  108984. get receiveShadows(): boolean;
  108985. /**
  108986. * The material of the source mesh
  108987. */
  108988. get material(): Nullable<Material>;
  108989. /**
  108990. * Visibility of the source mesh
  108991. */
  108992. get visibility(): number;
  108993. /**
  108994. * Skeleton of the source mesh
  108995. */
  108996. get skeleton(): Nullable<Skeleton>;
  108997. /**
  108998. * Rendering ground id of the source mesh
  108999. */
  109000. get renderingGroupId(): number;
  109001. set renderingGroupId(value: number);
  109002. /**
  109003. * Returns the total number of vertices (integer).
  109004. */
  109005. getTotalVertices(): number;
  109006. /**
  109007. * Returns a positive integer : the total number of indices in this mesh geometry.
  109008. * @returns the numner of indices or zero if the mesh has no geometry.
  109009. */
  109010. getTotalIndices(): number;
  109011. /**
  109012. * The source mesh of the instance
  109013. */
  109014. get sourceMesh(): Mesh;
  109015. /**
  109016. * Creates a new InstancedMesh object from the mesh model.
  109017. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109018. * @param name defines the name of the new instance
  109019. * @returns a new InstancedMesh
  109020. */
  109021. createInstance(name: string): InstancedMesh;
  109022. /**
  109023. * Is this node ready to be used/rendered
  109024. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109025. * @return {boolean} is it ready
  109026. */
  109027. isReady(completeCheck?: boolean): boolean;
  109028. /**
  109029. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  109030. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  109031. * @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.
  109032. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  109033. */
  109034. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  109035. /**
  109036. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109037. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109038. * The `data` are either a numeric array either a Float32Array.
  109039. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  109040. * 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).
  109041. * Note that a new underlying VertexBuffer object is created each call.
  109042. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109043. *
  109044. * Possible `kind` values :
  109045. * - VertexBuffer.PositionKind
  109046. * - VertexBuffer.UVKind
  109047. * - VertexBuffer.UV2Kind
  109048. * - VertexBuffer.UV3Kind
  109049. * - VertexBuffer.UV4Kind
  109050. * - VertexBuffer.UV5Kind
  109051. * - VertexBuffer.UV6Kind
  109052. * - VertexBuffer.ColorKind
  109053. * - VertexBuffer.MatricesIndicesKind
  109054. * - VertexBuffer.MatricesIndicesExtraKind
  109055. * - VertexBuffer.MatricesWeightsKind
  109056. * - VertexBuffer.MatricesWeightsExtraKind
  109057. *
  109058. * Returns the Mesh.
  109059. */
  109060. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109061. /**
  109062. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109063. * If the mesh has no geometry, it is simply returned as it is.
  109064. * The `data` are either a numeric array either a Float32Array.
  109065. * No new underlying VertexBuffer object is created.
  109066. * 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.
  109067. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  109068. *
  109069. * Possible `kind` values :
  109070. * - VertexBuffer.PositionKind
  109071. * - VertexBuffer.UVKind
  109072. * - VertexBuffer.UV2Kind
  109073. * - VertexBuffer.UV3Kind
  109074. * - VertexBuffer.UV4Kind
  109075. * - VertexBuffer.UV5Kind
  109076. * - VertexBuffer.UV6Kind
  109077. * - VertexBuffer.ColorKind
  109078. * - VertexBuffer.MatricesIndicesKind
  109079. * - VertexBuffer.MatricesIndicesExtraKind
  109080. * - VertexBuffer.MatricesWeightsKind
  109081. * - VertexBuffer.MatricesWeightsExtraKind
  109082. *
  109083. * Returns the Mesh.
  109084. */
  109085. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  109086. /**
  109087. * Sets the mesh indices.
  109088. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  109089. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109090. * This method creates a new index buffer each call.
  109091. * Returns the Mesh.
  109092. */
  109093. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  109094. /**
  109095. * Boolean : True if the mesh owns the requested kind of data.
  109096. */
  109097. isVerticesDataPresent(kind: string): boolean;
  109098. /**
  109099. * Returns an array of indices (IndicesArray).
  109100. */
  109101. getIndices(): Nullable<IndicesArray>;
  109102. get _positions(): Nullable<Vector3[]>;
  109103. /**
  109104. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109105. * This means the mesh underlying bounding box and sphere are recomputed.
  109106. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109107. * @returns the current mesh
  109108. */
  109109. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  109110. /** @hidden */
  109111. _preActivate(): InstancedMesh;
  109112. /** @hidden */
  109113. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109114. /** @hidden */
  109115. _postActivate(): void;
  109116. getWorldMatrix(): Matrix;
  109117. get isAnInstance(): boolean;
  109118. /**
  109119. * Returns the current associated LOD AbstractMesh.
  109120. */
  109121. getLOD(camera: Camera): AbstractMesh;
  109122. /** @hidden */
  109123. _preActivateForIntermediateRendering(renderId: number): Mesh;
  109124. /** @hidden */
  109125. _syncSubMeshes(): InstancedMesh;
  109126. /** @hidden */
  109127. _generatePointsArray(): boolean;
  109128. /** @hidden */
  109129. _updateBoundingInfo(): AbstractMesh;
  109130. /**
  109131. * Creates a new InstancedMesh from the current mesh.
  109132. * - name (string) : the cloned mesh name
  109133. * - newParent (optional Node) : the optional Node to parent the clone to.
  109134. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  109135. *
  109136. * Returns the clone.
  109137. */
  109138. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  109139. /**
  109140. * Disposes the InstancedMesh.
  109141. * Returns nothing.
  109142. */
  109143. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109144. }
  109145. interface Mesh {
  109146. /**
  109147. * Register a custom buffer that will be instanced
  109148. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  109149. * @param kind defines the buffer kind
  109150. * @param stride defines the stride in floats
  109151. */
  109152. registerInstancedBuffer(kind: string, stride: number): void;
  109153. /**
  109154. * true to use the edge renderer for all instances of this mesh
  109155. */
  109156. edgesShareWithInstances: boolean;
  109157. /** @hidden */
  109158. _userInstancedBuffersStorage: {
  109159. data: {
  109160. [key: string]: Float32Array;
  109161. };
  109162. sizes: {
  109163. [key: string]: number;
  109164. };
  109165. vertexBuffers: {
  109166. [key: string]: Nullable<VertexBuffer>;
  109167. };
  109168. strides: {
  109169. [key: string]: number;
  109170. };
  109171. };
  109172. }
  109173. interface AbstractMesh {
  109174. /**
  109175. * Object used to store instanced buffers defined by user
  109176. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  109177. */
  109178. instancedBuffers: {
  109179. [key: string]: any;
  109180. };
  109181. }
  109182. }
  109183. declare module BABYLON {
  109184. /**
  109185. * Defines the options associated with the creation of a shader material.
  109186. */
  109187. export interface IShaderMaterialOptions {
  109188. /**
  109189. * Does the material work in alpha blend mode
  109190. */
  109191. needAlphaBlending: boolean;
  109192. /**
  109193. * Does the material work in alpha test mode
  109194. */
  109195. needAlphaTesting: boolean;
  109196. /**
  109197. * The list of attribute names used in the shader
  109198. */
  109199. attributes: string[];
  109200. /**
  109201. * The list of unifrom names used in the shader
  109202. */
  109203. uniforms: string[];
  109204. /**
  109205. * The list of UBO names used in the shader
  109206. */
  109207. uniformBuffers: string[];
  109208. /**
  109209. * The list of sampler names used in the shader
  109210. */
  109211. samplers: string[];
  109212. /**
  109213. * The list of defines used in the shader
  109214. */
  109215. defines: string[];
  109216. }
  109217. /**
  109218. * 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.
  109219. *
  109220. * This returned material effects how the mesh will look based on the code in the shaders.
  109221. *
  109222. * @see https://doc.babylonjs.com/how_to/shader_material
  109223. */
  109224. export class ShaderMaterial extends Material {
  109225. private _shaderPath;
  109226. private _options;
  109227. private _textures;
  109228. private _textureArrays;
  109229. private _floats;
  109230. private _ints;
  109231. private _floatsArrays;
  109232. private _colors3;
  109233. private _colors3Arrays;
  109234. private _colors4;
  109235. private _colors4Arrays;
  109236. private _vectors2;
  109237. private _vectors3;
  109238. private _vectors4;
  109239. private _matrices;
  109240. private _matrixArrays;
  109241. private _matrices3x3;
  109242. private _matrices2x2;
  109243. private _vectors2Arrays;
  109244. private _vectors3Arrays;
  109245. private _vectors4Arrays;
  109246. private _cachedWorldViewMatrix;
  109247. private _cachedWorldViewProjectionMatrix;
  109248. private _renderId;
  109249. private _multiview;
  109250. private _cachedDefines;
  109251. /** Define the Url to load snippets */
  109252. static SnippetUrl: string;
  109253. /** Snippet ID if the material was created from the snippet server */
  109254. snippetId: string;
  109255. /**
  109256. * Instantiate a new shader material.
  109257. * 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.
  109258. * This returned material effects how the mesh will look based on the code in the shaders.
  109259. * @see https://doc.babylonjs.com/how_to/shader_material
  109260. * @param name Define the name of the material in the scene
  109261. * @param scene Define the scene the material belongs to
  109262. * @param shaderPath Defines the route to the shader code in one of three ways:
  109263. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  109264. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  109265. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  109266. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  109267. * @param options Define the options used to create the shader
  109268. */
  109269. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  109270. /**
  109271. * Gets the shader path used to define the shader code
  109272. * It can be modified to trigger a new compilation
  109273. */
  109274. get shaderPath(): any;
  109275. /**
  109276. * Sets the shader path used to define the shader code
  109277. * It can be modified to trigger a new compilation
  109278. */
  109279. set shaderPath(shaderPath: any);
  109280. /**
  109281. * Gets the options used to compile the shader.
  109282. * They can be modified to trigger a new compilation
  109283. */
  109284. get options(): IShaderMaterialOptions;
  109285. /**
  109286. * Gets the current class name of the material e.g. "ShaderMaterial"
  109287. * Mainly use in serialization.
  109288. * @returns the class name
  109289. */
  109290. getClassName(): string;
  109291. /**
  109292. * Specifies if the material will require alpha blending
  109293. * @returns a boolean specifying if alpha blending is needed
  109294. */
  109295. needAlphaBlending(): boolean;
  109296. /**
  109297. * Specifies if this material should be rendered in alpha test mode
  109298. * @returns a boolean specifying if an alpha test is needed.
  109299. */
  109300. needAlphaTesting(): boolean;
  109301. private _checkUniform;
  109302. /**
  109303. * Set a texture in the shader.
  109304. * @param name Define the name of the uniform samplers as defined in the shader
  109305. * @param texture Define the texture to bind to this sampler
  109306. * @return the material itself allowing "fluent" like uniform updates
  109307. */
  109308. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  109309. /**
  109310. * Set a texture array in the shader.
  109311. * @param name Define the name of the uniform sampler array as defined in the shader
  109312. * @param textures Define the list of textures to bind to this sampler
  109313. * @return the material itself allowing "fluent" like uniform updates
  109314. */
  109315. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  109316. /**
  109317. * Set a float in the shader.
  109318. * @param name Define the name of the uniform as defined in the shader
  109319. * @param value Define the value to give to the uniform
  109320. * @return the material itself allowing "fluent" like uniform updates
  109321. */
  109322. setFloat(name: string, value: number): ShaderMaterial;
  109323. /**
  109324. * Set a int in the shader.
  109325. * @param name Define the name of the uniform as defined in the shader
  109326. * @param value Define the value to give to the uniform
  109327. * @return the material itself allowing "fluent" like uniform updates
  109328. */
  109329. setInt(name: string, value: number): ShaderMaterial;
  109330. /**
  109331. * Set an array of floats in the shader.
  109332. * @param name Define the name of the uniform as defined in the shader
  109333. * @param value Define the value to give to the uniform
  109334. * @return the material itself allowing "fluent" like uniform updates
  109335. */
  109336. setFloats(name: string, value: number[]): ShaderMaterial;
  109337. /**
  109338. * Set a vec3 in the shader from a Color3.
  109339. * @param name Define the name of the uniform as defined in the shader
  109340. * @param value Define the value to give to the uniform
  109341. * @return the material itself allowing "fluent" like uniform updates
  109342. */
  109343. setColor3(name: string, value: Color3): ShaderMaterial;
  109344. /**
  109345. * Set a vec3 array in the shader from a Color3 array.
  109346. * @param name Define the name of the uniform as defined in the shader
  109347. * @param value Define the value to give to the uniform
  109348. * @return the material itself allowing "fluent" like uniform updates
  109349. */
  109350. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  109351. /**
  109352. * Set a vec4 in the shader from a Color4.
  109353. * @param name Define the name of the uniform as defined in the shader
  109354. * @param value Define the value to give to the uniform
  109355. * @return the material itself allowing "fluent" like uniform updates
  109356. */
  109357. setColor4(name: string, value: Color4): ShaderMaterial;
  109358. /**
  109359. * Set a vec4 array in the shader from a Color4 array.
  109360. * @param name Define the name of the uniform as defined in the shader
  109361. * @param value Define the value to give to the uniform
  109362. * @return the material itself allowing "fluent" like uniform updates
  109363. */
  109364. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  109365. /**
  109366. * Set a vec2 in the shader from a Vector2.
  109367. * @param name Define the name of the uniform as defined in the shader
  109368. * @param value Define the value to give to the uniform
  109369. * @return the material itself allowing "fluent" like uniform updates
  109370. */
  109371. setVector2(name: string, value: Vector2): ShaderMaterial;
  109372. /**
  109373. * Set a vec3 in the shader from a Vector3.
  109374. * @param name Define the name of the uniform as defined in the shader
  109375. * @param value Define the value to give to the uniform
  109376. * @return the material itself allowing "fluent" like uniform updates
  109377. */
  109378. setVector3(name: string, value: Vector3): ShaderMaterial;
  109379. /**
  109380. * Set a vec4 in the shader from a Vector4.
  109381. * @param name Define the name of the uniform as defined in the shader
  109382. * @param value Define the value to give to the uniform
  109383. * @return the material itself allowing "fluent" like uniform updates
  109384. */
  109385. setVector4(name: string, value: Vector4): ShaderMaterial;
  109386. /**
  109387. * Set a mat4 in the shader from a Matrix.
  109388. * @param name Define the name of the uniform as defined in the shader
  109389. * @param value Define the value to give to the uniform
  109390. * @return the material itself allowing "fluent" like uniform updates
  109391. */
  109392. setMatrix(name: string, value: Matrix): ShaderMaterial;
  109393. /**
  109394. * Set a float32Array in the shader from a matrix array.
  109395. * @param name Define the name of the uniform as defined in the shader
  109396. * @param value Define the value to give to the uniform
  109397. * @return the material itself allowing "fluent" like uniform updates
  109398. */
  109399. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  109400. /**
  109401. * Set a mat3 in the shader from a Float32Array.
  109402. * @param name Define the name of the uniform as defined in the shader
  109403. * @param value Define the value to give to the uniform
  109404. * @return the material itself allowing "fluent" like uniform updates
  109405. */
  109406. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  109407. /**
  109408. * Set a mat2 in the shader from a Float32Array.
  109409. * @param name Define the name of the uniform as defined in the shader
  109410. * @param value Define the value to give to the uniform
  109411. * @return the material itself allowing "fluent" like uniform updates
  109412. */
  109413. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  109414. /**
  109415. * Set a vec2 array in the shader from a number array.
  109416. * @param name Define the name of the uniform as defined in the shader
  109417. * @param value Define the value to give to the uniform
  109418. * @return the material itself allowing "fluent" like uniform updates
  109419. */
  109420. setArray2(name: string, value: number[]): ShaderMaterial;
  109421. /**
  109422. * Set a vec3 array in the shader from a number array.
  109423. * @param name Define the name of the uniform as defined in the shader
  109424. * @param value Define the value to give to the uniform
  109425. * @return the material itself allowing "fluent" like uniform updates
  109426. */
  109427. setArray3(name: string, value: number[]): ShaderMaterial;
  109428. /**
  109429. * Set a vec4 array in the shader from a number array.
  109430. * @param name Define the name of the uniform as defined in the shader
  109431. * @param value Define the value to give to the uniform
  109432. * @return the material itself allowing "fluent" like uniform updates
  109433. */
  109434. setArray4(name: string, value: number[]): ShaderMaterial;
  109435. private _checkCache;
  109436. /**
  109437. * Specifies that the submesh is ready to be used
  109438. * @param mesh defines the mesh to check
  109439. * @param subMesh defines which submesh to check
  109440. * @param useInstances specifies that instances should be used
  109441. * @returns a boolean indicating that the submesh is ready or not
  109442. */
  109443. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109444. /**
  109445. * Checks if the material is ready to render the requested mesh
  109446. * @param mesh Define the mesh to render
  109447. * @param useInstances Define whether or not the material is used with instances
  109448. * @returns true if ready, otherwise false
  109449. */
  109450. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  109451. /**
  109452. * Binds the world matrix to the material
  109453. * @param world defines the world transformation matrix
  109454. * @param effectOverride - If provided, use this effect instead of internal effect
  109455. */
  109456. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  109457. /**
  109458. * Binds the submesh to this material by preparing the effect and shader to draw
  109459. * @param world defines the world transformation matrix
  109460. * @param mesh defines the mesh containing the submesh
  109461. * @param subMesh defines the submesh to bind the material to
  109462. */
  109463. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109464. /**
  109465. * Binds the material to the mesh
  109466. * @param world defines the world transformation matrix
  109467. * @param mesh defines the mesh to bind the material to
  109468. * @param effectOverride - If provided, use this effect instead of internal effect
  109469. */
  109470. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  109471. protected _afterBind(mesh?: Mesh): void;
  109472. /**
  109473. * Gets the active textures from the material
  109474. * @returns an array of textures
  109475. */
  109476. getActiveTextures(): BaseTexture[];
  109477. /**
  109478. * Specifies if the material uses a texture
  109479. * @param texture defines the texture to check against the material
  109480. * @returns a boolean specifying if the material uses the texture
  109481. */
  109482. hasTexture(texture: BaseTexture): boolean;
  109483. /**
  109484. * Makes a duplicate of the material, and gives it a new name
  109485. * @param name defines the new name for the duplicated material
  109486. * @returns the cloned material
  109487. */
  109488. clone(name: string): ShaderMaterial;
  109489. /**
  109490. * Disposes the material
  109491. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109492. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109493. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  109494. */
  109495. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  109496. /**
  109497. * Serializes this material in a JSON representation
  109498. * @returns the serialized material object
  109499. */
  109500. serialize(): any;
  109501. /**
  109502. * Creates a shader material from parsed shader material data
  109503. * @param source defines the JSON represnetation of the material
  109504. * @param scene defines the hosting scene
  109505. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109506. * @returns a new material
  109507. */
  109508. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  109509. /**
  109510. * Creates a new ShaderMaterial from a snippet saved in a remote file
  109511. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  109512. * @param url defines the url to load from
  109513. * @param scene defines the hosting scene
  109514. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109515. * @returns a promise that will resolve to the new ShaderMaterial
  109516. */
  109517. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  109518. /**
  109519. * Creates a ShaderMaterial from a snippet saved by the Inspector
  109520. * @param snippetId defines the snippet to load
  109521. * @param scene defines the hosting scene
  109522. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109523. * @returns a promise that will resolve to the new ShaderMaterial
  109524. */
  109525. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  109526. }
  109527. }
  109528. declare module BABYLON {
  109529. /** @hidden */
  109530. export var colorPixelShader: {
  109531. name: string;
  109532. shader: string;
  109533. };
  109534. }
  109535. declare module BABYLON {
  109536. /** @hidden */
  109537. export var colorVertexShader: {
  109538. name: string;
  109539. shader: string;
  109540. };
  109541. }
  109542. declare module BABYLON {
  109543. /**
  109544. * Line mesh
  109545. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  109546. */
  109547. export class LinesMesh extends Mesh {
  109548. /**
  109549. * If vertex color should be applied to the mesh
  109550. */
  109551. readonly useVertexColor?: boolean | undefined;
  109552. /**
  109553. * If vertex alpha should be applied to the mesh
  109554. */
  109555. readonly useVertexAlpha?: boolean | undefined;
  109556. /**
  109557. * Color of the line (Default: White)
  109558. */
  109559. color: Color3;
  109560. /**
  109561. * Alpha of the line (Default: 1)
  109562. */
  109563. alpha: number;
  109564. /**
  109565. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  109566. * This margin is expressed in world space coordinates, so its value may vary.
  109567. * Default value is 0.1
  109568. */
  109569. intersectionThreshold: number;
  109570. private _colorShader;
  109571. private color4;
  109572. /**
  109573. * Creates a new LinesMesh
  109574. * @param name defines the name
  109575. * @param scene defines the hosting scene
  109576. * @param parent defines the parent mesh if any
  109577. * @param source defines the optional source LinesMesh used to clone data from
  109578. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  109579. * When false, achieved by calling a clone(), also passing False.
  109580. * This will make creation of children, recursive.
  109581. * @param useVertexColor defines if this LinesMesh supports vertex color
  109582. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  109583. */
  109584. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  109585. /**
  109586. * If vertex color should be applied to the mesh
  109587. */
  109588. useVertexColor?: boolean | undefined,
  109589. /**
  109590. * If vertex alpha should be applied to the mesh
  109591. */
  109592. useVertexAlpha?: boolean | undefined);
  109593. private _addClipPlaneDefine;
  109594. private _removeClipPlaneDefine;
  109595. isReady(): boolean;
  109596. /**
  109597. * Returns the string "LineMesh"
  109598. */
  109599. getClassName(): string;
  109600. /**
  109601. * @hidden
  109602. */
  109603. get material(): Material;
  109604. /**
  109605. * @hidden
  109606. */
  109607. set material(value: Material);
  109608. /**
  109609. * @hidden
  109610. */
  109611. get checkCollisions(): boolean;
  109612. /** @hidden */
  109613. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  109614. /** @hidden */
  109615. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  109616. /**
  109617. * Disposes of the line mesh
  109618. * @param doNotRecurse If children should be disposed
  109619. */
  109620. dispose(doNotRecurse?: boolean): void;
  109621. /**
  109622. * Returns a new LineMesh object cloned from the current one.
  109623. */
  109624. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  109625. /**
  109626. * Creates a new InstancedLinesMesh object from the mesh model.
  109627. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109628. * @param name defines the name of the new instance
  109629. * @returns a new InstancedLinesMesh
  109630. */
  109631. createInstance(name: string): InstancedLinesMesh;
  109632. }
  109633. /**
  109634. * Creates an instance based on a source LinesMesh
  109635. */
  109636. export class InstancedLinesMesh extends InstancedMesh {
  109637. /**
  109638. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  109639. * This margin is expressed in world space coordinates, so its value may vary.
  109640. * Initilized with the intersectionThreshold value of the source LinesMesh
  109641. */
  109642. intersectionThreshold: number;
  109643. constructor(name: string, source: LinesMesh);
  109644. /**
  109645. * Returns the string "InstancedLinesMesh".
  109646. */
  109647. getClassName(): string;
  109648. }
  109649. }
  109650. declare module BABYLON {
  109651. /** @hidden */
  109652. export var linePixelShader: {
  109653. name: string;
  109654. shader: string;
  109655. };
  109656. }
  109657. declare module BABYLON {
  109658. /** @hidden */
  109659. export var lineVertexShader: {
  109660. name: string;
  109661. shader: string;
  109662. };
  109663. }
  109664. declare module BABYLON {
  109665. interface Scene {
  109666. /** @hidden */
  109667. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  109668. }
  109669. interface AbstractMesh {
  109670. /**
  109671. * Gets the edgesRenderer associated with the mesh
  109672. */
  109673. edgesRenderer: Nullable<EdgesRenderer>;
  109674. }
  109675. interface LinesMesh {
  109676. /**
  109677. * Enables the edge rendering mode on the mesh.
  109678. * This mode makes the mesh edges visible
  109679. * @param epsilon defines the maximal distance between two angles to detect a face
  109680. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109681. * @returns the currentAbstractMesh
  109682. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109683. */
  109684. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  109685. }
  109686. interface InstancedLinesMesh {
  109687. /**
  109688. * Enables the edge rendering mode on the mesh.
  109689. * This mode makes the mesh edges visible
  109690. * @param epsilon defines the maximal distance between two angles to detect a face
  109691. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109692. * @returns the current InstancedLinesMesh
  109693. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109694. */
  109695. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  109696. }
  109697. /**
  109698. * Defines the minimum contract an Edges renderer should follow.
  109699. */
  109700. export interface IEdgesRenderer extends IDisposable {
  109701. /**
  109702. * Gets or sets a boolean indicating if the edgesRenderer is active
  109703. */
  109704. isEnabled: boolean;
  109705. /**
  109706. * Renders the edges of the attached mesh,
  109707. */
  109708. render(): void;
  109709. /**
  109710. * Checks wether or not the edges renderer is ready to render.
  109711. * @return true if ready, otherwise false.
  109712. */
  109713. isReady(): boolean;
  109714. /**
  109715. * List of instances to render in case the source mesh has instances
  109716. */
  109717. customInstances: SmartArray<Matrix>;
  109718. }
  109719. /**
  109720. * Defines the additional options of the edges renderer
  109721. */
  109722. export interface IEdgesRendererOptions {
  109723. /**
  109724. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  109725. * If not defined, the default value is true
  109726. */
  109727. useAlternateEdgeFinder?: boolean;
  109728. /**
  109729. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  109730. * If not defined, the default value is true.
  109731. * 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)
  109732. * This option is used only if useAlternateEdgeFinder = true
  109733. */
  109734. useFastVertexMerger?: boolean;
  109735. /**
  109736. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  109737. * The default value is 1e-6
  109738. * This option is used only if useAlternateEdgeFinder = true
  109739. */
  109740. epsilonVertexMerge?: number;
  109741. /**
  109742. * 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
  109743. * 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.
  109744. * This option is used only if useAlternateEdgeFinder = true
  109745. */
  109746. applyTessellation?: boolean;
  109747. /**
  109748. * 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
  109749. * The default value is 1e-6
  109750. * This option is used only if useAlternateEdgeFinder = true
  109751. */
  109752. epsilonVertexAligned?: number;
  109753. }
  109754. /**
  109755. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  109756. */
  109757. export class EdgesRenderer implements IEdgesRenderer {
  109758. /**
  109759. * Define the size of the edges with an orthographic camera
  109760. */
  109761. edgesWidthScalerForOrthographic: number;
  109762. /**
  109763. * Define the size of the edges with a perspective camera
  109764. */
  109765. edgesWidthScalerForPerspective: number;
  109766. protected _source: AbstractMesh;
  109767. protected _linesPositions: number[];
  109768. protected _linesNormals: number[];
  109769. protected _linesIndices: number[];
  109770. protected _epsilon: number;
  109771. protected _indicesCount: number;
  109772. protected _lineShader: ShaderMaterial;
  109773. protected _ib: DataBuffer;
  109774. protected _buffers: {
  109775. [key: string]: Nullable<VertexBuffer>;
  109776. };
  109777. protected _buffersForInstances: {
  109778. [key: string]: Nullable<VertexBuffer>;
  109779. };
  109780. protected _checkVerticesInsteadOfIndices: boolean;
  109781. protected _options: Nullable<IEdgesRendererOptions>;
  109782. private _meshRebuildObserver;
  109783. private _meshDisposeObserver;
  109784. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  109785. isEnabled: boolean;
  109786. /** Gets the vertices generated by the edge renderer */
  109787. get linesPositions(): Immutable<Array<number>>;
  109788. /** Gets the normals generated by the edge renderer */
  109789. get linesNormals(): Immutable<Array<number>>;
  109790. /** Gets the indices generated by the edge renderer */
  109791. get linesIndices(): Immutable<Array<number>>;
  109792. /**
  109793. * List of instances to render in case the source mesh has instances
  109794. */
  109795. customInstances: SmartArray<Matrix>;
  109796. private static GetShader;
  109797. /**
  109798. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  109799. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  109800. * @param source Mesh used to create edges
  109801. * @param epsilon sum of angles in adjacency to check for edge
  109802. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  109803. * @param generateEdgesLines - should generate Lines or only prepare resources.
  109804. * @param options The options to apply when generating the edges
  109805. */
  109806. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  109807. protected _prepareRessources(): void;
  109808. /** @hidden */
  109809. _rebuild(): void;
  109810. /**
  109811. * Releases the required resources for the edges renderer
  109812. */
  109813. dispose(): void;
  109814. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  109815. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  109816. /**
  109817. * Checks if the pair of p0 and p1 is en edge
  109818. * @param faceIndex
  109819. * @param edge
  109820. * @param faceNormals
  109821. * @param p0
  109822. * @param p1
  109823. * @private
  109824. */
  109825. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  109826. /**
  109827. * push line into the position, normal and index buffer
  109828. * @protected
  109829. */
  109830. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  109831. /**
  109832. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  109833. */
  109834. private _tessellateTriangle;
  109835. private _generateEdgesLinesAlternate;
  109836. /**
  109837. * Generates lines edges from adjacencjes
  109838. * @private
  109839. */
  109840. _generateEdgesLines(): void;
  109841. /**
  109842. * Checks wether or not the edges renderer is ready to render.
  109843. * @return true if ready, otherwise false.
  109844. */
  109845. isReady(): boolean;
  109846. /**
  109847. * Renders the edges of the attached mesh,
  109848. */
  109849. render(): void;
  109850. }
  109851. /**
  109852. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  109853. */
  109854. export class LineEdgesRenderer extends EdgesRenderer {
  109855. /**
  109856. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  109857. * @param source LineMesh used to generate edges
  109858. * @param epsilon not important (specified angle for edge detection)
  109859. * @param checkVerticesInsteadOfIndices not important for LineMesh
  109860. */
  109861. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  109862. /**
  109863. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  109864. */
  109865. _generateEdgesLines(): void;
  109866. }
  109867. }
  109868. declare module BABYLON {
  109869. /**
  109870. * This represents the object necessary to create a rendering group.
  109871. * This is exclusively used and created by the rendering manager.
  109872. * To modify the behavior, you use the available helpers in your scene or meshes.
  109873. * @hidden
  109874. */
  109875. export class RenderingGroup {
  109876. index: number;
  109877. private static _zeroVector;
  109878. private _scene;
  109879. private _opaqueSubMeshes;
  109880. private _transparentSubMeshes;
  109881. private _alphaTestSubMeshes;
  109882. private _depthOnlySubMeshes;
  109883. private _particleSystems;
  109884. private _spriteManagers;
  109885. private _opaqueSortCompareFn;
  109886. private _alphaTestSortCompareFn;
  109887. private _transparentSortCompareFn;
  109888. private _renderOpaque;
  109889. private _renderAlphaTest;
  109890. private _renderTransparent;
  109891. /** @hidden */
  109892. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  109893. onBeforeTransparentRendering: () => void;
  109894. /**
  109895. * Set the opaque sort comparison function.
  109896. * If null the sub meshes will be render in the order they were created
  109897. */
  109898. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  109899. /**
  109900. * Set the alpha test sort comparison function.
  109901. * If null the sub meshes will be render in the order they were created
  109902. */
  109903. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  109904. /**
  109905. * Set the transparent sort comparison function.
  109906. * If null the sub meshes will be render in the order they were created
  109907. */
  109908. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  109909. /**
  109910. * Creates a new rendering group.
  109911. * @param index The rendering group index
  109912. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  109913. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  109914. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  109915. */
  109916. 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>);
  109917. /**
  109918. * Render all the sub meshes contained in the group.
  109919. * @param customRenderFunction Used to override the default render behaviour of the group.
  109920. * @returns true if rendered some submeshes.
  109921. */
  109922. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  109923. /**
  109924. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  109925. * @param subMeshes The submeshes to render
  109926. */
  109927. private renderOpaqueSorted;
  109928. /**
  109929. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  109930. * @param subMeshes The submeshes to render
  109931. */
  109932. private renderAlphaTestSorted;
  109933. /**
  109934. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  109935. * @param subMeshes The submeshes to render
  109936. */
  109937. private renderTransparentSorted;
  109938. /**
  109939. * Renders the submeshes in a specified order.
  109940. * @param subMeshes The submeshes to sort before render
  109941. * @param sortCompareFn The comparison function use to sort
  109942. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  109943. * @param transparent Specifies to activate blending if true
  109944. */
  109945. private static renderSorted;
  109946. /**
  109947. * Renders the submeshes in the order they were dispatched (no sort applied).
  109948. * @param subMeshes The submeshes to render
  109949. */
  109950. private static renderUnsorted;
  109951. /**
  109952. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  109953. * are rendered back to front if in the same alpha index.
  109954. *
  109955. * @param a The first submesh
  109956. * @param b The second submesh
  109957. * @returns The result of the comparison
  109958. */
  109959. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  109960. /**
  109961. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  109962. * are rendered back to front.
  109963. *
  109964. * @param a The first submesh
  109965. * @param b The second submesh
  109966. * @returns The result of the comparison
  109967. */
  109968. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  109969. /**
  109970. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  109971. * are rendered front to back (prevent overdraw).
  109972. *
  109973. * @param a The first submesh
  109974. * @param b The second submesh
  109975. * @returns The result of the comparison
  109976. */
  109977. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  109978. /**
  109979. * Resets the different lists of submeshes to prepare a new frame.
  109980. */
  109981. prepare(): void;
  109982. dispose(): void;
  109983. /**
  109984. * Inserts the submesh in its correct queue depending on its material.
  109985. * @param subMesh The submesh to dispatch
  109986. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  109987. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  109988. */
  109989. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  109990. dispatchSprites(spriteManager: ISpriteManager): void;
  109991. dispatchParticles(particleSystem: IParticleSystem): void;
  109992. private _renderParticles;
  109993. private _renderSprites;
  109994. }
  109995. }
  109996. declare module BABYLON {
  109997. /**
  109998. * Interface describing the different options available in the rendering manager
  109999. * regarding Auto Clear between groups.
  110000. */
  110001. export interface IRenderingManagerAutoClearSetup {
  110002. /**
  110003. * Defines whether or not autoclear is enable.
  110004. */
  110005. autoClear: boolean;
  110006. /**
  110007. * Defines whether or not to autoclear the depth buffer.
  110008. */
  110009. depth: boolean;
  110010. /**
  110011. * Defines whether or not to autoclear the stencil buffer.
  110012. */
  110013. stencil: boolean;
  110014. }
  110015. /**
  110016. * This class is used by the onRenderingGroupObservable
  110017. */
  110018. export class RenderingGroupInfo {
  110019. /**
  110020. * The Scene that being rendered
  110021. */
  110022. scene: Scene;
  110023. /**
  110024. * The camera currently used for the rendering pass
  110025. */
  110026. camera: Nullable<Camera>;
  110027. /**
  110028. * The ID of the renderingGroup being processed
  110029. */
  110030. renderingGroupId: number;
  110031. }
  110032. /**
  110033. * This is the manager responsible of all the rendering for meshes sprites and particles.
  110034. * It is enable to manage the different groups as well as the different necessary sort functions.
  110035. * This should not be used directly aside of the few static configurations
  110036. */
  110037. export class RenderingManager {
  110038. /**
  110039. * The max id used for rendering groups (not included)
  110040. */
  110041. static MAX_RENDERINGGROUPS: number;
  110042. /**
  110043. * The min id used for rendering groups (included)
  110044. */
  110045. static MIN_RENDERINGGROUPS: number;
  110046. /**
  110047. * Used to globally prevent autoclearing scenes.
  110048. */
  110049. static AUTOCLEAR: boolean;
  110050. /**
  110051. * @hidden
  110052. */
  110053. _useSceneAutoClearSetup: boolean;
  110054. private _scene;
  110055. private _renderingGroups;
  110056. private _depthStencilBufferAlreadyCleaned;
  110057. private _autoClearDepthStencil;
  110058. private _customOpaqueSortCompareFn;
  110059. private _customAlphaTestSortCompareFn;
  110060. private _customTransparentSortCompareFn;
  110061. private _renderingGroupInfo;
  110062. /**
  110063. * Instantiates a new rendering group for a particular scene
  110064. * @param scene Defines the scene the groups belongs to
  110065. */
  110066. constructor(scene: Scene);
  110067. private _clearDepthStencilBuffer;
  110068. /**
  110069. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  110070. * @hidden
  110071. */
  110072. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  110073. /**
  110074. * Resets the different information of the group to prepare a new frame
  110075. * @hidden
  110076. */
  110077. reset(): void;
  110078. /**
  110079. * Dispose and release the group and its associated resources.
  110080. * @hidden
  110081. */
  110082. dispose(): void;
  110083. /**
  110084. * Clear the info related to rendering groups preventing retention points during dispose.
  110085. */
  110086. freeRenderingGroups(): void;
  110087. private _prepareRenderingGroup;
  110088. /**
  110089. * Add a sprite manager to the rendering manager in order to render it this frame.
  110090. * @param spriteManager Define the sprite manager to render
  110091. */
  110092. dispatchSprites(spriteManager: ISpriteManager): void;
  110093. /**
  110094. * Add a particle system to the rendering manager in order to render it this frame.
  110095. * @param particleSystem Define the particle system to render
  110096. */
  110097. dispatchParticles(particleSystem: IParticleSystem): void;
  110098. /**
  110099. * Add a submesh to the manager in order to render it this frame
  110100. * @param subMesh The submesh to dispatch
  110101. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  110102. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  110103. */
  110104. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  110105. /**
  110106. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110107. * This allowed control for front to back rendering or reversly depending of the special needs.
  110108. *
  110109. * @param renderingGroupId The rendering group id corresponding to its index
  110110. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110111. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110112. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110113. */
  110114. 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;
  110115. /**
  110116. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110117. *
  110118. * @param renderingGroupId The rendering group id corresponding to its index
  110119. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110120. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110121. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110122. */
  110123. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110124. /**
  110125. * Gets the current auto clear configuration for one rendering group of the rendering
  110126. * manager.
  110127. * @param index the rendering group index to get the information for
  110128. * @returns The auto clear setup for the requested rendering group
  110129. */
  110130. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110131. }
  110132. }
  110133. declare module BABYLON {
  110134. /**
  110135. * Defines the options associated with the creation of a custom shader for a shadow generator.
  110136. */
  110137. export interface ICustomShaderOptions {
  110138. /**
  110139. * Gets or sets the custom shader name to use
  110140. */
  110141. shaderName: string;
  110142. /**
  110143. * The list of attribute names used in the shader
  110144. */
  110145. attributes?: string[];
  110146. /**
  110147. * The list of unifrom names used in the shader
  110148. */
  110149. uniforms?: string[];
  110150. /**
  110151. * The list of sampler names used in the shader
  110152. */
  110153. samplers?: string[];
  110154. /**
  110155. * The list of defines used in the shader
  110156. */
  110157. defines?: string[];
  110158. }
  110159. /**
  110160. * Interface to implement to create a shadow generator compatible with BJS.
  110161. */
  110162. export interface IShadowGenerator {
  110163. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  110164. id: string;
  110165. /**
  110166. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  110167. * @returns The render target texture if present otherwise, null
  110168. */
  110169. getShadowMap(): Nullable<RenderTargetTexture>;
  110170. /**
  110171. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  110172. * @param subMesh The submesh we want to render in the shadow map
  110173. * @param useInstances Defines wether will draw in the map using instances
  110174. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  110175. * @returns true if ready otherwise, false
  110176. */
  110177. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  110178. /**
  110179. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  110180. * @param defines Defines of the material we want to update
  110181. * @param lightIndex Index of the light in the enabled light list of the material
  110182. */
  110183. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  110184. /**
  110185. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  110186. * defined in the generator but impacting the effect).
  110187. * It implies the unifroms available on the materials are the standard BJS ones.
  110188. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  110189. * @param effect The effect we are binfing the information for
  110190. */
  110191. bindShadowLight(lightIndex: string, effect: Effect): void;
  110192. /**
  110193. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  110194. * (eq to shadow prjection matrix * light transform matrix)
  110195. * @returns The transform matrix used to create the shadow map
  110196. */
  110197. getTransformMatrix(): Matrix;
  110198. /**
  110199. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  110200. * Cube and 2D textures for instance.
  110201. */
  110202. recreateShadowMap(): void;
  110203. /**
  110204. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110205. * @param onCompiled Callback triggered at the and of the effects compilation
  110206. * @param options Sets of optional options forcing the compilation with different modes
  110207. */
  110208. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  110209. useInstances: boolean;
  110210. }>): void;
  110211. /**
  110212. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110213. * @param options Sets of optional options forcing the compilation with different modes
  110214. * @returns A promise that resolves when the compilation completes
  110215. */
  110216. forceCompilationAsync(options?: Partial<{
  110217. useInstances: boolean;
  110218. }>): Promise<void>;
  110219. /**
  110220. * Serializes the shadow generator setup to a json object.
  110221. * @returns The serialized JSON object
  110222. */
  110223. serialize(): any;
  110224. /**
  110225. * Disposes the Shadow map and related Textures and effects.
  110226. */
  110227. dispose(): void;
  110228. }
  110229. /**
  110230. * Default implementation IShadowGenerator.
  110231. * This is the main object responsible of generating shadows in the framework.
  110232. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  110233. */
  110234. export class ShadowGenerator implements IShadowGenerator {
  110235. /**
  110236. * Name of the shadow generator class
  110237. */
  110238. static CLASSNAME: string;
  110239. /**
  110240. * Shadow generator mode None: no filtering applied.
  110241. */
  110242. static readonly FILTER_NONE: number;
  110243. /**
  110244. * Shadow generator mode ESM: Exponential Shadow Mapping.
  110245. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110246. */
  110247. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  110248. /**
  110249. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  110250. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  110251. */
  110252. static readonly FILTER_POISSONSAMPLING: number;
  110253. /**
  110254. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  110255. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110256. */
  110257. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  110258. /**
  110259. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  110260. * edge artifacts on steep falloff.
  110261. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110262. */
  110263. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  110264. /**
  110265. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  110266. * edge artifacts on steep falloff.
  110267. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110268. */
  110269. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  110270. /**
  110271. * Shadow generator mode PCF: Percentage Closer Filtering
  110272. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  110273. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  110274. */
  110275. static readonly FILTER_PCF: number;
  110276. /**
  110277. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  110278. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  110279. * Contact Hardening
  110280. */
  110281. static readonly FILTER_PCSS: number;
  110282. /**
  110283. * Reserved for PCF and PCSS
  110284. * Highest Quality.
  110285. *
  110286. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  110287. *
  110288. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  110289. */
  110290. static readonly QUALITY_HIGH: number;
  110291. /**
  110292. * Reserved for PCF and PCSS
  110293. * Good tradeoff for quality/perf cross devices
  110294. *
  110295. * Execute PCF on a 3*3 kernel.
  110296. *
  110297. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  110298. */
  110299. static readonly QUALITY_MEDIUM: number;
  110300. /**
  110301. * Reserved for PCF and PCSS
  110302. * The lowest quality but the fastest.
  110303. *
  110304. * Execute PCF on a 1*1 kernel.
  110305. *
  110306. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  110307. */
  110308. static readonly QUALITY_LOW: number;
  110309. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  110310. id: string;
  110311. /** Gets or sets the custom shader name to use */
  110312. customShaderOptions: ICustomShaderOptions;
  110313. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  110314. customAllowRendering: (subMesh: SubMesh) => boolean;
  110315. /**
  110316. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  110317. */
  110318. onBeforeShadowMapRenderObservable: Observable<Effect>;
  110319. /**
  110320. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  110321. */
  110322. onAfterShadowMapRenderObservable: Observable<Effect>;
  110323. /**
  110324. * Observable triggered before a mesh is rendered in the shadow map.
  110325. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  110326. */
  110327. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  110328. /**
  110329. * Observable triggered after a mesh is rendered in the shadow map.
  110330. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  110331. */
  110332. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  110333. protected _bias: number;
  110334. /**
  110335. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  110336. */
  110337. get bias(): number;
  110338. /**
  110339. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  110340. */
  110341. set bias(bias: number);
  110342. protected _normalBias: number;
  110343. /**
  110344. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  110345. */
  110346. get normalBias(): number;
  110347. /**
  110348. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  110349. */
  110350. set normalBias(normalBias: number);
  110351. protected _blurBoxOffset: number;
  110352. /**
  110353. * Gets the blur box offset: offset applied during the blur pass.
  110354. * Only useful if useKernelBlur = false
  110355. */
  110356. get blurBoxOffset(): number;
  110357. /**
  110358. * Sets the blur box offset: offset applied during the blur pass.
  110359. * Only useful if useKernelBlur = false
  110360. */
  110361. set blurBoxOffset(value: number);
  110362. protected _blurScale: number;
  110363. /**
  110364. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  110365. * 2 means half of the size.
  110366. */
  110367. get blurScale(): number;
  110368. /**
  110369. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  110370. * 2 means half of the size.
  110371. */
  110372. set blurScale(value: number);
  110373. protected _blurKernel: number;
  110374. /**
  110375. * Gets the blur kernel: kernel size of the blur pass.
  110376. * Only useful if useKernelBlur = true
  110377. */
  110378. get blurKernel(): number;
  110379. /**
  110380. * Sets the blur kernel: kernel size of the blur pass.
  110381. * Only useful if useKernelBlur = true
  110382. */
  110383. set blurKernel(value: number);
  110384. protected _useKernelBlur: boolean;
  110385. /**
  110386. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  110387. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  110388. */
  110389. get useKernelBlur(): boolean;
  110390. /**
  110391. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  110392. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  110393. */
  110394. set useKernelBlur(value: boolean);
  110395. protected _depthScale: number;
  110396. /**
  110397. * Gets the depth scale used in ESM mode.
  110398. */
  110399. get depthScale(): number;
  110400. /**
  110401. * Sets the depth scale used in ESM mode.
  110402. * This can override the scale stored on the light.
  110403. */
  110404. set depthScale(value: number);
  110405. protected _validateFilter(filter: number): number;
  110406. protected _filter: number;
  110407. /**
  110408. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  110409. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  110410. */
  110411. get filter(): number;
  110412. /**
  110413. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  110414. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  110415. */
  110416. set filter(value: number);
  110417. /**
  110418. * Gets if the current filter is set to Poisson Sampling.
  110419. */
  110420. get usePoissonSampling(): boolean;
  110421. /**
  110422. * Sets the current filter to Poisson Sampling.
  110423. */
  110424. set usePoissonSampling(value: boolean);
  110425. /**
  110426. * Gets if the current filter is set to ESM.
  110427. */
  110428. get useExponentialShadowMap(): boolean;
  110429. /**
  110430. * Sets the current filter is to ESM.
  110431. */
  110432. set useExponentialShadowMap(value: boolean);
  110433. /**
  110434. * Gets if the current filter is set to filtered ESM.
  110435. */
  110436. get useBlurExponentialShadowMap(): boolean;
  110437. /**
  110438. * Gets if the current filter is set to filtered ESM.
  110439. */
  110440. set useBlurExponentialShadowMap(value: boolean);
  110441. /**
  110442. * Gets if the current filter is set to "close ESM" (using the inverse of the
  110443. * exponential to prevent steep falloff artifacts).
  110444. */
  110445. get useCloseExponentialShadowMap(): boolean;
  110446. /**
  110447. * Sets the current filter to "close ESM" (using the inverse of the
  110448. * exponential to prevent steep falloff artifacts).
  110449. */
  110450. set useCloseExponentialShadowMap(value: boolean);
  110451. /**
  110452. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  110453. * exponential to prevent steep falloff artifacts).
  110454. */
  110455. get useBlurCloseExponentialShadowMap(): boolean;
  110456. /**
  110457. * Sets the current filter to filtered "close ESM" (using the inverse of the
  110458. * exponential to prevent steep falloff artifacts).
  110459. */
  110460. set useBlurCloseExponentialShadowMap(value: boolean);
  110461. /**
  110462. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  110463. */
  110464. get usePercentageCloserFiltering(): boolean;
  110465. /**
  110466. * Sets the current filter to "PCF" (percentage closer filtering).
  110467. */
  110468. set usePercentageCloserFiltering(value: boolean);
  110469. protected _filteringQuality: number;
  110470. /**
  110471. * Gets the PCF or PCSS Quality.
  110472. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  110473. */
  110474. get filteringQuality(): number;
  110475. /**
  110476. * Sets the PCF or PCSS Quality.
  110477. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  110478. */
  110479. set filteringQuality(filteringQuality: number);
  110480. /**
  110481. * Gets if the current filter is set to "PCSS" (contact hardening).
  110482. */
  110483. get useContactHardeningShadow(): boolean;
  110484. /**
  110485. * Sets the current filter to "PCSS" (contact hardening).
  110486. */
  110487. set useContactHardeningShadow(value: boolean);
  110488. protected _contactHardeningLightSizeUVRatio: number;
  110489. /**
  110490. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  110491. * Using a ratio helps keeping shape stability independently of the map size.
  110492. *
  110493. * It does not account for the light projection as it was having too much
  110494. * instability during the light setup or during light position changes.
  110495. *
  110496. * Only valid if useContactHardeningShadow is true.
  110497. */
  110498. get contactHardeningLightSizeUVRatio(): number;
  110499. /**
  110500. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  110501. * Using a ratio helps keeping shape stability independently of the map size.
  110502. *
  110503. * It does not account for the light projection as it was having too much
  110504. * instability during the light setup or during light position changes.
  110505. *
  110506. * Only valid if useContactHardeningShadow is true.
  110507. */
  110508. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  110509. protected _darkness: number;
  110510. /** Gets or sets the actual darkness of a shadow */
  110511. get darkness(): number;
  110512. set darkness(value: number);
  110513. /**
  110514. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  110515. * 0 means strongest and 1 would means no shadow.
  110516. * @returns the darkness.
  110517. */
  110518. getDarkness(): number;
  110519. /**
  110520. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  110521. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  110522. * @returns the shadow generator allowing fluent coding.
  110523. */
  110524. setDarkness(darkness: number): ShadowGenerator;
  110525. protected _transparencyShadow: boolean;
  110526. /** Gets or sets the ability to have transparent shadow */
  110527. get transparencyShadow(): boolean;
  110528. set transparencyShadow(value: boolean);
  110529. /**
  110530. * Sets the ability to have transparent shadow (boolean).
  110531. * @param transparent True if transparent else False
  110532. * @returns the shadow generator allowing fluent coding
  110533. */
  110534. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  110535. /**
  110536. * Enables or disables shadows with varying strength based on the transparency
  110537. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  110538. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  110539. * mesh.visibility * alphaTexture.a
  110540. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  110541. */
  110542. enableSoftTransparentShadow: boolean;
  110543. protected _shadowMap: Nullable<RenderTargetTexture>;
  110544. protected _shadowMap2: Nullable<RenderTargetTexture>;
  110545. /**
  110546. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  110547. * @returns The render target texture if present otherwise, null
  110548. */
  110549. getShadowMap(): Nullable<RenderTargetTexture>;
  110550. /**
  110551. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  110552. * @returns The render target texture if the shadow map is present otherwise, null
  110553. */
  110554. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  110555. /**
  110556. * Gets the class name of that object
  110557. * @returns "ShadowGenerator"
  110558. */
  110559. getClassName(): string;
  110560. /**
  110561. * Helper function to add a mesh and its descendants to the list of shadow casters.
  110562. * @param mesh Mesh to add
  110563. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  110564. * @returns the Shadow Generator itself
  110565. */
  110566. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  110567. /**
  110568. * Helper function to remove a mesh and its descendants from the list of shadow casters
  110569. * @param mesh Mesh to remove
  110570. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  110571. * @returns the Shadow Generator itself
  110572. */
  110573. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  110574. /**
  110575. * Controls the extent to which the shadows fade out at the edge of the frustum
  110576. */
  110577. frustumEdgeFalloff: number;
  110578. protected _light: IShadowLight;
  110579. /**
  110580. * Returns the associated light object.
  110581. * @returns the light generating the shadow
  110582. */
  110583. getLight(): IShadowLight;
  110584. /**
  110585. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  110586. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  110587. * It might on the other hand introduce peter panning.
  110588. */
  110589. forceBackFacesOnly: boolean;
  110590. protected _scene: Scene;
  110591. protected _lightDirection: Vector3;
  110592. protected _effect: Effect;
  110593. protected _viewMatrix: Matrix;
  110594. protected _projectionMatrix: Matrix;
  110595. protected _transformMatrix: Matrix;
  110596. protected _cachedPosition: Vector3;
  110597. protected _cachedDirection: Vector3;
  110598. protected _cachedDefines: string;
  110599. protected _currentRenderID: number;
  110600. protected _boxBlurPostprocess: Nullable<PostProcess>;
  110601. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  110602. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  110603. protected _blurPostProcesses: PostProcess[];
  110604. protected _mapSize: number;
  110605. protected _currentFaceIndex: number;
  110606. protected _currentFaceIndexCache: number;
  110607. protected _textureType: number;
  110608. protected _defaultTextureMatrix: Matrix;
  110609. protected _storedUniqueId: Nullable<number>;
  110610. /** @hidden */
  110611. static _SceneComponentInitialization: (scene: Scene) => void;
  110612. /**
  110613. * Gets or sets the size of the texture what stores the shadows
  110614. */
  110615. get mapSize(): number;
  110616. set mapSize(size: number);
  110617. /**
  110618. * Creates a ShadowGenerator object.
  110619. * A ShadowGenerator is the required tool to use the shadows.
  110620. * Each light casting shadows needs to use its own ShadowGenerator.
  110621. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  110622. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  110623. * @param light The light object generating the shadows.
  110624. * @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.
  110625. */
  110626. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  110627. protected _initializeGenerator(): void;
  110628. protected _createTargetRenderTexture(): void;
  110629. protected _initializeShadowMap(): void;
  110630. protected _initializeBlurRTTAndPostProcesses(): void;
  110631. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  110632. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  110633. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  110634. protected _applyFilterValues(): void;
  110635. /**
  110636. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110637. * @param onCompiled Callback triggered at the and of the effects compilation
  110638. * @param options Sets of optional options forcing the compilation with different modes
  110639. */
  110640. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  110641. useInstances: boolean;
  110642. }>): void;
  110643. /**
  110644. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110645. * @param options Sets of optional options forcing the compilation with different modes
  110646. * @returns A promise that resolves when the compilation completes
  110647. */
  110648. forceCompilationAsync(options?: Partial<{
  110649. useInstances: boolean;
  110650. }>): Promise<void>;
  110651. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  110652. private _prepareShadowDefines;
  110653. /**
  110654. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  110655. * @param subMesh The submesh we want to render in the shadow map
  110656. * @param useInstances Defines wether will draw in the map using instances
  110657. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  110658. * @returns true if ready otherwise, false
  110659. */
  110660. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  110661. /**
  110662. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  110663. * @param defines Defines of the material we want to update
  110664. * @param lightIndex Index of the light in the enabled light list of the material
  110665. */
  110666. prepareDefines(defines: any, lightIndex: number): void;
  110667. /**
  110668. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  110669. * defined in the generator but impacting the effect).
  110670. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  110671. * @param effect The effect we are binfing the information for
  110672. */
  110673. bindShadowLight(lightIndex: string, effect: Effect): void;
  110674. /**
  110675. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  110676. * (eq to shadow prjection matrix * light transform matrix)
  110677. * @returns The transform matrix used to create the shadow map
  110678. */
  110679. getTransformMatrix(): Matrix;
  110680. /**
  110681. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  110682. * Cube and 2D textures for instance.
  110683. */
  110684. recreateShadowMap(): void;
  110685. protected _disposeBlurPostProcesses(): void;
  110686. protected _disposeRTTandPostProcesses(): void;
  110687. /**
  110688. * Disposes the ShadowGenerator.
  110689. * Returns nothing.
  110690. */
  110691. dispose(): void;
  110692. /**
  110693. * Serializes the shadow generator setup to a json object.
  110694. * @returns The serialized JSON object
  110695. */
  110696. serialize(): any;
  110697. /**
  110698. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  110699. * @param parsedShadowGenerator The JSON object to parse
  110700. * @param scene The scene to create the shadow map for
  110701. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  110702. * @returns The parsed shadow generator
  110703. */
  110704. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  110705. }
  110706. }
  110707. declare module BABYLON {
  110708. /**
  110709. * Options to be used when creating a shadow depth material
  110710. */
  110711. export interface IIOptionShadowDepthMaterial {
  110712. /** Variables in the vertex shader code that need to have their names remapped.
  110713. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  110714. * "var_name" should be either: worldPos or vNormalW
  110715. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  110716. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  110717. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  110718. */
  110719. remappedVariables?: string[];
  110720. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  110721. standalone?: boolean;
  110722. }
  110723. /**
  110724. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  110725. */
  110726. export class ShadowDepthWrapper {
  110727. private _scene;
  110728. private _options?;
  110729. private _baseMaterial;
  110730. private _onEffectCreatedObserver;
  110731. private _subMeshToEffect;
  110732. private _subMeshToDepthEffect;
  110733. private _meshes;
  110734. /** @hidden */
  110735. _matriceNames: any;
  110736. /** Gets the standalone status of the wrapper */
  110737. get standalone(): boolean;
  110738. /** Gets the base material the wrapper is built upon */
  110739. get baseMaterial(): Material;
  110740. /**
  110741. * Instantiate a new shadow depth wrapper.
  110742. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  110743. * generate the shadow depth map. For more information, please refer to the documentation:
  110744. * https://doc.babylonjs.com/babylon101/shadows
  110745. * @param baseMaterial Material to wrap
  110746. * @param scene Define the scene the material belongs to
  110747. * @param options Options used to create the wrapper
  110748. */
  110749. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  110750. /**
  110751. * Gets the effect to use to generate the depth map
  110752. * @param subMesh subMesh to get the effect for
  110753. * @param shadowGenerator shadow generator to get the effect for
  110754. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  110755. */
  110756. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  110757. /**
  110758. * Specifies that the submesh is ready to be used for depth rendering
  110759. * @param subMesh submesh to check
  110760. * @param defines the list of defines to take into account when checking the effect
  110761. * @param shadowGenerator combined with subMesh, it defines the effect to check
  110762. * @param useInstances specifies that instances should be used
  110763. * @returns a boolean indicating that the submesh is ready or not
  110764. */
  110765. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  110766. /**
  110767. * Disposes the resources
  110768. */
  110769. dispose(): void;
  110770. private _makeEffect;
  110771. }
  110772. }
  110773. declare module BABYLON {
  110774. /**
  110775. * Options for compiling materials.
  110776. */
  110777. export interface IMaterialCompilationOptions {
  110778. /**
  110779. * Defines whether clip planes are enabled.
  110780. */
  110781. clipPlane: boolean;
  110782. /**
  110783. * Defines whether instances are enabled.
  110784. */
  110785. useInstances: boolean;
  110786. }
  110787. /**
  110788. * Options passed when calling customShaderNameResolve
  110789. */
  110790. export interface ICustomShaderNameResolveOptions {
  110791. /**
  110792. * 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
  110793. */
  110794. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110795. }
  110796. /**
  110797. * Base class for the main features of a material in Babylon.js
  110798. */
  110799. export class Material implements IAnimatable {
  110800. /**
  110801. * Returns the triangle fill mode
  110802. */
  110803. static readonly TriangleFillMode: number;
  110804. /**
  110805. * Returns the wireframe mode
  110806. */
  110807. static readonly WireFrameFillMode: number;
  110808. /**
  110809. * Returns the point fill mode
  110810. */
  110811. static readonly PointFillMode: number;
  110812. /**
  110813. * Returns the point list draw mode
  110814. */
  110815. static readonly PointListDrawMode: number;
  110816. /**
  110817. * Returns the line list draw mode
  110818. */
  110819. static readonly LineListDrawMode: number;
  110820. /**
  110821. * Returns the line loop draw mode
  110822. */
  110823. static readonly LineLoopDrawMode: number;
  110824. /**
  110825. * Returns the line strip draw mode
  110826. */
  110827. static readonly LineStripDrawMode: number;
  110828. /**
  110829. * Returns the triangle strip draw mode
  110830. */
  110831. static readonly TriangleStripDrawMode: number;
  110832. /**
  110833. * Returns the triangle fan draw mode
  110834. */
  110835. static readonly TriangleFanDrawMode: number;
  110836. /**
  110837. * Stores the clock-wise side orientation
  110838. */
  110839. static readonly ClockWiseSideOrientation: number;
  110840. /**
  110841. * Stores the counter clock-wise side orientation
  110842. */
  110843. static readonly CounterClockWiseSideOrientation: number;
  110844. /**
  110845. * The dirty texture flag value
  110846. */
  110847. static readonly TextureDirtyFlag: number;
  110848. /**
  110849. * The dirty light flag value
  110850. */
  110851. static readonly LightDirtyFlag: number;
  110852. /**
  110853. * The dirty fresnel flag value
  110854. */
  110855. static readonly FresnelDirtyFlag: number;
  110856. /**
  110857. * The dirty attribute flag value
  110858. */
  110859. static readonly AttributesDirtyFlag: number;
  110860. /**
  110861. * The dirty misc flag value
  110862. */
  110863. static readonly MiscDirtyFlag: number;
  110864. /**
  110865. * The dirty prepass flag value
  110866. */
  110867. static readonly PrePassDirtyFlag: number;
  110868. /**
  110869. * The all dirty flag value
  110870. */
  110871. static readonly AllDirtyFlag: number;
  110872. /**
  110873. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110874. */
  110875. static readonly MATERIAL_OPAQUE: number;
  110876. /**
  110877. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110878. */
  110879. static readonly MATERIAL_ALPHATEST: number;
  110880. /**
  110881. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110882. */
  110883. static readonly MATERIAL_ALPHABLEND: number;
  110884. /**
  110885. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110886. * They are also discarded below the alpha cutoff threshold to improve performances.
  110887. */
  110888. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  110889. /**
  110890. * The Whiteout method is used to blend normals.
  110891. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  110892. */
  110893. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  110894. /**
  110895. * The Reoriented Normal Mapping method is used to blend normals.
  110896. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  110897. */
  110898. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  110899. /**
  110900. * Custom callback helping to override the default shader used in the material.
  110901. */
  110902. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  110903. /**
  110904. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  110905. */
  110906. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  110907. /**
  110908. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  110909. * This means that the material can keep using a previous shader while a new one is being compiled.
  110910. * This is mostly used when shader parallel compilation is supported (true by default)
  110911. */
  110912. allowShaderHotSwapping: boolean;
  110913. /**
  110914. * The ID of the material
  110915. */
  110916. id: string;
  110917. /**
  110918. * Gets or sets the unique id of the material
  110919. */
  110920. uniqueId: number;
  110921. /**
  110922. * The name of the material
  110923. */
  110924. name: string;
  110925. /**
  110926. * Gets or sets user defined metadata
  110927. */
  110928. metadata: any;
  110929. /**
  110930. * For internal use only. Please do not use.
  110931. */
  110932. reservedDataStore: any;
  110933. /**
  110934. * Specifies if the ready state should be checked on each call
  110935. */
  110936. checkReadyOnEveryCall: boolean;
  110937. /**
  110938. * Specifies if the ready state should be checked once
  110939. */
  110940. checkReadyOnlyOnce: boolean;
  110941. /**
  110942. * The state of the material
  110943. */
  110944. state: string;
  110945. /**
  110946. * If the material can be rendered to several textures with MRT extension
  110947. */
  110948. get canRenderToMRT(): boolean;
  110949. /**
  110950. * The alpha value of the material
  110951. */
  110952. protected _alpha: number;
  110953. /**
  110954. * List of inspectable custom properties (used by the Inspector)
  110955. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110956. */
  110957. inspectableCustomProperties: IInspectable[];
  110958. /**
  110959. * Sets the alpha value of the material
  110960. */
  110961. set alpha(value: number);
  110962. /**
  110963. * Gets the alpha value of the material
  110964. */
  110965. get alpha(): number;
  110966. /**
  110967. * Specifies if back face culling is enabled
  110968. */
  110969. protected _backFaceCulling: boolean;
  110970. /**
  110971. * Sets the back-face culling state
  110972. */
  110973. set backFaceCulling(value: boolean);
  110974. /**
  110975. * Gets the back-face culling state
  110976. */
  110977. get backFaceCulling(): boolean;
  110978. /**
  110979. * Stores the value for side orientation
  110980. */
  110981. sideOrientation: number;
  110982. /**
  110983. * Callback triggered when the material is compiled
  110984. */
  110985. onCompiled: Nullable<(effect: Effect) => void>;
  110986. /**
  110987. * Callback triggered when an error occurs
  110988. */
  110989. onError: Nullable<(effect: Effect, errors: string) => void>;
  110990. /**
  110991. * Callback triggered to get the render target textures
  110992. */
  110993. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  110994. /**
  110995. * Gets a boolean indicating that current material needs to register RTT
  110996. */
  110997. get hasRenderTargetTextures(): boolean;
  110998. /**
  110999. * Specifies if the material should be serialized
  111000. */
  111001. doNotSerialize: boolean;
  111002. /**
  111003. * @hidden
  111004. */
  111005. _storeEffectOnSubMeshes: boolean;
  111006. /**
  111007. * Stores the animations for the material
  111008. */
  111009. animations: Nullable<Array<Animation>>;
  111010. /**
  111011. * An event triggered when the material is disposed
  111012. */
  111013. onDisposeObservable: Observable<Material>;
  111014. /**
  111015. * An observer which watches for dispose events
  111016. */
  111017. private _onDisposeObserver;
  111018. private _onUnBindObservable;
  111019. /**
  111020. * Called during a dispose event
  111021. */
  111022. set onDispose(callback: () => void);
  111023. private _onBindObservable;
  111024. /**
  111025. * An event triggered when the material is bound
  111026. */
  111027. get onBindObservable(): Observable<AbstractMesh>;
  111028. /**
  111029. * An observer which watches for bind events
  111030. */
  111031. private _onBindObserver;
  111032. /**
  111033. * Called during a bind event
  111034. */
  111035. set onBind(callback: (Mesh: AbstractMesh) => void);
  111036. /**
  111037. * An event triggered when the material is unbound
  111038. */
  111039. get onUnBindObservable(): Observable<Material>;
  111040. protected _onEffectCreatedObservable: Nullable<Observable<{
  111041. effect: Effect;
  111042. subMesh: Nullable<SubMesh>;
  111043. }>>;
  111044. /**
  111045. * An event triggered when the effect is (re)created
  111046. */
  111047. get onEffectCreatedObservable(): Observable<{
  111048. effect: Effect;
  111049. subMesh: Nullable<SubMesh>;
  111050. }>;
  111051. /**
  111052. * Stores the value of the alpha mode
  111053. */
  111054. private _alphaMode;
  111055. /**
  111056. * Sets the value of the alpha mode.
  111057. *
  111058. * | Value | Type | Description |
  111059. * | --- | --- | --- |
  111060. * | 0 | ALPHA_DISABLE | |
  111061. * | 1 | ALPHA_ADD | |
  111062. * | 2 | ALPHA_COMBINE | |
  111063. * | 3 | ALPHA_SUBTRACT | |
  111064. * | 4 | ALPHA_MULTIPLY | |
  111065. * | 5 | ALPHA_MAXIMIZED | |
  111066. * | 6 | ALPHA_ONEONE | |
  111067. * | 7 | ALPHA_PREMULTIPLIED | |
  111068. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  111069. * | 9 | ALPHA_INTERPOLATE | |
  111070. * | 10 | ALPHA_SCREENMODE | |
  111071. *
  111072. */
  111073. set alphaMode(value: number);
  111074. /**
  111075. * Gets the value of the alpha mode
  111076. */
  111077. get alphaMode(): number;
  111078. /**
  111079. * Stores the state of the need depth pre-pass value
  111080. */
  111081. private _needDepthPrePass;
  111082. /**
  111083. * Sets the need depth pre-pass value
  111084. */
  111085. set needDepthPrePass(value: boolean);
  111086. /**
  111087. * Gets the depth pre-pass value
  111088. */
  111089. get needDepthPrePass(): boolean;
  111090. /**
  111091. * Specifies if depth writing should be disabled
  111092. */
  111093. disableDepthWrite: boolean;
  111094. /**
  111095. * Specifies if color writing should be disabled
  111096. */
  111097. disableColorWrite: boolean;
  111098. /**
  111099. * Specifies if depth writing should be forced
  111100. */
  111101. forceDepthWrite: boolean;
  111102. /**
  111103. * Specifies the depth function that should be used. 0 means the default engine function
  111104. */
  111105. depthFunction: number;
  111106. /**
  111107. * Specifies if there should be a separate pass for culling
  111108. */
  111109. separateCullingPass: boolean;
  111110. /**
  111111. * Stores the state specifing if fog should be enabled
  111112. */
  111113. private _fogEnabled;
  111114. /**
  111115. * Sets the state for enabling fog
  111116. */
  111117. set fogEnabled(value: boolean);
  111118. /**
  111119. * Gets the value of the fog enabled state
  111120. */
  111121. get fogEnabled(): boolean;
  111122. /**
  111123. * Stores the size of points
  111124. */
  111125. pointSize: number;
  111126. /**
  111127. * Stores the z offset value
  111128. */
  111129. zOffset: number;
  111130. get wireframe(): boolean;
  111131. /**
  111132. * Sets the state of wireframe mode
  111133. */
  111134. set wireframe(value: boolean);
  111135. /**
  111136. * Gets the value specifying if point clouds are enabled
  111137. */
  111138. get pointsCloud(): boolean;
  111139. /**
  111140. * Sets the state of point cloud mode
  111141. */
  111142. set pointsCloud(value: boolean);
  111143. /**
  111144. * Gets the material fill mode
  111145. */
  111146. get fillMode(): number;
  111147. /**
  111148. * Sets the material fill mode
  111149. */
  111150. set fillMode(value: number);
  111151. /**
  111152. * @hidden
  111153. * Stores the effects for the material
  111154. */
  111155. _effect: Nullable<Effect>;
  111156. /**
  111157. * Specifies if uniform buffers should be used
  111158. */
  111159. private _useUBO;
  111160. /**
  111161. * Stores a reference to the scene
  111162. */
  111163. private _scene;
  111164. /**
  111165. * Stores the fill mode state
  111166. */
  111167. private _fillMode;
  111168. /**
  111169. * Specifies if the depth write state should be cached
  111170. */
  111171. private _cachedDepthWriteState;
  111172. /**
  111173. * Specifies if the color write state should be cached
  111174. */
  111175. private _cachedColorWriteState;
  111176. /**
  111177. * Specifies if the depth function state should be cached
  111178. */
  111179. private _cachedDepthFunctionState;
  111180. /**
  111181. * Stores the uniform buffer
  111182. */
  111183. protected _uniformBuffer: UniformBuffer;
  111184. /** @hidden */
  111185. _indexInSceneMaterialArray: number;
  111186. /** @hidden */
  111187. meshMap: Nullable<{
  111188. [id: string]: AbstractMesh | undefined;
  111189. }>;
  111190. /**
  111191. * Creates a material instance
  111192. * @param name defines the name of the material
  111193. * @param scene defines the scene to reference
  111194. * @param doNotAdd specifies if the material should be added to the scene
  111195. */
  111196. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  111197. /**
  111198. * Returns a string representation of the current material
  111199. * @param fullDetails defines a boolean indicating which levels of logging is desired
  111200. * @returns a string with material information
  111201. */
  111202. toString(fullDetails?: boolean): string;
  111203. /**
  111204. * Gets the class name of the material
  111205. * @returns a string with the class name of the material
  111206. */
  111207. getClassName(): string;
  111208. /**
  111209. * Specifies if updates for the material been locked
  111210. */
  111211. get isFrozen(): boolean;
  111212. /**
  111213. * Locks updates for the material
  111214. */
  111215. freeze(): void;
  111216. /**
  111217. * Unlocks updates for the material
  111218. */
  111219. unfreeze(): void;
  111220. /**
  111221. * Specifies if the material is ready to be used
  111222. * @param mesh defines the mesh to check
  111223. * @param useInstances specifies if instances should be used
  111224. * @returns a boolean indicating if the material is ready to be used
  111225. */
  111226. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  111227. /**
  111228. * Specifies that the submesh is ready to be used
  111229. * @param mesh defines the mesh to check
  111230. * @param subMesh defines which submesh to check
  111231. * @param useInstances specifies that instances should be used
  111232. * @returns a boolean indicating that the submesh is ready or not
  111233. */
  111234. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111235. /**
  111236. * Returns the material effect
  111237. * @returns the effect associated with the material
  111238. */
  111239. getEffect(): Nullable<Effect>;
  111240. /**
  111241. * Returns the current scene
  111242. * @returns a Scene
  111243. */
  111244. getScene(): Scene;
  111245. /**
  111246. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111247. */
  111248. protected _forceAlphaTest: boolean;
  111249. /**
  111250. * The transparency mode of the material.
  111251. */
  111252. protected _transparencyMode: Nullable<number>;
  111253. /**
  111254. * Gets the current transparency mode.
  111255. */
  111256. get transparencyMode(): Nullable<number>;
  111257. /**
  111258. * Sets the transparency mode of the material.
  111259. *
  111260. * | Value | Type | Description |
  111261. * | ----- | ----------------------------------- | ----------- |
  111262. * | 0 | OPAQUE | |
  111263. * | 1 | ALPHATEST | |
  111264. * | 2 | ALPHABLEND | |
  111265. * | 3 | ALPHATESTANDBLEND | |
  111266. *
  111267. */
  111268. set transparencyMode(value: Nullable<number>);
  111269. /**
  111270. * Returns true if alpha blending should be disabled.
  111271. */
  111272. protected get _disableAlphaBlending(): boolean;
  111273. /**
  111274. * Specifies whether or not this material should be rendered in alpha blend mode.
  111275. * @returns a boolean specifying if alpha blending is needed
  111276. */
  111277. needAlphaBlending(): boolean;
  111278. /**
  111279. * Specifies if the mesh will require alpha blending
  111280. * @param mesh defines the mesh to check
  111281. * @returns a boolean specifying if alpha blending is needed for the mesh
  111282. */
  111283. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  111284. /**
  111285. * Specifies whether or not this material should be rendered in alpha test mode.
  111286. * @returns a boolean specifying if an alpha test is needed.
  111287. */
  111288. needAlphaTesting(): boolean;
  111289. /**
  111290. * Specifies if material alpha testing should be turned on for the mesh
  111291. * @param mesh defines the mesh to check
  111292. */
  111293. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  111294. /**
  111295. * Gets the texture used for the alpha test
  111296. * @returns the texture to use for alpha testing
  111297. */
  111298. getAlphaTestTexture(): Nullable<BaseTexture>;
  111299. /**
  111300. * Marks the material to indicate that it needs to be re-calculated
  111301. */
  111302. markDirty(): void;
  111303. /** @hidden */
  111304. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  111305. /**
  111306. * Binds the material to the mesh
  111307. * @param world defines the world transformation matrix
  111308. * @param mesh defines the mesh to bind the material to
  111309. */
  111310. bind(world: Matrix, mesh?: Mesh): void;
  111311. /**
  111312. * Binds the submesh to the material
  111313. * @param world defines the world transformation matrix
  111314. * @param mesh defines the mesh containing the submesh
  111315. * @param subMesh defines the submesh to bind the material to
  111316. */
  111317. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111318. /**
  111319. * Binds the world matrix to the material
  111320. * @param world defines the world transformation matrix
  111321. */
  111322. bindOnlyWorldMatrix(world: Matrix): void;
  111323. /**
  111324. * Binds the scene's uniform buffer to the effect.
  111325. * @param effect defines the effect to bind to the scene uniform buffer
  111326. * @param sceneUbo defines the uniform buffer storing scene data
  111327. */
  111328. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  111329. /**
  111330. * Binds the view matrix to the effect
  111331. * @param effect defines the effect to bind the view matrix to
  111332. */
  111333. bindView(effect: Effect): void;
  111334. /**
  111335. * Binds the view projection matrix to the effect
  111336. * @param effect defines the effect to bind the view projection matrix to
  111337. */
  111338. bindViewProjection(effect: Effect): void;
  111339. /**
  111340. * Processes to execute after binding the material to a mesh
  111341. * @param mesh defines the rendered mesh
  111342. */
  111343. protected _afterBind(mesh?: Mesh): void;
  111344. /**
  111345. * Unbinds the material from the mesh
  111346. */
  111347. unbind(): void;
  111348. /**
  111349. * Gets the active textures from the material
  111350. * @returns an array of textures
  111351. */
  111352. getActiveTextures(): BaseTexture[];
  111353. /**
  111354. * Specifies if the material uses a texture
  111355. * @param texture defines the texture to check against the material
  111356. * @returns a boolean specifying if the material uses the texture
  111357. */
  111358. hasTexture(texture: BaseTexture): boolean;
  111359. /**
  111360. * Makes a duplicate of the material, and gives it a new name
  111361. * @param name defines the new name for the duplicated material
  111362. * @returns the cloned material
  111363. */
  111364. clone(name: string): Nullable<Material>;
  111365. /**
  111366. * Gets the meshes bound to the material
  111367. * @returns an array of meshes bound to the material
  111368. */
  111369. getBindedMeshes(): AbstractMesh[];
  111370. /**
  111371. * Force shader compilation
  111372. * @param mesh defines the mesh associated with this material
  111373. * @param onCompiled defines a function to execute once the material is compiled
  111374. * @param options defines the options to configure the compilation
  111375. * @param onError defines a function to execute if the material fails compiling
  111376. */
  111377. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  111378. /**
  111379. * Force shader compilation
  111380. * @param mesh defines the mesh that will use this material
  111381. * @param options defines additional options for compiling the shaders
  111382. * @returns a promise that resolves when the compilation completes
  111383. */
  111384. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  111385. private static readonly _AllDirtyCallBack;
  111386. private static readonly _ImageProcessingDirtyCallBack;
  111387. private static readonly _TextureDirtyCallBack;
  111388. private static readonly _FresnelDirtyCallBack;
  111389. private static readonly _MiscDirtyCallBack;
  111390. private static readonly _PrePassDirtyCallBack;
  111391. private static readonly _LightsDirtyCallBack;
  111392. private static readonly _AttributeDirtyCallBack;
  111393. private static _FresnelAndMiscDirtyCallBack;
  111394. private static _TextureAndMiscDirtyCallBack;
  111395. private static readonly _DirtyCallbackArray;
  111396. private static readonly _RunDirtyCallBacks;
  111397. /**
  111398. * Marks a define in the material to indicate that it needs to be re-computed
  111399. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  111400. */
  111401. markAsDirty(flag: number): void;
  111402. /**
  111403. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  111404. * @param func defines a function which checks material defines against the submeshes
  111405. */
  111406. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  111407. /**
  111408. * Indicates that the scene should check if the rendering now needs a prepass
  111409. */
  111410. protected _markScenePrePassDirty(): void;
  111411. /**
  111412. * Indicates that we need to re-calculated for all submeshes
  111413. */
  111414. protected _markAllSubMeshesAsAllDirty(): void;
  111415. /**
  111416. * Indicates that image processing needs to be re-calculated for all submeshes
  111417. */
  111418. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  111419. /**
  111420. * Indicates that textures need to be re-calculated for all submeshes
  111421. */
  111422. protected _markAllSubMeshesAsTexturesDirty(): void;
  111423. /**
  111424. * Indicates that fresnel needs to be re-calculated for all submeshes
  111425. */
  111426. protected _markAllSubMeshesAsFresnelDirty(): void;
  111427. /**
  111428. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  111429. */
  111430. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  111431. /**
  111432. * Indicates that lights need to be re-calculated for all submeshes
  111433. */
  111434. protected _markAllSubMeshesAsLightsDirty(): void;
  111435. /**
  111436. * Indicates that attributes need to be re-calculated for all submeshes
  111437. */
  111438. protected _markAllSubMeshesAsAttributesDirty(): void;
  111439. /**
  111440. * Indicates that misc needs to be re-calculated for all submeshes
  111441. */
  111442. protected _markAllSubMeshesAsMiscDirty(): void;
  111443. /**
  111444. * Indicates that prepass needs to be re-calculated for all submeshes
  111445. */
  111446. protected _markAllSubMeshesAsPrePassDirty(): void;
  111447. /**
  111448. * Indicates that textures and misc need to be re-calculated for all submeshes
  111449. */
  111450. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  111451. /**
  111452. * Sets the required values to the prepass renderer.
  111453. * @param prePassRenderer defines the prepass renderer to setup.
  111454. * @returns true if the pre pass is needed.
  111455. */
  111456. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  111457. /**
  111458. * Disposes the material
  111459. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111460. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111461. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  111462. */
  111463. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  111464. /** @hidden */
  111465. private releaseVertexArrayObject;
  111466. /**
  111467. * Serializes this material
  111468. * @returns the serialized material object
  111469. */
  111470. serialize(): any;
  111471. /**
  111472. * Creates a material from parsed material data
  111473. * @param parsedMaterial defines parsed material data
  111474. * @param scene defines the hosting scene
  111475. * @param rootUrl defines the root URL to use to load textures
  111476. * @returns a new material
  111477. */
  111478. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  111479. }
  111480. }
  111481. declare module BABYLON {
  111482. /**
  111483. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111484. * separate meshes. This can be use to improve performances.
  111485. * @see https://doc.babylonjs.com/how_to/multi_materials
  111486. */
  111487. export class MultiMaterial extends Material {
  111488. private _subMaterials;
  111489. /**
  111490. * Gets or Sets the list of Materials used within the multi material.
  111491. * They need to be ordered according to the submeshes order in the associated mesh
  111492. */
  111493. get subMaterials(): Nullable<Material>[];
  111494. set subMaterials(value: Nullable<Material>[]);
  111495. /**
  111496. * Function used to align with Node.getChildren()
  111497. * @returns the list of Materials used within the multi material
  111498. */
  111499. getChildren(): Nullable<Material>[];
  111500. /**
  111501. * Instantiates a new Multi Material
  111502. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111503. * separate meshes. This can be use to improve performances.
  111504. * @see https://doc.babylonjs.com/how_to/multi_materials
  111505. * @param name Define the name in the scene
  111506. * @param scene Define the scene the material belongs to
  111507. */
  111508. constructor(name: string, scene: Scene);
  111509. private _hookArray;
  111510. /**
  111511. * Get one of the submaterial by its index in the submaterials array
  111512. * @param index The index to look the sub material at
  111513. * @returns The Material if the index has been defined
  111514. */
  111515. getSubMaterial(index: number): Nullable<Material>;
  111516. /**
  111517. * Get the list of active textures for the whole sub materials list.
  111518. * @returns All the textures that will be used during the rendering
  111519. */
  111520. getActiveTextures(): BaseTexture[];
  111521. /**
  111522. * Specifies if any sub-materials of this multi-material use a given texture.
  111523. * @param texture Defines the texture to check against this multi-material's sub-materials.
  111524. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  111525. */
  111526. hasTexture(texture: BaseTexture): boolean;
  111527. /**
  111528. * Gets the current class name of the material e.g. "MultiMaterial"
  111529. * Mainly use in serialization.
  111530. * @returns the class name
  111531. */
  111532. getClassName(): string;
  111533. /**
  111534. * Checks if the material is ready to render the requested sub mesh
  111535. * @param mesh Define the mesh the submesh belongs to
  111536. * @param subMesh Define the sub mesh to look readyness for
  111537. * @param useInstances Define whether or not the material is used with instances
  111538. * @returns true if ready, otherwise false
  111539. */
  111540. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111541. /**
  111542. * Clones the current material and its related sub materials
  111543. * @param name Define the name of the newly cloned material
  111544. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  111545. * @returns the cloned material
  111546. */
  111547. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  111548. /**
  111549. * Serializes the materials into a JSON representation.
  111550. * @returns the JSON representation
  111551. */
  111552. serialize(): any;
  111553. /**
  111554. * Dispose the material and release its associated resources
  111555. * @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)
  111556. * @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)
  111557. * @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)
  111558. */
  111559. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  111560. /**
  111561. * Creates a MultiMaterial from parsed MultiMaterial data.
  111562. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  111563. * @param scene defines the hosting scene
  111564. * @returns a new MultiMaterial
  111565. */
  111566. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  111567. }
  111568. }
  111569. declare module BABYLON {
  111570. /**
  111571. * Defines a subdivision inside a mesh
  111572. */
  111573. export class SubMesh implements ICullable {
  111574. /** the material index to use */
  111575. materialIndex: number;
  111576. /** vertex index start */
  111577. verticesStart: number;
  111578. /** vertices count */
  111579. verticesCount: number;
  111580. /** index start */
  111581. indexStart: number;
  111582. /** indices count */
  111583. indexCount: number;
  111584. /** @hidden */
  111585. _materialDefines: Nullable<MaterialDefines>;
  111586. /** @hidden */
  111587. _materialEffect: Nullable<Effect>;
  111588. /** @hidden */
  111589. _effectOverride: Nullable<Effect>;
  111590. /**
  111591. * Gets material defines used by the effect associated to the sub mesh
  111592. */
  111593. get materialDefines(): Nullable<MaterialDefines>;
  111594. /**
  111595. * Sets material defines used by the effect associated to the sub mesh
  111596. */
  111597. set materialDefines(defines: Nullable<MaterialDefines>);
  111598. /**
  111599. * Gets associated effect
  111600. */
  111601. get effect(): Nullable<Effect>;
  111602. /**
  111603. * Sets associated effect (effect used to render this submesh)
  111604. * @param effect defines the effect to associate with
  111605. * @param defines defines the set of defines used to compile this effect
  111606. */
  111607. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  111608. /** @hidden */
  111609. _linesIndexCount: number;
  111610. private _mesh;
  111611. private _renderingMesh;
  111612. private _boundingInfo;
  111613. private _linesIndexBuffer;
  111614. /** @hidden */
  111615. _lastColliderWorldVertices: Nullable<Vector3[]>;
  111616. /** @hidden */
  111617. _trianglePlanes: Plane[];
  111618. /** @hidden */
  111619. _lastColliderTransformMatrix: Nullable<Matrix>;
  111620. /** @hidden */
  111621. _renderId: number;
  111622. /** @hidden */
  111623. _alphaIndex: number;
  111624. /** @hidden */
  111625. _distanceToCamera: number;
  111626. /** @hidden */
  111627. _id: number;
  111628. private _currentMaterial;
  111629. /**
  111630. * Add a new submesh to a mesh
  111631. * @param materialIndex defines the material index to use
  111632. * @param verticesStart defines vertex index start
  111633. * @param verticesCount defines vertices count
  111634. * @param indexStart defines index start
  111635. * @param indexCount defines indices count
  111636. * @param mesh defines the parent mesh
  111637. * @param renderingMesh defines an optional rendering mesh
  111638. * @param createBoundingBox defines if bounding box should be created for this submesh
  111639. * @returns the new submesh
  111640. */
  111641. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  111642. /**
  111643. * Creates a new submesh
  111644. * @param materialIndex defines the material index to use
  111645. * @param verticesStart defines vertex index start
  111646. * @param verticesCount defines vertices count
  111647. * @param indexStart defines index start
  111648. * @param indexCount defines indices count
  111649. * @param mesh defines the parent mesh
  111650. * @param renderingMesh defines an optional rendering mesh
  111651. * @param createBoundingBox defines if bounding box should be created for this submesh
  111652. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  111653. */
  111654. constructor(
  111655. /** the material index to use */
  111656. materialIndex: number,
  111657. /** vertex index start */
  111658. verticesStart: number,
  111659. /** vertices count */
  111660. verticesCount: number,
  111661. /** index start */
  111662. indexStart: number,
  111663. /** indices count */
  111664. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  111665. /**
  111666. * Returns true if this submesh covers the entire parent mesh
  111667. * @ignorenaming
  111668. */
  111669. get IsGlobal(): boolean;
  111670. /**
  111671. * Returns the submesh BoudingInfo object
  111672. * @returns current bounding info (or mesh's one if the submesh is global)
  111673. */
  111674. getBoundingInfo(): BoundingInfo;
  111675. /**
  111676. * Sets the submesh BoundingInfo
  111677. * @param boundingInfo defines the new bounding info to use
  111678. * @returns the SubMesh
  111679. */
  111680. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  111681. /**
  111682. * Returns the mesh of the current submesh
  111683. * @return the parent mesh
  111684. */
  111685. getMesh(): AbstractMesh;
  111686. /**
  111687. * Returns the rendering mesh of the submesh
  111688. * @returns the rendering mesh (could be different from parent mesh)
  111689. */
  111690. getRenderingMesh(): Mesh;
  111691. /**
  111692. * Returns the replacement mesh of the submesh
  111693. * @returns the replacement mesh (could be different from parent mesh)
  111694. */
  111695. getReplacementMesh(): Nullable<AbstractMesh>;
  111696. /**
  111697. * Returns the effective mesh of the submesh
  111698. * @returns the effective mesh (could be different from parent mesh)
  111699. */
  111700. getEffectiveMesh(): AbstractMesh;
  111701. /**
  111702. * Returns the submesh material
  111703. * @returns null or the current material
  111704. */
  111705. getMaterial(): Nullable<Material>;
  111706. private _IsMultiMaterial;
  111707. /**
  111708. * Sets a new updated BoundingInfo object to the submesh
  111709. * @param data defines an optional position array to use to determine the bounding info
  111710. * @returns the SubMesh
  111711. */
  111712. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  111713. /** @hidden */
  111714. _checkCollision(collider: Collider): boolean;
  111715. /**
  111716. * Updates the submesh BoundingInfo
  111717. * @param world defines the world matrix to use to update the bounding info
  111718. * @returns the submesh
  111719. */
  111720. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  111721. /**
  111722. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  111723. * @param frustumPlanes defines the frustum planes
  111724. * @returns true if the submesh is intersecting with the frustum
  111725. */
  111726. isInFrustum(frustumPlanes: Plane[]): boolean;
  111727. /**
  111728. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  111729. * @param frustumPlanes defines the frustum planes
  111730. * @returns true if the submesh is inside the frustum
  111731. */
  111732. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111733. /**
  111734. * Renders the submesh
  111735. * @param enableAlphaMode defines if alpha needs to be used
  111736. * @returns the submesh
  111737. */
  111738. render(enableAlphaMode: boolean): SubMesh;
  111739. /**
  111740. * @hidden
  111741. */
  111742. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  111743. /**
  111744. * Checks if the submesh intersects with a ray
  111745. * @param ray defines the ray to test
  111746. * @returns true is the passed ray intersects the submesh bounding box
  111747. */
  111748. canIntersects(ray: Ray): boolean;
  111749. /**
  111750. * Intersects current submesh with a ray
  111751. * @param ray defines the ray to test
  111752. * @param positions defines mesh's positions array
  111753. * @param indices defines mesh's indices array
  111754. * @param fastCheck defines if the first intersection will be used (and not the closest)
  111755. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111756. * @returns intersection info or null if no intersection
  111757. */
  111758. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  111759. /** @hidden */
  111760. private _intersectLines;
  111761. /** @hidden */
  111762. private _intersectUnIndexedLines;
  111763. /** @hidden */
  111764. private _intersectTriangles;
  111765. /** @hidden */
  111766. private _intersectUnIndexedTriangles;
  111767. /** @hidden */
  111768. _rebuild(): void;
  111769. /**
  111770. * Creates a new submesh from the passed mesh
  111771. * @param newMesh defines the new hosting mesh
  111772. * @param newRenderingMesh defines an optional rendering mesh
  111773. * @returns the new submesh
  111774. */
  111775. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  111776. /**
  111777. * Release associated resources
  111778. */
  111779. dispose(): void;
  111780. /**
  111781. * Gets the class name
  111782. * @returns the string "SubMesh".
  111783. */
  111784. getClassName(): string;
  111785. /**
  111786. * Creates a new submesh from indices data
  111787. * @param materialIndex the index of the main mesh material
  111788. * @param startIndex the index where to start the copy in the mesh indices array
  111789. * @param indexCount the number of indices to copy then from the startIndex
  111790. * @param mesh the main mesh to create the submesh from
  111791. * @param renderingMesh the optional rendering mesh
  111792. * @returns a new submesh
  111793. */
  111794. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  111795. }
  111796. }
  111797. declare module BABYLON {
  111798. /**
  111799. * Class used to represent data loading progression
  111800. */
  111801. export class SceneLoaderFlags {
  111802. private static _ForceFullSceneLoadingForIncremental;
  111803. private static _ShowLoadingScreen;
  111804. private static _CleanBoneMatrixWeights;
  111805. private static _loggingLevel;
  111806. /**
  111807. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111808. */
  111809. static get ForceFullSceneLoadingForIncremental(): boolean;
  111810. static set ForceFullSceneLoadingForIncremental(value: boolean);
  111811. /**
  111812. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111813. */
  111814. static get ShowLoadingScreen(): boolean;
  111815. static set ShowLoadingScreen(value: boolean);
  111816. /**
  111817. * Defines the current logging level (while loading the scene)
  111818. * @ignorenaming
  111819. */
  111820. static get loggingLevel(): number;
  111821. static set loggingLevel(value: number);
  111822. /**
  111823. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111824. */
  111825. static get CleanBoneMatrixWeights(): boolean;
  111826. static set CleanBoneMatrixWeights(value: boolean);
  111827. }
  111828. }
  111829. declare module BABYLON {
  111830. /**
  111831. * Class used to store geometry data (vertex buffers + index buffer)
  111832. */
  111833. export class Geometry implements IGetSetVerticesData {
  111834. /**
  111835. * Gets or sets the ID of the geometry
  111836. */
  111837. id: string;
  111838. /**
  111839. * Gets or sets the unique ID of the geometry
  111840. */
  111841. uniqueId: number;
  111842. /**
  111843. * Gets the delay loading state of the geometry (none by default which means not delayed)
  111844. */
  111845. delayLoadState: number;
  111846. /**
  111847. * Gets the file containing the data to load when running in delay load state
  111848. */
  111849. delayLoadingFile: Nullable<string>;
  111850. /**
  111851. * Callback called when the geometry is updated
  111852. */
  111853. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  111854. private _scene;
  111855. private _engine;
  111856. private _meshes;
  111857. private _totalVertices;
  111858. /** @hidden */
  111859. _indices: IndicesArray;
  111860. /** @hidden */
  111861. _vertexBuffers: {
  111862. [key: string]: VertexBuffer;
  111863. };
  111864. private _isDisposed;
  111865. private _extend;
  111866. private _boundingBias;
  111867. /** @hidden */
  111868. _delayInfo: Array<string>;
  111869. private _indexBuffer;
  111870. private _indexBufferIsUpdatable;
  111871. /** @hidden */
  111872. _boundingInfo: Nullable<BoundingInfo>;
  111873. /** @hidden */
  111874. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  111875. /** @hidden */
  111876. _softwareSkinningFrameId: number;
  111877. private _vertexArrayObjects;
  111878. private _updatable;
  111879. /** @hidden */
  111880. _positions: Nullable<Vector3[]>;
  111881. private _positionsCache;
  111882. /**
  111883. * 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
  111884. */
  111885. get boundingBias(): Vector2;
  111886. /**
  111887. * 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
  111888. */
  111889. set boundingBias(value: Vector2);
  111890. /**
  111891. * Static function used to attach a new empty geometry to a mesh
  111892. * @param mesh defines the mesh to attach the geometry to
  111893. * @returns the new Geometry
  111894. */
  111895. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  111896. /** Get the list of meshes using this geometry */
  111897. get meshes(): Mesh[];
  111898. /**
  111899. * 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
  111900. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  111901. */
  111902. useBoundingInfoFromGeometry: boolean;
  111903. /**
  111904. * Creates a new geometry
  111905. * @param id defines the unique ID
  111906. * @param scene defines the hosting scene
  111907. * @param vertexData defines the VertexData used to get geometry data
  111908. * @param updatable defines if geometry must be updatable (false by default)
  111909. * @param mesh defines the mesh that will be associated with the geometry
  111910. */
  111911. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  111912. /**
  111913. * Gets the current extend of the geometry
  111914. */
  111915. get extend(): {
  111916. minimum: Vector3;
  111917. maximum: Vector3;
  111918. };
  111919. /**
  111920. * Gets the hosting scene
  111921. * @returns the hosting Scene
  111922. */
  111923. getScene(): Scene;
  111924. /**
  111925. * Gets the hosting engine
  111926. * @returns the hosting Engine
  111927. */
  111928. getEngine(): Engine;
  111929. /**
  111930. * Defines if the geometry is ready to use
  111931. * @returns true if the geometry is ready to be used
  111932. */
  111933. isReady(): boolean;
  111934. /**
  111935. * Gets a value indicating that the geometry should not be serialized
  111936. */
  111937. get doNotSerialize(): boolean;
  111938. /** @hidden */
  111939. _rebuild(): void;
  111940. /**
  111941. * Affects all geometry data in one call
  111942. * @param vertexData defines the geometry data
  111943. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  111944. */
  111945. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  111946. /**
  111947. * Set specific vertex data
  111948. * @param kind defines the data kind (Position, normal, etc...)
  111949. * @param data defines the vertex data to use
  111950. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  111951. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  111952. */
  111953. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  111954. /**
  111955. * Removes a specific vertex data
  111956. * @param kind defines the data kind (Position, normal, etc...)
  111957. */
  111958. removeVerticesData(kind: string): void;
  111959. /**
  111960. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  111961. * @param buffer defines the vertex buffer to use
  111962. * @param totalVertices defines the total number of vertices for position kind (could be null)
  111963. */
  111964. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  111965. /**
  111966. * Update a specific vertex buffer
  111967. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  111968. * It will do nothing if the buffer is not updatable
  111969. * @param kind defines the data kind (Position, normal, etc...)
  111970. * @param data defines the data to use
  111971. * @param offset defines the offset in the target buffer where to store the data
  111972. * @param useBytes set to true if the offset is in bytes
  111973. */
  111974. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  111975. /**
  111976. * Update a specific vertex buffer
  111977. * This function will create a new buffer if the current one is not updatable
  111978. * @param kind defines the data kind (Position, normal, etc...)
  111979. * @param data defines the data to use
  111980. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  111981. */
  111982. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  111983. private _updateBoundingInfo;
  111984. /** @hidden */
  111985. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  111986. /**
  111987. * Gets total number of vertices
  111988. * @returns the total number of vertices
  111989. */
  111990. getTotalVertices(): number;
  111991. /**
  111992. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  111993. * @param kind defines the data kind (Position, normal, etc...)
  111994. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111995. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111996. * @returns a float array containing vertex data
  111997. */
  111998. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  111999. /**
  112000. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  112001. * @param kind defines the data kind (Position, normal, etc...)
  112002. * @returns true if the vertex buffer with the specified kind is updatable
  112003. */
  112004. isVertexBufferUpdatable(kind: string): boolean;
  112005. /**
  112006. * Gets a specific vertex buffer
  112007. * @param kind defines the data kind (Position, normal, etc...)
  112008. * @returns a VertexBuffer
  112009. */
  112010. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  112011. /**
  112012. * Returns all vertex buffers
  112013. * @return an object holding all vertex buffers indexed by kind
  112014. */
  112015. getVertexBuffers(): Nullable<{
  112016. [key: string]: VertexBuffer;
  112017. }>;
  112018. /**
  112019. * Gets a boolean indicating if specific vertex buffer is present
  112020. * @param kind defines the data kind (Position, normal, etc...)
  112021. * @returns true if data is present
  112022. */
  112023. isVerticesDataPresent(kind: string): boolean;
  112024. /**
  112025. * Gets a list of all attached data kinds (Position, normal, etc...)
  112026. * @returns a list of string containing all kinds
  112027. */
  112028. getVerticesDataKinds(): string[];
  112029. /**
  112030. * Update index buffer
  112031. * @param indices defines the indices to store in the index buffer
  112032. * @param offset defines the offset in the target buffer where to store the data
  112033. * @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)
  112034. */
  112035. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  112036. /**
  112037. * Creates a new index buffer
  112038. * @param indices defines the indices to store in the index buffer
  112039. * @param totalVertices defines the total number of vertices (could be null)
  112040. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  112041. */
  112042. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  112043. /**
  112044. * Return the total number of indices
  112045. * @returns the total number of indices
  112046. */
  112047. getTotalIndices(): number;
  112048. /**
  112049. * Gets the index buffer array
  112050. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  112051. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  112052. * @returns the index buffer array
  112053. */
  112054. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  112055. /**
  112056. * Gets the index buffer
  112057. * @return the index buffer
  112058. */
  112059. getIndexBuffer(): Nullable<DataBuffer>;
  112060. /** @hidden */
  112061. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  112062. /**
  112063. * Release the associated resources for a specific mesh
  112064. * @param mesh defines the source mesh
  112065. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  112066. */
  112067. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  112068. /**
  112069. * Apply current geometry to a given mesh
  112070. * @param mesh defines the mesh to apply geometry to
  112071. */
  112072. applyToMesh(mesh: Mesh): void;
  112073. private _updateExtend;
  112074. private _applyToMesh;
  112075. private notifyUpdate;
  112076. /**
  112077. * Load the geometry if it was flagged as delay loaded
  112078. * @param scene defines the hosting scene
  112079. * @param onLoaded defines a callback called when the geometry is loaded
  112080. */
  112081. load(scene: Scene, onLoaded?: () => void): void;
  112082. private _queueLoad;
  112083. /**
  112084. * Invert the geometry to move from a right handed system to a left handed one.
  112085. */
  112086. toLeftHanded(): void;
  112087. /** @hidden */
  112088. _resetPointsArrayCache(): void;
  112089. /** @hidden */
  112090. _generatePointsArray(): boolean;
  112091. /**
  112092. * Gets a value indicating if the geometry is disposed
  112093. * @returns true if the geometry was disposed
  112094. */
  112095. isDisposed(): boolean;
  112096. private _disposeVertexArrayObjects;
  112097. /**
  112098. * Free all associated resources
  112099. */
  112100. dispose(): void;
  112101. /**
  112102. * Clone the current geometry into a new geometry
  112103. * @param id defines the unique ID of the new geometry
  112104. * @returns a new geometry object
  112105. */
  112106. copy(id: string): Geometry;
  112107. /**
  112108. * Serialize the current geometry info (and not the vertices data) into a JSON object
  112109. * @return a JSON representation of the current geometry data (without the vertices data)
  112110. */
  112111. serialize(): any;
  112112. private toNumberArray;
  112113. /**
  112114. * Serialize all vertices data into a JSON oject
  112115. * @returns a JSON representation of the current geometry data
  112116. */
  112117. serializeVerticeData(): any;
  112118. /**
  112119. * Extracts a clone of a mesh geometry
  112120. * @param mesh defines the source mesh
  112121. * @param id defines the unique ID of the new geometry object
  112122. * @returns the new geometry object
  112123. */
  112124. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  112125. /**
  112126. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  112127. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  112128. * Be aware Math.random() could cause collisions, but:
  112129. * "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"
  112130. * @returns a string containing a new GUID
  112131. */
  112132. static RandomId(): string;
  112133. /** @hidden */
  112134. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  112135. private static _CleanMatricesWeights;
  112136. /**
  112137. * Create a new geometry from persisted data (Using .babylon file format)
  112138. * @param parsedVertexData defines the persisted data
  112139. * @param scene defines the hosting scene
  112140. * @param rootUrl defines the root url to use to load assets (like delayed data)
  112141. * @returns the new geometry object
  112142. */
  112143. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  112144. }
  112145. }
  112146. declare module BABYLON {
  112147. /**
  112148. * Defines a target to use with MorphTargetManager
  112149. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112150. */
  112151. export class MorphTarget implements IAnimatable {
  112152. /** defines the name of the target */
  112153. name: string;
  112154. /**
  112155. * Gets or sets the list of animations
  112156. */
  112157. animations: Animation[];
  112158. private _scene;
  112159. private _positions;
  112160. private _normals;
  112161. private _tangents;
  112162. private _uvs;
  112163. private _influence;
  112164. private _uniqueId;
  112165. /**
  112166. * Observable raised when the influence changes
  112167. */
  112168. onInfluenceChanged: Observable<boolean>;
  112169. /** @hidden */
  112170. _onDataLayoutChanged: Observable<void>;
  112171. /**
  112172. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  112173. */
  112174. get influence(): number;
  112175. set influence(influence: number);
  112176. /**
  112177. * Gets or sets the id of the morph Target
  112178. */
  112179. id: string;
  112180. private _animationPropertiesOverride;
  112181. /**
  112182. * Gets or sets the animation properties override
  112183. */
  112184. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112185. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112186. /**
  112187. * Creates a new MorphTarget
  112188. * @param name defines the name of the target
  112189. * @param influence defines the influence to use
  112190. * @param scene defines the scene the morphtarget belongs to
  112191. */
  112192. constructor(
  112193. /** defines the name of the target */
  112194. name: string, influence?: number, scene?: Nullable<Scene>);
  112195. /**
  112196. * Gets the unique ID of this manager
  112197. */
  112198. get uniqueId(): number;
  112199. /**
  112200. * Gets a boolean defining if the target contains position data
  112201. */
  112202. get hasPositions(): boolean;
  112203. /**
  112204. * Gets a boolean defining if the target contains normal data
  112205. */
  112206. get hasNormals(): boolean;
  112207. /**
  112208. * Gets a boolean defining if the target contains tangent data
  112209. */
  112210. get hasTangents(): boolean;
  112211. /**
  112212. * Gets a boolean defining if the target contains texture coordinates data
  112213. */
  112214. get hasUVs(): boolean;
  112215. /**
  112216. * Affects position data to this target
  112217. * @param data defines the position data to use
  112218. */
  112219. setPositions(data: Nullable<FloatArray>): void;
  112220. /**
  112221. * Gets the position data stored in this target
  112222. * @returns a FloatArray containing the position data (or null if not present)
  112223. */
  112224. getPositions(): Nullable<FloatArray>;
  112225. /**
  112226. * Affects normal data to this target
  112227. * @param data defines the normal data to use
  112228. */
  112229. setNormals(data: Nullable<FloatArray>): void;
  112230. /**
  112231. * Gets the normal data stored in this target
  112232. * @returns a FloatArray containing the normal data (or null if not present)
  112233. */
  112234. getNormals(): Nullable<FloatArray>;
  112235. /**
  112236. * Affects tangent data to this target
  112237. * @param data defines the tangent data to use
  112238. */
  112239. setTangents(data: Nullable<FloatArray>): void;
  112240. /**
  112241. * Gets the tangent data stored in this target
  112242. * @returns a FloatArray containing the tangent data (or null if not present)
  112243. */
  112244. getTangents(): Nullable<FloatArray>;
  112245. /**
  112246. * Affects texture coordinates data to this target
  112247. * @param data defines the texture coordinates data to use
  112248. */
  112249. setUVs(data: Nullable<FloatArray>): void;
  112250. /**
  112251. * Gets the texture coordinates data stored in this target
  112252. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  112253. */
  112254. getUVs(): Nullable<FloatArray>;
  112255. /**
  112256. * Clone the current target
  112257. * @returns a new MorphTarget
  112258. */
  112259. clone(): MorphTarget;
  112260. /**
  112261. * Serializes the current target into a Serialization object
  112262. * @returns the serialized object
  112263. */
  112264. serialize(): any;
  112265. /**
  112266. * Returns the string "MorphTarget"
  112267. * @returns "MorphTarget"
  112268. */
  112269. getClassName(): string;
  112270. /**
  112271. * Creates a new target from serialized data
  112272. * @param serializationObject defines the serialized data to use
  112273. * @returns a new MorphTarget
  112274. */
  112275. static Parse(serializationObject: any): MorphTarget;
  112276. /**
  112277. * Creates a MorphTarget from mesh data
  112278. * @param mesh defines the source mesh
  112279. * @param name defines the name to use for the new target
  112280. * @param influence defines the influence to attach to the target
  112281. * @returns a new MorphTarget
  112282. */
  112283. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  112284. }
  112285. }
  112286. declare module BABYLON {
  112287. /**
  112288. * This class is used to deform meshes using morphing between different targets
  112289. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112290. */
  112291. export class MorphTargetManager {
  112292. private _targets;
  112293. private _targetInfluenceChangedObservers;
  112294. private _targetDataLayoutChangedObservers;
  112295. private _activeTargets;
  112296. private _scene;
  112297. private _influences;
  112298. private _supportsNormals;
  112299. private _supportsTangents;
  112300. private _supportsUVs;
  112301. private _vertexCount;
  112302. private _uniqueId;
  112303. private _tempInfluences;
  112304. /**
  112305. * Gets or sets a boolean indicating if normals must be morphed
  112306. */
  112307. enableNormalMorphing: boolean;
  112308. /**
  112309. * Gets or sets a boolean indicating if tangents must be morphed
  112310. */
  112311. enableTangentMorphing: boolean;
  112312. /**
  112313. * Gets or sets a boolean indicating if UV must be morphed
  112314. */
  112315. enableUVMorphing: boolean;
  112316. /**
  112317. * Creates a new MorphTargetManager
  112318. * @param scene defines the current scene
  112319. */
  112320. constructor(scene?: Nullable<Scene>);
  112321. /**
  112322. * Gets the unique ID of this manager
  112323. */
  112324. get uniqueId(): number;
  112325. /**
  112326. * Gets the number of vertices handled by this manager
  112327. */
  112328. get vertexCount(): number;
  112329. /**
  112330. * Gets a boolean indicating if this manager supports morphing of normals
  112331. */
  112332. get supportsNormals(): boolean;
  112333. /**
  112334. * Gets a boolean indicating if this manager supports morphing of tangents
  112335. */
  112336. get supportsTangents(): boolean;
  112337. /**
  112338. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  112339. */
  112340. get supportsUVs(): boolean;
  112341. /**
  112342. * Gets the number of targets stored in this manager
  112343. */
  112344. get numTargets(): number;
  112345. /**
  112346. * Gets the number of influencers (ie. the number of targets with influences > 0)
  112347. */
  112348. get numInfluencers(): number;
  112349. /**
  112350. * Gets the list of influences (one per target)
  112351. */
  112352. get influences(): Float32Array;
  112353. /**
  112354. * Gets the active target at specified index. An active target is a target with an influence > 0
  112355. * @param index defines the index to check
  112356. * @returns the requested target
  112357. */
  112358. getActiveTarget(index: number): MorphTarget;
  112359. /**
  112360. * Gets the target at specified index
  112361. * @param index defines the index to check
  112362. * @returns the requested target
  112363. */
  112364. getTarget(index: number): MorphTarget;
  112365. /**
  112366. * Add a new target to this manager
  112367. * @param target defines the target to add
  112368. */
  112369. addTarget(target: MorphTarget): void;
  112370. /**
  112371. * Removes a target from the manager
  112372. * @param target defines the target to remove
  112373. */
  112374. removeTarget(target: MorphTarget): void;
  112375. /**
  112376. * Clone the current manager
  112377. * @returns a new MorphTargetManager
  112378. */
  112379. clone(): MorphTargetManager;
  112380. /**
  112381. * Serializes the current manager into a Serialization object
  112382. * @returns the serialized object
  112383. */
  112384. serialize(): any;
  112385. private _syncActiveTargets;
  112386. /**
  112387. * Syncrhonize the targets with all the meshes using this morph target manager
  112388. */
  112389. synchronize(): void;
  112390. /**
  112391. * Creates a new MorphTargetManager from serialized data
  112392. * @param serializationObject defines the serialized data
  112393. * @param scene defines the hosting scene
  112394. * @returns the new MorphTargetManager
  112395. */
  112396. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  112397. }
  112398. }
  112399. declare module BABYLON {
  112400. /**
  112401. * Class used to represent a specific level of detail of a mesh
  112402. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  112403. */
  112404. export class MeshLODLevel {
  112405. /** Defines the distance where this level should start being displayed */
  112406. distance: number;
  112407. /** Defines the mesh to use to render this level */
  112408. mesh: Nullable<Mesh>;
  112409. /**
  112410. * Creates a new LOD level
  112411. * @param distance defines the distance where this level should star being displayed
  112412. * @param mesh defines the mesh to use to render this level
  112413. */
  112414. constructor(
  112415. /** Defines the distance where this level should start being displayed */
  112416. distance: number,
  112417. /** Defines the mesh to use to render this level */
  112418. mesh: Nullable<Mesh>);
  112419. }
  112420. }
  112421. declare module BABYLON {
  112422. /**
  112423. * Helper class used to generate a canvas to manipulate images
  112424. */
  112425. export class CanvasGenerator {
  112426. /**
  112427. * Create a new canvas (or offscreen canvas depending on the context)
  112428. * @param width defines the expected width
  112429. * @param height defines the expected height
  112430. * @return a new canvas or offscreen canvas
  112431. */
  112432. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  112433. }
  112434. }
  112435. declare module BABYLON {
  112436. /**
  112437. * Mesh representing the gorund
  112438. */
  112439. export class GroundMesh extends Mesh {
  112440. /** If octree should be generated */
  112441. generateOctree: boolean;
  112442. private _heightQuads;
  112443. /** @hidden */
  112444. _subdivisionsX: number;
  112445. /** @hidden */
  112446. _subdivisionsY: number;
  112447. /** @hidden */
  112448. _width: number;
  112449. /** @hidden */
  112450. _height: number;
  112451. /** @hidden */
  112452. _minX: number;
  112453. /** @hidden */
  112454. _maxX: number;
  112455. /** @hidden */
  112456. _minZ: number;
  112457. /** @hidden */
  112458. _maxZ: number;
  112459. constructor(name: string, scene: Scene);
  112460. /**
  112461. * "GroundMesh"
  112462. * @returns "GroundMesh"
  112463. */
  112464. getClassName(): string;
  112465. /**
  112466. * The minimum of x and y subdivisions
  112467. */
  112468. get subdivisions(): number;
  112469. /**
  112470. * X subdivisions
  112471. */
  112472. get subdivisionsX(): number;
  112473. /**
  112474. * Y subdivisions
  112475. */
  112476. get subdivisionsY(): number;
  112477. /**
  112478. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  112479. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112480. * @param chunksCount the number of subdivisions for x and y
  112481. * @param octreeBlocksSize (Default: 32)
  112482. */
  112483. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  112484. /**
  112485. * Returns a height (y) value in the Worl system :
  112486. * the ground altitude at the coordinates (x, z) expressed in the World system.
  112487. * @param x x coordinate
  112488. * @param z z coordinate
  112489. * @returns the ground y position if (x, z) are outside the ground surface.
  112490. */
  112491. getHeightAtCoordinates(x: number, z: number): number;
  112492. /**
  112493. * Returns a normalized vector (Vector3) orthogonal to the ground
  112494. * at the ground coordinates (x, z) expressed in the World system.
  112495. * @param x x coordinate
  112496. * @param z z coordinate
  112497. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  112498. */
  112499. getNormalAtCoordinates(x: number, z: number): Vector3;
  112500. /**
  112501. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  112502. * at the ground coordinates (x, z) expressed in the World system.
  112503. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  112504. * @param x x coordinate
  112505. * @param z z coordinate
  112506. * @param ref vector to store the result
  112507. * @returns the GroundMesh.
  112508. */
  112509. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  112510. /**
  112511. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  112512. * if the ground has been updated.
  112513. * This can be used in the render loop.
  112514. * @returns the GroundMesh.
  112515. */
  112516. updateCoordinateHeights(): GroundMesh;
  112517. private _getFacetAt;
  112518. private _initHeightQuads;
  112519. private _computeHeightQuads;
  112520. /**
  112521. * Serializes this ground mesh
  112522. * @param serializationObject object to write serialization to
  112523. */
  112524. serialize(serializationObject: any): void;
  112525. /**
  112526. * Parses a serialized ground mesh
  112527. * @param parsedMesh the serialized mesh
  112528. * @param scene the scene to create the ground mesh in
  112529. * @returns the created ground mesh
  112530. */
  112531. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  112532. }
  112533. }
  112534. declare module BABYLON {
  112535. /**
  112536. * Interface for Physics-Joint data
  112537. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112538. */
  112539. export interface PhysicsJointData {
  112540. /**
  112541. * The main pivot of the joint
  112542. */
  112543. mainPivot?: Vector3;
  112544. /**
  112545. * The connected pivot of the joint
  112546. */
  112547. connectedPivot?: Vector3;
  112548. /**
  112549. * The main axis of the joint
  112550. */
  112551. mainAxis?: Vector3;
  112552. /**
  112553. * The connected axis of the joint
  112554. */
  112555. connectedAxis?: Vector3;
  112556. /**
  112557. * The collision of the joint
  112558. */
  112559. collision?: boolean;
  112560. /**
  112561. * Native Oimo/Cannon/Energy data
  112562. */
  112563. nativeParams?: any;
  112564. }
  112565. /**
  112566. * This is a holder class for the physics joint created by the physics plugin
  112567. * It holds a set of functions to control the underlying joint
  112568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112569. */
  112570. export class PhysicsJoint {
  112571. /**
  112572. * The type of the physics joint
  112573. */
  112574. type: number;
  112575. /**
  112576. * The data for the physics joint
  112577. */
  112578. jointData: PhysicsJointData;
  112579. private _physicsJoint;
  112580. protected _physicsPlugin: IPhysicsEnginePlugin;
  112581. /**
  112582. * Initializes the physics joint
  112583. * @param type The type of the physics joint
  112584. * @param jointData The data for the physics joint
  112585. */
  112586. constructor(
  112587. /**
  112588. * The type of the physics joint
  112589. */
  112590. type: number,
  112591. /**
  112592. * The data for the physics joint
  112593. */
  112594. jointData: PhysicsJointData);
  112595. /**
  112596. * Gets the physics joint
  112597. */
  112598. get physicsJoint(): any;
  112599. /**
  112600. * Sets the physics joint
  112601. */
  112602. set physicsJoint(newJoint: any);
  112603. /**
  112604. * Sets the physics plugin
  112605. */
  112606. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  112607. /**
  112608. * Execute a function that is physics-plugin specific.
  112609. * @param {Function} func the function that will be executed.
  112610. * It accepts two parameters: the physics world and the physics joint
  112611. */
  112612. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112613. /**
  112614. * Distance-Joint type
  112615. */
  112616. static DistanceJoint: number;
  112617. /**
  112618. * Hinge-Joint type
  112619. */
  112620. static HingeJoint: number;
  112621. /**
  112622. * Ball-and-Socket joint type
  112623. */
  112624. static BallAndSocketJoint: number;
  112625. /**
  112626. * Wheel-Joint type
  112627. */
  112628. static WheelJoint: number;
  112629. /**
  112630. * Slider-Joint type
  112631. */
  112632. static SliderJoint: number;
  112633. /**
  112634. * Prismatic-Joint type
  112635. */
  112636. static PrismaticJoint: number;
  112637. /**
  112638. * Universal-Joint type
  112639. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112640. */
  112641. static UniversalJoint: number;
  112642. /**
  112643. * Hinge-Joint 2 type
  112644. */
  112645. static Hinge2Joint: number;
  112646. /**
  112647. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112648. */
  112649. static PointToPointJoint: number;
  112650. /**
  112651. * Spring-Joint type
  112652. */
  112653. static SpringJoint: number;
  112654. /**
  112655. * Lock-Joint type
  112656. */
  112657. static LockJoint: number;
  112658. }
  112659. /**
  112660. * A class representing a physics distance joint
  112661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112662. */
  112663. export class DistanceJoint extends PhysicsJoint {
  112664. /**
  112665. *
  112666. * @param jointData The data for the Distance-Joint
  112667. */
  112668. constructor(jointData: DistanceJointData);
  112669. /**
  112670. * Update the predefined distance.
  112671. * @param maxDistance The maximum preferred distance
  112672. * @param minDistance The minimum preferred distance
  112673. */
  112674. updateDistance(maxDistance: number, minDistance?: number): void;
  112675. }
  112676. /**
  112677. * Represents a Motor-Enabled Joint
  112678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112679. */
  112680. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112681. /**
  112682. * Initializes the Motor-Enabled Joint
  112683. * @param type The type of the joint
  112684. * @param jointData The physica joint data for the joint
  112685. */
  112686. constructor(type: number, jointData: PhysicsJointData);
  112687. /**
  112688. * Set the motor values.
  112689. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112690. * @param force the force to apply
  112691. * @param maxForce max force for this motor.
  112692. */
  112693. setMotor(force?: number, maxForce?: number): void;
  112694. /**
  112695. * Set the motor's limits.
  112696. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112697. * @param upperLimit The upper limit of the motor
  112698. * @param lowerLimit The lower limit of the motor
  112699. */
  112700. setLimit(upperLimit: number, lowerLimit?: number): void;
  112701. }
  112702. /**
  112703. * This class represents a single physics Hinge-Joint
  112704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112705. */
  112706. export class HingeJoint extends MotorEnabledJoint {
  112707. /**
  112708. * Initializes the Hinge-Joint
  112709. * @param jointData The joint data for the Hinge-Joint
  112710. */
  112711. constructor(jointData: PhysicsJointData);
  112712. /**
  112713. * Set the motor values.
  112714. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112715. * @param {number} force the force to apply
  112716. * @param {number} maxForce max force for this motor.
  112717. */
  112718. setMotor(force?: number, maxForce?: number): void;
  112719. /**
  112720. * Set the motor's limits.
  112721. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112722. * @param upperLimit The upper limit of the motor
  112723. * @param lowerLimit The lower limit of the motor
  112724. */
  112725. setLimit(upperLimit: number, lowerLimit?: number): void;
  112726. }
  112727. /**
  112728. * This class represents a dual hinge physics joint (same as wheel joint)
  112729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112730. */
  112731. export class Hinge2Joint extends MotorEnabledJoint {
  112732. /**
  112733. * Initializes the Hinge2-Joint
  112734. * @param jointData The joint data for the Hinge2-Joint
  112735. */
  112736. constructor(jointData: PhysicsJointData);
  112737. /**
  112738. * Set the motor values.
  112739. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112740. * @param {number} targetSpeed the speed the motor is to reach
  112741. * @param {number} maxForce max force for this motor.
  112742. * @param {motorIndex} the motor's index, 0 or 1.
  112743. */
  112744. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112745. /**
  112746. * Set the motor limits.
  112747. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112748. * @param {number} upperLimit the upper limit
  112749. * @param {number} lowerLimit lower limit
  112750. * @param {motorIndex} the motor's index, 0 or 1.
  112751. */
  112752. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112753. }
  112754. /**
  112755. * Interface for a motor enabled joint
  112756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112757. */
  112758. export interface IMotorEnabledJoint {
  112759. /**
  112760. * Physics joint
  112761. */
  112762. physicsJoint: any;
  112763. /**
  112764. * Sets the motor of the motor-enabled joint
  112765. * @param force The force of the motor
  112766. * @param maxForce The maximum force of the motor
  112767. * @param motorIndex The index of the motor
  112768. */
  112769. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112770. /**
  112771. * Sets the limit of the motor
  112772. * @param upperLimit The upper limit of the motor
  112773. * @param lowerLimit The lower limit of the motor
  112774. * @param motorIndex The index of the motor
  112775. */
  112776. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112777. }
  112778. /**
  112779. * Joint data for a Distance-Joint
  112780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112781. */
  112782. export interface DistanceJointData extends PhysicsJointData {
  112783. /**
  112784. * Max distance the 2 joint objects can be apart
  112785. */
  112786. maxDistance: number;
  112787. }
  112788. /**
  112789. * Joint data from a spring joint
  112790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112791. */
  112792. export interface SpringJointData extends PhysicsJointData {
  112793. /**
  112794. * Length of the spring
  112795. */
  112796. length: number;
  112797. /**
  112798. * Stiffness of the spring
  112799. */
  112800. stiffness: number;
  112801. /**
  112802. * Damping of the spring
  112803. */
  112804. damping: number;
  112805. /** this callback will be called when applying the force to the impostors. */
  112806. forceApplicationCallback: () => void;
  112807. }
  112808. }
  112809. declare module BABYLON {
  112810. /**
  112811. * Holds the data for the raycast result
  112812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112813. */
  112814. export class PhysicsRaycastResult {
  112815. private _hasHit;
  112816. private _hitDistance;
  112817. private _hitNormalWorld;
  112818. private _hitPointWorld;
  112819. private _rayFromWorld;
  112820. private _rayToWorld;
  112821. /**
  112822. * Gets if there was a hit
  112823. */
  112824. get hasHit(): boolean;
  112825. /**
  112826. * Gets the distance from the hit
  112827. */
  112828. get hitDistance(): number;
  112829. /**
  112830. * Gets the hit normal/direction in the world
  112831. */
  112832. get hitNormalWorld(): Vector3;
  112833. /**
  112834. * Gets the hit point in the world
  112835. */
  112836. get hitPointWorld(): Vector3;
  112837. /**
  112838. * Gets the ray "start point" of the ray in the world
  112839. */
  112840. get rayFromWorld(): Vector3;
  112841. /**
  112842. * Gets the ray "end point" of the ray in the world
  112843. */
  112844. get rayToWorld(): Vector3;
  112845. /**
  112846. * Sets the hit data (normal & point in world space)
  112847. * @param hitNormalWorld defines the normal in world space
  112848. * @param hitPointWorld defines the point in world space
  112849. */
  112850. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112851. /**
  112852. * Sets the distance from the start point to the hit point
  112853. * @param distance
  112854. */
  112855. setHitDistance(distance: number): void;
  112856. /**
  112857. * Calculates the distance manually
  112858. */
  112859. calculateHitDistance(): void;
  112860. /**
  112861. * Resets all the values to default
  112862. * @param from The from point on world space
  112863. * @param to The to point on world space
  112864. */
  112865. reset(from?: Vector3, to?: Vector3): void;
  112866. }
  112867. /**
  112868. * Interface for the size containing width and height
  112869. */
  112870. interface IXYZ {
  112871. /**
  112872. * X
  112873. */
  112874. x: number;
  112875. /**
  112876. * Y
  112877. */
  112878. y: number;
  112879. /**
  112880. * Z
  112881. */
  112882. z: number;
  112883. }
  112884. }
  112885. declare module BABYLON {
  112886. /**
  112887. * Interface used to describe a physics joint
  112888. */
  112889. export interface PhysicsImpostorJoint {
  112890. /** Defines the main impostor to which the joint is linked */
  112891. mainImpostor: PhysicsImpostor;
  112892. /** Defines the impostor that is connected to the main impostor using this joint */
  112893. connectedImpostor: PhysicsImpostor;
  112894. /** Defines the joint itself */
  112895. joint: PhysicsJoint;
  112896. }
  112897. /** @hidden */
  112898. export interface IPhysicsEnginePlugin {
  112899. world: any;
  112900. name: string;
  112901. setGravity(gravity: Vector3): void;
  112902. setTimeStep(timeStep: number): void;
  112903. getTimeStep(): number;
  112904. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112905. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112906. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112907. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112908. removePhysicsBody(impostor: PhysicsImpostor): void;
  112909. generateJoint(joint: PhysicsImpostorJoint): void;
  112910. removeJoint(joint: PhysicsImpostorJoint): void;
  112911. isSupported(): boolean;
  112912. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112913. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112914. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112915. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  112916. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112917. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112918. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112919. getBodyMass(impostor: PhysicsImpostor): number;
  112920. getBodyFriction(impostor: PhysicsImpostor): number;
  112921. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112922. getBodyRestitution(impostor: PhysicsImpostor): number;
  112923. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112924. getBodyPressure?(impostor: PhysicsImpostor): number;
  112925. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  112926. getBodyStiffness?(impostor: PhysicsImpostor): number;
  112927. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  112928. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  112929. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  112930. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  112931. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  112932. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112933. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  112934. sleepBody(impostor: PhysicsImpostor): void;
  112935. wakeUpBody(impostor: PhysicsImpostor): void;
  112936. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112937. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112938. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  112939. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112940. getRadius(impostor: PhysicsImpostor): number;
  112941. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112942. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112943. dispose(): void;
  112944. }
  112945. /**
  112946. * Interface used to define a physics engine
  112947. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112948. */
  112949. export interface IPhysicsEngine {
  112950. /**
  112951. * Gets the gravity vector used by the simulation
  112952. */
  112953. gravity: Vector3;
  112954. /**
  112955. * Sets the gravity vector used by the simulation
  112956. * @param gravity defines the gravity vector to use
  112957. */
  112958. setGravity(gravity: Vector3): void;
  112959. /**
  112960. * Set the time step of the physics engine.
  112961. * Default is 1/60.
  112962. * To slow it down, enter 1/600 for example.
  112963. * To speed it up, 1/30
  112964. * @param newTimeStep the new timestep to apply to this world.
  112965. */
  112966. setTimeStep(newTimeStep: number): void;
  112967. /**
  112968. * Get the time step of the physics engine.
  112969. * @returns the current time step
  112970. */
  112971. getTimeStep(): number;
  112972. /**
  112973. * Set the sub time step of the physics engine.
  112974. * Default is 0 meaning there is no sub steps
  112975. * To increase physics resolution precision, set a small value (like 1 ms)
  112976. * @param subTimeStep defines the new sub timestep used for physics resolution.
  112977. */
  112978. setSubTimeStep(subTimeStep: number): void;
  112979. /**
  112980. * Get the sub time step of the physics engine.
  112981. * @returns the current sub time step
  112982. */
  112983. getSubTimeStep(): number;
  112984. /**
  112985. * Release all resources
  112986. */
  112987. dispose(): void;
  112988. /**
  112989. * Gets the name of the current physics plugin
  112990. * @returns the name of the plugin
  112991. */
  112992. getPhysicsPluginName(): string;
  112993. /**
  112994. * Adding a new impostor for the impostor tracking.
  112995. * This will be done by the impostor itself.
  112996. * @param impostor the impostor to add
  112997. */
  112998. addImpostor(impostor: PhysicsImpostor): void;
  112999. /**
  113000. * Remove an impostor from the engine.
  113001. * This impostor and its mesh will not longer be updated by the physics engine.
  113002. * @param impostor the impostor to remove
  113003. */
  113004. removeImpostor(impostor: PhysicsImpostor): void;
  113005. /**
  113006. * Add a joint to the physics engine
  113007. * @param mainImpostor defines the main impostor to which the joint is added.
  113008. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  113009. * @param joint defines the joint that will connect both impostors.
  113010. */
  113011. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113012. /**
  113013. * Removes a joint from the simulation
  113014. * @param mainImpostor defines the impostor used with the joint
  113015. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  113016. * @param joint defines the joint to remove
  113017. */
  113018. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113019. /**
  113020. * Gets the current plugin used to run the simulation
  113021. * @returns current plugin
  113022. */
  113023. getPhysicsPlugin(): IPhysicsEnginePlugin;
  113024. /**
  113025. * Gets the list of physic impostors
  113026. * @returns an array of PhysicsImpostor
  113027. */
  113028. getImpostors(): Array<PhysicsImpostor>;
  113029. /**
  113030. * Gets the impostor for a physics enabled object
  113031. * @param object defines the object impersonated by the impostor
  113032. * @returns the PhysicsImpostor or null if not found
  113033. */
  113034. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113035. /**
  113036. * Gets the impostor for a physics body object
  113037. * @param body defines physics body used by the impostor
  113038. * @returns the PhysicsImpostor or null if not found
  113039. */
  113040. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  113041. /**
  113042. * Does a raycast in the physics world
  113043. * @param from when should the ray start?
  113044. * @param to when should the ray end?
  113045. * @returns PhysicsRaycastResult
  113046. */
  113047. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113048. /**
  113049. * Called by the scene. No need to call it.
  113050. * @param delta defines the timespam between frames
  113051. */
  113052. _step(delta: number): void;
  113053. }
  113054. }
  113055. declare module BABYLON {
  113056. /**
  113057. * The interface for the physics imposter parameters
  113058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113059. */
  113060. export interface PhysicsImpostorParameters {
  113061. /**
  113062. * The mass of the physics imposter
  113063. */
  113064. mass: number;
  113065. /**
  113066. * The friction of the physics imposter
  113067. */
  113068. friction?: number;
  113069. /**
  113070. * The coefficient of restitution of the physics imposter
  113071. */
  113072. restitution?: number;
  113073. /**
  113074. * The native options of the physics imposter
  113075. */
  113076. nativeOptions?: any;
  113077. /**
  113078. * Specifies if the parent should be ignored
  113079. */
  113080. ignoreParent?: boolean;
  113081. /**
  113082. * Specifies if bi-directional transformations should be disabled
  113083. */
  113084. disableBidirectionalTransformation?: boolean;
  113085. /**
  113086. * The pressure inside the physics imposter, soft object only
  113087. */
  113088. pressure?: number;
  113089. /**
  113090. * The stiffness the physics imposter, soft object only
  113091. */
  113092. stiffness?: number;
  113093. /**
  113094. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  113095. */
  113096. velocityIterations?: number;
  113097. /**
  113098. * The number of iterations used in maintaining consistent vertex positions, soft object only
  113099. */
  113100. positionIterations?: number;
  113101. /**
  113102. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  113103. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  113104. * Add to fix multiple points
  113105. */
  113106. fixedPoints?: number;
  113107. /**
  113108. * The collision margin around a soft object
  113109. */
  113110. margin?: number;
  113111. /**
  113112. * The collision margin around a soft object
  113113. */
  113114. damping?: number;
  113115. /**
  113116. * The path for a rope based on an extrusion
  113117. */
  113118. path?: any;
  113119. /**
  113120. * The shape of an extrusion used for a rope based on an extrusion
  113121. */
  113122. shape?: any;
  113123. }
  113124. /**
  113125. * Interface for a physics-enabled object
  113126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113127. */
  113128. export interface IPhysicsEnabledObject {
  113129. /**
  113130. * The position of the physics-enabled object
  113131. */
  113132. position: Vector3;
  113133. /**
  113134. * The rotation of the physics-enabled object
  113135. */
  113136. rotationQuaternion: Nullable<Quaternion>;
  113137. /**
  113138. * The scale of the physics-enabled object
  113139. */
  113140. scaling: Vector3;
  113141. /**
  113142. * The rotation of the physics-enabled object
  113143. */
  113144. rotation?: Vector3;
  113145. /**
  113146. * The parent of the physics-enabled object
  113147. */
  113148. parent?: any;
  113149. /**
  113150. * The bounding info of the physics-enabled object
  113151. * @returns The bounding info of the physics-enabled object
  113152. */
  113153. getBoundingInfo(): BoundingInfo;
  113154. /**
  113155. * Computes the world matrix
  113156. * @param force Specifies if the world matrix should be computed by force
  113157. * @returns A world matrix
  113158. */
  113159. computeWorldMatrix(force: boolean): Matrix;
  113160. /**
  113161. * Gets the world matrix
  113162. * @returns A world matrix
  113163. */
  113164. getWorldMatrix?(): Matrix;
  113165. /**
  113166. * Gets the child meshes
  113167. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  113168. * @returns An array of abstract meshes
  113169. */
  113170. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  113171. /**
  113172. * Gets the vertex data
  113173. * @param kind The type of vertex data
  113174. * @returns A nullable array of numbers, or a float32 array
  113175. */
  113176. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  113177. /**
  113178. * Gets the indices from the mesh
  113179. * @returns A nullable array of index arrays
  113180. */
  113181. getIndices?(): Nullable<IndicesArray>;
  113182. /**
  113183. * Gets the scene from the mesh
  113184. * @returns the indices array or null
  113185. */
  113186. getScene?(): Scene;
  113187. /**
  113188. * Gets the absolute position from the mesh
  113189. * @returns the absolute position
  113190. */
  113191. getAbsolutePosition(): Vector3;
  113192. /**
  113193. * Gets the absolute pivot point from the mesh
  113194. * @returns the absolute pivot point
  113195. */
  113196. getAbsolutePivotPoint(): Vector3;
  113197. /**
  113198. * Rotates the mesh
  113199. * @param axis The axis of rotation
  113200. * @param amount The amount of rotation
  113201. * @param space The space of the rotation
  113202. * @returns The rotation transform node
  113203. */
  113204. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  113205. /**
  113206. * Translates the mesh
  113207. * @param axis The axis of translation
  113208. * @param distance The distance of translation
  113209. * @param space The space of the translation
  113210. * @returns The transform node
  113211. */
  113212. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  113213. /**
  113214. * Sets the absolute position of the mesh
  113215. * @param absolutePosition The absolute position of the mesh
  113216. * @returns The transform node
  113217. */
  113218. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  113219. /**
  113220. * Gets the class name of the mesh
  113221. * @returns The class name
  113222. */
  113223. getClassName(): string;
  113224. }
  113225. /**
  113226. * Represents a physics imposter
  113227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113228. */
  113229. export class PhysicsImpostor {
  113230. /**
  113231. * The physics-enabled object used as the physics imposter
  113232. */
  113233. object: IPhysicsEnabledObject;
  113234. /**
  113235. * The type of the physics imposter
  113236. */
  113237. type: number;
  113238. private _options;
  113239. private _scene?;
  113240. /**
  113241. * The default object size of the imposter
  113242. */
  113243. static DEFAULT_OBJECT_SIZE: Vector3;
  113244. /**
  113245. * The identity quaternion of the imposter
  113246. */
  113247. static IDENTITY_QUATERNION: Quaternion;
  113248. /** @hidden */
  113249. _pluginData: any;
  113250. private _physicsEngine;
  113251. private _physicsBody;
  113252. private _bodyUpdateRequired;
  113253. private _onBeforePhysicsStepCallbacks;
  113254. private _onAfterPhysicsStepCallbacks;
  113255. /** @hidden */
  113256. _onPhysicsCollideCallbacks: Array<{
  113257. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  113258. otherImpostors: Array<PhysicsImpostor>;
  113259. }>;
  113260. private _deltaPosition;
  113261. private _deltaRotation;
  113262. private _deltaRotationConjugated;
  113263. /** @hidden */
  113264. _isFromLine: boolean;
  113265. private _parent;
  113266. private _isDisposed;
  113267. private static _tmpVecs;
  113268. private static _tmpQuat;
  113269. /**
  113270. * Specifies if the physics imposter is disposed
  113271. */
  113272. get isDisposed(): boolean;
  113273. /**
  113274. * Gets the mass of the physics imposter
  113275. */
  113276. get mass(): number;
  113277. set mass(value: number);
  113278. /**
  113279. * Gets the coefficient of friction
  113280. */
  113281. get friction(): number;
  113282. /**
  113283. * Sets the coefficient of friction
  113284. */
  113285. set friction(value: number);
  113286. /**
  113287. * Gets the coefficient of restitution
  113288. */
  113289. get restitution(): number;
  113290. /**
  113291. * Sets the coefficient of restitution
  113292. */
  113293. set restitution(value: number);
  113294. /**
  113295. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  113296. */
  113297. get pressure(): number;
  113298. /**
  113299. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  113300. */
  113301. set pressure(value: number);
  113302. /**
  113303. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113304. */
  113305. get stiffness(): number;
  113306. /**
  113307. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113308. */
  113309. set stiffness(value: number);
  113310. /**
  113311. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113312. */
  113313. get velocityIterations(): number;
  113314. /**
  113315. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113316. */
  113317. set velocityIterations(value: number);
  113318. /**
  113319. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113320. */
  113321. get positionIterations(): number;
  113322. /**
  113323. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113324. */
  113325. set positionIterations(value: number);
  113326. /**
  113327. * The unique id of the physics imposter
  113328. * set by the physics engine when adding this impostor to the array
  113329. */
  113330. uniqueId: number;
  113331. /**
  113332. * @hidden
  113333. */
  113334. soft: boolean;
  113335. /**
  113336. * @hidden
  113337. */
  113338. segments: number;
  113339. private _joints;
  113340. /**
  113341. * Initializes the physics imposter
  113342. * @param object The physics-enabled object used as the physics imposter
  113343. * @param type The type of the physics imposter
  113344. * @param _options The options for the physics imposter
  113345. * @param _scene The Babylon scene
  113346. */
  113347. constructor(
  113348. /**
  113349. * The physics-enabled object used as the physics imposter
  113350. */
  113351. object: IPhysicsEnabledObject,
  113352. /**
  113353. * The type of the physics imposter
  113354. */
  113355. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  113356. /**
  113357. * This function will completly initialize this impostor.
  113358. * It will create a new body - but only if this mesh has no parent.
  113359. * If it has, this impostor will not be used other than to define the impostor
  113360. * of the child mesh.
  113361. * @hidden
  113362. */
  113363. _init(): void;
  113364. private _getPhysicsParent;
  113365. /**
  113366. * Should a new body be generated.
  113367. * @returns boolean specifying if body initialization is required
  113368. */
  113369. isBodyInitRequired(): boolean;
  113370. /**
  113371. * Sets the updated scaling
  113372. * @param updated Specifies if the scaling is updated
  113373. */
  113374. setScalingUpdated(): void;
  113375. /**
  113376. * Force a regeneration of this or the parent's impostor's body.
  113377. * Use under cautious - This will remove all joints already implemented.
  113378. */
  113379. forceUpdate(): void;
  113380. /**
  113381. * Gets the body that holds this impostor. Either its own, or its parent.
  113382. */
  113383. get physicsBody(): any;
  113384. /**
  113385. * Get the parent of the physics imposter
  113386. * @returns Physics imposter or null
  113387. */
  113388. get parent(): Nullable<PhysicsImpostor>;
  113389. /**
  113390. * Sets the parent of the physics imposter
  113391. */
  113392. set parent(value: Nullable<PhysicsImpostor>);
  113393. /**
  113394. * Set the physics body. Used mainly by the physics engine/plugin
  113395. */
  113396. set physicsBody(physicsBody: any);
  113397. /**
  113398. * Resets the update flags
  113399. */
  113400. resetUpdateFlags(): void;
  113401. /**
  113402. * Gets the object extend size
  113403. * @returns the object extend size
  113404. */
  113405. getObjectExtendSize(): Vector3;
  113406. /**
  113407. * Gets the object center
  113408. * @returns The object center
  113409. */
  113410. getObjectCenter(): Vector3;
  113411. /**
  113412. * Get a specific parameter from the options parameters
  113413. * @param paramName The object parameter name
  113414. * @returns The object parameter
  113415. */
  113416. getParam(paramName: string): any;
  113417. /**
  113418. * Sets a specific parameter in the options given to the physics plugin
  113419. * @param paramName The parameter name
  113420. * @param value The value of the parameter
  113421. */
  113422. setParam(paramName: string, value: number): void;
  113423. /**
  113424. * Specifically change the body's mass option. Won't recreate the physics body object
  113425. * @param mass The mass of the physics imposter
  113426. */
  113427. setMass(mass: number): void;
  113428. /**
  113429. * Gets the linear velocity
  113430. * @returns linear velocity or null
  113431. */
  113432. getLinearVelocity(): Nullable<Vector3>;
  113433. /**
  113434. * Sets the linear velocity
  113435. * @param velocity linear velocity or null
  113436. */
  113437. setLinearVelocity(velocity: Nullable<Vector3>): void;
  113438. /**
  113439. * Gets the angular velocity
  113440. * @returns angular velocity or null
  113441. */
  113442. getAngularVelocity(): Nullable<Vector3>;
  113443. /**
  113444. * Sets the angular velocity
  113445. * @param velocity The velocity or null
  113446. */
  113447. setAngularVelocity(velocity: Nullable<Vector3>): void;
  113448. /**
  113449. * Execute a function with the physics plugin native code
  113450. * Provide a function the will have two variables - the world object and the physics body object
  113451. * @param func The function to execute with the physics plugin native code
  113452. */
  113453. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  113454. /**
  113455. * Register a function that will be executed before the physics world is stepping forward
  113456. * @param func The function to execute before the physics world is stepped forward
  113457. */
  113458. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113459. /**
  113460. * Unregister a function that will be executed before the physics world is stepping forward
  113461. * @param func The function to execute before the physics world is stepped forward
  113462. */
  113463. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113464. /**
  113465. * Register a function that will be executed after the physics step
  113466. * @param func The function to execute after physics step
  113467. */
  113468. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113469. /**
  113470. * Unregisters a function that will be executed after the physics step
  113471. * @param func The function to execute after physics step
  113472. */
  113473. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113474. /**
  113475. * register a function that will be executed when this impostor collides against a different body
  113476. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  113477. * @param func Callback that is executed on collision
  113478. */
  113479. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  113480. /**
  113481. * Unregisters the physics imposter on contact
  113482. * @param collideAgainst The physics object to collide against
  113483. * @param func Callback to execute on collision
  113484. */
  113485. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  113486. private _tmpQuat;
  113487. private _tmpQuat2;
  113488. /**
  113489. * Get the parent rotation
  113490. * @returns The parent rotation
  113491. */
  113492. getParentsRotation(): Quaternion;
  113493. /**
  113494. * this function is executed by the physics engine.
  113495. */
  113496. beforeStep: () => void;
  113497. /**
  113498. * this function is executed by the physics engine
  113499. */
  113500. afterStep: () => void;
  113501. /**
  113502. * Legacy collision detection event support
  113503. */
  113504. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  113505. /**
  113506. * event and body object due to cannon's event-based architecture.
  113507. */
  113508. onCollide: (e: {
  113509. body: any;
  113510. point: Nullable<Vector3>;
  113511. }) => void;
  113512. /**
  113513. * Apply a force
  113514. * @param force The force to apply
  113515. * @param contactPoint The contact point for the force
  113516. * @returns The physics imposter
  113517. */
  113518. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113519. /**
  113520. * Apply an impulse
  113521. * @param force The impulse force
  113522. * @param contactPoint The contact point for the impulse force
  113523. * @returns The physics imposter
  113524. */
  113525. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113526. /**
  113527. * A help function to create a joint
  113528. * @param otherImpostor A physics imposter used to create a joint
  113529. * @param jointType The type of joint
  113530. * @param jointData The data for the joint
  113531. * @returns The physics imposter
  113532. */
  113533. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  113534. /**
  113535. * Add a joint to this impostor with a different impostor
  113536. * @param otherImpostor A physics imposter used to add a joint
  113537. * @param joint The joint to add
  113538. * @returns The physics imposter
  113539. */
  113540. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  113541. /**
  113542. * Add an anchor to a cloth impostor
  113543. * @param otherImpostor rigid impostor to anchor to
  113544. * @param width ratio across width from 0 to 1
  113545. * @param height ratio up height from 0 to 1
  113546. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113547. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  113548. * @returns impostor the soft imposter
  113549. */
  113550. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113551. /**
  113552. * Add a hook to a rope impostor
  113553. * @param otherImpostor rigid impostor to anchor to
  113554. * @param length ratio across rope from 0 to 1
  113555. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  113556. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113557. * @returns impostor the rope imposter
  113558. */
  113559. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113560. /**
  113561. * Will keep this body still, in a sleep mode.
  113562. * @returns the physics imposter
  113563. */
  113564. sleep(): PhysicsImpostor;
  113565. /**
  113566. * Wake the body up.
  113567. * @returns The physics imposter
  113568. */
  113569. wakeUp(): PhysicsImpostor;
  113570. /**
  113571. * Clones the physics imposter
  113572. * @param newObject The physics imposter clones to this physics-enabled object
  113573. * @returns A nullable physics imposter
  113574. */
  113575. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113576. /**
  113577. * Disposes the physics imposter
  113578. */
  113579. dispose(): void;
  113580. /**
  113581. * Sets the delta position
  113582. * @param position The delta position amount
  113583. */
  113584. setDeltaPosition(position: Vector3): void;
  113585. /**
  113586. * Sets the delta rotation
  113587. * @param rotation The delta rotation amount
  113588. */
  113589. setDeltaRotation(rotation: Quaternion): void;
  113590. /**
  113591. * Gets the box size of the physics imposter and stores the result in the input parameter
  113592. * @param result Stores the box size
  113593. * @returns The physics imposter
  113594. */
  113595. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  113596. /**
  113597. * Gets the radius of the physics imposter
  113598. * @returns Radius of the physics imposter
  113599. */
  113600. getRadius(): number;
  113601. /**
  113602. * Sync a bone with this impostor
  113603. * @param bone The bone to sync to the impostor.
  113604. * @param boneMesh The mesh that the bone is influencing.
  113605. * @param jointPivot The pivot of the joint / bone in local space.
  113606. * @param distToJoint Optional distance from the impostor to the joint.
  113607. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113608. */
  113609. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  113610. /**
  113611. * Sync impostor to a bone
  113612. * @param bone The bone that the impostor will be synced to.
  113613. * @param boneMesh The mesh that the bone is influencing.
  113614. * @param jointPivot The pivot of the joint / bone in local space.
  113615. * @param distToJoint Optional distance from the impostor to the joint.
  113616. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113617. * @param boneAxis Optional vector3 axis the bone is aligned with
  113618. */
  113619. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113620. /**
  113621. * No-Imposter type
  113622. */
  113623. static NoImpostor: number;
  113624. /**
  113625. * Sphere-Imposter type
  113626. */
  113627. static SphereImpostor: number;
  113628. /**
  113629. * Box-Imposter type
  113630. */
  113631. static BoxImpostor: number;
  113632. /**
  113633. * Plane-Imposter type
  113634. */
  113635. static PlaneImpostor: number;
  113636. /**
  113637. * Mesh-imposter type
  113638. */
  113639. static MeshImpostor: number;
  113640. /**
  113641. * Capsule-Impostor type (Ammo.js plugin only)
  113642. */
  113643. static CapsuleImpostor: number;
  113644. /**
  113645. * Cylinder-Imposter type
  113646. */
  113647. static CylinderImpostor: number;
  113648. /**
  113649. * Particle-Imposter type
  113650. */
  113651. static ParticleImpostor: number;
  113652. /**
  113653. * Heightmap-Imposter type
  113654. */
  113655. static HeightmapImpostor: number;
  113656. /**
  113657. * ConvexHull-Impostor type (Ammo.js plugin only)
  113658. */
  113659. static ConvexHullImpostor: number;
  113660. /**
  113661. * Custom-Imposter type (Ammo.js plugin only)
  113662. */
  113663. static CustomImpostor: number;
  113664. /**
  113665. * Rope-Imposter type
  113666. */
  113667. static RopeImpostor: number;
  113668. /**
  113669. * Cloth-Imposter type
  113670. */
  113671. static ClothImpostor: number;
  113672. /**
  113673. * Softbody-Imposter type
  113674. */
  113675. static SoftbodyImpostor: number;
  113676. }
  113677. }
  113678. declare module BABYLON {
  113679. /**
  113680. * @hidden
  113681. **/
  113682. export class _CreationDataStorage {
  113683. closePath?: boolean;
  113684. closeArray?: boolean;
  113685. idx: number[];
  113686. dashSize: number;
  113687. gapSize: number;
  113688. path3D: Path3D;
  113689. pathArray: Vector3[][];
  113690. arc: number;
  113691. radius: number;
  113692. cap: number;
  113693. tessellation: number;
  113694. }
  113695. /**
  113696. * @hidden
  113697. **/
  113698. class _InstanceDataStorage {
  113699. visibleInstances: any;
  113700. batchCache: _InstancesBatch;
  113701. instancesBufferSize: number;
  113702. instancesBuffer: Nullable<Buffer>;
  113703. instancesData: Float32Array;
  113704. overridenInstanceCount: number;
  113705. isFrozen: boolean;
  113706. previousBatch: Nullable<_InstancesBatch>;
  113707. hardwareInstancedRendering: boolean;
  113708. sideOrientation: number;
  113709. manualUpdate: boolean;
  113710. previousRenderId: number;
  113711. }
  113712. /**
  113713. * @hidden
  113714. **/
  113715. export class _InstancesBatch {
  113716. mustReturn: boolean;
  113717. visibleInstances: Nullable<InstancedMesh[]>[];
  113718. renderSelf: boolean[];
  113719. hardwareInstancedRendering: boolean[];
  113720. }
  113721. /**
  113722. * @hidden
  113723. **/
  113724. class _ThinInstanceDataStorage {
  113725. instancesCount: number;
  113726. matrixBuffer: Nullable<Buffer>;
  113727. matrixBufferSize: number;
  113728. matrixData: Nullable<Float32Array>;
  113729. boundingVectors: Array<Vector3>;
  113730. worldMatrices: Nullable<Matrix[]>;
  113731. }
  113732. /**
  113733. * Class used to represent renderable models
  113734. */
  113735. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113736. /**
  113737. * Mesh side orientation : usually the external or front surface
  113738. */
  113739. static readonly FRONTSIDE: number;
  113740. /**
  113741. * Mesh side orientation : usually the internal or back surface
  113742. */
  113743. static readonly BACKSIDE: number;
  113744. /**
  113745. * Mesh side orientation : both internal and external or front and back surfaces
  113746. */
  113747. static readonly DOUBLESIDE: number;
  113748. /**
  113749. * Mesh side orientation : by default, `FRONTSIDE`
  113750. */
  113751. static readonly DEFAULTSIDE: number;
  113752. /**
  113753. * Mesh cap setting : no cap
  113754. */
  113755. static readonly NO_CAP: number;
  113756. /**
  113757. * Mesh cap setting : one cap at the beginning of the mesh
  113758. */
  113759. static readonly CAP_START: number;
  113760. /**
  113761. * Mesh cap setting : one cap at the end of the mesh
  113762. */
  113763. static readonly CAP_END: number;
  113764. /**
  113765. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113766. */
  113767. static readonly CAP_ALL: number;
  113768. /**
  113769. * Mesh pattern setting : no flip or rotate
  113770. */
  113771. static readonly NO_FLIP: number;
  113772. /**
  113773. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113774. */
  113775. static readonly FLIP_TILE: number;
  113776. /**
  113777. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113778. */
  113779. static readonly ROTATE_TILE: number;
  113780. /**
  113781. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113782. */
  113783. static readonly FLIP_ROW: number;
  113784. /**
  113785. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113786. */
  113787. static readonly ROTATE_ROW: number;
  113788. /**
  113789. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113790. */
  113791. static readonly FLIP_N_ROTATE_TILE: number;
  113792. /**
  113793. * Mesh pattern setting : rotate pattern and rotate
  113794. */
  113795. static readonly FLIP_N_ROTATE_ROW: number;
  113796. /**
  113797. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113798. */
  113799. static readonly CENTER: number;
  113800. /**
  113801. * Mesh tile positioning : part tiles on left
  113802. */
  113803. static readonly LEFT: number;
  113804. /**
  113805. * Mesh tile positioning : part tiles on right
  113806. */
  113807. static readonly RIGHT: number;
  113808. /**
  113809. * Mesh tile positioning : part tiles on top
  113810. */
  113811. static readonly TOP: number;
  113812. /**
  113813. * Mesh tile positioning : part tiles on bottom
  113814. */
  113815. static readonly BOTTOM: number;
  113816. /**
  113817. * Gets the default side orientation.
  113818. * @param orientation the orientation to value to attempt to get
  113819. * @returns the default orientation
  113820. * @hidden
  113821. */
  113822. static _GetDefaultSideOrientation(orientation?: number): number;
  113823. private _internalMeshDataInfo;
  113824. get computeBonesUsingShaders(): boolean;
  113825. set computeBonesUsingShaders(value: boolean);
  113826. /**
  113827. * An event triggered before rendering the mesh
  113828. */
  113829. get onBeforeRenderObservable(): Observable<Mesh>;
  113830. /**
  113831. * An event triggered before binding the mesh
  113832. */
  113833. get onBeforeBindObservable(): Observable<Mesh>;
  113834. /**
  113835. * An event triggered after rendering the mesh
  113836. */
  113837. get onAfterRenderObservable(): Observable<Mesh>;
  113838. /**
  113839. * An event triggered before drawing the mesh
  113840. */
  113841. get onBeforeDrawObservable(): Observable<Mesh>;
  113842. private _onBeforeDrawObserver;
  113843. /**
  113844. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113845. */
  113846. set onBeforeDraw(callback: () => void);
  113847. get hasInstances(): boolean;
  113848. get hasThinInstances(): boolean;
  113849. /**
  113850. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113851. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113852. */
  113853. delayLoadState: number;
  113854. /**
  113855. * Gets the list of instances created from this mesh
  113856. * it is not supposed to be modified manually.
  113857. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113858. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113859. */
  113860. instances: InstancedMesh[];
  113861. /**
  113862. * Gets the file containing delay loading data for this mesh
  113863. */
  113864. delayLoadingFile: string;
  113865. /** @hidden */
  113866. _binaryInfo: any;
  113867. /**
  113868. * User defined function used to change how LOD level selection is done
  113869. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113870. */
  113871. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  113872. /**
  113873. * Gets or sets the morph target manager
  113874. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  113875. */
  113876. get morphTargetManager(): Nullable<MorphTargetManager>;
  113877. set morphTargetManager(value: Nullable<MorphTargetManager>);
  113878. /** @hidden */
  113879. _creationDataStorage: Nullable<_CreationDataStorage>;
  113880. /** @hidden */
  113881. _geometry: Nullable<Geometry>;
  113882. /** @hidden */
  113883. _delayInfo: Array<string>;
  113884. /** @hidden */
  113885. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  113886. /** @hidden */
  113887. _instanceDataStorage: _InstanceDataStorage;
  113888. /** @hidden */
  113889. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  113890. private _effectiveMaterial;
  113891. /** @hidden */
  113892. _shouldGenerateFlatShading: boolean;
  113893. /** @hidden */
  113894. _originalBuilderSideOrientation: number;
  113895. /**
  113896. * Use this property to change the original side orientation defined at construction time
  113897. */
  113898. overrideMaterialSideOrientation: Nullable<number>;
  113899. /**
  113900. * Gets the source mesh (the one used to clone this one from)
  113901. */
  113902. get source(): Nullable<Mesh>;
  113903. /**
  113904. * Gets the list of clones of this mesh
  113905. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  113906. * Note that useClonedMeshMap=true is the default setting
  113907. */
  113908. get cloneMeshMap(): Nullable<{
  113909. [id: string]: Mesh | undefined;
  113910. }>;
  113911. /**
  113912. * Gets or sets a boolean indicating that this mesh does not use index buffer
  113913. */
  113914. get isUnIndexed(): boolean;
  113915. set isUnIndexed(value: boolean);
  113916. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  113917. get worldMatrixInstancedBuffer(): Float32Array;
  113918. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  113919. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  113920. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  113921. /**
  113922. * @constructor
  113923. * @param name The value used by scene.getMeshByName() to do a lookup.
  113924. * @param scene The scene to add this mesh to.
  113925. * @param parent The parent of this mesh, if it has one
  113926. * @param source An optional Mesh from which geometry is shared, cloned.
  113927. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  113928. * When false, achieved by calling a clone(), also passing False.
  113929. * This will make creation of children, recursive.
  113930. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  113931. */
  113932. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  113933. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  113934. doNotInstantiate: boolean;
  113935. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  113936. /**
  113937. * Gets the class name
  113938. * @returns the string "Mesh".
  113939. */
  113940. getClassName(): string;
  113941. /** @hidden */
  113942. get _isMesh(): boolean;
  113943. /**
  113944. * Returns a description of this mesh
  113945. * @param fullDetails define if full details about this mesh must be used
  113946. * @returns a descriptive string representing this mesh
  113947. */
  113948. toString(fullDetails?: boolean): string;
  113949. /** @hidden */
  113950. _unBindEffect(): void;
  113951. /**
  113952. * Gets a boolean indicating if this mesh has LOD
  113953. */
  113954. get hasLODLevels(): boolean;
  113955. /**
  113956. * Gets the list of MeshLODLevel associated with the current mesh
  113957. * @returns an array of MeshLODLevel
  113958. */
  113959. getLODLevels(): MeshLODLevel[];
  113960. private _sortLODLevels;
  113961. /**
  113962. * Add a mesh as LOD level triggered at the given distance.
  113963. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113964. * @param distance The distance from the center of the object to show this level
  113965. * @param mesh The mesh to be added as LOD level (can be null)
  113966. * @return This mesh (for chaining)
  113967. */
  113968. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  113969. /**
  113970. * Returns the LOD level mesh at the passed distance or null if not found.
  113971. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113972. * @param distance The distance from the center of the object to show this level
  113973. * @returns a Mesh or `null`
  113974. */
  113975. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  113976. /**
  113977. * Remove a mesh from the LOD array
  113978. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113979. * @param mesh defines the mesh to be removed
  113980. * @return This mesh (for chaining)
  113981. */
  113982. removeLODLevel(mesh: Mesh): Mesh;
  113983. /**
  113984. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  113985. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113986. * @param camera defines the camera to use to compute distance
  113987. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  113988. * @return This mesh (for chaining)
  113989. */
  113990. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  113991. /**
  113992. * Gets the mesh internal Geometry object
  113993. */
  113994. get geometry(): Nullable<Geometry>;
  113995. /**
  113996. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  113997. * @returns the total number of vertices
  113998. */
  113999. getTotalVertices(): number;
  114000. /**
  114001. * Returns the content of an associated vertex buffer
  114002. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114003. * - VertexBuffer.PositionKind
  114004. * - VertexBuffer.UVKind
  114005. * - VertexBuffer.UV2Kind
  114006. * - VertexBuffer.UV3Kind
  114007. * - VertexBuffer.UV4Kind
  114008. * - VertexBuffer.UV5Kind
  114009. * - VertexBuffer.UV6Kind
  114010. * - VertexBuffer.ColorKind
  114011. * - VertexBuffer.MatricesIndicesKind
  114012. * - VertexBuffer.MatricesIndicesExtraKind
  114013. * - VertexBuffer.MatricesWeightsKind
  114014. * - VertexBuffer.MatricesWeightsExtraKind
  114015. * @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
  114016. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  114017. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  114018. */
  114019. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  114020. /**
  114021. * Returns the mesh VertexBuffer object from the requested `kind`
  114022. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114023. * - VertexBuffer.PositionKind
  114024. * - VertexBuffer.NormalKind
  114025. * - VertexBuffer.UVKind
  114026. * - VertexBuffer.UV2Kind
  114027. * - VertexBuffer.UV3Kind
  114028. * - VertexBuffer.UV4Kind
  114029. * - VertexBuffer.UV5Kind
  114030. * - VertexBuffer.UV6Kind
  114031. * - VertexBuffer.ColorKind
  114032. * - VertexBuffer.MatricesIndicesKind
  114033. * - VertexBuffer.MatricesIndicesExtraKind
  114034. * - VertexBuffer.MatricesWeightsKind
  114035. * - VertexBuffer.MatricesWeightsExtraKind
  114036. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  114037. */
  114038. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  114039. /**
  114040. * Tests if a specific vertex buffer is associated with this mesh
  114041. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114042. * - VertexBuffer.PositionKind
  114043. * - VertexBuffer.NormalKind
  114044. * - VertexBuffer.UVKind
  114045. * - VertexBuffer.UV2Kind
  114046. * - VertexBuffer.UV3Kind
  114047. * - VertexBuffer.UV4Kind
  114048. * - VertexBuffer.UV5Kind
  114049. * - VertexBuffer.UV6Kind
  114050. * - VertexBuffer.ColorKind
  114051. * - VertexBuffer.MatricesIndicesKind
  114052. * - VertexBuffer.MatricesIndicesExtraKind
  114053. * - VertexBuffer.MatricesWeightsKind
  114054. * - VertexBuffer.MatricesWeightsExtraKind
  114055. * @returns a boolean
  114056. */
  114057. isVerticesDataPresent(kind: string): boolean;
  114058. /**
  114059. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  114060. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114061. * - VertexBuffer.PositionKind
  114062. * - VertexBuffer.UVKind
  114063. * - VertexBuffer.UV2Kind
  114064. * - VertexBuffer.UV3Kind
  114065. * - VertexBuffer.UV4Kind
  114066. * - VertexBuffer.UV5Kind
  114067. * - VertexBuffer.UV6Kind
  114068. * - VertexBuffer.ColorKind
  114069. * - VertexBuffer.MatricesIndicesKind
  114070. * - VertexBuffer.MatricesIndicesExtraKind
  114071. * - VertexBuffer.MatricesWeightsKind
  114072. * - VertexBuffer.MatricesWeightsExtraKind
  114073. * @returns a boolean
  114074. */
  114075. isVertexBufferUpdatable(kind: string): boolean;
  114076. /**
  114077. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  114078. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114079. * - VertexBuffer.PositionKind
  114080. * - VertexBuffer.NormalKind
  114081. * - VertexBuffer.UVKind
  114082. * - VertexBuffer.UV2Kind
  114083. * - VertexBuffer.UV3Kind
  114084. * - VertexBuffer.UV4Kind
  114085. * - VertexBuffer.UV5Kind
  114086. * - VertexBuffer.UV6Kind
  114087. * - VertexBuffer.ColorKind
  114088. * - VertexBuffer.MatricesIndicesKind
  114089. * - VertexBuffer.MatricesIndicesExtraKind
  114090. * - VertexBuffer.MatricesWeightsKind
  114091. * - VertexBuffer.MatricesWeightsExtraKind
  114092. * @returns an array of strings
  114093. */
  114094. getVerticesDataKinds(): string[];
  114095. /**
  114096. * Returns a positive integer : the total number of indices in this mesh geometry.
  114097. * @returns the numner of indices or zero if the mesh has no geometry.
  114098. */
  114099. getTotalIndices(): number;
  114100. /**
  114101. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  114102. * @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.
  114103. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  114104. * @returns the indices array or an empty array if the mesh has no geometry
  114105. */
  114106. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  114107. get isBlocked(): boolean;
  114108. /**
  114109. * Determine if the current mesh is ready to be rendered
  114110. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  114111. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  114112. * @returns true if all associated assets are ready (material, textures, shaders)
  114113. */
  114114. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  114115. /**
  114116. * 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.
  114117. */
  114118. get areNormalsFrozen(): boolean;
  114119. /**
  114120. * 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.
  114121. * @returns the current mesh
  114122. */
  114123. freezeNormals(): Mesh;
  114124. /**
  114125. * 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
  114126. * @returns the current mesh
  114127. */
  114128. unfreezeNormals(): Mesh;
  114129. /**
  114130. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  114131. */
  114132. set overridenInstanceCount(count: number);
  114133. /** @hidden */
  114134. _preActivate(): Mesh;
  114135. /** @hidden */
  114136. _preActivateForIntermediateRendering(renderId: number): Mesh;
  114137. /** @hidden */
  114138. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  114139. protected _afterComputeWorldMatrix(): void;
  114140. /** @hidden */
  114141. _postActivate(): void;
  114142. /**
  114143. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  114144. * This means the mesh underlying bounding box and sphere are recomputed.
  114145. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  114146. * @returns the current mesh
  114147. */
  114148. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  114149. /** @hidden */
  114150. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  114151. /**
  114152. * This function will subdivide the mesh into multiple submeshes
  114153. * @param count defines the expected number of submeshes
  114154. */
  114155. subdivide(count: number): void;
  114156. /**
  114157. * Copy a FloatArray into a specific associated vertex buffer
  114158. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114159. * - VertexBuffer.PositionKind
  114160. * - VertexBuffer.UVKind
  114161. * - VertexBuffer.UV2Kind
  114162. * - VertexBuffer.UV3Kind
  114163. * - VertexBuffer.UV4Kind
  114164. * - VertexBuffer.UV5Kind
  114165. * - VertexBuffer.UV6Kind
  114166. * - VertexBuffer.ColorKind
  114167. * - VertexBuffer.MatricesIndicesKind
  114168. * - VertexBuffer.MatricesIndicesExtraKind
  114169. * - VertexBuffer.MatricesWeightsKind
  114170. * - VertexBuffer.MatricesWeightsExtraKind
  114171. * @param data defines the data source
  114172. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114173. * @param stride defines the data stride size (can be null)
  114174. * @returns the current mesh
  114175. */
  114176. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  114177. /**
  114178. * Delete a vertex buffer associated with this mesh
  114179. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  114180. * - VertexBuffer.PositionKind
  114181. * - VertexBuffer.UVKind
  114182. * - VertexBuffer.UV2Kind
  114183. * - VertexBuffer.UV3Kind
  114184. * - VertexBuffer.UV4Kind
  114185. * - VertexBuffer.UV5Kind
  114186. * - VertexBuffer.UV6Kind
  114187. * - VertexBuffer.ColorKind
  114188. * - VertexBuffer.MatricesIndicesKind
  114189. * - VertexBuffer.MatricesIndicesExtraKind
  114190. * - VertexBuffer.MatricesWeightsKind
  114191. * - VertexBuffer.MatricesWeightsExtraKind
  114192. */
  114193. removeVerticesData(kind: string): void;
  114194. /**
  114195. * Flags an associated vertex buffer as updatable
  114196. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  114197. * - VertexBuffer.PositionKind
  114198. * - VertexBuffer.UVKind
  114199. * - VertexBuffer.UV2Kind
  114200. * - VertexBuffer.UV3Kind
  114201. * - VertexBuffer.UV4Kind
  114202. * - VertexBuffer.UV5Kind
  114203. * - VertexBuffer.UV6Kind
  114204. * - VertexBuffer.ColorKind
  114205. * - VertexBuffer.MatricesIndicesKind
  114206. * - VertexBuffer.MatricesIndicesExtraKind
  114207. * - VertexBuffer.MatricesWeightsKind
  114208. * - VertexBuffer.MatricesWeightsExtraKind
  114209. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114210. */
  114211. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  114212. /**
  114213. * Sets the mesh global Vertex Buffer
  114214. * @param buffer defines the buffer to use
  114215. * @returns the current mesh
  114216. */
  114217. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  114218. /**
  114219. * Update a specific associated vertex buffer
  114220. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114221. * - VertexBuffer.PositionKind
  114222. * - VertexBuffer.UVKind
  114223. * - VertexBuffer.UV2Kind
  114224. * - VertexBuffer.UV3Kind
  114225. * - VertexBuffer.UV4Kind
  114226. * - VertexBuffer.UV5Kind
  114227. * - VertexBuffer.UV6Kind
  114228. * - VertexBuffer.ColorKind
  114229. * - VertexBuffer.MatricesIndicesKind
  114230. * - VertexBuffer.MatricesIndicesExtraKind
  114231. * - VertexBuffer.MatricesWeightsKind
  114232. * - VertexBuffer.MatricesWeightsExtraKind
  114233. * @param data defines the data source
  114234. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  114235. * @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)
  114236. * @returns the current mesh
  114237. */
  114238. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  114239. /**
  114240. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  114241. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  114242. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  114243. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  114244. * @returns the current mesh
  114245. */
  114246. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  114247. /**
  114248. * Creates a un-shared specific occurence of the geometry for the mesh.
  114249. * @returns the current mesh
  114250. */
  114251. makeGeometryUnique(): Mesh;
  114252. /**
  114253. * Set the index buffer of this mesh
  114254. * @param indices defines the source data
  114255. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  114256. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  114257. * @returns the current mesh
  114258. */
  114259. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  114260. /**
  114261. * Update the current index buffer
  114262. * @param indices defines the source data
  114263. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  114264. * @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)
  114265. * @returns the current mesh
  114266. */
  114267. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  114268. /**
  114269. * Invert the geometry to move from a right handed system to a left handed one.
  114270. * @returns the current mesh
  114271. */
  114272. toLeftHanded(): Mesh;
  114273. /** @hidden */
  114274. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  114275. /** @hidden */
  114276. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  114277. /**
  114278. * Registers for this mesh a javascript function called just before the rendering process
  114279. * @param func defines the function to call before rendering this mesh
  114280. * @returns the current mesh
  114281. */
  114282. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114283. /**
  114284. * Disposes a previously registered javascript function called before the rendering
  114285. * @param func defines the function to remove
  114286. * @returns the current mesh
  114287. */
  114288. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114289. /**
  114290. * Registers for this mesh a javascript function called just after the rendering is complete
  114291. * @param func defines the function to call after rendering this mesh
  114292. * @returns the current mesh
  114293. */
  114294. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114295. /**
  114296. * Disposes a previously registered javascript function called after the rendering.
  114297. * @param func defines the function to remove
  114298. * @returns the current mesh
  114299. */
  114300. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114301. /** @hidden */
  114302. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  114303. /** @hidden */
  114304. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  114305. /** @hidden */
  114306. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  114307. /** @hidden */
  114308. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  114309. /** @hidden */
  114310. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  114311. /** @hidden */
  114312. _rebuild(): void;
  114313. /** @hidden */
  114314. _freeze(): void;
  114315. /** @hidden */
  114316. _unFreeze(): void;
  114317. /**
  114318. * 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
  114319. * @param subMesh defines the subMesh to render
  114320. * @param enableAlphaMode defines if alpha mode can be changed
  114321. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  114322. * @returns the current mesh
  114323. */
  114324. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  114325. private _onBeforeDraw;
  114326. /**
  114327. * Renormalize the mesh and patch it up if there are no weights
  114328. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  114329. * However in the case of zero weights then we set just a single influence to 1.
  114330. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  114331. */
  114332. cleanMatrixWeights(): void;
  114333. private normalizeSkinFourWeights;
  114334. private normalizeSkinWeightsAndExtra;
  114335. /**
  114336. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  114337. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  114338. * the user know there was an issue with importing the mesh
  114339. * @returns a validation object with skinned, valid and report string
  114340. */
  114341. validateSkinning(): {
  114342. skinned: boolean;
  114343. valid: boolean;
  114344. report: string;
  114345. };
  114346. /** @hidden */
  114347. _checkDelayState(): Mesh;
  114348. private _queueLoad;
  114349. /**
  114350. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  114351. * A mesh is in the frustum if its bounding box intersects the frustum
  114352. * @param frustumPlanes defines the frustum to test
  114353. * @returns true if the mesh is in the frustum planes
  114354. */
  114355. isInFrustum(frustumPlanes: Plane[]): boolean;
  114356. /**
  114357. * Sets the mesh material by the material or multiMaterial `id` property
  114358. * @param id is a string identifying the material or the multiMaterial
  114359. * @returns the current mesh
  114360. */
  114361. setMaterialByID(id: string): Mesh;
  114362. /**
  114363. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  114364. * @returns an array of IAnimatable
  114365. */
  114366. getAnimatables(): IAnimatable[];
  114367. /**
  114368. * Modifies the mesh geometry according to the passed transformation matrix.
  114369. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  114370. * The mesh normals are modified using the same transformation.
  114371. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114372. * @param transform defines the transform matrix to use
  114373. * @see https://doc.babylonjs.com/resources/baking_transformations
  114374. * @returns the current mesh
  114375. */
  114376. bakeTransformIntoVertices(transform: Matrix): Mesh;
  114377. /**
  114378. * Modifies the mesh geometry according to its own current World Matrix.
  114379. * The mesh World Matrix is then reset.
  114380. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  114381. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114382. * @see https://doc.babylonjs.com/resources/baking_transformations
  114383. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  114384. * @returns the current mesh
  114385. */
  114386. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  114387. /** @hidden */
  114388. get _positions(): Nullable<Vector3[]>;
  114389. /** @hidden */
  114390. _resetPointsArrayCache(): Mesh;
  114391. /** @hidden */
  114392. _generatePointsArray(): boolean;
  114393. /**
  114394. * Returns a new Mesh object generated from the current mesh properties.
  114395. * This method must not get confused with createInstance()
  114396. * @param name is a string, the name given to the new mesh
  114397. * @param newParent can be any Node object (default `null`)
  114398. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  114399. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  114400. * @returns a new mesh
  114401. */
  114402. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  114403. /**
  114404. * Releases resources associated with this mesh.
  114405. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114406. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114407. */
  114408. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114409. /** @hidden */
  114410. _disposeInstanceSpecificData(): void;
  114411. /** @hidden */
  114412. _disposeThinInstanceSpecificData(): void;
  114413. /**
  114414. * Modifies the mesh geometry according to a displacement map.
  114415. * 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.
  114416. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114417. * @param url is a string, the URL from the image file is to be downloaded.
  114418. * @param minHeight is the lower limit of the displacement.
  114419. * @param maxHeight is the upper limit of the displacement.
  114420. * @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.
  114421. * @param uvOffset is an optional vector2 used to offset UV.
  114422. * @param uvScale is an optional vector2 used to scale UV.
  114423. * @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.
  114424. * @returns the Mesh.
  114425. */
  114426. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114427. /**
  114428. * Modifies the mesh geometry according to a displacementMap buffer.
  114429. * 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.
  114430. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114431. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  114432. * @param heightMapWidth is the width of the buffer image.
  114433. * @param heightMapHeight is the height of the buffer image.
  114434. * @param minHeight is the lower limit of the displacement.
  114435. * @param maxHeight is the upper limit of the displacement.
  114436. * @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.
  114437. * @param uvOffset is an optional vector2 used to offset UV.
  114438. * @param uvScale is an optional vector2 used to scale UV.
  114439. * @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.
  114440. * @returns the Mesh.
  114441. */
  114442. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114443. /**
  114444. * Modify the mesh to get a flat shading rendering.
  114445. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  114446. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  114447. * @returns current mesh
  114448. */
  114449. convertToFlatShadedMesh(): Mesh;
  114450. /**
  114451. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  114452. * In other words, more vertices, no more indices and a single bigger VBO.
  114453. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  114454. * @returns current mesh
  114455. */
  114456. convertToUnIndexedMesh(): Mesh;
  114457. /**
  114458. * Inverses facet orientations.
  114459. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114460. * @param flipNormals will also inverts the normals
  114461. * @returns current mesh
  114462. */
  114463. flipFaces(flipNormals?: boolean): Mesh;
  114464. /**
  114465. * Increase the number of facets and hence vertices in a mesh
  114466. * Vertex normals are interpolated from existing vertex normals
  114467. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114468. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  114469. */
  114470. increaseVertices(numberPerEdge: number): void;
  114471. /**
  114472. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  114473. * This will undo any application of covertToFlatShadedMesh
  114474. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114475. */
  114476. forceSharedVertices(): void;
  114477. /** @hidden */
  114478. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  114479. /** @hidden */
  114480. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  114481. /**
  114482. * Creates a new InstancedMesh object from the mesh model.
  114483. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114484. * @param name defines the name of the new instance
  114485. * @returns a new InstancedMesh
  114486. */
  114487. createInstance(name: string): InstancedMesh;
  114488. /**
  114489. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  114490. * After this call, all the mesh instances have the same submeshes than the current mesh.
  114491. * @returns the current mesh
  114492. */
  114493. synchronizeInstances(): Mesh;
  114494. /**
  114495. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  114496. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  114497. * This should be used together with the simplification to avoid disappearing triangles.
  114498. * @param successCallback an optional success callback to be called after the optimization finished.
  114499. * @returns the current mesh
  114500. */
  114501. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  114502. /**
  114503. * Serialize current mesh
  114504. * @param serializationObject defines the object which will receive the serialization data
  114505. */
  114506. serialize(serializationObject: any): void;
  114507. /** @hidden */
  114508. _syncGeometryWithMorphTargetManager(): void;
  114509. /** @hidden */
  114510. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  114511. /**
  114512. * Returns a new Mesh object parsed from the source provided.
  114513. * @param parsedMesh is the source
  114514. * @param scene defines the hosting scene
  114515. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  114516. * @returns a new Mesh
  114517. */
  114518. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  114519. /**
  114520. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  114521. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114522. * @param name defines the name of the mesh to create
  114523. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  114524. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  114525. * @param closePath creates a seam between the first and the last points of each path of the path array
  114526. * @param offset is taken in account only if the `pathArray` is containing a single path
  114527. * @param scene defines the hosting scene
  114528. * @param updatable defines if the mesh must be flagged as updatable
  114529. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114530. * @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)
  114531. * @returns a new Mesh
  114532. */
  114533. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114534. /**
  114535. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  114536. * @param name defines the name of the mesh to create
  114537. * @param radius sets the radius size (float) of the polygon (default 0.5)
  114538. * @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
  114539. * @param scene defines the hosting scene
  114540. * @param updatable defines if the mesh must be flagged as updatable
  114541. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114542. * @returns a new Mesh
  114543. */
  114544. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114545. /**
  114546. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  114547. * @param name defines the name of the mesh to create
  114548. * @param size sets the size (float) of each box side (default 1)
  114549. * @param scene defines the hosting scene
  114550. * @param updatable defines if the mesh must be flagged as updatable
  114551. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114552. * @returns a new Mesh
  114553. */
  114554. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114555. /**
  114556. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  114557. * @param name defines the name of the mesh to create
  114558. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114559. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114560. * @param scene defines the hosting scene
  114561. * @param updatable defines if the mesh must be flagged as updatable
  114562. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114563. * @returns a new Mesh
  114564. */
  114565. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114566. /**
  114567. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  114568. * @param name defines the name of the mesh to create
  114569. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114570. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114571. * @param scene defines the hosting scene
  114572. * @returns a new Mesh
  114573. */
  114574. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  114575. /**
  114576. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  114577. * @param name defines the name of the mesh to create
  114578. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  114579. * @param diameterTop set the top cap diameter (floats, default 1)
  114580. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  114581. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  114582. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  114583. * @param scene defines the hosting scene
  114584. * @param updatable defines if the mesh must be flagged as updatable
  114585. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114586. * @returns a new Mesh
  114587. */
  114588. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  114589. /**
  114590. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  114591. * @param name defines the name of the mesh to create
  114592. * @param diameter sets the diameter size (float) of the torus (default 1)
  114593. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  114594. * @param tessellation sets the number of torus sides (postive integer, default 16)
  114595. * @param scene defines the hosting scene
  114596. * @param updatable defines if the mesh must be flagged as updatable
  114597. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114598. * @returns a new Mesh
  114599. */
  114600. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114601. /**
  114602. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  114603. * @param name defines the name of the mesh to create
  114604. * @param radius sets the global radius size (float) of the torus knot (default 2)
  114605. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  114606. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  114607. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  114608. * @param p the number of windings on X axis (positive integers, default 2)
  114609. * @param q the number of windings on Y axis (positive integers, default 3)
  114610. * @param scene defines the hosting scene
  114611. * @param updatable defines if the mesh must be flagged as updatable
  114612. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114613. * @returns a new Mesh
  114614. */
  114615. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114616. /**
  114617. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114618. * @param name defines the name of the mesh to create
  114619. * @param points is an array successive Vector3
  114620. * @param scene defines the hosting scene
  114621. * @param updatable defines if the mesh must be flagged as updatable
  114622. * @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).
  114623. * @returns a new Mesh
  114624. */
  114625. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114626. /**
  114627. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114628. * @param name defines the name of the mesh to create
  114629. * @param points is an array successive Vector3
  114630. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114631. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114632. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114633. * @param scene defines the hosting scene
  114634. * @param updatable defines if the mesh must be flagged as updatable
  114635. * @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)
  114636. * @returns a new Mesh
  114637. */
  114638. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114639. /**
  114640. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114641. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114642. * 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.
  114643. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114644. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114645. * Remember you can only change the shape positions, not their number when updating a polygon.
  114646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114647. * @param name defines the name of the mesh to create
  114648. * @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
  114649. * @param scene defines the hosting scene
  114650. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114651. * @param updatable defines if the mesh must be flagged as updatable
  114652. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114653. * @param earcutInjection can be used to inject your own earcut reference
  114654. * @returns a new Mesh
  114655. */
  114656. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114657. /**
  114658. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114659. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114660. * @param name defines the name of the mesh to create
  114661. * @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
  114662. * @param depth defines the height of extrusion
  114663. * @param scene defines the hosting scene
  114664. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  114668. * @returns a new Mesh
  114669. */
  114670. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114671. /**
  114672. * Creates an extruded shape mesh.
  114673. * 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
  114674. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114675. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114676. * @param name defines the name of the mesh to create
  114677. * @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
  114678. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114679. * @param scale is the value to scale the shape
  114680. * @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
  114681. * @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
  114682. * @param scene defines the hosting scene
  114683. * @param updatable defines if the mesh must be flagged as updatable
  114684. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114685. * @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)
  114686. * @returns a new Mesh
  114687. */
  114688. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114689. /**
  114690. * Creates an custom extruded shape mesh.
  114691. * The custom extrusion is a parametric shape.
  114692. * It has no predefined shape. Its final shape will depend on the input parameters.
  114693. * Please consider using the same method from the MeshBuilder class instead
  114694. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114695. * @param name defines the name of the mesh to create
  114696. * @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
  114697. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114698. * @param scaleFunction is a custom Javascript function called on each path point
  114699. * @param rotationFunction is a custom Javascript function called on each path point
  114700. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114701. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114702. * @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
  114703. * @param scene defines the hosting scene
  114704. * @param updatable defines if the mesh must be flagged as updatable
  114705. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114706. * @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)
  114707. * @returns a new Mesh
  114708. */
  114709. 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;
  114710. /**
  114711. * Creates lathe mesh.
  114712. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114713. * Please consider using the same method from the MeshBuilder class instead
  114714. * @param name defines the name of the mesh to create
  114715. * @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
  114716. * @param radius is the radius value of the lathe
  114717. * @param tessellation is the side number of the lathe.
  114718. * @param scene defines the hosting scene
  114719. * @param updatable defines if the mesh must be flagged as updatable
  114720. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114721. * @returns a new Mesh
  114722. */
  114723. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114724. /**
  114725. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114726. * @param name defines the name of the mesh to create
  114727. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114728. * @param scene defines the hosting scene
  114729. * @param updatable defines if the mesh must be flagged as updatable
  114730. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114731. * @returns a new Mesh
  114732. */
  114733. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114734. /**
  114735. * Creates a ground mesh.
  114736. * Please consider using the same method from the MeshBuilder class instead
  114737. * @param name defines the name of the mesh to create
  114738. * @param width set the width of the ground
  114739. * @param height set the height of the ground
  114740. * @param subdivisions sets the number of subdivisions per side
  114741. * @param scene defines the hosting scene
  114742. * @param updatable defines if the mesh must be flagged as updatable
  114743. * @returns a new Mesh
  114744. */
  114745. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114746. /**
  114747. * Creates a tiled ground mesh.
  114748. * Please consider using the same method from the MeshBuilder class instead
  114749. * @param name defines the name of the mesh to create
  114750. * @param xmin set the ground minimum X coordinate
  114751. * @param zmin set the ground minimum Y coordinate
  114752. * @param xmax set the ground maximum X coordinate
  114753. * @param zmax set the ground maximum Z coordinate
  114754. * @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
  114755. * @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
  114756. * @param scene defines the hosting scene
  114757. * @param updatable defines if the mesh must be flagged as updatable
  114758. * @returns a new Mesh
  114759. */
  114760. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114761. w: number;
  114762. h: number;
  114763. }, precision: {
  114764. w: number;
  114765. h: number;
  114766. }, scene: Scene, updatable?: boolean): Mesh;
  114767. /**
  114768. * Creates a ground mesh from a height map.
  114769. * Please consider using the same method from the MeshBuilder class instead
  114770. * @see https://doc.babylonjs.com/babylon101/height_map
  114771. * @param name defines the name of the mesh to create
  114772. * @param url sets the URL of the height map image resource
  114773. * @param width set the ground width size
  114774. * @param height set the ground height size
  114775. * @param subdivisions sets the number of subdivision per side
  114776. * @param minHeight is the minimum altitude on the ground
  114777. * @param maxHeight is the maximum altitude on the ground
  114778. * @param scene defines the hosting scene
  114779. * @param updatable defines if the mesh must be flagged as updatable
  114780. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114781. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114782. * @returns a new Mesh
  114783. */
  114784. 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;
  114785. /**
  114786. * Creates a tube mesh.
  114787. * The tube is a parametric shape.
  114788. * It has no predefined shape. Its final shape will depend on the input parameters.
  114789. * Please consider using the same method from the MeshBuilder class instead
  114790. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114791. * @param name defines the name of the mesh to create
  114792. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114793. * @param radius sets the tube radius size
  114794. * @param tessellation is the number of sides on the tubular surface
  114795. * @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
  114796. * @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
  114797. * @param scene defines the hosting scene
  114798. * @param updatable defines if the mesh must be flagged as updatable
  114799. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114800. * @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)
  114801. * @returns a new Mesh
  114802. */
  114803. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114804. (i: number, distance: number): number;
  114805. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114806. /**
  114807. * Creates a polyhedron mesh.
  114808. * Please consider using the same method from the MeshBuilder class instead.
  114809. * * 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
  114810. * * The parameter `size` (positive float, default 1) sets the polygon size
  114811. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114812. * * 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`
  114813. * * 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
  114814. * * 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)`)
  114815. * * 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
  114816. * * 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
  114817. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114820. * @param name defines the name of the mesh to create
  114821. * @param options defines the options used to create the mesh
  114822. * @param scene defines the hosting scene
  114823. * @returns a new Mesh
  114824. */
  114825. static CreatePolyhedron(name: string, options: {
  114826. type?: number;
  114827. size?: number;
  114828. sizeX?: number;
  114829. sizeY?: number;
  114830. sizeZ?: number;
  114831. custom?: any;
  114832. faceUV?: Vector4[];
  114833. faceColors?: Color4[];
  114834. updatable?: boolean;
  114835. sideOrientation?: number;
  114836. }, scene: Scene): Mesh;
  114837. /**
  114838. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114839. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114840. * * 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`)
  114841. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114842. * * 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
  114843. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114844. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114846. * @param name defines the name of the mesh
  114847. * @param options defines the options used to create the mesh
  114848. * @param scene defines the hosting scene
  114849. * @returns a new Mesh
  114850. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114851. */
  114852. static CreateIcoSphere(name: string, options: {
  114853. radius?: number;
  114854. flat?: boolean;
  114855. subdivisions?: number;
  114856. sideOrientation?: number;
  114857. updatable?: boolean;
  114858. }, scene: Scene): Mesh;
  114859. /**
  114860. * Creates a decal mesh.
  114861. * Please consider using the same method from the MeshBuilder class instead.
  114862. * A decal is a mesh usually applied as a model onto the surface of another mesh
  114863. * @param name defines the name of the mesh
  114864. * @param sourceMesh defines the mesh receiving the decal
  114865. * @param position sets the position of the decal in world coordinates
  114866. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  114867. * @param size sets the decal scaling
  114868. * @param angle sets the angle to rotate the decal
  114869. * @returns a new Mesh
  114870. */
  114871. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  114872. /** Creates a Capsule Mesh
  114873. * @param name defines the name of the mesh.
  114874. * @param options the constructors options used to shape the mesh.
  114875. * @param scene defines the scene the mesh is scoped to.
  114876. * @returns the capsule mesh
  114877. * @see https://doc.babylonjs.com/how_to/capsule_shape
  114878. */
  114879. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  114880. /**
  114881. * Prepare internal position array for software CPU skinning
  114882. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  114883. */
  114884. setPositionsForCPUSkinning(): Float32Array;
  114885. /**
  114886. * Prepare internal normal array for software CPU skinning
  114887. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  114888. */
  114889. setNormalsForCPUSkinning(): Float32Array;
  114890. /**
  114891. * Updates the vertex buffer by applying transformation from the bones
  114892. * @param skeleton defines the skeleton to apply to current mesh
  114893. * @returns the current mesh
  114894. */
  114895. applySkeleton(skeleton: Skeleton): Mesh;
  114896. /**
  114897. * 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
  114898. * @param meshes defines the list of meshes to scan
  114899. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  114900. */
  114901. static MinMax(meshes: AbstractMesh[]): {
  114902. min: Vector3;
  114903. max: Vector3;
  114904. };
  114905. /**
  114906. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  114907. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  114908. * @returns a vector3
  114909. */
  114910. static Center(meshesOrMinMaxVector: {
  114911. min: Vector3;
  114912. max: Vector3;
  114913. } | AbstractMesh[]): Vector3;
  114914. /**
  114915. * Merge the array of meshes into a single mesh for performance reasons.
  114916. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  114917. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  114918. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  114919. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  114920. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  114921. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  114922. * @returns a new mesh
  114923. */
  114924. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  114925. /** @hidden */
  114926. addInstance(instance: InstancedMesh): void;
  114927. /** @hidden */
  114928. removeInstance(instance: InstancedMesh): void;
  114929. }
  114930. }
  114931. declare module BABYLON {
  114932. /**
  114933. * The options Interface for creating a Capsule Mesh
  114934. */
  114935. export interface ICreateCapsuleOptions {
  114936. /** The Orientation of the capsule. Default : Vector3.Up() */
  114937. orientation?: Vector3;
  114938. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  114939. subdivisions: number;
  114940. /** Number of cylindrical segments on the capsule. */
  114941. tessellation: number;
  114942. /** Height or Length of the capsule. */
  114943. height: number;
  114944. /** Radius of the capsule. */
  114945. radius: number;
  114946. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  114947. capSubdivisions: number;
  114948. /** Overwrite for the top radius. */
  114949. radiusTop?: number;
  114950. /** Overwrite for the bottom radius. */
  114951. radiusBottom?: number;
  114952. /** Overwrite for the top capSubdivisions. */
  114953. topCapSubdivisions?: number;
  114954. /** Overwrite for the bottom capSubdivisions. */
  114955. bottomCapSubdivisions?: number;
  114956. }
  114957. /**
  114958. * Class containing static functions to help procedurally build meshes
  114959. */
  114960. export class CapsuleBuilder {
  114961. /**
  114962. * Creates a capsule or a pill mesh
  114963. * @param name defines the name of the mesh
  114964. * @param options The constructors options.
  114965. * @param scene The scene the mesh is scoped to.
  114966. * @returns Capsule Mesh
  114967. */
  114968. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  114969. }
  114970. }
  114971. declare module BABYLON {
  114972. /**
  114973. * Define an interface for all classes that will get and set the data on vertices
  114974. */
  114975. export interface IGetSetVerticesData {
  114976. /**
  114977. * Gets a boolean indicating if specific vertex data is present
  114978. * @param kind defines the vertex data kind to use
  114979. * @returns true is data kind is present
  114980. */
  114981. isVerticesDataPresent(kind: string): boolean;
  114982. /**
  114983. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  114984. * @param kind defines the data kind (Position, normal, etc...)
  114985. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  114986. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  114987. * @returns a float array containing vertex data
  114988. */
  114989. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  114990. /**
  114991. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  114992. * @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.
  114993. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  114994. * @returns the indices array or an empty array if the mesh has no geometry
  114995. */
  114996. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  114997. /**
  114998. * Set specific vertex data
  114999. * @param kind defines the data kind (Position, normal, etc...)
  115000. * @param data defines the vertex data to use
  115001. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  115002. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  115003. */
  115004. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  115005. /**
  115006. * Update a specific associated vertex buffer
  115007. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  115008. * - VertexBuffer.PositionKind
  115009. * - VertexBuffer.UVKind
  115010. * - VertexBuffer.UV2Kind
  115011. * - VertexBuffer.UV3Kind
  115012. * - VertexBuffer.UV4Kind
  115013. * - VertexBuffer.UV5Kind
  115014. * - VertexBuffer.UV6Kind
  115015. * - VertexBuffer.ColorKind
  115016. * - VertexBuffer.MatricesIndicesKind
  115017. * - VertexBuffer.MatricesIndicesExtraKind
  115018. * - VertexBuffer.MatricesWeightsKind
  115019. * - VertexBuffer.MatricesWeightsExtraKind
  115020. * @param data defines the data source
  115021. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  115022. * @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)
  115023. */
  115024. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  115025. /**
  115026. * Creates a new index buffer
  115027. * @param indices defines the indices to store in the index buffer
  115028. * @param totalVertices defines the total number of vertices (could be null)
  115029. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  115030. */
  115031. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  115032. }
  115033. /**
  115034. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  115035. */
  115036. export class VertexData {
  115037. /**
  115038. * Mesh side orientation : usually the external or front surface
  115039. */
  115040. static readonly FRONTSIDE: number;
  115041. /**
  115042. * Mesh side orientation : usually the internal or back surface
  115043. */
  115044. static readonly BACKSIDE: number;
  115045. /**
  115046. * Mesh side orientation : both internal and external or front and back surfaces
  115047. */
  115048. static readonly DOUBLESIDE: number;
  115049. /**
  115050. * Mesh side orientation : by default, `FRONTSIDE`
  115051. */
  115052. static readonly DEFAULTSIDE: number;
  115053. /**
  115054. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  115055. */
  115056. positions: Nullable<FloatArray>;
  115057. /**
  115058. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  115059. */
  115060. normals: Nullable<FloatArray>;
  115061. /**
  115062. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  115063. */
  115064. tangents: Nullable<FloatArray>;
  115065. /**
  115066. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115067. */
  115068. uvs: Nullable<FloatArray>;
  115069. /**
  115070. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115071. */
  115072. uvs2: Nullable<FloatArray>;
  115073. /**
  115074. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115075. */
  115076. uvs3: Nullable<FloatArray>;
  115077. /**
  115078. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115079. */
  115080. uvs4: Nullable<FloatArray>;
  115081. /**
  115082. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115083. */
  115084. uvs5: Nullable<FloatArray>;
  115085. /**
  115086. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115087. */
  115088. uvs6: Nullable<FloatArray>;
  115089. /**
  115090. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  115091. */
  115092. colors: Nullable<FloatArray>;
  115093. /**
  115094. * 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).
  115095. */
  115096. matricesIndices: Nullable<FloatArray>;
  115097. /**
  115098. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  115099. */
  115100. matricesWeights: Nullable<FloatArray>;
  115101. /**
  115102. * An array extending the number of possible indices
  115103. */
  115104. matricesIndicesExtra: Nullable<FloatArray>;
  115105. /**
  115106. * An array extending the number of possible weights when the number of indices is extended
  115107. */
  115108. matricesWeightsExtra: Nullable<FloatArray>;
  115109. /**
  115110. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  115111. */
  115112. indices: Nullable<IndicesArray>;
  115113. /**
  115114. * Uses the passed data array to set the set the values for the specified kind of data
  115115. * @param data a linear array of floating numbers
  115116. * @param kind the type of data that is being set, eg positions, colors etc
  115117. */
  115118. set(data: FloatArray, kind: string): void;
  115119. /**
  115120. * Associates the vertexData to the passed Mesh.
  115121. * Sets it as updatable or not (default `false`)
  115122. * @param mesh the mesh the vertexData is applied to
  115123. * @param updatable when used and having the value true allows new data to update the vertexData
  115124. * @returns the VertexData
  115125. */
  115126. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  115127. /**
  115128. * Associates the vertexData to the passed Geometry.
  115129. * Sets it as updatable or not (default `false`)
  115130. * @param geometry the geometry the vertexData is applied to
  115131. * @param updatable when used and having the value true allows new data to update the vertexData
  115132. * @returns VertexData
  115133. */
  115134. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  115135. /**
  115136. * Updates the associated mesh
  115137. * @param mesh the mesh to be updated
  115138. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  115139. * @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
  115140. * @returns VertexData
  115141. */
  115142. updateMesh(mesh: Mesh): VertexData;
  115143. /**
  115144. * Updates the associated geometry
  115145. * @param geometry the geometry to be updated
  115146. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  115147. * @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
  115148. * @returns VertexData.
  115149. */
  115150. updateGeometry(geometry: Geometry): VertexData;
  115151. private _applyTo;
  115152. private _update;
  115153. /**
  115154. * Transforms each position and each normal of the vertexData according to the passed Matrix
  115155. * @param matrix the transforming matrix
  115156. * @returns the VertexData
  115157. */
  115158. transform(matrix: Matrix): VertexData;
  115159. /**
  115160. * Merges the passed VertexData into the current one
  115161. * @param other the VertexData to be merged into the current one
  115162. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  115163. * @returns the modified VertexData
  115164. */
  115165. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  115166. private _mergeElement;
  115167. private _validate;
  115168. /**
  115169. * Serializes the VertexData
  115170. * @returns a serialized object
  115171. */
  115172. serialize(): any;
  115173. /**
  115174. * Extracts the vertexData from a mesh
  115175. * @param mesh the mesh from which to extract the VertexData
  115176. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  115177. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  115178. * @returns the object VertexData associated to the passed mesh
  115179. */
  115180. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  115181. /**
  115182. * Extracts the vertexData from the geometry
  115183. * @param geometry the geometry from which to extract the VertexData
  115184. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  115185. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  115186. * @returns the object VertexData associated to the passed mesh
  115187. */
  115188. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  115189. private static _ExtractFrom;
  115190. /**
  115191. * Creates the VertexData for a Ribbon
  115192. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  115193. * * pathArray array of paths, each of which an array of successive Vector3
  115194. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  115195. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  115196. * * 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
  115197. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115198. * * 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)
  115199. * * 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)
  115200. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  115201. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  115202. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  115203. * @returns the VertexData of the ribbon
  115204. */
  115205. static CreateRibbon(options: {
  115206. pathArray: Vector3[][];
  115207. closeArray?: boolean;
  115208. closePath?: boolean;
  115209. offset?: number;
  115210. sideOrientation?: number;
  115211. frontUVs?: Vector4;
  115212. backUVs?: Vector4;
  115213. invertUV?: boolean;
  115214. uvs?: Vector2[];
  115215. colors?: Color4[];
  115216. }): VertexData;
  115217. /**
  115218. * Creates the VertexData for a box
  115219. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115220. * * size sets the width, height and depth of the box to the value of size, optional default 1
  115221. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  115222. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  115223. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  115224. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  115225. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  115226. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115227. * * 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)
  115228. * * 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)
  115229. * @returns the VertexData of the box
  115230. */
  115231. static CreateBox(options: {
  115232. size?: number;
  115233. width?: number;
  115234. height?: number;
  115235. depth?: number;
  115236. faceUV?: Vector4[];
  115237. faceColors?: Color4[];
  115238. sideOrientation?: number;
  115239. frontUVs?: Vector4;
  115240. backUVs?: Vector4;
  115241. }): VertexData;
  115242. /**
  115243. * Creates the VertexData for a tiled box
  115244. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115245. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115246. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  115247. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  115248. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115249. * @returns the VertexData of the box
  115250. */
  115251. static CreateTiledBox(options: {
  115252. pattern?: number;
  115253. width?: number;
  115254. height?: number;
  115255. depth?: number;
  115256. tileSize?: number;
  115257. tileWidth?: number;
  115258. tileHeight?: number;
  115259. alignHorizontal?: number;
  115260. alignVertical?: number;
  115261. faceUV?: Vector4[];
  115262. faceColors?: Color4[];
  115263. sideOrientation?: number;
  115264. }): VertexData;
  115265. /**
  115266. * Creates the VertexData for a tiled plane
  115267. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115268. * * pattern a limited pattern arrangement depending on the number
  115269. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  115270. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  115271. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  115272. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115273. * * 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)
  115274. * * 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)
  115275. * @returns the VertexData of the tiled plane
  115276. */
  115277. static CreateTiledPlane(options: {
  115278. pattern?: number;
  115279. tileSize?: number;
  115280. tileWidth?: number;
  115281. tileHeight?: number;
  115282. size?: number;
  115283. width?: number;
  115284. height?: number;
  115285. alignHorizontal?: number;
  115286. alignVertical?: number;
  115287. sideOrientation?: number;
  115288. frontUVs?: Vector4;
  115289. backUVs?: Vector4;
  115290. }): VertexData;
  115291. /**
  115292. * Creates the VertexData for an ellipsoid, defaults to a sphere
  115293. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115294. * * segments sets the number of horizontal strips optional, default 32
  115295. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  115296. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  115297. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  115298. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  115299. * * 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
  115300. * * 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
  115301. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115302. * * 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)
  115303. * * 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)
  115304. * @returns the VertexData of the ellipsoid
  115305. */
  115306. static CreateSphere(options: {
  115307. segments?: number;
  115308. diameter?: number;
  115309. diameterX?: number;
  115310. diameterY?: number;
  115311. diameterZ?: number;
  115312. arc?: number;
  115313. slice?: number;
  115314. sideOrientation?: number;
  115315. frontUVs?: Vector4;
  115316. backUVs?: Vector4;
  115317. }): VertexData;
  115318. /**
  115319. * Creates the VertexData for a cylinder, cone or prism
  115320. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115321. * * height sets the height (y direction) of the cylinder, optional, default 2
  115322. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  115323. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  115324. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  115325. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  115326. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  115327. * * 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
  115328. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115329. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115330. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  115331. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  115332. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115333. * * 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)
  115334. * * 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)
  115335. * @returns the VertexData of the cylinder, cone or prism
  115336. */
  115337. static CreateCylinder(options: {
  115338. height?: number;
  115339. diameterTop?: number;
  115340. diameterBottom?: number;
  115341. diameter?: number;
  115342. tessellation?: number;
  115343. subdivisions?: number;
  115344. arc?: number;
  115345. faceColors?: Color4[];
  115346. faceUV?: Vector4[];
  115347. hasRings?: boolean;
  115348. enclose?: boolean;
  115349. sideOrientation?: number;
  115350. frontUVs?: Vector4;
  115351. backUVs?: Vector4;
  115352. }): VertexData;
  115353. /**
  115354. * Creates the VertexData for a torus
  115355. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115356. * * diameter the diameter of the torus, optional default 1
  115357. * * thickness the diameter of the tube forming the torus, optional default 0.5
  115358. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  115359. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115360. * * 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)
  115361. * * 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)
  115362. * @returns the VertexData of the torus
  115363. */
  115364. static CreateTorus(options: {
  115365. diameter?: number;
  115366. thickness?: number;
  115367. tessellation?: number;
  115368. sideOrientation?: number;
  115369. frontUVs?: Vector4;
  115370. backUVs?: Vector4;
  115371. }): VertexData;
  115372. /**
  115373. * Creates the VertexData of the LineSystem
  115374. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  115375. * - lines an array of lines, each line being an array of successive Vector3
  115376. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  115377. * @returns the VertexData of the LineSystem
  115378. */
  115379. static CreateLineSystem(options: {
  115380. lines: Vector3[][];
  115381. colors?: Nullable<Color4[][]>;
  115382. }): VertexData;
  115383. /**
  115384. * Create the VertexData for a DashedLines
  115385. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  115386. * - points an array successive Vector3
  115387. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  115388. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  115389. * - dashNb the intended total number of dashes, optional, default 200
  115390. * @returns the VertexData for the DashedLines
  115391. */
  115392. static CreateDashedLines(options: {
  115393. points: Vector3[];
  115394. dashSize?: number;
  115395. gapSize?: number;
  115396. dashNb?: number;
  115397. }): VertexData;
  115398. /**
  115399. * Creates the VertexData for a Ground
  115400. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  115401. * - width the width (x direction) of the ground, optional, default 1
  115402. * - height the height (z direction) of the ground, optional, default 1
  115403. * - subdivisions the number of subdivisions per side, optional, default 1
  115404. * @returns the VertexData of the Ground
  115405. */
  115406. static CreateGround(options: {
  115407. width?: number;
  115408. height?: number;
  115409. subdivisions?: number;
  115410. subdivisionsX?: number;
  115411. subdivisionsY?: number;
  115412. }): VertexData;
  115413. /**
  115414. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  115415. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  115416. * * xmin the ground minimum X coordinate, optional, default -1
  115417. * * zmin the ground minimum Z coordinate, optional, default -1
  115418. * * xmax the ground maximum X coordinate, optional, default 1
  115419. * * zmax the ground maximum Z coordinate, optional, default 1
  115420. * * 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}
  115421. * * 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}
  115422. * @returns the VertexData of the TiledGround
  115423. */
  115424. static CreateTiledGround(options: {
  115425. xmin: number;
  115426. zmin: number;
  115427. xmax: number;
  115428. zmax: number;
  115429. subdivisions?: {
  115430. w: number;
  115431. h: number;
  115432. };
  115433. precision?: {
  115434. w: number;
  115435. h: number;
  115436. };
  115437. }): VertexData;
  115438. /**
  115439. * Creates the VertexData of the Ground designed from a heightmap
  115440. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  115441. * * width the width (x direction) of the ground
  115442. * * height the height (z direction) of the ground
  115443. * * subdivisions the number of subdivisions per side
  115444. * * minHeight the minimum altitude on the ground, optional, default 0
  115445. * * maxHeight the maximum altitude on the ground, optional default 1
  115446. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  115447. * * buffer the array holding the image color data
  115448. * * bufferWidth the width of image
  115449. * * bufferHeight the height of image
  115450. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  115451. * @returns the VertexData of the Ground designed from a heightmap
  115452. */
  115453. static CreateGroundFromHeightMap(options: {
  115454. width: number;
  115455. height: number;
  115456. subdivisions: number;
  115457. minHeight: number;
  115458. maxHeight: number;
  115459. colorFilter: Color3;
  115460. buffer: Uint8Array;
  115461. bufferWidth: number;
  115462. bufferHeight: number;
  115463. alphaFilter: number;
  115464. }): VertexData;
  115465. /**
  115466. * Creates the VertexData for a Plane
  115467. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  115468. * * size sets the width and height of the plane to the value of size, optional default 1
  115469. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  115470. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  115471. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115472. * * 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)
  115473. * * 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)
  115474. * @returns the VertexData of the box
  115475. */
  115476. static CreatePlane(options: {
  115477. size?: number;
  115478. width?: number;
  115479. height?: number;
  115480. sideOrientation?: number;
  115481. frontUVs?: Vector4;
  115482. backUVs?: Vector4;
  115483. }): VertexData;
  115484. /**
  115485. * Creates the VertexData of the Disc or regular Polygon
  115486. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  115487. * * radius the radius of the disc, optional default 0.5
  115488. * * tessellation the number of polygon sides, optional, default 64
  115489. * * 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
  115490. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115491. * * 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)
  115492. * * 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)
  115493. * @returns the VertexData of the box
  115494. */
  115495. static CreateDisc(options: {
  115496. radius?: number;
  115497. tessellation?: number;
  115498. arc?: number;
  115499. sideOrientation?: number;
  115500. frontUVs?: Vector4;
  115501. backUVs?: Vector4;
  115502. }): VertexData;
  115503. /**
  115504. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  115505. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  115506. * @param polygon a mesh built from polygonTriangulation.build()
  115507. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115508. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115509. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115510. * @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)
  115511. * @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)
  115512. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  115513. * @returns the VertexData of the Polygon
  115514. */
  115515. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  115516. /**
  115517. * Creates the VertexData of the IcoSphere
  115518. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  115519. * * radius the radius of the IcoSphere, optional default 1
  115520. * * radiusX allows stretching in the x direction, optional, default radius
  115521. * * radiusY allows stretching in the y direction, optional, default radius
  115522. * * radiusZ allows stretching in the z direction, optional, default radius
  115523. * * flat when true creates a flat shaded mesh, optional, default true
  115524. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  115525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115526. * * 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)
  115527. * * 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)
  115528. * @returns the VertexData of the IcoSphere
  115529. */
  115530. static CreateIcoSphere(options: {
  115531. radius?: number;
  115532. radiusX?: number;
  115533. radiusY?: number;
  115534. radiusZ?: number;
  115535. flat?: boolean;
  115536. subdivisions?: number;
  115537. sideOrientation?: number;
  115538. frontUVs?: Vector4;
  115539. backUVs?: Vector4;
  115540. }): VertexData;
  115541. /**
  115542. * Creates the VertexData for a Polyhedron
  115543. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  115544. * * type provided types are:
  115545. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  115546. * * 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)
  115547. * * size the size of the IcoSphere, optional default 1
  115548. * * sizeX allows stretching in the x direction, optional, default size
  115549. * * sizeY allows stretching in the y direction, optional, default size
  115550. * * sizeZ allows stretching in the z direction, optional, default size
  115551. * * 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
  115552. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115553. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115554. * * flat when true creates a flat shaded mesh, optional, default true
  115555. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  115556. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115557. * * 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)
  115558. * * 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)
  115559. * @returns the VertexData of the Polyhedron
  115560. */
  115561. static CreatePolyhedron(options: {
  115562. type?: number;
  115563. size?: number;
  115564. sizeX?: number;
  115565. sizeY?: number;
  115566. sizeZ?: number;
  115567. custom?: any;
  115568. faceUV?: Vector4[];
  115569. faceColors?: Color4[];
  115570. flat?: boolean;
  115571. sideOrientation?: number;
  115572. frontUVs?: Vector4;
  115573. backUVs?: Vector4;
  115574. }): VertexData;
  115575. /**
  115576. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  115577. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  115578. * @returns the VertexData of the Capsule
  115579. */
  115580. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  115581. /**
  115582. * Creates the VertexData for a TorusKnot
  115583. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  115584. * * radius the radius of the torus knot, optional, default 2
  115585. * * tube the thickness of the tube, optional, default 0.5
  115586. * * radialSegments the number of sides on each tube segments, optional, default 32
  115587. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  115588. * * p the number of windings around the z axis, optional, default 2
  115589. * * q the number of windings around the x axis, optional, default 3
  115590. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115591. * * 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)
  115592. * * 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)
  115593. * @returns the VertexData of the Torus Knot
  115594. */
  115595. static CreateTorusKnot(options: {
  115596. radius?: number;
  115597. tube?: number;
  115598. radialSegments?: number;
  115599. tubularSegments?: number;
  115600. p?: number;
  115601. q?: number;
  115602. sideOrientation?: number;
  115603. frontUVs?: Vector4;
  115604. backUVs?: Vector4;
  115605. }): VertexData;
  115606. /**
  115607. * Compute normals for given positions and indices
  115608. * @param positions an array of vertex positions, [...., x, y, z, ......]
  115609. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  115610. * @param normals an array of vertex normals, [...., x, y, z, ......]
  115611. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  115612. * * facetNormals : optional array of facet normals (vector3)
  115613. * * facetPositions : optional array of facet positions (vector3)
  115614. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  115615. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  115616. * * bInfo : optional bounding info, required for facetPartitioning computation
  115617. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  115618. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  115619. * * useRightHandedSystem: optional boolean to for right handed system computation
  115620. * * depthSort : optional boolean to enable the facet depth sort computation
  115621. * * distanceTo : optional Vector3 to compute the facet depth from this location
  115622. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  115623. */
  115624. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  115625. facetNormals?: any;
  115626. facetPositions?: any;
  115627. facetPartitioning?: any;
  115628. ratio?: number;
  115629. bInfo?: any;
  115630. bbSize?: Vector3;
  115631. subDiv?: any;
  115632. useRightHandedSystem?: boolean;
  115633. depthSort?: boolean;
  115634. distanceTo?: Vector3;
  115635. depthSortedFacets?: any;
  115636. }): void;
  115637. /** @hidden */
  115638. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  115639. /**
  115640. * Applies VertexData created from the imported parameters to the geometry
  115641. * @param parsedVertexData the parsed data from an imported file
  115642. * @param geometry the geometry to apply the VertexData to
  115643. */
  115644. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  115645. }
  115646. }
  115647. declare module BABYLON {
  115648. /**
  115649. * Class containing static functions to help procedurally build meshes
  115650. */
  115651. export class DiscBuilder {
  115652. /**
  115653. * Creates a plane polygonal mesh. By default, this is a disc
  115654. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115655. * * 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
  115656. * * 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
  115657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115658. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115660. * @param name defines the name of the mesh
  115661. * @param options defines the options used to create the mesh
  115662. * @param scene defines the hosting scene
  115663. * @returns the plane polygonal mesh
  115664. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115665. */
  115666. static CreateDisc(name: string, options: {
  115667. radius?: number;
  115668. tessellation?: number;
  115669. arc?: number;
  115670. updatable?: boolean;
  115671. sideOrientation?: number;
  115672. frontUVs?: Vector4;
  115673. backUVs?: Vector4;
  115674. }, scene?: Nullable<Scene>): Mesh;
  115675. }
  115676. }
  115677. declare module BABYLON {
  115678. /**
  115679. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  115680. *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.
  115681. * The SPS is also a particle system. It provides some methods to manage the particles.
  115682. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  115683. *
  115684. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  115685. */
  115686. export class SolidParticleSystem implements IDisposable {
  115687. /**
  115688. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  115689. * Example : var p = SPS.particles[i];
  115690. */
  115691. particles: SolidParticle[];
  115692. /**
  115693. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  115694. */
  115695. nbParticles: number;
  115696. /**
  115697. * If the particles must ever face the camera (default false). Useful for planar particles.
  115698. */
  115699. billboard: boolean;
  115700. /**
  115701. * Recompute normals when adding a shape
  115702. */
  115703. recomputeNormals: boolean;
  115704. /**
  115705. * This a counter ofr your own usage. It's not set by any SPS functions.
  115706. */
  115707. counter: number;
  115708. /**
  115709. * The SPS name. This name is also given to the underlying mesh.
  115710. */
  115711. name: string;
  115712. /**
  115713. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  115714. */
  115715. mesh: Mesh;
  115716. /**
  115717. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  115718. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  115719. */
  115720. vars: any;
  115721. /**
  115722. * This array is populated when the SPS is set as 'pickable'.
  115723. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  115724. * Each element of this array is an object `{idx: int, faceId: int}`.
  115725. * `idx` is the picked particle index in the `SPS.particles` array
  115726. * `faceId` is the picked face index counted within this particle.
  115727. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  115728. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  115729. * Use the method SPS.pickedParticle(pickingInfo) instead.
  115730. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115731. */
  115732. pickedParticles: {
  115733. idx: number;
  115734. faceId: number;
  115735. }[];
  115736. /**
  115737. * This array is populated when the SPS is set as 'pickable'
  115738. * Each key of this array is a submesh index.
  115739. * Each element of this array is a second array defined like this :
  115740. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  115741. * Each element of this second array is an object `{idx: int, faceId: int}`.
  115742. * `idx` is the picked particle index in the `SPS.particles` array
  115743. * `faceId` is the picked face index counted within this particle.
  115744. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  115745. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115746. */
  115747. pickedBySubMesh: {
  115748. idx: number;
  115749. faceId: number;
  115750. }[][];
  115751. /**
  115752. * This array is populated when `enableDepthSort` is set to true.
  115753. * Each element of this array is an instance of the class DepthSortedParticle.
  115754. */
  115755. depthSortedParticles: DepthSortedParticle[];
  115756. /**
  115757. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  115758. * @hidden
  115759. */
  115760. _bSphereOnly: boolean;
  115761. /**
  115762. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  115763. * @hidden
  115764. */
  115765. _bSphereRadiusFactor: number;
  115766. private _scene;
  115767. private _positions;
  115768. private _indices;
  115769. private _normals;
  115770. private _colors;
  115771. private _uvs;
  115772. private _indices32;
  115773. private _positions32;
  115774. private _normals32;
  115775. private _fixedNormal32;
  115776. private _colors32;
  115777. private _uvs32;
  115778. private _index;
  115779. private _updatable;
  115780. private _pickable;
  115781. private _isVisibilityBoxLocked;
  115782. private _alwaysVisible;
  115783. private _depthSort;
  115784. private _expandable;
  115785. private _shapeCounter;
  115786. private _copy;
  115787. private _color;
  115788. private _computeParticleColor;
  115789. private _computeParticleTexture;
  115790. private _computeParticleRotation;
  115791. private _computeParticleVertex;
  115792. private _computeBoundingBox;
  115793. private _depthSortParticles;
  115794. private _camera;
  115795. private _mustUnrotateFixedNormals;
  115796. private _particlesIntersect;
  115797. private _needs32Bits;
  115798. private _isNotBuilt;
  115799. private _lastParticleId;
  115800. private _idxOfId;
  115801. private _multimaterialEnabled;
  115802. private _useModelMaterial;
  115803. private _indicesByMaterial;
  115804. private _materialIndexes;
  115805. private _depthSortFunction;
  115806. private _materialSortFunction;
  115807. private _materials;
  115808. private _multimaterial;
  115809. private _materialIndexesById;
  115810. private _defaultMaterial;
  115811. private _autoUpdateSubMeshes;
  115812. private _tmpVertex;
  115813. /**
  115814. * Creates a SPS (Solid Particle System) object.
  115815. * @param name (String) is the SPS name, this will be the underlying mesh name.
  115816. * @param scene (Scene) is the scene in which the SPS is added.
  115817. * @param options defines the options of the sps e.g.
  115818. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  115819. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  115820. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  115821. * * 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.
  115822. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  115823. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  115824. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  115825. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  115826. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  115827. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  115828. */
  115829. constructor(name: string, scene: Scene, options?: {
  115830. updatable?: boolean;
  115831. isPickable?: boolean;
  115832. enableDepthSort?: boolean;
  115833. particleIntersection?: boolean;
  115834. boundingSphereOnly?: boolean;
  115835. bSphereRadiusFactor?: number;
  115836. expandable?: boolean;
  115837. useModelMaterial?: boolean;
  115838. enableMultiMaterial?: boolean;
  115839. });
  115840. /**
  115841. * Builds the SPS underlying mesh. Returns a standard Mesh.
  115842. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  115843. * @returns the created mesh
  115844. */
  115845. buildMesh(): Mesh;
  115846. /**
  115847. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  115848. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  115849. * Thus the particles generated from `digest()` have their property `position` set yet.
  115850. * @param mesh ( Mesh ) is the mesh to be digested
  115851. * @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
  115852. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  115853. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  115854. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115855. * @returns the current SPS
  115856. */
  115857. digest(mesh: Mesh, options?: {
  115858. facetNb?: number;
  115859. number?: number;
  115860. delta?: number;
  115861. storage?: [];
  115862. }): SolidParticleSystem;
  115863. /**
  115864. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  115865. * @hidden
  115866. */
  115867. private _unrotateFixedNormals;
  115868. /**
  115869. * Resets the temporary working copy particle
  115870. * @hidden
  115871. */
  115872. private _resetCopy;
  115873. /**
  115874. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  115875. * @param p the current index in the positions array to be updated
  115876. * @param ind the current index in the indices array
  115877. * @param shape a Vector3 array, the shape geometry
  115878. * @param positions the positions array to be updated
  115879. * @param meshInd the shape indices array
  115880. * @param indices the indices array to be updated
  115881. * @param meshUV the shape uv array
  115882. * @param uvs the uv array to be updated
  115883. * @param meshCol the shape color array
  115884. * @param colors the color array to be updated
  115885. * @param meshNor the shape normals array
  115886. * @param normals the normals array to be updated
  115887. * @param idx the particle index
  115888. * @param idxInShape the particle index in its shape
  115889. * @param options the addShape() method passed options
  115890. * @model the particle model
  115891. * @hidden
  115892. */
  115893. private _meshBuilder;
  115894. /**
  115895. * Returns a shape Vector3 array from positions float array
  115896. * @param positions float array
  115897. * @returns a vector3 array
  115898. * @hidden
  115899. */
  115900. private _posToShape;
  115901. /**
  115902. * Returns a shapeUV array from a float uvs (array deep copy)
  115903. * @param uvs as a float array
  115904. * @returns a shapeUV array
  115905. * @hidden
  115906. */
  115907. private _uvsToShapeUV;
  115908. /**
  115909. * Adds a new particle object in the particles array
  115910. * @param idx particle index in particles array
  115911. * @param id particle id
  115912. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  115913. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  115914. * @param model particle ModelShape object
  115915. * @param shapeId model shape identifier
  115916. * @param idxInShape index of the particle in the current model
  115917. * @param bInfo model bounding info object
  115918. * @param storage target storage array, if any
  115919. * @hidden
  115920. */
  115921. private _addParticle;
  115922. /**
  115923. * Adds some particles to the SPS from the model shape. Returns the shape id.
  115924. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  115925. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115926. * @param nb (positive integer) the number of particles to be created from this model
  115927. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115928. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115929. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115930. * @returns the number of shapes in the system
  115931. */
  115932. addShape(mesh: Mesh, nb: number, options?: {
  115933. positionFunction?: any;
  115934. vertexFunction?: any;
  115935. storage?: [];
  115936. }): number;
  115937. /**
  115938. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115939. * @hidden
  115940. */
  115941. private _rebuildParticle;
  115942. /**
  115943. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115944. * @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.
  115945. * @returns the SPS.
  115946. */
  115947. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115948. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115949. * Returns an array with the removed particles.
  115950. * 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.
  115951. * The SPS can't be empty so at least one particle needs to remain in place.
  115952. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115953. * @param start index of the first particle to remove
  115954. * @param end index of the last particle to remove (included)
  115955. * @returns an array populated with the removed particles
  115956. */
  115957. removeParticles(start: number, end: number): SolidParticle[];
  115958. /**
  115959. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115960. * @param solidParticleArray an array populated with Solid Particles objects
  115961. * @returns the SPS
  115962. */
  115963. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  115964. /**
  115965. * Creates a new particle and modifies the SPS mesh geometry :
  115966. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  115967. * - calls _addParticle() to populate the particle array
  115968. * factorized code from addShape() and insertParticlesFromArray()
  115969. * @param idx particle index in the particles array
  115970. * @param i particle index in its shape
  115971. * @param modelShape particle ModelShape object
  115972. * @param shape shape vertex array
  115973. * @param meshInd shape indices array
  115974. * @param meshUV shape uv array
  115975. * @param meshCol shape color array
  115976. * @param meshNor shape normals array
  115977. * @param bbInfo shape bounding info
  115978. * @param storage target particle storage
  115979. * @options addShape() passed options
  115980. * @hidden
  115981. */
  115982. private _insertNewParticle;
  115983. /**
  115984. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  115985. * This method calls `updateParticle()` for each particle of the SPS.
  115986. * For an animated SPS, it is usually called within the render loop.
  115987. * 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.
  115988. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  115989. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  115990. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  115991. * @returns the SPS.
  115992. */
  115993. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  115994. /**
  115995. * Disposes the SPS.
  115996. */
  115997. dispose(): void;
  115998. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  115999. * idx is the particle index in the SPS
  116000. * faceId is the picked face index counted within this particle.
  116001. * Returns null if the pickInfo can't identify a picked particle.
  116002. * @param pickingInfo (PickingInfo object)
  116003. * @returns {idx: number, faceId: number} or null
  116004. */
  116005. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  116006. idx: number;
  116007. faceId: number;
  116008. }>;
  116009. /**
  116010. * Returns a SolidParticle object from its identifier : particle.id
  116011. * @param id (integer) the particle Id
  116012. * @returns the searched particle or null if not found in the SPS.
  116013. */
  116014. getParticleById(id: number): Nullable<SolidParticle>;
  116015. /**
  116016. * Returns a new array populated with the particles having the passed shapeId.
  116017. * @param shapeId (integer) the shape identifier
  116018. * @returns a new solid particle array
  116019. */
  116020. getParticlesByShapeId(shapeId: number): SolidParticle[];
  116021. /**
  116022. * Populates the passed array "ref" with the particles having the passed shapeId.
  116023. * @param shapeId the shape identifier
  116024. * @returns the SPS
  116025. * @param ref
  116026. */
  116027. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  116028. /**
  116029. * Computes the required SubMeshes according the materials assigned to the particles.
  116030. * @returns the solid particle system.
  116031. * Does nothing if called before the SPS mesh is built.
  116032. */
  116033. computeSubMeshes(): SolidParticleSystem;
  116034. /**
  116035. * Sorts the solid particles by material when MultiMaterial is enabled.
  116036. * Updates the indices32 array.
  116037. * Updates the indicesByMaterial array.
  116038. * Updates the mesh indices array.
  116039. * @returns the SPS
  116040. * @hidden
  116041. */
  116042. private _sortParticlesByMaterial;
  116043. /**
  116044. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  116045. * @hidden
  116046. */
  116047. private _setMaterialIndexesById;
  116048. /**
  116049. * Returns an array with unique values of Materials from the passed array
  116050. * @param array the material array to be checked and filtered
  116051. * @hidden
  116052. */
  116053. private _filterUniqueMaterialId;
  116054. /**
  116055. * Sets a new Standard Material as _defaultMaterial if not already set.
  116056. * @hidden
  116057. */
  116058. private _setDefaultMaterial;
  116059. /**
  116060. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  116061. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116062. * @returns the SPS.
  116063. */
  116064. refreshVisibleSize(): SolidParticleSystem;
  116065. /**
  116066. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  116067. * @param size the size (float) of the visibility box
  116068. * note : this doesn't lock the SPS mesh bounding box.
  116069. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116070. */
  116071. setVisibilityBox(size: number): void;
  116072. /**
  116073. * Gets whether the SPS as always visible or not
  116074. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116075. */
  116076. get isAlwaysVisible(): boolean;
  116077. /**
  116078. * Sets the SPS as always visible or not
  116079. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116080. */
  116081. set isAlwaysVisible(val: boolean);
  116082. /**
  116083. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116084. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116085. */
  116086. set isVisibilityBoxLocked(val: boolean);
  116087. /**
  116088. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116089. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116090. */
  116091. get isVisibilityBoxLocked(): boolean;
  116092. /**
  116093. * Tells to `setParticles()` to compute the particle rotations or not.
  116094. * Default value : true. The SPS is faster when it's set to false.
  116095. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116096. */
  116097. set computeParticleRotation(val: boolean);
  116098. /**
  116099. * Tells to `setParticles()` to compute the particle colors or not.
  116100. * Default value : true. The SPS is faster when it's set to false.
  116101. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116102. */
  116103. set computeParticleColor(val: boolean);
  116104. set computeParticleTexture(val: boolean);
  116105. /**
  116106. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  116107. * Default value : false. The SPS is faster when it's set to false.
  116108. * Note : the particle custom vertex positions aren't stored values.
  116109. */
  116110. set computeParticleVertex(val: boolean);
  116111. /**
  116112. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  116113. */
  116114. set computeBoundingBox(val: boolean);
  116115. /**
  116116. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  116117. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116118. * Default : `true`
  116119. */
  116120. set depthSortParticles(val: boolean);
  116121. /**
  116122. * Gets if `setParticles()` computes the particle rotations or not.
  116123. * Default value : true. The SPS is faster when it's set to false.
  116124. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116125. */
  116126. get computeParticleRotation(): boolean;
  116127. /**
  116128. * Gets if `setParticles()` computes the particle colors or not.
  116129. * Default value : true. The SPS is faster when it's set to false.
  116130. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116131. */
  116132. get computeParticleColor(): boolean;
  116133. /**
  116134. * Gets if `setParticles()` computes the particle textures or not.
  116135. * Default value : true. The SPS is faster when it's set to false.
  116136. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  116137. */
  116138. get computeParticleTexture(): boolean;
  116139. /**
  116140. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  116141. * Default value : false. The SPS is faster when it's set to false.
  116142. * Note : the particle custom vertex positions aren't stored values.
  116143. */
  116144. get computeParticleVertex(): boolean;
  116145. /**
  116146. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  116147. */
  116148. get computeBoundingBox(): boolean;
  116149. /**
  116150. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  116151. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116152. * Default : `true`
  116153. */
  116154. get depthSortParticles(): boolean;
  116155. /**
  116156. * Gets if the SPS is created as expandable at construction time.
  116157. * Default : `false`
  116158. */
  116159. get expandable(): boolean;
  116160. /**
  116161. * Gets if the SPS supports the Multi Materials
  116162. */
  116163. get multimaterialEnabled(): boolean;
  116164. /**
  116165. * Gets if the SPS uses the model materials for its own multimaterial.
  116166. */
  116167. get useModelMaterial(): boolean;
  116168. /**
  116169. * The SPS used material array.
  116170. */
  116171. get materials(): Material[];
  116172. /**
  116173. * Sets the SPS MultiMaterial from the passed materials.
  116174. * Note : the passed array is internally copied and not used then by reference.
  116175. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  116176. */
  116177. setMultiMaterial(materials: Material[]): void;
  116178. /**
  116179. * The SPS computed multimaterial object
  116180. */
  116181. get multimaterial(): MultiMaterial;
  116182. set multimaterial(mm: MultiMaterial);
  116183. /**
  116184. * If the subMeshes must be updated on the next call to setParticles()
  116185. */
  116186. get autoUpdateSubMeshes(): boolean;
  116187. set autoUpdateSubMeshes(val: boolean);
  116188. /**
  116189. * This function does nothing. It may be overwritten to set all the particle first values.
  116190. * The SPS doesn't call this function, you may have to call it by your own.
  116191. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116192. */
  116193. initParticles(): void;
  116194. /**
  116195. * This function does nothing. It may be overwritten to recycle a particle.
  116196. * The SPS doesn't call this function, you may have to call it by your own.
  116197. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116198. * @param particle The particle to recycle
  116199. * @returns the recycled particle
  116200. */
  116201. recycleParticle(particle: SolidParticle): SolidParticle;
  116202. /**
  116203. * Updates a particle : this function should be overwritten by the user.
  116204. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  116205. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116206. * @example : just set a particle position or velocity and recycle conditions
  116207. * @param particle The particle to update
  116208. * @returns the updated particle
  116209. */
  116210. updateParticle(particle: SolidParticle): SolidParticle;
  116211. /**
  116212. * Updates a vertex of a particle : it can be overwritten by the user.
  116213. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  116214. * @param particle the current particle
  116215. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  116216. * @param pt the index of the current vertex in the particle shape
  116217. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  116218. * @example : just set a vertex particle position or color
  116219. * @returns the sps
  116220. */
  116221. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  116222. /**
  116223. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  116224. * This does nothing and may be overwritten by the user.
  116225. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116226. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116227. * @param update the boolean update value actually passed to setParticles()
  116228. */
  116229. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116230. /**
  116231. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  116232. * This will be passed three parameters.
  116233. * This does nothing and may be overwritten by the user.
  116234. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116235. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116236. * @param update the boolean update value actually passed to setParticles()
  116237. */
  116238. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116239. }
  116240. }
  116241. declare module BABYLON {
  116242. /**
  116243. * Represents one particle of a solid particle system.
  116244. */
  116245. export class SolidParticle {
  116246. /**
  116247. * particle global index
  116248. */
  116249. idx: number;
  116250. /**
  116251. * particle identifier
  116252. */
  116253. id: number;
  116254. /**
  116255. * The color of the particle
  116256. */
  116257. color: Nullable<Color4>;
  116258. /**
  116259. * The world space position of the particle.
  116260. */
  116261. position: Vector3;
  116262. /**
  116263. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  116264. */
  116265. rotation: Vector3;
  116266. /**
  116267. * The world space rotation quaternion of the particle.
  116268. */
  116269. rotationQuaternion: Nullable<Quaternion>;
  116270. /**
  116271. * The scaling of the particle.
  116272. */
  116273. scaling: Vector3;
  116274. /**
  116275. * The uvs of the particle.
  116276. */
  116277. uvs: Vector4;
  116278. /**
  116279. * The current speed of the particle.
  116280. */
  116281. velocity: Vector3;
  116282. /**
  116283. * The pivot point in the particle local space.
  116284. */
  116285. pivot: Vector3;
  116286. /**
  116287. * Must the particle be translated from its pivot point in its local space ?
  116288. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  116289. * Default : false
  116290. */
  116291. translateFromPivot: boolean;
  116292. /**
  116293. * Is the particle active or not ?
  116294. */
  116295. alive: boolean;
  116296. /**
  116297. * Is the particle visible or not ?
  116298. */
  116299. isVisible: boolean;
  116300. /**
  116301. * Index of this particle in the global "positions" array (Internal use)
  116302. * @hidden
  116303. */
  116304. _pos: number;
  116305. /**
  116306. * @hidden Index of this particle in the global "indices" array (Internal use)
  116307. */
  116308. _ind: number;
  116309. /**
  116310. * @hidden ModelShape of this particle (Internal use)
  116311. */
  116312. _model: ModelShape;
  116313. /**
  116314. * ModelShape id of this particle
  116315. */
  116316. shapeId: number;
  116317. /**
  116318. * Index of the particle in its shape id
  116319. */
  116320. idxInShape: number;
  116321. /**
  116322. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  116323. */
  116324. _modelBoundingInfo: BoundingInfo;
  116325. /**
  116326. * @hidden Particle BoundingInfo object (Internal use)
  116327. */
  116328. _boundingInfo: BoundingInfo;
  116329. /**
  116330. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  116331. */
  116332. _sps: SolidParticleSystem;
  116333. /**
  116334. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  116335. */
  116336. _stillInvisible: boolean;
  116337. /**
  116338. * @hidden Last computed particle rotation matrix
  116339. */
  116340. _rotationMatrix: number[];
  116341. /**
  116342. * Parent particle Id, if any.
  116343. * Default null.
  116344. */
  116345. parentId: Nullable<number>;
  116346. /**
  116347. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  116348. */
  116349. materialIndex: Nullable<number>;
  116350. /**
  116351. * Custom object or properties.
  116352. */
  116353. props: Nullable<any>;
  116354. /**
  116355. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  116356. * The possible values are :
  116357. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116358. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116359. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116360. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116361. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116362. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  116363. * */
  116364. cullingStrategy: number;
  116365. /**
  116366. * @hidden Internal global position in the SPS.
  116367. */
  116368. _globalPosition: Vector3;
  116369. /**
  116370. * Creates a Solid Particle object.
  116371. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  116372. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  116373. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  116374. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  116375. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  116376. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  116377. * @param shapeId (integer) is the model shape identifier in the SPS.
  116378. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  116379. * @param sps defines the sps it is associated to
  116380. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  116381. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  116382. */
  116383. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  116384. /**
  116385. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  116386. * @param target the particle target
  116387. * @returns the current particle
  116388. */
  116389. copyToRef(target: SolidParticle): SolidParticle;
  116390. /**
  116391. * Legacy support, changed scale to scaling
  116392. */
  116393. get scale(): Vector3;
  116394. /**
  116395. * Legacy support, changed scale to scaling
  116396. */
  116397. set scale(scale: Vector3);
  116398. /**
  116399. * Legacy support, changed quaternion to rotationQuaternion
  116400. */
  116401. get quaternion(): Nullable<Quaternion>;
  116402. /**
  116403. * Legacy support, changed quaternion to rotationQuaternion
  116404. */
  116405. set quaternion(q: Nullable<Quaternion>);
  116406. /**
  116407. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  116408. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  116409. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  116410. * @returns true if it intersects
  116411. */
  116412. intersectsMesh(target: Mesh | SolidParticle): boolean;
  116413. /**
  116414. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  116415. * A particle is in the frustum if its bounding box intersects the frustum
  116416. * @param frustumPlanes defines the frustum to test
  116417. * @returns true if the particle is in the frustum planes
  116418. */
  116419. isInFrustum(frustumPlanes: Plane[]): boolean;
  116420. /**
  116421. * get the rotation matrix of the particle
  116422. * @hidden
  116423. */
  116424. getRotationMatrix(m: Matrix): void;
  116425. }
  116426. /**
  116427. * Represents the shape of the model used by one particle of a solid particle system.
  116428. * SPS internal tool, don't use it manually.
  116429. */
  116430. export class ModelShape {
  116431. /**
  116432. * The shape id
  116433. * @hidden
  116434. */
  116435. shapeID: number;
  116436. /**
  116437. * flat array of model positions (internal use)
  116438. * @hidden
  116439. */
  116440. _shape: Vector3[];
  116441. /**
  116442. * flat array of model UVs (internal use)
  116443. * @hidden
  116444. */
  116445. _shapeUV: number[];
  116446. /**
  116447. * color array of the model
  116448. * @hidden
  116449. */
  116450. _shapeColors: number[];
  116451. /**
  116452. * indices array of the model
  116453. * @hidden
  116454. */
  116455. _indices: number[];
  116456. /**
  116457. * normals array of the model
  116458. * @hidden
  116459. */
  116460. _normals: number[];
  116461. /**
  116462. * length of the shape in the model indices array (internal use)
  116463. * @hidden
  116464. */
  116465. _indicesLength: number;
  116466. /**
  116467. * Custom position function (internal use)
  116468. * @hidden
  116469. */
  116470. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  116471. /**
  116472. * Custom vertex function (internal use)
  116473. * @hidden
  116474. */
  116475. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  116476. /**
  116477. * Model material (internal use)
  116478. * @hidden
  116479. */
  116480. _material: Nullable<Material>;
  116481. /**
  116482. * 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.
  116483. * SPS internal tool, don't use it manually.
  116484. * @hidden
  116485. */
  116486. 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>);
  116487. }
  116488. /**
  116489. * Represents a Depth Sorted Particle in the solid particle system.
  116490. * @hidden
  116491. */
  116492. export class DepthSortedParticle {
  116493. /**
  116494. * Particle index
  116495. */
  116496. idx: number;
  116497. /**
  116498. * Index of the particle in the "indices" array
  116499. */
  116500. ind: number;
  116501. /**
  116502. * Length of the particle shape in the "indices" array
  116503. */
  116504. indicesLength: number;
  116505. /**
  116506. * Squared distance from the particle to the camera
  116507. */
  116508. sqDistance: number;
  116509. /**
  116510. * Material index when used with MultiMaterials
  116511. */
  116512. materialIndex: number;
  116513. /**
  116514. * Creates a new sorted particle
  116515. * @param materialIndex
  116516. */
  116517. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  116518. }
  116519. /**
  116520. * Represents a solid particle vertex
  116521. */
  116522. export class SolidParticleVertex {
  116523. /**
  116524. * Vertex position
  116525. */
  116526. position: Vector3;
  116527. /**
  116528. * Vertex color
  116529. */
  116530. color: Color4;
  116531. /**
  116532. * Vertex UV
  116533. */
  116534. uv: Vector2;
  116535. /**
  116536. * Creates a new solid particle vertex
  116537. */
  116538. constructor();
  116539. /** Vertex x coordinate */
  116540. get x(): number;
  116541. set x(val: number);
  116542. /** Vertex y coordinate */
  116543. get y(): number;
  116544. set y(val: number);
  116545. /** Vertex z coordinate */
  116546. get z(): number;
  116547. set z(val: number);
  116548. }
  116549. }
  116550. declare module BABYLON {
  116551. /**
  116552. * @hidden
  116553. */
  116554. export class _MeshCollisionData {
  116555. _checkCollisions: boolean;
  116556. _collisionMask: number;
  116557. _collisionGroup: number;
  116558. _surroundingMeshes: Nullable<AbstractMesh[]>;
  116559. _collider: Nullable<Collider>;
  116560. _oldPositionForCollisions: Vector3;
  116561. _diffPositionForCollisions: Vector3;
  116562. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  116563. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  116564. _collisionResponse: boolean;
  116565. }
  116566. }
  116567. declare module BABYLON {
  116568. /** @hidden */
  116569. class _FacetDataStorage {
  116570. facetPositions: Vector3[];
  116571. facetNormals: Vector3[];
  116572. facetPartitioning: number[][];
  116573. facetNb: number;
  116574. partitioningSubdivisions: number;
  116575. partitioningBBoxRatio: number;
  116576. facetDataEnabled: boolean;
  116577. facetParameters: any;
  116578. bbSize: Vector3;
  116579. subDiv: {
  116580. max: number;
  116581. X: number;
  116582. Y: number;
  116583. Z: number;
  116584. };
  116585. facetDepthSort: boolean;
  116586. facetDepthSortEnabled: boolean;
  116587. depthSortedIndices: IndicesArray;
  116588. depthSortedFacets: {
  116589. ind: number;
  116590. sqDistance: number;
  116591. }[];
  116592. facetDepthSortFunction: (f1: {
  116593. ind: number;
  116594. sqDistance: number;
  116595. }, f2: {
  116596. ind: number;
  116597. sqDistance: number;
  116598. }) => number;
  116599. facetDepthSortFrom: Vector3;
  116600. facetDepthSortOrigin: Vector3;
  116601. invertedMatrix: Matrix;
  116602. }
  116603. /**
  116604. * @hidden
  116605. **/
  116606. class _InternalAbstractMeshDataInfo {
  116607. _hasVertexAlpha: boolean;
  116608. _useVertexColors: boolean;
  116609. _numBoneInfluencers: number;
  116610. _applyFog: boolean;
  116611. _receiveShadows: boolean;
  116612. _facetData: _FacetDataStorage;
  116613. _visibility: number;
  116614. _skeleton: Nullable<Skeleton>;
  116615. _layerMask: number;
  116616. _computeBonesUsingShaders: boolean;
  116617. _isActive: boolean;
  116618. _onlyForInstances: boolean;
  116619. _isActiveIntermediate: boolean;
  116620. _onlyForInstancesIntermediate: boolean;
  116621. _actAsRegularMesh: boolean;
  116622. _currentLOD: Nullable<AbstractMesh>;
  116623. _currentLODIsUpToDate: boolean;
  116624. }
  116625. /**
  116626. * Class used to store all common mesh properties
  116627. */
  116628. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  116629. /** No occlusion */
  116630. static OCCLUSION_TYPE_NONE: number;
  116631. /** Occlusion set to optimisitic */
  116632. static OCCLUSION_TYPE_OPTIMISTIC: number;
  116633. /** Occlusion set to strict */
  116634. static OCCLUSION_TYPE_STRICT: number;
  116635. /** Use an accurante occlusion algorithm */
  116636. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  116637. /** Use a conservative occlusion algorithm */
  116638. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  116639. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  116640. * Test order :
  116641. * Is the bounding sphere outside the frustum ?
  116642. * If not, are the bounding box vertices outside the frustum ?
  116643. * It not, then the cullable object is in the frustum.
  116644. */
  116645. static readonly CULLINGSTRATEGY_STANDARD: number;
  116646. /** Culling strategy : Bounding Sphere Only.
  116647. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  116648. * It's also less accurate than the standard because some not visible objects can still be selected.
  116649. * Test : is the bounding sphere outside the frustum ?
  116650. * If not, then the cullable object is in the frustum.
  116651. */
  116652. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  116653. /** Culling strategy : Optimistic Inclusion.
  116654. * This in an inclusion test first, then the standard exclusion test.
  116655. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  116656. * 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.
  116657. * Anyway, it's as accurate as the standard strategy.
  116658. * Test :
  116659. * Is the cullable object bounding sphere center in the frustum ?
  116660. * If not, apply the default culling strategy.
  116661. */
  116662. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  116663. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  116664. * This in an inclusion test first, then the bounding sphere only exclusion test.
  116665. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  116666. * 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.
  116667. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  116668. * Test :
  116669. * Is the cullable object bounding sphere center in the frustum ?
  116670. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  116671. */
  116672. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  116673. /**
  116674. * No billboard
  116675. */
  116676. static get BILLBOARDMODE_NONE(): number;
  116677. /** Billboard on X axis */
  116678. static get BILLBOARDMODE_X(): number;
  116679. /** Billboard on Y axis */
  116680. static get BILLBOARDMODE_Y(): number;
  116681. /** Billboard on Z axis */
  116682. static get BILLBOARDMODE_Z(): number;
  116683. /** Billboard on all axes */
  116684. static get BILLBOARDMODE_ALL(): number;
  116685. /** Billboard on using position instead of orientation */
  116686. static get BILLBOARDMODE_USE_POSITION(): number;
  116687. /** @hidden */
  116688. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  116689. /**
  116690. * The culling strategy to use to check whether the mesh must be rendered or not.
  116691. * This value can be changed at any time and will be used on the next render mesh selection.
  116692. * The possible values are :
  116693. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116694. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116695. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116696. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116697. * Please read each static variable documentation to get details about the culling process.
  116698. * */
  116699. cullingStrategy: number;
  116700. /**
  116701. * Gets the number of facets in the mesh
  116702. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116703. */
  116704. get facetNb(): number;
  116705. /**
  116706. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  116707. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116708. */
  116709. get partitioningSubdivisions(): number;
  116710. set partitioningSubdivisions(nb: number);
  116711. /**
  116712. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  116713. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  116714. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116715. */
  116716. get partitioningBBoxRatio(): number;
  116717. set partitioningBBoxRatio(ratio: number);
  116718. /**
  116719. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  116720. * Works only for updatable meshes.
  116721. * Doesn't work with multi-materials
  116722. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116723. */
  116724. get mustDepthSortFacets(): boolean;
  116725. set mustDepthSortFacets(sort: boolean);
  116726. /**
  116727. * The location (Vector3) where the facet depth sort must be computed from.
  116728. * By default, the active camera position.
  116729. * Used only when facet depth sort is enabled
  116730. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116731. */
  116732. get facetDepthSortFrom(): Vector3;
  116733. set facetDepthSortFrom(location: Vector3);
  116734. /**
  116735. * gets a boolean indicating if facetData is enabled
  116736. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116737. */
  116738. get isFacetDataEnabled(): boolean;
  116739. /** @hidden */
  116740. _updateNonUniformScalingState(value: boolean): boolean;
  116741. /**
  116742. * An event triggered when this mesh collides with another one
  116743. */
  116744. onCollideObservable: Observable<AbstractMesh>;
  116745. /** Set a function to call when this mesh collides with another one */
  116746. set onCollide(callback: () => void);
  116747. /**
  116748. * An event triggered when the collision's position changes
  116749. */
  116750. onCollisionPositionChangeObservable: Observable<Vector3>;
  116751. /** Set a function to call when the collision's position changes */
  116752. set onCollisionPositionChange(callback: () => void);
  116753. /**
  116754. * An event triggered when material is changed
  116755. */
  116756. onMaterialChangedObservable: Observable<AbstractMesh>;
  116757. /**
  116758. * Gets or sets the orientation for POV movement & rotation
  116759. */
  116760. definedFacingForward: boolean;
  116761. /** @hidden */
  116762. _occlusionQuery: Nullable<WebGLQuery>;
  116763. /** @hidden */
  116764. _renderingGroup: Nullable<RenderingGroup>;
  116765. /**
  116766. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116767. */
  116768. get visibility(): number;
  116769. /**
  116770. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116771. */
  116772. set visibility(value: number);
  116773. /** Gets or sets the alpha index used to sort transparent meshes
  116774. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  116775. */
  116776. alphaIndex: number;
  116777. /**
  116778. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  116779. */
  116780. isVisible: boolean;
  116781. /**
  116782. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  116783. */
  116784. isPickable: boolean;
  116785. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  116786. showSubMeshesBoundingBox: boolean;
  116787. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  116788. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116789. */
  116790. isBlocker: boolean;
  116791. /**
  116792. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  116793. */
  116794. enablePointerMoveEvents: boolean;
  116795. private _renderingGroupId;
  116796. /**
  116797. * Specifies the rendering group id for this mesh (0 by default)
  116798. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  116799. */
  116800. get renderingGroupId(): number;
  116801. set renderingGroupId(value: number);
  116802. private _material;
  116803. /** Gets or sets current material */
  116804. get material(): Nullable<Material>;
  116805. set material(value: Nullable<Material>);
  116806. /**
  116807. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  116808. * @see https://doc.babylonjs.com/babylon101/shadows
  116809. */
  116810. get receiveShadows(): boolean;
  116811. set receiveShadows(value: boolean);
  116812. /** Defines color to use when rendering outline */
  116813. outlineColor: Color3;
  116814. /** Define width to use when rendering outline */
  116815. outlineWidth: number;
  116816. /** Defines color to use when rendering overlay */
  116817. overlayColor: Color3;
  116818. /** Defines alpha to use when rendering overlay */
  116819. overlayAlpha: number;
  116820. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  116821. get hasVertexAlpha(): boolean;
  116822. set hasVertexAlpha(value: boolean);
  116823. /** 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) */
  116824. get useVertexColors(): boolean;
  116825. set useVertexColors(value: boolean);
  116826. /**
  116827. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  116828. */
  116829. get computeBonesUsingShaders(): boolean;
  116830. set computeBonesUsingShaders(value: boolean);
  116831. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  116832. get numBoneInfluencers(): number;
  116833. set numBoneInfluencers(value: number);
  116834. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  116835. get applyFog(): boolean;
  116836. set applyFog(value: boolean);
  116837. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  116838. useOctreeForRenderingSelection: boolean;
  116839. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  116840. useOctreeForPicking: boolean;
  116841. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  116842. useOctreeForCollisions: boolean;
  116843. /**
  116844. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  116845. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  116846. */
  116847. get layerMask(): number;
  116848. set layerMask(value: number);
  116849. /**
  116850. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  116851. */
  116852. alwaysSelectAsActiveMesh: boolean;
  116853. /**
  116854. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  116855. */
  116856. doNotSyncBoundingInfo: boolean;
  116857. /**
  116858. * Gets or sets the current action manager
  116859. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116860. */
  116861. actionManager: Nullable<AbstractActionManager>;
  116862. private _meshCollisionData;
  116863. /**
  116864. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  116865. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116866. */
  116867. ellipsoid: Vector3;
  116868. /**
  116869. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  116870. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116871. */
  116872. ellipsoidOffset: Vector3;
  116873. /**
  116874. * Gets or sets a collision mask used to mask collisions (default is -1).
  116875. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116876. */
  116877. get collisionMask(): number;
  116878. set collisionMask(mask: number);
  116879. /**
  116880. * Gets or sets a collision response flag (default is true).
  116881. * when collisionResponse is false, events are still triggered but colliding entity has no response
  116882. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  116883. * to respond to the collision.
  116884. */
  116885. get collisionResponse(): boolean;
  116886. set collisionResponse(response: boolean);
  116887. /**
  116888. * Gets or sets the current collision group mask (-1 by default).
  116889. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116890. */
  116891. get collisionGroup(): number;
  116892. set collisionGroup(mask: number);
  116893. /**
  116894. * Gets or sets current surrounding meshes (null by default).
  116895. *
  116896. * By default collision detection is tested against every mesh in the scene.
  116897. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  116898. * meshes will be tested for the collision.
  116899. *
  116900. * Note: if set to an empty array no collision will happen when this mesh is moved.
  116901. */
  116902. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  116903. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  116904. /**
  116905. * Defines edge width used when edgesRenderer is enabled
  116906. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116907. */
  116908. edgesWidth: number;
  116909. /**
  116910. * Defines edge color used when edgesRenderer is enabled
  116911. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116912. */
  116913. edgesColor: Color4;
  116914. /** @hidden */
  116915. _edgesRenderer: Nullable<IEdgesRenderer>;
  116916. /** @hidden */
  116917. _masterMesh: Nullable<AbstractMesh>;
  116918. /** @hidden */
  116919. _boundingInfo: Nullable<BoundingInfo>;
  116920. /** @hidden */
  116921. _renderId: number;
  116922. /**
  116923. * Gets or sets the list of subMeshes
  116924. * @see https://doc.babylonjs.com/how_to/multi_materials
  116925. */
  116926. subMeshes: SubMesh[];
  116927. /** @hidden */
  116928. _intersectionsInProgress: AbstractMesh[];
  116929. /** @hidden */
  116930. _unIndexed: boolean;
  116931. /** @hidden */
  116932. _lightSources: Light[];
  116933. /** Gets the list of lights affecting that mesh */
  116934. get lightSources(): Light[];
  116935. /** @hidden */
  116936. get _positions(): Nullable<Vector3[]>;
  116937. /** @hidden */
  116938. _waitingData: {
  116939. lods: Nullable<any>;
  116940. actions: Nullable<any>;
  116941. freezeWorldMatrix: Nullable<boolean>;
  116942. };
  116943. /** @hidden */
  116944. _bonesTransformMatrices: Nullable<Float32Array>;
  116945. /** @hidden */
  116946. _transformMatrixTexture: Nullable<RawTexture>;
  116947. /**
  116948. * Gets or sets a skeleton to apply skining transformations
  116949. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116950. */
  116951. set skeleton(value: Nullable<Skeleton>);
  116952. get skeleton(): Nullable<Skeleton>;
  116953. /**
  116954. * An event triggered when the mesh is rebuilt.
  116955. */
  116956. onRebuildObservable: Observable<AbstractMesh>;
  116957. /**
  116958. * Creates a new AbstractMesh
  116959. * @param name defines the name of the mesh
  116960. * @param scene defines the hosting scene
  116961. */
  116962. constructor(name: string, scene?: Nullable<Scene>);
  116963. /**
  116964. * Returns the string "AbstractMesh"
  116965. * @returns "AbstractMesh"
  116966. */
  116967. getClassName(): string;
  116968. /**
  116969. * Gets a string representation of the current mesh
  116970. * @param fullDetails defines a boolean indicating if full details must be included
  116971. * @returns a string representation of the current mesh
  116972. */
  116973. toString(fullDetails?: boolean): string;
  116974. /**
  116975. * @hidden
  116976. */
  116977. protected _getEffectiveParent(): Nullable<Node>;
  116978. /** @hidden */
  116979. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116980. /** @hidden */
  116981. _rebuild(): void;
  116982. /** @hidden */
  116983. _resyncLightSources(): void;
  116984. /** @hidden */
  116985. _resyncLightSource(light: Light): void;
  116986. /** @hidden */
  116987. _unBindEffect(): void;
  116988. /** @hidden */
  116989. _removeLightSource(light: Light, dispose: boolean): void;
  116990. private _markSubMeshesAsDirty;
  116991. /** @hidden */
  116992. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  116993. /** @hidden */
  116994. _markSubMeshesAsAttributesDirty(): void;
  116995. /** @hidden */
  116996. _markSubMeshesAsMiscDirty(): void;
  116997. /**
  116998. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  116999. */
  117000. get scaling(): Vector3;
  117001. set scaling(newScaling: Vector3);
  117002. /**
  117003. * Returns true if the mesh is blocked. Implemented by child classes
  117004. */
  117005. get isBlocked(): boolean;
  117006. /**
  117007. * Returns the mesh itself by default. Implemented by child classes
  117008. * @param camera defines the camera to use to pick the right LOD level
  117009. * @returns the currentAbstractMesh
  117010. */
  117011. getLOD(camera: Camera): Nullable<AbstractMesh>;
  117012. /**
  117013. * Returns 0 by default. Implemented by child classes
  117014. * @returns an integer
  117015. */
  117016. getTotalVertices(): number;
  117017. /**
  117018. * Returns a positive integer : the total number of indices in this mesh geometry.
  117019. * @returns the numner of indices or zero if the mesh has no geometry.
  117020. */
  117021. getTotalIndices(): number;
  117022. /**
  117023. * Returns null by default. Implemented by child classes
  117024. * @returns null
  117025. */
  117026. getIndices(): Nullable<IndicesArray>;
  117027. /**
  117028. * Returns the array of the requested vertex data kind. Implemented by child classes
  117029. * @param kind defines the vertex data kind to use
  117030. * @returns null
  117031. */
  117032. getVerticesData(kind: string): Nullable<FloatArray>;
  117033. /**
  117034. * Sets the vertex data of the mesh geometry for the requested `kind`.
  117035. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  117036. * Note that a new underlying VertexBuffer object is created each call.
  117037. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  117038. * @param kind defines vertex data kind:
  117039. * * VertexBuffer.PositionKind
  117040. * * VertexBuffer.UVKind
  117041. * * VertexBuffer.UV2Kind
  117042. * * VertexBuffer.UV3Kind
  117043. * * VertexBuffer.UV4Kind
  117044. * * VertexBuffer.UV5Kind
  117045. * * VertexBuffer.UV6Kind
  117046. * * VertexBuffer.ColorKind
  117047. * * VertexBuffer.MatricesIndicesKind
  117048. * * VertexBuffer.MatricesIndicesExtraKind
  117049. * * VertexBuffer.MatricesWeightsKind
  117050. * * VertexBuffer.MatricesWeightsExtraKind
  117051. * @param data defines the data source
  117052. * @param updatable defines if the data must be flagged as updatable (or static)
  117053. * @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
  117054. * @returns the current mesh
  117055. */
  117056. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  117057. /**
  117058. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  117059. * If the mesh has no geometry, it is simply returned as it is.
  117060. * @param kind defines vertex data kind:
  117061. * * VertexBuffer.PositionKind
  117062. * * VertexBuffer.UVKind
  117063. * * VertexBuffer.UV2Kind
  117064. * * VertexBuffer.UV3Kind
  117065. * * VertexBuffer.UV4Kind
  117066. * * VertexBuffer.UV5Kind
  117067. * * VertexBuffer.UV6Kind
  117068. * * VertexBuffer.ColorKind
  117069. * * VertexBuffer.MatricesIndicesKind
  117070. * * VertexBuffer.MatricesIndicesExtraKind
  117071. * * VertexBuffer.MatricesWeightsKind
  117072. * * VertexBuffer.MatricesWeightsExtraKind
  117073. * @param data defines the data source
  117074. * @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
  117075. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  117076. * @returns the current mesh
  117077. */
  117078. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  117079. /**
  117080. * Sets the mesh indices,
  117081. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  117082. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  117083. * @param totalVertices Defines the total number of vertices
  117084. * @returns the current mesh
  117085. */
  117086. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  117087. /**
  117088. * Gets a boolean indicating if specific vertex data is present
  117089. * @param kind defines the vertex data kind to use
  117090. * @returns true is data kind is present
  117091. */
  117092. isVerticesDataPresent(kind: string): boolean;
  117093. /**
  117094. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  117095. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  117096. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  117097. * @returns a BoundingInfo
  117098. */
  117099. getBoundingInfo(): BoundingInfo;
  117100. /**
  117101. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  117102. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  117103. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  117104. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  117105. * @returns the current mesh
  117106. */
  117107. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  117108. /**
  117109. * Overwrite the current bounding info
  117110. * @param boundingInfo defines the new bounding info
  117111. * @returns the current mesh
  117112. */
  117113. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  117114. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  117115. get useBones(): boolean;
  117116. /** @hidden */
  117117. _preActivate(): void;
  117118. /** @hidden */
  117119. _preActivateForIntermediateRendering(renderId: number): void;
  117120. /** @hidden */
  117121. _activate(renderId: number, intermediateRendering: boolean): boolean;
  117122. /** @hidden */
  117123. _postActivate(): void;
  117124. /** @hidden */
  117125. _freeze(): void;
  117126. /** @hidden */
  117127. _unFreeze(): void;
  117128. /**
  117129. * Gets the current world matrix
  117130. * @returns a Matrix
  117131. */
  117132. getWorldMatrix(): Matrix;
  117133. /** @hidden */
  117134. _getWorldMatrixDeterminant(): number;
  117135. /**
  117136. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  117137. */
  117138. get isAnInstance(): boolean;
  117139. /**
  117140. * Gets a boolean indicating if this mesh has instances
  117141. */
  117142. get hasInstances(): boolean;
  117143. /**
  117144. * Gets a boolean indicating if this mesh has thin instances
  117145. */
  117146. get hasThinInstances(): boolean;
  117147. /**
  117148. * Perform relative position change from the point of view of behind the front of the mesh.
  117149. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117150. * Supports definition of mesh facing forward or backward
  117151. * @param amountRight defines the distance on the right axis
  117152. * @param amountUp defines the distance on the up axis
  117153. * @param amountForward defines the distance on the forward axis
  117154. * @returns the current mesh
  117155. */
  117156. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  117157. /**
  117158. * Calculate relative position change from the point of view of behind the front of the mesh.
  117159. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117160. * Supports definition of mesh facing forward or backward
  117161. * @param amountRight defines the distance on the right axis
  117162. * @param amountUp defines the distance on the up axis
  117163. * @param amountForward defines the distance on the forward axis
  117164. * @returns the new displacement vector
  117165. */
  117166. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  117167. /**
  117168. * Perform relative rotation change from the point of view of behind the front of the mesh.
  117169. * Supports definition of mesh facing forward or backward
  117170. * @param flipBack defines the flip
  117171. * @param twirlClockwise defines the twirl
  117172. * @param tiltRight defines the tilt
  117173. * @returns the current mesh
  117174. */
  117175. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  117176. /**
  117177. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  117178. * Supports definition of mesh facing forward or backward.
  117179. * @param flipBack defines the flip
  117180. * @param twirlClockwise defines the twirl
  117181. * @param tiltRight defines the tilt
  117182. * @returns the new rotation vector
  117183. */
  117184. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  117185. /**
  117186. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  117187. * This means the mesh underlying bounding box and sphere are recomputed.
  117188. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  117189. * @returns the current mesh
  117190. */
  117191. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  117192. /** @hidden */
  117193. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  117194. /** @hidden */
  117195. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  117196. /** @hidden */
  117197. _updateBoundingInfo(): AbstractMesh;
  117198. /** @hidden */
  117199. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  117200. /** @hidden */
  117201. protected _afterComputeWorldMatrix(): void;
  117202. /** @hidden */
  117203. get _effectiveMesh(): AbstractMesh;
  117204. /**
  117205. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  117206. * A mesh is in the frustum if its bounding box intersects the frustum
  117207. * @param frustumPlanes defines the frustum to test
  117208. * @returns true if the mesh is in the frustum planes
  117209. */
  117210. isInFrustum(frustumPlanes: Plane[]): boolean;
  117211. /**
  117212. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  117213. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  117214. * @param frustumPlanes defines the frustum to test
  117215. * @returns true if the mesh is completely in the frustum planes
  117216. */
  117217. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  117218. /**
  117219. * True if the mesh intersects another mesh or a SolidParticle object
  117220. * @param mesh defines a target mesh or SolidParticle to test
  117221. * @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)
  117222. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  117223. * @returns true if there is an intersection
  117224. */
  117225. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  117226. /**
  117227. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  117228. * @param point defines the point to test
  117229. * @returns true if there is an intersection
  117230. */
  117231. intersectsPoint(point: Vector3): boolean;
  117232. /**
  117233. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  117234. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117235. */
  117236. get checkCollisions(): boolean;
  117237. set checkCollisions(collisionEnabled: boolean);
  117238. /**
  117239. * Gets Collider object used to compute collisions (not physics)
  117240. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117241. */
  117242. get collider(): Nullable<Collider>;
  117243. /**
  117244. * Move the mesh using collision engine
  117245. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117246. * @param displacement defines the requested displacement vector
  117247. * @returns the current mesh
  117248. */
  117249. moveWithCollisions(displacement: Vector3): AbstractMesh;
  117250. private _onCollisionPositionChange;
  117251. /** @hidden */
  117252. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  117253. /** @hidden */
  117254. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  117255. /** @hidden */
  117256. _checkCollision(collider: Collider): AbstractMesh;
  117257. /** @hidden */
  117258. _generatePointsArray(): boolean;
  117259. /**
  117260. * Checks if the passed Ray intersects with the mesh
  117261. * @param ray defines the ray to use
  117262. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  117263. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117264. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  117265. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  117266. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  117267. * @returns the picking info
  117268. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  117269. */
  117270. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  117271. /**
  117272. * Clones the current mesh
  117273. * @param name defines the mesh name
  117274. * @param newParent defines the new mesh parent
  117275. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  117276. * @returns the new mesh
  117277. */
  117278. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  117279. /**
  117280. * Disposes all the submeshes of the current meshnp
  117281. * @returns the current mesh
  117282. */
  117283. releaseSubMeshes(): AbstractMesh;
  117284. /**
  117285. * Releases resources associated with this abstract mesh.
  117286. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117287. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117288. */
  117289. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117290. /**
  117291. * Adds the passed mesh as a child to the current mesh
  117292. * @param mesh defines the child mesh
  117293. * @returns the current mesh
  117294. */
  117295. addChild(mesh: AbstractMesh): AbstractMesh;
  117296. /**
  117297. * Removes the passed mesh from the current mesh children list
  117298. * @param mesh defines the child mesh
  117299. * @returns the current mesh
  117300. */
  117301. removeChild(mesh: AbstractMesh): AbstractMesh;
  117302. /** @hidden */
  117303. private _initFacetData;
  117304. /**
  117305. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  117306. * This method can be called within the render loop.
  117307. * 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
  117308. * @returns the current mesh
  117309. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117310. */
  117311. updateFacetData(): AbstractMesh;
  117312. /**
  117313. * Returns the facetLocalNormals array.
  117314. * The normals are expressed in the mesh local spac
  117315. * @returns an array of Vector3
  117316. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117317. */
  117318. getFacetLocalNormals(): Vector3[];
  117319. /**
  117320. * Returns the facetLocalPositions array.
  117321. * The facet positions are expressed in the mesh local space
  117322. * @returns an array of Vector3
  117323. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117324. */
  117325. getFacetLocalPositions(): Vector3[];
  117326. /**
  117327. * Returns the facetLocalPartioning array
  117328. * @returns an array of array of numbers
  117329. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117330. */
  117331. getFacetLocalPartitioning(): number[][];
  117332. /**
  117333. * Returns the i-th facet position in the world system.
  117334. * This method allocates a new Vector3 per call
  117335. * @param i defines the facet index
  117336. * @returns a new Vector3
  117337. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117338. */
  117339. getFacetPosition(i: number): Vector3;
  117340. /**
  117341. * Sets the reference Vector3 with the i-th facet position in the world system
  117342. * @param i defines the facet index
  117343. * @param ref defines the target vector
  117344. * @returns the current mesh
  117345. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117346. */
  117347. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  117348. /**
  117349. * Returns the i-th facet normal in the world system.
  117350. * This method allocates a new Vector3 per call
  117351. * @param i defines the facet index
  117352. * @returns a new Vector3
  117353. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117354. */
  117355. getFacetNormal(i: number): Vector3;
  117356. /**
  117357. * Sets the reference Vector3 with the i-th facet normal in the world system
  117358. * @param i defines the facet index
  117359. * @param ref defines the target vector
  117360. * @returns the current mesh
  117361. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117362. */
  117363. getFacetNormalToRef(i: number, ref: Vector3): this;
  117364. /**
  117365. * 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)
  117366. * @param x defines x coordinate
  117367. * @param y defines y coordinate
  117368. * @param z defines z coordinate
  117369. * @returns the array of facet indexes
  117370. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117371. */
  117372. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  117373. /**
  117374. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  117375. * @param projected sets as the (x,y,z) world projection on the facet
  117376. * @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
  117377. * @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
  117378. * @param x defines x coordinate
  117379. * @param y defines y coordinate
  117380. * @param z defines z coordinate
  117381. * @returns the face index if found (or null instead)
  117382. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117383. */
  117384. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117385. /**
  117386. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  117387. * @param projected sets as the (x,y,z) local projection on the facet
  117388. * @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
  117389. * @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
  117390. * @param x defines x coordinate
  117391. * @param y defines y coordinate
  117392. * @param z defines z coordinate
  117393. * @returns the face index if found (or null instead)
  117394. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117395. */
  117396. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117397. /**
  117398. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  117399. * @returns the parameters
  117400. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117401. */
  117402. getFacetDataParameters(): any;
  117403. /**
  117404. * Disables the feature FacetData and frees the related memory
  117405. * @returns the current mesh
  117406. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117407. */
  117408. disableFacetData(): AbstractMesh;
  117409. /**
  117410. * Updates the AbstractMesh indices array
  117411. * @param indices defines the data source
  117412. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  117413. * @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)
  117414. * @returns the current mesh
  117415. */
  117416. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  117417. /**
  117418. * Creates new normals data for the mesh
  117419. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  117420. * @returns the current mesh
  117421. */
  117422. createNormals(updatable: boolean): AbstractMesh;
  117423. /**
  117424. * Align the mesh with a normal
  117425. * @param normal defines the normal to use
  117426. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  117427. * @returns the current mesh
  117428. */
  117429. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  117430. /** @hidden */
  117431. _checkOcclusionQuery(): boolean;
  117432. /**
  117433. * Disables the mesh edge rendering mode
  117434. * @returns the currentAbstractMesh
  117435. */
  117436. disableEdgesRendering(): AbstractMesh;
  117437. /**
  117438. * Enables the edge rendering mode on the mesh.
  117439. * This mode makes the mesh edges visible
  117440. * @param epsilon defines the maximal distance between two angles to detect a face
  117441. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  117442. * @param options options to the edge renderer
  117443. * @returns the currentAbstractMesh
  117444. * @see https://www.babylonjs-playground.com/#19O9TU#0
  117445. */
  117446. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  117447. /**
  117448. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  117449. * @returns an array of particle systems in the scene that use the mesh as an emitter
  117450. */
  117451. getConnectedParticleSystems(): IParticleSystem[];
  117452. }
  117453. }
  117454. declare module BABYLON {
  117455. /**
  117456. * Interface used to define ActionEvent
  117457. */
  117458. export interface IActionEvent {
  117459. /** The mesh or sprite that triggered the action */
  117460. source: any;
  117461. /** The X mouse cursor position at the time of the event */
  117462. pointerX: number;
  117463. /** The Y mouse cursor position at the time of the event */
  117464. pointerY: number;
  117465. /** The mesh that is currently pointed at (can be null) */
  117466. meshUnderPointer: Nullable<AbstractMesh>;
  117467. /** the original (browser) event that triggered the ActionEvent */
  117468. sourceEvent?: any;
  117469. /** additional data for the event */
  117470. additionalData?: any;
  117471. }
  117472. /**
  117473. * ActionEvent is the event being sent when an action is triggered.
  117474. */
  117475. export class ActionEvent implements IActionEvent {
  117476. /** The mesh or sprite that triggered the action */
  117477. source: any;
  117478. /** The X mouse cursor position at the time of the event */
  117479. pointerX: number;
  117480. /** The Y mouse cursor position at the time of the event */
  117481. pointerY: number;
  117482. /** The mesh that is currently pointed at (can be null) */
  117483. meshUnderPointer: Nullable<AbstractMesh>;
  117484. /** the original (browser) event that triggered the ActionEvent */
  117485. sourceEvent?: any;
  117486. /** additional data for the event */
  117487. additionalData?: any;
  117488. /**
  117489. * Creates a new ActionEvent
  117490. * @param source The mesh or sprite that triggered the action
  117491. * @param pointerX The X mouse cursor position at the time of the event
  117492. * @param pointerY The Y mouse cursor position at the time of the event
  117493. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  117494. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  117495. * @param additionalData additional data for the event
  117496. */
  117497. constructor(
  117498. /** The mesh or sprite that triggered the action */
  117499. source: any,
  117500. /** The X mouse cursor position at the time of the event */
  117501. pointerX: number,
  117502. /** The Y mouse cursor position at the time of the event */
  117503. pointerY: number,
  117504. /** The mesh that is currently pointed at (can be null) */
  117505. meshUnderPointer: Nullable<AbstractMesh>,
  117506. /** the original (browser) event that triggered the ActionEvent */
  117507. sourceEvent?: any,
  117508. /** additional data for the event */
  117509. additionalData?: any);
  117510. /**
  117511. * Helper function to auto-create an ActionEvent from a source mesh.
  117512. * @param source The source mesh that triggered the event
  117513. * @param evt The original (browser) event
  117514. * @param additionalData additional data for the event
  117515. * @returns the new ActionEvent
  117516. */
  117517. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  117518. /**
  117519. * Helper function to auto-create an ActionEvent from a source sprite
  117520. * @param source The source sprite that triggered the event
  117521. * @param scene Scene associated with the sprite
  117522. * @param evt The original (browser) event
  117523. * @param additionalData additional data for the event
  117524. * @returns the new ActionEvent
  117525. */
  117526. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  117527. /**
  117528. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  117529. * @param scene the scene where the event occurred
  117530. * @param evt The original (browser) event
  117531. * @returns the new ActionEvent
  117532. */
  117533. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  117534. /**
  117535. * Helper function to auto-create an ActionEvent from a primitive
  117536. * @param prim defines the target primitive
  117537. * @param pointerPos defines the pointer position
  117538. * @param evt The original (browser) event
  117539. * @param additionalData additional data for the event
  117540. * @returns the new ActionEvent
  117541. */
  117542. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  117543. }
  117544. }
  117545. declare module BABYLON {
  117546. /**
  117547. * Abstract class used to decouple action Manager from scene and meshes.
  117548. * Do not instantiate.
  117549. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117550. */
  117551. export abstract class AbstractActionManager implements IDisposable {
  117552. /** Gets the list of active triggers */
  117553. static Triggers: {
  117554. [key: string]: number;
  117555. };
  117556. /** Gets the cursor to use when hovering items */
  117557. hoverCursor: string;
  117558. /** Gets the list of actions */
  117559. actions: IAction[];
  117560. /**
  117561. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  117562. */
  117563. isRecursive: boolean;
  117564. /**
  117565. * Releases all associated resources
  117566. */
  117567. abstract dispose(): void;
  117568. /**
  117569. * Does this action manager has pointer triggers
  117570. */
  117571. abstract get hasPointerTriggers(): boolean;
  117572. /**
  117573. * Does this action manager has pick triggers
  117574. */
  117575. abstract get hasPickTriggers(): boolean;
  117576. /**
  117577. * Process a specific trigger
  117578. * @param trigger defines the trigger to process
  117579. * @param evt defines the event details to be processed
  117580. */
  117581. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  117582. /**
  117583. * Does this action manager handles actions of any of the given triggers
  117584. * @param triggers defines the triggers to be tested
  117585. * @return a boolean indicating whether one (or more) of the triggers is handled
  117586. */
  117587. abstract hasSpecificTriggers(triggers: number[]): boolean;
  117588. /**
  117589. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  117590. * speed.
  117591. * @param triggerA defines the trigger to be tested
  117592. * @param triggerB defines the trigger to be tested
  117593. * @return a boolean indicating whether one (or more) of the triggers is handled
  117594. */
  117595. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  117596. /**
  117597. * Does this action manager handles actions of a given trigger
  117598. * @param trigger defines the trigger to be tested
  117599. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  117600. * @return whether the trigger is handled
  117601. */
  117602. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  117603. /**
  117604. * Serialize this manager to a JSON object
  117605. * @param name defines the property name to store this manager
  117606. * @returns a JSON representation of this manager
  117607. */
  117608. abstract serialize(name: string): any;
  117609. /**
  117610. * Registers an action to this action manager
  117611. * @param action defines the action to be registered
  117612. * @return the action amended (prepared) after registration
  117613. */
  117614. abstract registerAction(action: IAction): Nullable<IAction>;
  117615. /**
  117616. * Unregisters an action to this action manager
  117617. * @param action defines the action to be unregistered
  117618. * @return a boolean indicating whether the action has been unregistered
  117619. */
  117620. abstract unregisterAction(action: IAction): Boolean;
  117621. /**
  117622. * Does exist one action manager with at least one trigger
  117623. **/
  117624. static get HasTriggers(): boolean;
  117625. /**
  117626. * Does exist one action manager with at least one pick trigger
  117627. **/
  117628. static get HasPickTriggers(): boolean;
  117629. /**
  117630. * Does exist one action manager that handles actions of a given trigger
  117631. * @param trigger defines the trigger to be tested
  117632. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  117633. **/
  117634. static HasSpecificTrigger(trigger: number): boolean;
  117635. }
  117636. }
  117637. declare module BABYLON {
  117638. /**
  117639. * Defines how a node can be built from a string name.
  117640. */
  117641. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  117642. /**
  117643. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  117644. */
  117645. export class Node implements IBehaviorAware<Node> {
  117646. /** @hidden */
  117647. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  117648. private static _NodeConstructors;
  117649. /**
  117650. * Add a new node constructor
  117651. * @param type defines the type name of the node to construct
  117652. * @param constructorFunc defines the constructor function
  117653. */
  117654. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  117655. /**
  117656. * Returns a node constructor based on type name
  117657. * @param type defines the type name
  117658. * @param name defines the new node name
  117659. * @param scene defines the hosting scene
  117660. * @param options defines optional options to transmit to constructors
  117661. * @returns the new constructor or null
  117662. */
  117663. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  117664. /**
  117665. * Gets or sets the name of the node
  117666. */
  117667. name: string;
  117668. /**
  117669. * Gets or sets the id of the node
  117670. */
  117671. id: string;
  117672. /**
  117673. * Gets or sets the unique id of the node
  117674. */
  117675. uniqueId: number;
  117676. /**
  117677. * Gets or sets a string used to store user defined state for the node
  117678. */
  117679. state: string;
  117680. /**
  117681. * Gets or sets an object used to store user defined information for the node
  117682. */
  117683. metadata: any;
  117684. /**
  117685. * For internal use only. Please do not use.
  117686. */
  117687. reservedDataStore: any;
  117688. /**
  117689. * List of inspectable custom properties (used by the Inspector)
  117690. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117691. */
  117692. inspectableCustomProperties: IInspectable[];
  117693. private _doNotSerialize;
  117694. /**
  117695. * Gets or sets a boolean used to define if the node must be serialized
  117696. */
  117697. get doNotSerialize(): boolean;
  117698. set doNotSerialize(value: boolean);
  117699. /** @hidden */
  117700. _isDisposed: boolean;
  117701. /**
  117702. * Gets a list of Animations associated with the node
  117703. */
  117704. animations: Animation[];
  117705. protected _ranges: {
  117706. [name: string]: Nullable<AnimationRange>;
  117707. };
  117708. /**
  117709. * Callback raised when the node is ready to be used
  117710. */
  117711. onReady: Nullable<(node: Node) => void>;
  117712. private _isEnabled;
  117713. private _isParentEnabled;
  117714. private _isReady;
  117715. /** @hidden */
  117716. _currentRenderId: number;
  117717. private _parentUpdateId;
  117718. /** @hidden */
  117719. _childUpdateId: number;
  117720. /** @hidden */
  117721. _waitingParentId: Nullable<string>;
  117722. /** @hidden */
  117723. _scene: Scene;
  117724. /** @hidden */
  117725. _cache: any;
  117726. private _parentNode;
  117727. private _children;
  117728. /** @hidden */
  117729. _worldMatrix: Matrix;
  117730. /** @hidden */
  117731. _worldMatrixDeterminant: number;
  117732. /** @hidden */
  117733. _worldMatrixDeterminantIsDirty: boolean;
  117734. /** @hidden */
  117735. private _sceneRootNodesIndex;
  117736. /**
  117737. * Gets a boolean indicating if the node has been disposed
  117738. * @returns true if the node was disposed
  117739. */
  117740. isDisposed(): boolean;
  117741. /**
  117742. * Gets or sets the parent of the node (without keeping the current position in the scene)
  117743. * @see https://doc.babylonjs.com/how_to/parenting
  117744. */
  117745. set parent(parent: Nullable<Node>);
  117746. get parent(): Nullable<Node>;
  117747. /** @hidden */
  117748. _addToSceneRootNodes(): void;
  117749. /** @hidden */
  117750. _removeFromSceneRootNodes(): void;
  117751. private _animationPropertiesOverride;
  117752. /**
  117753. * Gets or sets the animation properties override
  117754. */
  117755. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117756. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117757. /**
  117758. * Gets a string identifying the name of the class
  117759. * @returns "Node" string
  117760. */
  117761. getClassName(): string;
  117762. /** @hidden */
  117763. readonly _isNode: boolean;
  117764. /**
  117765. * An event triggered when the mesh is disposed
  117766. */
  117767. onDisposeObservable: Observable<Node>;
  117768. private _onDisposeObserver;
  117769. /**
  117770. * Sets a callback that will be raised when the node will be disposed
  117771. */
  117772. set onDispose(callback: () => void);
  117773. /**
  117774. * Creates a new Node
  117775. * @param name the name and id to be given to this node
  117776. * @param scene the scene this node will be added to
  117777. */
  117778. constructor(name: string, scene?: Nullable<Scene>);
  117779. /**
  117780. * Gets the scene of the node
  117781. * @returns a scene
  117782. */
  117783. getScene(): Scene;
  117784. /**
  117785. * Gets the engine of the node
  117786. * @returns a Engine
  117787. */
  117788. getEngine(): Engine;
  117789. private _behaviors;
  117790. /**
  117791. * Attach a behavior to the node
  117792. * @see https://doc.babylonjs.com/features/behaviour
  117793. * @param behavior defines the behavior to attach
  117794. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  117795. * @returns the current Node
  117796. */
  117797. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  117798. /**
  117799. * Remove an attached behavior
  117800. * @see https://doc.babylonjs.com/features/behaviour
  117801. * @param behavior defines the behavior to attach
  117802. * @returns the current Node
  117803. */
  117804. removeBehavior(behavior: Behavior<Node>): Node;
  117805. /**
  117806. * Gets the list of attached behaviors
  117807. * @see https://doc.babylonjs.com/features/behaviour
  117808. */
  117809. get behaviors(): Behavior<Node>[];
  117810. /**
  117811. * Gets an attached behavior by name
  117812. * @param name defines the name of the behavior to look for
  117813. * @see https://doc.babylonjs.com/features/behaviour
  117814. * @returns null if behavior was not found else the requested behavior
  117815. */
  117816. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  117817. /**
  117818. * Returns the latest update of the World matrix
  117819. * @returns a Matrix
  117820. */
  117821. getWorldMatrix(): Matrix;
  117822. /** @hidden */
  117823. _getWorldMatrixDeterminant(): number;
  117824. /**
  117825. * Returns directly the latest state of the mesh World matrix.
  117826. * A Matrix is returned.
  117827. */
  117828. get worldMatrixFromCache(): Matrix;
  117829. /** @hidden */
  117830. _initCache(): void;
  117831. /** @hidden */
  117832. updateCache(force?: boolean): void;
  117833. /** @hidden */
  117834. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117835. /** @hidden */
  117836. _updateCache(ignoreParentClass?: boolean): void;
  117837. /** @hidden */
  117838. _isSynchronized(): boolean;
  117839. /** @hidden */
  117840. _markSyncedWithParent(): void;
  117841. /** @hidden */
  117842. isSynchronizedWithParent(): boolean;
  117843. /** @hidden */
  117844. isSynchronized(): boolean;
  117845. /**
  117846. * Is this node ready to be used/rendered
  117847. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117848. * @return true if the node is ready
  117849. */
  117850. isReady(completeCheck?: boolean): boolean;
  117851. /**
  117852. * Is this node enabled?
  117853. * 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
  117854. * @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
  117855. * @return whether this node (and its parent) is enabled
  117856. */
  117857. isEnabled(checkAncestors?: boolean): boolean;
  117858. /** @hidden */
  117859. protected _syncParentEnabledState(): void;
  117860. /**
  117861. * Set the enabled state of this node
  117862. * @param value defines the new enabled state
  117863. */
  117864. setEnabled(value: boolean): void;
  117865. /**
  117866. * Is this node a descendant of the given node?
  117867. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  117868. * @param ancestor defines the parent node to inspect
  117869. * @returns a boolean indicating if this node is a descendant of the given node
  117870. */
  117871. isDescendantOf(ancestor: Node): boolean;
  117872. /** @hidden */
  117873. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  117874. /**
  117875. * Will return all nodes that have this node as ascendant
  117876. * @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
  117877. * @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
  117878. * @return all children nodes of all types
  117879. */
  117880. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  117881. /**
  117882. * Get all child-meshes of this node
  117883. * @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)
  117884. * @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
  117885. * @returns an array of AbstractMesh
  117886. */
  117887. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  117888. /**
  117889. * Get all direct children of this node
  117890. * @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
  117891. * @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)
  117892. * @returns an array of Node
  117893. */
  117894. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  117895. /** @hidden */
  117896. _setReady(state: boolean): void;
  117897. /**
  117898. * Get an animation by name
  117899. * @param name defines the name of the animation to look for
  117900. * @returns null if not found else the requested animation
  117901. */
  117902. getAnimationByName(name: string): Nullable<Animation>;
  117903. /**
  117904. * Creates an animation range for this node
  117905. * @param name defines the name of the range
  117906. * @param from defines the starting key
  117907. * @param to defines the end key
  117908. */
  117909. createAnimationRange(name: string, from: number, to: number): void;
  117910. /**
  117911. * Delete a specific animation range
  117912. * @param name defines the name of the range to delete
  117913. * @param deleteFrames defines if animation frames from the range must be deleted as well
  117914. */
  117915. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  117916. /**
  117917. * Get an animation range by name
  117918. * @param name defines the name of the animation range to look for
  117919. * @returns null if not found else the requested animation range
  117920. */
  117921. getAnimationRange(name: string): Nullable<AnimationRange>;
  117922. /**
  117923. * Gets the list of all animation ranges defined on this node
  117924. * @returns an array
  117925. */
  117926. getAnimationRanges(): Nullable<AnimationRange>[];
  117927. /**
  117928. * Will start the animation sequence
  117929. * @param name defines the range frames for animation sequence
  117930. * @param loop defines if the animation should loop (false by default)
  117931. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  117932. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  117933. * @returns the object created for this animation. If range does not exist, it will return null
  117934. */
  117935. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  117936. /**
  117937. * Serialize animation ranges into a JSON compatible object
  117938. * @returns serialization object
  117939. */
  117940. serializeAnimationRanges(): any;
  117941. /**
  117942. * Computes the world matrix of the node
  117943. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117944. * @returns the world matrix
  117945. */
  117946. computeWorldMatrix(force?: boolean): Matrix;
  117947. /**
  117948. * Releases resources associated with this node.
  117949. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117950. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117951. */
  117952. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117953. /**
  117954. * Parse animation range data from a serialization object and store them into a given node
  117955. * @param node defines where to store the animation ranges
  117956. * @param parsedNode defines the serialization object to read data from
  117957. * @param scene defines the hosting scene
  117958. */
  117959. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117960. /**
  117961. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117962. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117963. * @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
  117964. * @returns the new bounding vectors
  117965. */
  117966. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  117967. min: Vector3;
  117968. max: Vector3;
  117969. };
  117970. }
  117971. }
  117972. declare module BABYLON {
  117973. /**
  117974. * @hidden
  117975. */
  117976. export class _IAnimationState {
  117977. key: number;
  117978. repeatCount: number;
  117979. workValue?: any;
  117980. loopMode?: number;
  117981. offsetValue?: any;
  117982. highLimitValue?: any;
  117983. }
  117984. /**
  117985. * Class used to store any kind of animation
  117986. */
  117987. export class Animation {
  117988. /**Name of the animation */
  117989. name: string;
  117990. /**Property to animate */
  117991. targetProperty: string;
  117992. /**The frames per second of the animation */
  117993. framePerSecond: number;
  117994. /**The data type of the animation */
  117995. dataType: number;
  117996. /**The loop mode of the animation */
  117997. loopMode?: number | undefined;
  117998. /**Specifies if blending should be enabled */
  117999. enableBlending?: boolean | undefined;
  118000. /**
  118001. * Use matrix interpolation instead of using direct key value when animating matrices
  118002. */
  118003. static AllowMatricesInterpolation: boolean;
  118004. /**
  118005. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  118006. */
  118007. static AllowMatrixDecomposeForInterpolation: boolean;
  118008. /** Define the Url to load snippets */
  118009. static SnippetUrl: string;
  118010. /** Snippet ID if the animation was created from the snippet server */
  118011. snippetId: string;
  118012. /**
  118013. * Stores the key frames of the animation
  118014. */
  118015. private _keys;
  118016. /**
  118017. * Stores the easing function of the animation
  118018. */
  118019. private _easingFunction;
  118020. /**
  118021. * @hidden Internal use only
  118022. */
  118023. _runtimeAnimations: RuntimeAnimation[];
  118024. /**
  118025. * The set of event that will be linked to this animation
  118026. */
  118027. private _events;
  118028. /**
  118029. * Stores an array of target property paths
  118030. */
  118031. targetPropertyPath: string[];
  118032. /**
  118033. * Stores the blending speed of the animation
  118034. */
  118035. blendingSpeed: number;
  118036. /**
  118037. * Stores the animation ranges for the animation
  118038. */
  118039. private _ranges;
  118040. /**
  118041. * @hidden Internal use
  118042. */
  118043. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  118044. /**
  118045. * Sets up an animation
  118046. * @param property The property to animate
  118047. * @param animationType The animation type to apply
  118048. * @param framePerSecond The frames per second of the animation
  118049. * @param easingFunction The easing function used in the animation
  118050. * @returns The created animation
  118051. */
  118052. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  118053. /**
  118054. * Create and start an animation on a node
  118055. * @param name defines the name of the global animation that will be run on all nodes
  118056. * @param node defines the root node where the animation will take place
  118057. * @param targetProperty defines property to animate
  118058. * @param framePerSecond defines the number of frame per second yo use
  118059. * @param totalFrame defines the number of frames in total
  118060. * @param from defines the initial value
  118061. * @param to defines the final value
  118062. * @param loopMode defines which loop mode you want to use (off by default)
  118063. * @param easingFunction defines the easing function to use (linear by default)
  118064. * @param onAnimationEnd defines the callback to call when animation end
  118065. * @returns the animatable created for this animation
  118066. */
  118067. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118068. /**
  118069. * Create and start an animation on a node and its descendants
  118070. * @param name defines the name of the global animation that will be run on all nodes
  118071. * @param node defines the root node where the animation will take place
  118072. * @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
  118073. * @param targetProperty defines property to animate
  118074. * @param framePerSecond defines the number of frame per second to use
  118075. * @param totalFrame defines the number of frames in total
  118076. * @param from defines the initial value
  118077. * @param to defines the final value
  118078. * @param loopMode defines which loop mode you want to use (off by default)
  118079. * @param easingFunction defines the easing function to use (linear by default)
  118080. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  118081. * @returns the list of animatables created for all nodes
  118082. * @example https://www.babylonjs-playground.com/#MH0VLI
  118083. */
  118084. 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[]>;
  118085. /**
  118086. * Creates a new animation, merges it with the existing animations and starts it
  118087. * @param name Name of the animation
  118088. * @param node Node which contains the scene that begins the animations
  118089. * @param targetProperty Specifies which property to animate
  118090. * @param framePerSecond The frames per second of the animation
  118091. * @param totalFrame The total number of frames
  118092. * @param from The frame at the beginning of the animation
  118093. * @param to The frame at the end of the animation
  118094. * @param loopMode Specifies the loop mode of the animation
  118095. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  118096. * @param onAnimationEnd Callback to run once the animation is complete
  118097. * @returns Nullable animation
  118098. */
  118099. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118100. /**
  118101. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118102. * @param sourceAnimation defines the Animation containing keyframes to convert
  118103. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118104. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  118105. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  118106. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  118107. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  118108. */
  118109. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  118110. /**
  118111. * Transition property of an host to the target Value
  118112. * @param property The property to transition
  118113. * @param targetValue The target Value of the property
  118114. * @param host The object where the property to animate belongs
  118115. * @param scene Scene used to run the animation
  118116. * @param frameRate Framerate (in frame/s) to use
  118117. * @param transition The transition type we want to use
  118118. * @param duration The duration of the animation, in milliseconds
  118119. * @param onAnimationEnd Callback trigger at the end of the animation
  118120. * @returns Nullable animation
  118121. */
  118122. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  118123. /**
  118124. * Return the array of runtime animations currently using this animation
  118125. */
  118126. get runtimeAnimations(): RuntimeAnimation[];
  118127. /**
  118128. * Specifies if any of the runtime animations are currently running
  118129. */
  118130. get hasRunningRuntimeAnimations(): boolean;
  118131. /**
  118132. * Initializes the animation
  118133. * @param name Name of the animation
  118134. * @param targetProperty Property to animate
  118135. * @param framePerSecond The frames per second of the animation
  118136. * @param dataType The data type of the animation
  118137. * @param loopMode The loop mode of the animation
  118138. * @param enableBlending Specifies if blending should be enabled
  118139. */
  118140. constructor(
  118141. /**Name of the animation */
  118142. name: string,
  118143. /**Property to animate */
  118144. targetProperty: string,
  118145. /**The frames per second of the animation */
  118146. framePerSecond: number,
  118147. /**The data type of the animation */
  118148. dataType: number,
  118149. /**The loop mode of the animation */
  118150. loopMode?: number | undefined,
  118151. /**Specifies if blending should be enabled */
  118152. enableBlending?: boolean | undefined);
  118153. /**
  118154. * Converts the animation to a string
  118155. * @param fullDetails support for multiple levels of logging within scene loading
  118156. * @returns String form of the animation
  118157. */
  118158. toString(fullDetails?: boolean): string;
  118159. /**
  118160. * Add an event to this animation
  118161. * @param event Event to add
  118162. */
  118163. addEvent(event: AnimationEvent): void;
  118164. /**
  118165. * Remove all events found at the given frame
  118166. * @param frame The frame to remove events from
  118167. */
  118168. removeEvents(frame: number): void;
  118169. /**
  118170. * Retrieves all the events from the animation
  118171. * @returns Events from the animation
  118172. */
  118173. getEvents(): AnimationEvent[];
  118174. /**
  118175. * Creates an animation range
  118176. * @param name Name of the animation range
  118177. * @param from Starting frame of the animation range
  118178. * @param to Ending frame of the animation
  118179. */
  118180. createRange(name: string, from: number, to: number): void;
  118181. /**
  118182. * Deletes an animation range by name
  118183. * @param name Name of the animation range to delete
  118184. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  118185. */
  118186. deleteRange(name: string, deleteFrames?: boolean): void;
  118187. /**
  118188. * Gets the animation range by name, or null if not defined
  118189. * @param name Name of the animation range
  118190. * @returns Nullable animation range
  118191. */
  118192. getRange(name: string): Nullable<AnimationRange>;
  118193. /**
  118194. * Gets the key frames from the animation
  118195. * @returns The key frames of the animation
  118196. */
  118197. getKeys(): Array<IAnimationKey>;
  118198. /**
  118199. * Gets the highest frame rate of the animation
  118200. * @returns Highest frame rate of the animation
  118201. */
  118202. getHighestFrame(): number;
  118203. /**
  118204. * Gets the easing function of the animation
  118205. * @returns Easing function of the animation
  118206. */
  118207. getEasingFunction(): IEasingFunction;
  118208. /**
  118209. * Sets the easing function of the animation
  118210. * @param easingFunction A custom mathematical formula for animation
  118211. */
  118212. setEasingFunction(easingFunction: EasingFunction): void;
  118213. /**
  118214. * Interpolates a scalar linearly
  118215. * @param startValue Start value of the animation curve
  118216. * @param endValue End value of the animation curve
  118217. * @param gradient Scalar amount to interpolate
  118218. * @returns Interpolated scalar value
  118219. */
  118220. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  118221. /**
  118222. * Interpolates a scalar cubically
  118223. * @param startValue Start value of the animation curve
  118224. * @param outTangent End tangent of the animation
  118225. * @param endValue End value of the animation curve
  118226. * @param inTangent Start tangent of the animation curve
  118227. * @param gradient Scalar amount to interpolate
  118228. * @returns Interpolated scalar value
  118229. */
  118230. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  118231. /**
  118232. * Interpolates a quaternion using a spherical linear interpolation
  118233. * @param startValue Start value of the animation curve
  118234. * @param endValue End value of the animation curve
  118235. * @param gradient Scalar amount to interpolate
  118236. * @returns Interpolated quaternion value
  118237. */
  118238. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  118239. /**
  118240. * Interpolates a quaternion cubically
  118241. * @param startValue Start value of the animation curve
  118242. * @param outTangent End tangent of the animation curve
  118243. * @param endValue End value of the animation curve
  118244. * @param inTangent Start tangent of the animation curve
  118245. * @param gradient Scalar amount to interpolate
  118246. * @returns Interpolated quaternion value
  118247. */
  118248. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  118249. /**
  118250. * Interpolates a Vector3 linearl
  118251. * @param startValue Start value of the animation curve
  118252. * @param endValue End value of the animation curve
  118253. * @param gradient Scalar amount to interpolate
  118254. * @returns Interpolated scalar value
  118255. */
  118256. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  118257. /**
  118258. * Interpolates a Vector3 cubically
  118259. * @param startValue Start value of the animation curve
  118260. * @param outTangent End tangent of the animation
  118261. * @param endValue End value of the animation curve
  118262. * @param inTangent Start tangent of the animation curve
  118263. * @param gradient Scalar amount to interpolate
  118264. * @returns InterpolatedVector3 value
  118265. */
  118266. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  118267. /**
  118268. * Interpolates a Vector2 linearly
  118269. * @param startValue Start value of the animation curve
  118270. * @param endValue End value of the animation curve
  118271. * @param gradient Scalar amount to interpolate
  118272. * @returns Interpolated Vector2 value
  118273. */
  118274. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  118275. /**
  118276. * Interpolates a Vector2 cubically
  118277. * @param startValue Start value of the animation curve
  118278. * @param outTangent End tangent of the animation
  118279. * @param endValue End value of the animation curve
  118280. * @param inTangent Start tangent of the animation curve
  118281. * @param gradient Scalar amount to interpolate
  118282. * @returns Interpolated Vector2 value
  118283. */
  118284. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  118285. /**
  118286. * Interpolates a size linearly
  118287. * @param startValue Start value of the animation curve
  118288. * @param endValue End value of the animation curve
  118289. * @param gradient Scalar amount to interpolate
  118290. * @returns Interpolated Size value
  118291. */
  118292. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  118293. /**
  118294. * Interpolates a Color3 linearly
  118295. * @param startValue Start value of the animation curve
  118296. * @param endValue End value of the animation curve
  118297. * @param gradient Scalar amount to interpolate
  118298. * @returns Interpolated Color3 value
  118299. */
  118300. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  118301. /**
  118302. * Interpolates a Color4 linearly
  118303. * @param startValue Start value of the animation curve
  118304. * @param endValue End value of the animation curve
  118305. * @param gradient Scalar amount to interpolate
  118306. * @returns Interpolated Color3 value
  118307. */
  118308. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  118309. /**
  118310. * @hidden Internal use only
  118311. */
  118312. _getKeyValue(value: any): any;
  118313. /**
  118314. * @hidden Internal use only
  118315. */
  118316. _interpolate(currentFrame: number, state: _IAnimationState): any;
  118317. /**
  118318. * Defines the function to use to interpolate matrices
  118319. * @param startValue defines the start matrix
  118320. * @param endValue defines the end matrix
  118321. * @param gradient defines the gradient between both matrices
  118322. * @param result defines an optional target matrix where to store the interpolation
  118323. * @returns the interpolated matrix
  118324. */
  118325. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  118326. /**
  118327. * Makes a copy of the animation
  118328. * @returns Cloned animation
  118329. */
  118330. clone(): Animation;
  118331. /**
  118332. * Sets the key frames of the animation
  118333. * @param values The animation key frames to set
  118334. */
  118335. setKeys(values: Array<IAnimationKey>): void;
  118336. /**
  118337. * Serializes the animation to an object
  118338. * @returns Serialized object
  118339. */
  118340. serialize(): any;
  118341. /**
  118342. * Float animation type
  118343. */
  118344. static readonly ANIMATIONTYPE_FLOAT: number;
  118345. /**
  118346. * Vector3 animation type
  118347. */
  118348. static readonly ANIMATIONTYPE_VECTOR3: number;
  118349. /**
  118350. * Quaternion animation type
  118351. */
  118352. static readonly ANIMATIONTYPE_QUATERNION: number;
  118353. /**
  118354. * Matrix animation type
  118355. */
  118356. static readonly ANIMATIONTYPE_MATRIX: number;
  118357. /**
  118358. * Color3 animation type
  118359. */
  118360. static readonly ANIMATIONTYPE_COLOR3: number;
  118361. /**
  118362. * Color3 animation type
  118363. */
  118364. static readonly ANIMATIONTYPE_COLOR4: number;
  118365. /**
  118366. * Vector2 animation type
  118367. */
  118368. static readonly ANIMATIONTYPE_VECTOR2: number;
  118369. /**
  118370. * Size animation type
  118371. */
  118372. static readonly ANIMATIONTYPE_SIZE: number;
  118373. /**
  118374. * Relative Loop Mode
  118375. */
  118376. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  118377. /**
  118378. * Cycle Loop Mode
  118379. */
  118380. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  118381. /**
  118382. * Constant Loop Mode
  118383. */
  118384. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  118385. /** @hidden */
  118386. static _UniversalLerp(left: any, right: any, amount: number): any;
  118387. /**
  118388. * Parses an animation object and creates an animation
  118389. * @param parsedAnimation Parsed animation object
  118390. * @returns Animation object
  118391. */
  118392. static Parse(parsedAnimation: any): Animation;
  118393. /**
  118394. * Appends the serialized animations from the source animations
  118395. * @param source Source containing the animations
  118396. * @param destination Target to store the animations
  118397. */
  118398. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118399. /**
  118400. * Creates a new animation or an array of animations from a snippet saved in a remote file
  118401. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  118402. * @param url defines the url to load from
  118403. * @returns a promise that will resolve to the new animation or an array of animations
  118404. */
  118405. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  118406. /**
  118407. * Creates an animation or an array of animations from a snippet saved by the Inspector
  118408. * @param snippetId defines the snippet to load
  118409. * @returns a promise that will resolve to the new animation or a new array of animations
  118410. */
  118411. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  118412. }
  118413. }
  118414. declare module BABYLON {
  118415. /**
  118416. * Interface containing an array of animations
  118417. */
  118418. export interface IAnimatable {
  118419. /**
  118420. * Array of animations
  118421. */
  118422. animations: Nullable<Array<Animation>>;
  118423. }
  118424. }
  118425. declare module BABYLON {
  118426. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  118427. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118428. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118429. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118430. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118431. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118432. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118433. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118434. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118435. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118436. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118437. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118438. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118439. /**
  118440. * Decorator used to define property that can be serialized as reference to a camera
  118441. * @param sourceName defines the name of the property to decorate
  118442. */
  118443. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118444. /**
  118445. * Class used to help serialization objects
  118446. */
  118447. export class SerializationHelper {
  118448. /** @hidden */
  118449. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  118450. /** @hidden */
  118451. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  118452. /** @hidden */
  118453. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  118454. /** @hidden */
  118455. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  118456. /**
  118457. * Appends the serialized animations from the source animations
  118458. * @param source Source containing the animations
  118459. * @param destination Target to store the animations
  118460. */
  118461. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118462. /**
  118463. * Static function used to serialized a specific entity
  118464. * @param entity defines the entity to serialize
  118465. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  118466. * @returns a JSON compatible object representing the serialization of the entity
  118467. */
  118468. static Serialize<T>(entity: T, serializationObject?: any): any;
  118469. /**
  118470. * Creates a new entity from a serialization data object
  118471. * @param creationFunction defines a function used to instanciated the new entity
  118472. * @param source defines the source serialization data
  118473. * @param scene defines the hosting scene
  118474. * @param rootUrl defines the root url for resources
  118475. * @returns a new entity
  118476. */
  118477. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  118478. /**
  118479. * Clones an object
  118480. * @param creationFunction defines the function used to instanciate the new object
  118481. * @param source defines the source object
  118482. * @returns the cloned object
  118483. */
  118484. static Clone<T>(creationFunction: () => T, source: T): T;
  118485. /**
  118486. * Instanciates a new object based on a source one (some data will be shared between both object)
  118487. * @param creationFunction defines the function used to instanciate the new object
  118488. * @param source defines the source object
  118489. * @returns the new object
  118490. */
  118491. static Instanciate<T>(creationFunction: () => T, source: T): T;
  118492. }
  118493. }
  118494. declare module BABYLON {
  118495. /**
  118496. * This is the base class of all the camera used in the application.
  118497. * @see https://doc.babylonjs.com/features/cameras
  118498. */
  118499. export class Camera extends Node {
  118500. /** @hidden */
  118501. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  118502. /**
  118503. * This is the default projection mode used by the cameras.
  118504. * It helps recreating a feeling of perspective and better appreciate depth.
  118505. * This is the best way to simulate real life cameras.
  118506. */
  118507. static readonly PERSPECTIVE_CAMERA: number;
  118508. /**
  118509. * This helps creating camera with an orthographic mode.
  118510. * 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.
  118511. */
  118512. static readonly ORTHOGRAPHIC_CAMERA: number;
  118513. /**
  118514. * This is the default FOV mode for perspective cameras.
  118515. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  118516. */
  118517. static readonly FOVMODE_VERTICAL_FIXED: number;
  118518. /**
  118519. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  118520. */
  118521. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  118522. /**
  118523. * This specifies ther is no need for a camera rig.
  118524. * Basically only one eye is rendered corresponding to the camera.
  118525. */
  118526. static readonly RIG_MODE_NONE: number;
  118527. /**
  118528. * Simulates a camera Rig with one blue eye and one red eye.
  118529. * This can be use with 3d blue and red glasses.
  118530. */
  118531. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  118532. /**
  118533. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  118534. */
  118535. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  118536. /**
  118537. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  118538. */
  118539. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  118540. /**
  118541. * Defines that both eyes of the camera will be rendered over under each other.
  118542. */
  118543. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  118544. /**
  118545. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  118546. */
  118547. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  118548. /**
  118549. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  118550. */
  118551. static readonly RIG_MODE_VR: number;
  118552. /**
  118553. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  118554. */
  118555. static readonly RIG_MODE_WEBVR: number;
  118556. /**
  118557. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  118558. */
  118559. static readonly RIG_MODE_CUSTOM: number;
  118560. /**
  118561. * Defines if by default attaching controls should prevent the default javascript event to continue.
  118562. */
  118563. static ForceAttachControlToAlwaysPreventDefault: boolean;
  118564. /**
  118565. * Define the input manager associated with the camera.
  118566. */
  118567. inputs: CameraInputsManager<Camera>;
  118568. /** @hidden */
  118569. _position: Vector3;
  118570. /**
  118571. * Define the current local position of the camera in the scene
  118572. */
  118573. get position(): Vector3;
  118574. set position(newPosition: Vector3);
  118575. protected _upVector: Vector3;
  118576. /**
  118577. * The vector the camera should consider as up.
  118578. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  118579. */
  118580. set upVector(vec: Vector3);
  118581. get upVector(): Vector3;
  118582. /**
  118583. * Define the current limit on the left side for an orthographic camera
  118584. * In scene unit
  118585. */
  118586. orthoLeft: Nullable<number>;
  118587. /**
  118588. * Define the current limit on the right side for an orthographic camera
  118589. * In scene unit
  118590. */
  118591. orthoRight: Nullable<number>;
  118592. /**
  118593. * Define the current limit on the bottom side for an orthographic camera
  118594. * In scene unit
  118595. */
  118596. orthoBottom: Nullable<number>;
  118597. /**
  118598. * Define the current limit on the top side for an orthographic camera
  118599. * In scene unit
  118600. */
  118601. orthoTop: Nullable<number>;
  118602. /**
  118603. * Field Of View is set in Radians. (default is 0.8)
  118604. */
  118605. fov: number;
  118606. /**
  118607. * Define the minimum distance the camera can see from.
  118608. * This is important to note that the depth buffer are not infinite and the closer it starts
  118609. * the more your scene might encounter depth fighting issue.
  118610. */
  118611. minZ: number;
  118612. /**
  118613. * Define the maximum distance the camera can see to.
  118614. * This is important to note that the depth buffer are not infinite and the further it end
  118615. * the more your scene might encounter depth fighting issue.
  118616. */
  118617. maxZ: number;
  118618. /**
  118619. * Define the default inertia of the camera.
  118620. * This helps giving a smooth feeling to the camera movement.
  118621. */
  118622. inertia: number;
  118623. /**
  118624. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  118625. */
  118626. mode: number;
  118627. /**
  118628. * Define whether the camera is intermediate.
  118629. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  118630. */
  118631. isIntermediate: boolean;
  118632. /**
  118633. * Define the viewport of the camera.
  118634. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  118635. */
  118636. viewport: Viewport;
  118637. /**
  118638. * Restricts the camera to viewing objects with the same layerMask.
  118639. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  118640. */
  118641. layerMask: number;
  118642. /**
  118643. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  118644. */
  118645. fovMode: number;
  118646. /**
  118647. * Rig mode of the camera.
  118648. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  118649. * This is normally controlled byt the camera themselves as internal use.
  118650. */
  118651. cameraRigMode: number;
  118652. /**
  118653. * Defines the distance between both "eyes" in case of a RIG
  118654. */
  118655. interaxialDistance: number;
  118656. /**
  118657. * Defines if stereoscopic rendering is done side by side or over under.
  118658. */
  118659. isStereoscopicSideBySide: boolean;
  118660. /**
  118661. * 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
  118662. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  118663. * else in the scene. (Eg. security camera)
  118664. *
  118665. * 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)
  118666. */
  118667. customRenderTargets: RenderTargetTexture[];
  118668. /**
  118669. * When set, the camera will render to this render target instead of the default canvas
  118670. *
  118671. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  118672. */
  118673. outputRenderTarget: Nullable<RenderTargetTexture>;
  118674. /**
  118675. * Observable triggered when the camera view matrix has changed.
  118676. */
  118677. onViewMatrixChangedObservable: Observable<Camera>;
  118678. /**
  118679. * Observable triggered when the camera Projection matrix has changed.
  118680. */
  118681. onProjectionMatrixChangedObservable: Observable<Camera>;
  118682. /**
  118683. * Observable triggered when the inputs have been processed.
  118684. */
  118685. onAfterCheckInputsObservable: Observable<Camera>;
  118686. /**
  118687. * Observable triggered when reset has been called and applied to the camera.
  118688. */
  118689. onRestoreStateObservable: Observable<Camera>;
  118690. /**
  118691. * Is this camera a part of a rig system?
  118692. */
  118693. isRigCamera: boolean;
  118694. /**
  118695. * If isRigCamera set to true this will be set with the parent camera.
  118696. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  118697. */
  118698. rigParent?: Camera;
  118699. /** @hidden */
  118700. _cameraRigParams: any;
  118701. /** @hidden */
  118702. _rigCameras: Camera[];
  118703. /** @hidden */
  118704. _rigPostProcess: Nullable<PostProcess>;
  118705. protected _webvrViewMatrix: Matrix;
  118706. /** @hidden */
  118707. _skipRendering: boolean;
  118708. /** @hidden */
  118709. _projectionMatrix: Matrix;
  118710. /** @hidden */
  118711. _postProcesses: Nullable<PostProcess>[];
  118712. /** @hidden */
  118713. _activeMeshes: SmartArray<AbstractMesh>;
  118714. protected _globalPosition: Vector3;
  118715. /** @hidden */
  118716. _computedViewMatrix: Matrix;
  118717. private _doNotComputeProjectionMatrix;
  118718. private _transformMatrix;
  118719. private _frustumPlanes;
  118720. private _refreshFrustumPlanes;
  118721. private _storedFov;
  118722. private _stateStored;
  118723. /**
  118724. * Instantiates a new camera object.
  118725. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  118726. * @see https://doc.babylonjs.com/features/cameras
  118727. * @param name Defines the name of the camera in the scene
  118728. * @param position Defines the position of the camera
  118729. * @param scene Defines the scene the camera belongs too
  118730. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  118731. */
  118732. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  118733. /**
  118734. * Store current camera state (fov, position, etc..)
  118735. * @returns the camera
  118736. */
  118737. storeState(): Camera;
  118738. /**
  118739. * Restores the camera state values if it has been stored. You must call storeState() first
  118740. */
  118741. protected _restoreStateValues(): boolean;
  118742. /**
  118743. * Restored camera state. You must call storeState() first.
  118744. * @returns true if restored and false otherwise
  118745. */
  118746. restoreState(): boolean;
  118747. /**
  118748. * Gets the class name of the camera.
  118749. * @returns the class name
  118750. */
  118751. getClassName(): string;
  118752. /** @hidden */
  118753. readonly _isCamera: boolean;
  118754. /**
  118755. * Gets a string representation of the camera useful for debug purpose.
  118756. * @param fullDetails Defines that a more verboe level of logging is required
  118757. * @returns the string representation
  118758. */
  118759. toString(fullDetails?: boolean): string;
  118760. /**
  118761. * Gets the current world space position of the camera.
  118762. */
  118763. get globalPosition(): Vector3;
  118764. /**
  118765. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  118766. * @returns the active meshe list
  118767. */
  118768. getActiveMeshes(): SmartArray<AbstractMesh>;
  118769. /**
  118770. * Check whether a mesh is part of the current active mesh list of the camera
  118771. * @param mesh Defines the mesh to check
  118772. * @returns true if active, false otherwise
  118773. */
  118774. isActiveMesh(mesh: Mesh): boolean;
  118775. /**
  118776. * Is this camera ready to be used/rendered
  118777. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  118778. * @return true if the camera is ready
  118779. */
  118780. isReady(completeCheck?: boolean): boolean;
  118781. /** @hidden */
  118782. _initCache(): void;
  118783. /** @hidden */
  118784. _updateCache(ignoreParentClass?: boolean): void;
  118785. /** @hidden */
  118786. _isSynchronized(): boolean;
  118787. /** @hidden */
  118788. _isSynchronizedViewMatrix(): boolean;
  118789. /** @hidden */
  118790. _isSynchronizedProjectionMatrix(): boolean;
  118791. /**
  118792. * Attach the input controls to a specific dom element to get the input from.
  118793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118794. */
  118795. attachControl(noPreventDefault?: boolean): void;
  118796. /**
  118797. * Attach the input controls to a specific dom element to get the input from.
  118798. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  118799. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118800. * BACK COMPAT SIGNATURE ONLY.
  118801. */
  118802. attachControl(ignored: any, noPreventDefault?: boolean): void;
  118803. /**
  118804. * Detach the current controls from the specified dom element.
  118805. */
  118806. detachControl(): void;
  118807. /**
  118808. * Detach the current controls from the specified dom element.
  118809. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  118810. */
  118811. detachControl(ignored: any): void;
  118812. /**
  118813. * Update the camera state according to the different inputs gathered during the frame.
  118814. */
  118815. update(): void;
  118816. /** @hidden */
  118817. _checkInputs(): void;
  118818. /** @hidden */
  118819. get rigCameras(): Camera[];
  118820. /**
  118821. * Gets the post process used by the rig cameras
  118822. */
  118823. get rigPostProcess(): Nullable<PostProcess>;
  118824. /**
  118825. * Internal, gets the first post proces.
  118826. * @returns the first post process to be run on this camera.
  118827. */
  118828. _getFirstPostProcess(): Nullable<PostProcess>;
  118829. private _cascadePostProcessesToRigCams;
  118830. /**
  118831. * Attach a post process to the camera.
  118832. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  118833. * @param postProcess The post process to attach to the camera
  118834. * @param insertAt The position of the post process in case several of them are in use in the scene
  118835. * @returns the position the post process has been inserted at
  118836. */
  118837. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  118838. /**
  118839. * Detach a post process to the camera.
  118840. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  118841. * @param postProcess The post process to detach from the camera
  118842. */
  118843. detachPostProcess(postProcess: PostProcess): void;
  118844. /**
  118845. * Gets the current world matrix of the camera
  118846. */
  118847. getWorldMatrix(): Matrix;
  118848. /** @hidden */
  118849. _getViewMatrix(): Matrix;
  118850. /**
  118851. * Gets the current view matrix of the camera.
  118852. * @param force forces the camera to recompute the matrix without looking at the cached state
  118853. * @returns the view matrix
  118854. */
  118855. getViewMatrix(force?: boolean): Matrix;
  118856. /**
  118857. * Freeze the projection matrix.
  118858. * It will prevent the cache check of the camera projection compute and can speed up perf
  118859. * if no parameter of the camera are meant to change
  118860. * @param projection Defines manually a projection if necessary
  118861. */
  118862. freezeProjectionMatrix(projection?: Matrix): void;
  118863. /**
  118864. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  118865. */
  118866. unfreezeProjectionMatrix(): void;
  118867. /**
  118868. * Gets the current projection matrix of the camera.
  118869. * @param force forces the camera to recompute the matrix without looking at the cached state
  118870. * @returns the projection matrix
  118871. */
  118872. getProjectionMatrix(force?: boolean): Matrix;
  118873. /**
  118874. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  118875. * @returns a Matrix
  118876. */
  118877. getTransformationMatrix(): Matrix;
  118878. private _updateFrustumPlanes;
  118879. /**
  118880. * Checks if a cullable object (mesh...) is in the camera frustum
  118881. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  118882. * @param target The object to check
  118883. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  118884. * @returns true if the object is in frustum otherwise false
  118885. */
  118886. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  118887. /**
  118888. * Checks if a cullable object (mesh...) is in the camera frustum
  118889. * Unlike isInFrustum this cheks the full bounding box
  118890. * @param target The object to check
  118891. * @returns true if the object is in frustum otherwise false
  118892. */
  118893. isCompletelyInFrustum(target: ICullable): boolean;
  118894. /**
  118895. * Gets a ray in the forward direction from the camera.
  118896. * @param length Defines the length of the ray to create
  118897. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  118898. * @param origin Defines the start point of the ray which defaults to the camera position
  118899. * @returns the forward ray
  118900. */
  118901. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  118902. /**
  118903. * Gets a ray in the forward direction from the camera.
  118904. * @param refRay the ray to (re)use when setting the values
  118905. * @param length Defines the length of the ray to create
  118906. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  118907. * @param origin Defines the start point of the ray which defaults to the camera position
  118908. * @returns the forward ray
  118909. */
  118910. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  118911. /**
  118912. * Releases resources associated with this node.
  118913. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118914. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118915. */
  118916. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118917. /** @hidden */
  118918. _isLeftCamera: boolean;
  118919. /**
  118920. * Gets the left camera of a rig setup in case of Rigged Camera
  118921. */
  118922. get isLeftCamera(): boolean;
  118923. /** @hidden */
  118924. _isRightCamera: boolean;
  118925. /**
  118926. * Gets the right camera of a rig setup in case of Rigged Camera
  118927. */
  118928. get isRightCamera(): boolean;
  118929. /**
  118930. * Gets the left camera of a rig setup in case of Rigged Camera
  118931. */
  118932. get leftCamera(): Nullable<FreeCamera>;
  118933. /**
  118934. * Gets the right camera of a rig setup in case of Rigged Camera
  118935. */
  118936. get rightCamera(): Nullable<FreeCamera>;
  118937. /**
  118938. * Gets the left camera target of a rig setup in case of Rigged Camera
  118939. * @returns the target position
  118940. */
  118941. getLeftTarget(): Nullable<Vector3>;
  118942. /**
  118943. * Gets the right camera target of a rig setup in case of Rigged Camera
  118944. * @returns the target position
  118945. */
  118946. getRightTarget(): Nullable<Vector3>;
  118947. /**
  118948. * @hidden
  118949. */
  118950. setCameraRigMode(mode: number, rigParams: any): void;
  118951. /** @hidden */
  118952. static _setStereoscopicRigMode(camera: Camera): void;
  118953. /** @hidden */
  118954. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  118955. /** @hidden */
  118956. static _setVRRigMode(camera: Camera, rigParams: any): void;
  118957. /** @hidden */
  118958. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  118959. /** @hidden */
  118960. _getVRProjectionMatrix(): Matrix;
  118961. protected _updateCameraRotationMatrix(): void;
  118962. protected _updateWebVRCameraRotationMatrix(): void;
  118963. /**
  118964. * This function MUST be overwritten by the different WebVR cameras available.
  118965. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  118966. * @hidden
  118967. */
  118968. _getWebVRProjectionMatrix(): Matrix;
  118969. /**
  118970. * This function MUST be overwritten by the different WebVR cameras available.
  118971. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  118972. * @hidden
  118973. */
  118974. _getWebVRViewMatrix(): Matrix;
  118975. /** @hidden */
  118976. setCameraRigParameter(name: string, value: any): void;
  118977. /**
  118978. * needs to be overridden by children so sub has required properties to be copied
  118979. * @hidden
  118980. */
  118981. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  118982. /**
  118983. * May need to be overridden by children
  118984. * @hidden
  118985. */
  118986. _updateRigCameras(): void;
  118987. /** @hidden */
  118988. _setupInputs(): void;
  118989. /**
  118990. * Serialiaze the camera setup to a json represention
  118991. * @returns the JSON representation
  118992. */
  118993. serialize(): any;
  118994. /**
  118995. * Clones the current camera.
  118996. * @param name The cloned camera name
  118997. * @returns the cloned camera
  118998. */
  118999. clone(name: string): Camera;
  119000. /**
  119001. * Gets the direction of the camera relative to a given local axis.
  119002. * @param localAxis Defines the reference axis to provide a relative direction.
  119003. * @return the direction
  119004. */
  119005. getDirection(localAxis: Vector3): Vector3;
  119006. /**
  119007. * Returns the current camera absolute rotation
  119008. */
  119009. get absoluteRotation(): Quaternion;
  119010. /**
  119011. * Gets the direction of the camera relative to a given local axis into a passed vector.
  119012. * @param localAxis Defines the reference axis to provide a relative direction.
  119013. * @param result Defines the vector to store the result in
  119014. */
  119015. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  119016. /**
  119017. * Gets a camera constructor for a given camera type
  119018. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  119019. * @param name The name of the camera the result will be able to instantiate
  119020. * @param scene The scene the result will construct the camera in
  119021. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  119022. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  119023. * @returns a factory method to construc the camera
  119024. */
  119025. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  119026. /**
  119027. * Compute the world matrix of the camera.
  119028. * @returns the camera world matrix
  119029. */
  119030. computeWorldMatrix(): Matrix;
  119031. /**
  119032. * Parse a JSON and creates the camera from the parsed information
  119033. * @param parsedCamera The JSON to parse
  119034. * @param scene The scene to instantiate the camera in
  119035. * @returns the newly constructed camera
  119036. */
  119037. static Parse(parsedCamera: any, scene: Scene): Camera;
  119038. }
  119039. }
  119040. declare module BABYLON {
  119041. /**
  119042. * PostProcessManager is used to manage one or more post processes or post process pipelines
  119043. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  119044. */
  119045. export class PostProcessManager {
  119046. private _scene;
  119047. private _indexBuffer;
  119048. private _vertexBuffers;
  119049. /**
  119050. * Creates a new instance PostProcess
  119051. * @param scene The scene that the post process is associated with.
  119052. */
  119053. constructor(scene: Scene);
  119054. private _prepareBuffers;
  119055. private _buildIndexBuffer;
  119056. /**
  119057. * Rebuilds the vertex buffers of the manager.
  119058. * @hidden
  119059. */
  119060. _rebuild(): void;
  119061. /**
  119062. * Prepares a frame to be run through a post process.
  119063. * @param sourceTexture The input texture to the post procesess. (default: null)
  119064. * @param postProcesses An array of post processes to be run. (default: null)
  119065. * @returns True if the post processes were able to be run.
  119066. * @hidden
  119067. */
  119068. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  119069. /**
  119070. * Manually render a set of post processes to a texture.
  119071. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  119072. * @param postProcesses An array of post processes to be run.
  119073. * @param targetTexture The target texture to render to.
  119074. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  119075. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  119076. * @param lodLevel defines which lod of the texture to render to
  119077. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  119078. */
  119079. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  119080. /**
  119081. * Finalize the result of the output of the postprocesses.
  119082. * @param doNotPresent If true the result will not be displayed to the screen.
  119083. * @param targetTexture The target texture to render to.
  119084. * @param faceIndex The index of the face to bind the target texture to.
  119085. * @param postProcesses The array of post processes to render.
  119086. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  119087. * @hidden
  119088. */
  119089. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  119090. /**
  119091. * Disposes of the post process manager.
  119092. */
  119093. dispose(): void;
  119094. }
  119095. }
  119096. declare module BABYLON {
  119097. /**
  119098. * This Helps creating a texture that will be created from a camera in your scene.
  119099. * It is basically a dynamic texture that could be used to create special effects for instance.
  119100. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  119101. */
  119102. export class RenderTargetTexture extends Texture {
  119103. /**
  119104. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  119105. */
  119106. static readonly REFRESHRATE_RENDER_ONCE: number;
  119107. /**
  119108. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  119109. */
  119110. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  119111. /**
  119112. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  119113. * the central point of your effect and can save a lot of performances.
  119114. */
  119115. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  119116. /**
  119117. * Use this predicate to dynamically define the list of mesh you want to render.
  119118. * If set, the renderList property will be overwritten.
  119119. */
  119120. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  119121. private _renderList;
  119122. /**
  119123. * Use this list to define the list of mesh you want to render.
  119124. */
  119125. get renderList(): Nullable<Array<AbstractMesh>>;
  119126. set renderList(value: Nullable<Array<AbstractMesh>>);
  119127. /**
  119128. * Use this function to overload the renderList array at rendering time.
  119129. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  119130. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  119131. * the cube (if the RTT is a cube, else layerOrFace=0).
  119132. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  119133. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  119134. * hold dummy elements!
  119135. */
  119136. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  119137. private _hookArray;
  119138. /**
  119139. * Define if particles should be rendered in your texture.
  119140. */
  119141. renderParticles: boolean;
  119142. /**
  119143. * Define if sprites should be rendered in your texture.
  119144. */
  119145. renderSprites: boolean;
  119146. /**
  119147. * Define the camera used to render the texture.
  119148. */
  119149. activeCamera: Nullable<Camera>;
  119150. /**
  119151. * Override the mesh isReady function with your own one.
  119152. */
  119153. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  119154. /**
  119155. * Override the render function of the texture with your own one.
  119156. */
  119157. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  119158. /**
  119159. * Define if camera post processes should be use while rendering the texture.
  119160. */
  119161. useCameraPostProcesses: boolean;
  119162. /**
  119163. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  119164. */
  119165. ignoreCameraViewport: boolean;
  119166. private _postProcessManager;
  119167. private _postProcesses;
  119168. private _resizeObserver;
  119169. /**
  119170. * An event triggered when the texture is unbind.
  119171. */
  119172. onBeforeBindObservable: Observable<RenderTargetTexture>;
  119173. /**
  119174. * An event triggered when the texture is unbind.
  119175. */
  119176. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  119177. private _onAfterUnbindObserver;
  119178. /**
  119179. * Set a after unbind callback in the texture.
  119180. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  119181. */
  119182. set onAfterUnbind(callback: () => void);
  119183. /**
  119184. * An event triggered before rendering the texture
  119185. */
  119186. onBeforeRenderObservable: Observable<number>;
  119187. private _onBeforeRenderObserver;
  119188. /**
  119189. * Set a before render callback in the texture.
  119190. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  119191. */
  119192. set onBeforeRender(callback: (faceIndex: number) => void);
  119193. /**
  119194. * An event triggered after rendering the texture
  119195. */
  119196. onAfterRenderObservable: Observable<number>;
  119197. private _onAfterRenderObserver;
  119198. /**
  119199. * Set a after render callback in the texture.
  119200. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  119201. */
  119202. set onAfterRender(callback: (faceIndex: number) => void);
  119203. /**
  119204. * An event triggered after the texture clear
  119205. */
  119206. onClearObservable: Observable<Engine>;
  119207. private _onClearObserver;
  119208. /**
  119209. * Set a clear callback in the texture.
  119210. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  119211. */
  119212. set onClear(callback: (Engine: Engine) => void);
  119213. /**
  119214. * An event triggered when the texture is resized.
  119215. */
  119216. onResizeObservable: Observable<RenderTargetTexture>;
  119217. /**
  119218. * Define the clear color of the Render Target if it should be different from the scene.
  119219. */
  119220. clearColor: Color4;
  119221. protected _size: number | {
  119222. width: number;
  119223. height: number;
  119224. layers?: number;
  119225. };
  119226. protected _initialSizeParameter: number | {
  119227. width: number;
  119228. height: number;
  119229. } | {
  119230. ratio: number;
  119231. };
  119232. protected _sizeRatio: Nullable<number>;
  119233. /** @hidden */
  119234. _generateMipMaps: boolean;
  119235. protected _renderingManager: RenderingManager;
  119236. /** @hidden */
  119237. _waitingRenderList?: string[];
  119238. protected _doNotChangeAspectRatio: boolean;
  119239. protected _currentRefreshId: number;
  119240. protected _refreshRate: number;
  119241. protected _textureMatrix: Matrix;
  119242. protected _samples: number;
  119243. protected _renderTargetOptions: RenderTargetCreationOptions;
  119244. /**
  119245. * Gets render target creation options that were used.
  119246. */
  119247. get renderTargetOptions(): RenderTargetCreationOptions;
  119248. protected _onRatioRescale(): void;
  119249. /**
  119250. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  119251. * It must define where the camera used to render the texture is set
  119252. */
  119253. boundingBoxPosition: Vector3;
  119254. private _boundingBoxSize;
  119255. /**
  119256. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  119257. * When defined, the cubemap will switch to local mode
  119258. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119259. * @example https://www.babylonjs-playground.com/#RNASML
  119260. */
  119261. set boundingBoxSize(value: Vector3);
  119262. get boundingBoxSize(): Vector3;
  119263. /**
  119264. * In case the RTT has been created with a depth texture, get the associated
  119265. * depth texture.
  119266. * Otherwise, return null.
  119267. */
  119268. get depthStencilTexture(): Nullable<InternalTexture>;
  119269. /**
  119270. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  119271. * or used a shadow, depth texture...
  119272. * @param name The friendly name of the texture
  119273. * @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)
  119274. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  119275. * @param generateMipMaps True if mip maps need to be generated after render.
  119276. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  119277. * @param type The type of the buffer in the RTT (int, half float, float...)
  119278. * @param isCube True if a cube texture needs to be created
  119279. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  119280. * @param generateDepthBuffer True to generate a depth buffer
  119281. * @param generateStencilBuffer True to generate a stencil buffer
  119282. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  119283. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  119284. * @param delayAllocation if the texture allocation should be delayed (default: false)
  119285. */
  119286. constructor(name: string, size: number | {
  119287. width: number;
  119288. height: number;
  119289. layers?: number;
  119290. } | {
  119291. ratio: number;
  119292. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  119293. /**
  119294. * Creates a depth stencil texture.
  119295. * This is only available in WebGL 2 or with the depth texture extension available.
  119296. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  119297. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  119298. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  119299. */
  119300. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  119301. private _processSizeParameter;
  119302. /**
  119303. * Define the number of samples to use in case of MSAA.
  119304. * It defaults to one meaning no MSAA has been enabled.
  119305. */
  119306. get samples(): number;
  119307. set samples(value: number);
  119308. /**
  119309. * Resets the refresh counter of the texture and start bak from scratch.
  119310. * Could be useful to regenerate the texture if it is setup to render only once.
  119311. */
  119312. resetRefreshCounter(): void;
  119313. /**
  119314. * Define the refresh rate of the texture or the rendering frequency.
  119315. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  119316. */
  119317. get refreshRate(): number;
  119318. set refreshRate(value: number);
  119319. /**
  119320. * Adds a post process to the render target rendering passes.
  119321. * @param postProcess define the post process to add
  119322. */
  119323. addPostProcess(postProcess: PostProcess): void;
  119324. /**
  119325. * Clear all the post processes attached to the render target
  119326. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  119327. */
  119328. clearPostProcesses(dispose?: boolean): void;
  119329. /**
  119330. * Remove one of the post process from the list of attached post processes to the texture
  119331. * @param postProcess define the post process to remove from the list
  119332. */
  119333. removePostProcess(postProcess: PostProcess): void;
  119334. /** @hidden */
  119335. _shouldRender(): boolean;
  119336. /**
  119337. * Gets the actual render size of the texture.
  119338. * @returns the width of the render size
  119339. */
  119340. getRenderSize(): number;
  119341. /**
  119342. * Gets the actual render width of the texture.
  119343. * @returns the width of the render size
  119344. */
  119345. getRenderWidth(): number;
  119346. /**
  119347. * Gets the actual render height of the texture.
  119348. * @returns the height of the render size
  119349. */
  119350. getRenderHeight(): number;
  119351. /**
  119352. * Gets the actual number of layers of the texture.
  119353. * @returns the number of layers
  119354. */
  119355. getRenderLayers(): number;
  119356. /**
  119357. * Get if the texture can be rescaled or not.
  119358. */
  119359. get canRescale(): boolean;
  119360. /**
  119361. * Resize the texture using a ratio.
  119362. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  119363. */
  119364. scale(ratio: number): void;
  119365. /**
  119366. * Get the texture reflection matrix used to rotate/transform the reflection.
  119367. * @returns the reflection matrix
  119368. */
  119369. getReflectionTextureMatrix(): Matrix;
  119370. /**
  119371. * Resize the texture to a new desired size.
  119372. * Be carrefull as it will recreate all the data in the new texture.
  119373. * @param size Define the new size. It can be:
  119374. * - a number for squared texture,
  119375. * - an object containing { width: number, height: number }
  119376. * - or an object containing a ratio { ratio: number }
  119377. */
  119378. resize(size: number | {
  119379. width: number;
  119380. height: number;
  119381. } | {
  119382. ratio: number;
  119383. }): void;
  119384. private _defaultRenderListPrepared;
  119385. /**
  119386. * Renders all the objects from the render list into the texture.
  119387. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  119388. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  119389. */
  119390. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  119391. private _bestReflectionRenderTargetDimension;
  119392. private _prepareRenderingManager;
  119393. /**
  119394. * @hidden
  119395. * @param faceIndex face index to bind to if this is a cubetexture
  119396. * @param layer defines the index of the texture to bind in the array
  119397. */
  119398. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  119399. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  119400. private renderToTarget;
  119401. /**
  119402. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  119403. * This allowed control for front to back rendering or reversly depending of the special needs.
  119404. *
  119405. * @param renderingGroupId The rendering group id corresponding to its index
  119406. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  119407. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  119408. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  119409. */
  119410. 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;
  119411. /**
  119412. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  119413. *
  119414. * @param renderingGroupId The rendering group id corresponding to its index
  119415. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119416. */
  119417. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  119418. /**
  119419. * Clones the texture.
  119420. * @returns the cloned texture
  119421. */
  119422. clone(): RenderTargetTexture;
  119423. /**
  119424. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  119425. * @returns The JSON representation of the texture
  119426. */
  119427. serialize(): any;
  119428. /**
  119429. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  119430. */
  119431. disposeFramebufferObjects(): void;
  119432. /**
  119433. * Dispose the texture and release its associated resources.
  119434. */
  119435. dispose(): void;
  119436. /** @hidden */
  119437. _rebuild(): void;
  119438. /**
  119439. * Clear the info related to rendering groups preventing retention point in material dispose.
  119440. */
  119441. freeRenderingGroups(): void;
  119442. /**
  119443. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  119444. * @returns the view count
  119445. */
  119446. getViewCount(): number;
  119447. }
  119448. }
  119449. declare module BABYLON {
  119450. /**
  119451. * Options to be used when creating an effect.
  119452. */
  119453. export interface IEffectCreationOptions {
  119454. /**
  119455. * Atrributes that will be used in the shader.
  119456. */
  119457. attributes: string[];
  119458. /**
  119459. * Uniform varible names that will be set in the shader.
  119460. */
  119461. uniformsNames: string[];
  119462. /**
  119463. * Uniform buffer variable names that will be set in the shader.
  119464. */
  119465. uniformBuffersNames: string[];
  119466. /**
  119467. * Sampler texture variable names that will be set in the shader.
  119468. */
  119469. samplers: string[];
  119470. /**
  119471. * Define statements that will be set in the shader.
  119472. */
  119473. defines: any;
  119474. /**
  119475. * Possible fallbacks for this effect to improve performance when needed.
  119476. */
  119477. fallbacks: Nullable<IEffectFallbacks>;
  119478. /**
  119479. * Callback that will be called when the shader is compiled.
  119480. */
  119481. onCompiled: Nullable<(effect: Effect) => void>;
  119482. /**
  119483. * Callback that will be called if an error occurs during shader compilation.
  119484. */
  119485. onError: Nullable<(effect: Effect, errors: string) => void>;
  119486. /**
  119487. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  119488. */
  119489. indexParameters?: any;
  119490. /**
  119491. * Max number of lights that can be used in the shader.
  119492. */
  119493. maxSimultaneousLights?: number;
  119494. /**
  119495. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  119496. */
  119497. transformFeedbackVaryings?: Nullable<string[]>;
  119498. /**
  119499. * 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
  119500. */
  119501. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  119502. /**
  119503. * Is this effect rendering to several color attachments ?
  119504. */
  119505. multiTarget?: boolean;
  119506. }
  119507. /**
  119508. * Effect containing vertex and fragment shader that can be executed on an object.
  119509. */
  119510. export class Effect implements IDisposable {
  119511. /**
  119512. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119513. */
  119514. static ShadersRepository: string;
  119515. /**
  119516. * Enable logging of the shader code when a compilation error occurs
  119517. */
  119518. static LogShaderCodeOnCompilationError: boolean;
  119519. /**
  119520. * Name of the effect.
  119521. */
  119522. name: any;
  119523. /**
  119524. * String container all the define statements that should be set on the shader.
  119525. */
  119526. defines: string;
  119527. /**
  119528. * Callback that will be called when the shader is compiled.
  119529. */
  119530. onCompiled: Nullable<(effect: Effect) => void>;
  119531. /**
  119532. * Callback that will be called if an error occurs during shader compilation.
  119533. */
  119534. onError: Nullable<(effect: Effect, errors: string) => void>;
  119535. /**
  119536. * Callback that will be called when effect is bound.
  119537. */
  119538. onBind: Nullable<(effect: Effect) => void>;
  119539. /**
  119540. * Unique ID of the effect.
  119541. */
  119542. uniqueId: number;
  119543. /**
  119544. * Observable that will be called when the shader is compiled.
  119545. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  119546. */
  119547. onCompileObservable: Observable<Effect>;
  119548. /**
  119549. * Observable that will be called if an error occurs during shader compilation.
  119550. */
  119551. onErrorObservable: Observable<Effect>;
  119552. /** @hidden */
  119553. _onBindObservable: Nullable<Observable<Effect>>;
  119554. /**
  119555. * @hidden
  119556. * Specifies if the effect was previously ready
  119557. */
  119558. _wasPreviouslyReady: boolean;
  119559. /**
  119560. * Observable that will be called when effect is bound.
  119561. */
  119562. get onBindObservable(): Observable<Effect>;
  119563. /** @hidden */
  119564. _bonesComputationForcedToCPU: boolean;
  119565. /** @hidden */
  119566. _multiTarget: boolean;
  119567. private static _uniqueIdSeed;
  119568. private _engine;
  119569. private _uniformBuffersNames;
  119570. private _uniformBuffersNamesList;
  119571. private _uniformsNames;
  119572. private _samplerList;
  119573. private _samplers;
  119574. private _isReady;
  119575. private _compilationError;
  119576. private _allFallbacksProcessed;
  119577. private _attributesNames;
  119578. private _attributes;
  119579. private _attributeLocationByName;
  119580. private _uniforms;
  119581. /**
  119582. * Key for the effect.
  119583. * @hidden
  119584. */
  119585. _key: string;
  119586. private _indexParameters;
  119587. private _fallbacks;
  119588. private _vertexSourceCode;
  119589. private _fragmentSourceCode;
  119590. private _vertexSourceCodeOverride;
  119591. private _fragmentSourceCodeOverride;
  119592. private _transformFeedbackVaryings;
  119593. private _rawVertexSourceCode;
  119594. private _rawFragmentSourceCode;
  119595. /**
  119596. * Compiled shader to webGL program.
  119597. * @hidden
  119598. */
  119599. _pipelineContext: Nullable<IPipelineContext>;
  119600. private _valueCache;
  119601. private static _baseCache;
  119602. /**
  119603. * Instantiates an effect.
  119604. * An effect can be used to create/manage/execute vertex and fragment shaders.
  119605. * @param baseName Name of the effect.
  119606. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  119607. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  119608. * @param samplers List of sampler variables that will be passed to the shader.
  119609. * @param engine Engine to be used to render the effect
  119610. * @param defines Define statements to be added to the shader.
  119611. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  119612. * @param onCompiled Callback that will be called when the shader is compiled.
  119613. * @param onError Callback that will be called if an error occurs during shader compilation.
  119614. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  119615. */
  119616. 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);
  119617. private _useFinalCode;
  119618. /**
  119619. * Unique key for this effect
  119620. */
  119621. get key(): string;
  119622. /**
  119623. * If the effect has been compiled and prepared.
  119624. * @returns if the effect is compiled and prepared.
  119625. */
  119626. isReady(): boolean;
  119627. private _isReadyInternal;
  119628. /**
  119629. * The engine the effect was initialized with.
  119630. * @returns the engine.
  119631. */
  119632. getEngine(): Engine;
  119633. /**
  119634. * The pipeline context for this effect
  119635. * @returns the associated pipeline context
  119636. */
  119637. getPipelineContext(): Nullable<IPipelineContext>;
  119638. /**
  119639. * The set of names of attribute variables for the shader.
  119640. * @returns An array of attribute names.
  119641. */
  119642. getAttributesNames(): string[];
  119643. /**
  119644. * Returns the attribute at the given index.
  119645. * @param index The index of the attribute.
  119646. * @returns The location of the attribute.
  119647. */
  119648. getAttributeLocation(index: number): number;
  119649. /**
  119650. * Returns the attribute based on the name of the variable.
  119651. * @param name of the attribute to look up.
  119652. * @returns the attribute location.
  119653. */
  119654. getAttributeLocationByName(name: string): number;
  119655. /**
  119656. * The number of attributes.
  119657. * @returns the numnber of attributes.
  119658. */
  119659. getAttributesCount(): number;
  119660. /**
  119661. * Gets the index of a uniform variable.
  119662. * @param uniformName of the uniform to look up.
  119663. * @returns the index.
  119664. */
  119665. getUniformIndex(uniformName: string): number;
  119666. /**
  119667. * Returns the attribute based on the name of the variable.
  119668. * @param uniformName of the uniform to look up.
  119669. * @returns the location of the uniform.
  119670. */
  119671. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  119672. /**
  119673. * Returns an array of sampler variable names
  119674. * @returns The array of sampler variable names.
  119675. */
  119676. getSamplers(): string[];
  119677. /**
  119678. * Returns an array of uniform variable names
  119679. * @returns The array of uniform variable names.
  119680. */
  119681. getUniformNames(): string[];
  119682. /**
  119683. * Returns an array of uniform buffer variable names
  119684. * @returns The array of uniform buffer variable names.
  119685. */
  119686. getUniformBuffersNames(): string[];
  119687. /**
  119688. * Returns the index parameters used to create the effect
  119689. * @returns The index parameters object
  119690. */
  119691. getIndexParameters(): any;
  119692. /**
  119693. * The error from the last compilation.
  119694. * @returns the error string.
  119695. */
  119696. getCompilationError(): string;
  119697. /**
  119698. * Gets a boolean indicating that all fallbacks were used during compilation
  119699. * @returns true if all fallbacks were used
  119700. */
  119701. allFallbacksProcessed(): boolean;
  119702. /**
  119703. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  119704. * @param func The callback to be used.
  119705. */
  119706. executeWhenCompiled(func: (effect: Effect) => void): void;
  119707. private _checkIsReady;
  119708. private _loadShader;
  119709. /**
  119710. * Gets the vertex shader source code of this effect
  119711. */
  119712. get vertexSourceCode(): string;
  119713. /**
  119714. * Gets the fragment shader source code of this effect
  119715. */
  119716. get fragmentSourceCode(): string;
  119717. /**
  119718. * Gets the vertex shader source code before it has been processed by the preprocessor
  119719. */
  119720. get rawVertexSourceCode(): string;
  119721. /**
  119722. * Gets the fragment shader source code before it has been processed by the preprocessor
  119723. */
  119724. get rawFragmentSourceCode(): string;
  119725. /**
  119726. * Recompiles the webGL program
  119727. * @param vertexSourceCode The source code for the vertex shader.
  119728. * @param fragmentSourceCode The source code for the fragment shader.
  119729. * @param onCompiled Callback called when completed.
  119730. * @param onError Callback called on error.
  119731. * @hidden
  119732. */
  119733. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  119734. /**
  119735. * Prepares the effect
  119736. * @hidden
  119737. */
  119738. _prepareEffect(): void;
  119739. private _getShaderCodeAndErrorLine;
  119740. private _processCompilationErrors;
  119741. /**
  119742. * Checks if the effect is supported. (Must be called after compilation)
  119743. */
  119744. get isSupported(): boolean;
  119745. /**
  119746. * Binds a texture to the engine to be used as output of the shader.
  119747. * @param channel Name of the output variable.
  119748. * @param texture Texture to bind.
  119749. * @hidden
  119750. */
  119751. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  119752. /**
  119753. * Sets a texture on the engine to be used in the shader.
  119754. * @param channel Name of the sampler variable.
  119755. * @param texture Texture to set.
  119756. */
  119757. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  119758. /**
  119759. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  119760. * @param channel Name of the sampler variable.
  119761. * @param texture Texture to set.
  119762. */
  119763. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  119764. /**
  119765. * Sets an array of textures on the engine to be used in the shader.
  119766. * @param channel Name of the variable.
  119767. * @param textures Textures to set.
  119768. */
  119769. setTextureArray(channel: string, textures: ThinTexture[]): void;
  119770. /**
  119771. * 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)
  119772. * @param channel Name of the sampler variable.
  119773. * @param postProcess Post process to get the input texture from.
  119774. */
  119775. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  119776. /**
  119777. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  119778. * 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)
  119779. * @param channel Name of the sampler variable.
  119780. * @param postProcess Post process to get the output texture from.
  119781. */
  119782. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  119783. /** @hidden */
  119784. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  119785. /** @hidden */
  119786. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  119787. /** @hidden */
  119788. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  119789. /** @hidden */
  119790. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  119791. /**
  119792. * Binds a buffer to a uniform.
  119793. * @param buffer Buffer to bind.
  119794. * @param name Name of the uniform variable to bind to.
  119795. */
  119796. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  119797. /**
  119798. * Binds block to a uniform.
  119799. * @param blockName Name of the block to bind.
  119800. * @param index Index to bind.
  119801. */
  119802. bindUniformBlock(blockName: string, index: number): void;
  119803. /**
  119804. * Sets an interger value on a uniform variable.
  119805. * @param uniformName Name of the variable.
  119806. * @param value Value to be set.
  119807. * @returns this effect.
  119808. */
  119809. setInt(uniformName: string, value: number): Effect;
  119810. /**
  119811. * Sets an int array on a uniform variable.
  119812. * @param uniformName Name of the variable.
  119813. * @param array array to be set.
  119814. * @returns this effect.
  119815. */
  119816. setIntArray(uniformName: string, array: Int32Array): Effect;
  119817. /**
  119818. * 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)
  119819. * @param uniformName Name of the variable.
  119820. * @param array array to be set.
  119821. * @returns this effect.
  119822. */
  119823. setIntArray2(uniformName: string, array: Int32Array): Effect;
  119824. /**
  119825. * 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)
  119826. * @param uniformName Name of the variable.
  119827. * @param array array to be set.
  119828. * @returns this effect.
  119829. */
  119830. setIntArray3(uniformName: string, array: Int32Array): Effect;
  119831. /**
  119832. * 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)
  119833. * @param uniformName Name of the variable.
  119834. * @param array array to be set.
  119835. * @returns this effect.
  119836. */
  119837. setIntArray4(uniformName: string, array: Int32Array): Effect;
  119838. /**
  119839. * Sets an float array on a uniform variable.
  119840. * @param uniformName Name of the variable.
  119841. * @param array array to be set.
  119842. * @returns this effect.
  119843. */
  119844. setFloatArray(uniformName: string, array: Float32Array): Effect;
  119845. /**
  119846. * 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)
  119847. * @param uniformName Name of the variable.
  119848. * @param array array to be set.
  119849. * @returns this effect.
  119850. */
  119851. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  119852. /**
  119853. * 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)
  119854. * @param uniformName Name of the variable.
  119855. * @param array array to be set.
  119856. * @returns this effect.
  119857. */
  119858. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  119859. /**
  119860. * 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)
  119861. * @param uniformName Name of the variable.
  119862. * @param array array to be set.
  119863. * @returns this effect.
  119864. */
  119865. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  119866. /**
  119867. * Sets an array on a uniform variable.
  119868. * @param uniformName Name of the variable.
  119869. * @param array array to be set.
  119870. * @returns this effect.
  119871. */
  119872. setArray(uniformName: string, array: number[]): Effect;
  119873. /**
  119874. * 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)
  119875. * @param uniformName Name of the variable.
  119876. * @param array array to be set.
  119877. * @returns this effect.
  119878. */
  119879. setArray2(uniformName: string, array: number[]): Effect;
  119880. /**
  119881. * 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)
  119882. * @param uniformName Name of the variable.
  119883. * @param array array to be set.
  119884. * @returns this effect.
  119885. */
  119886. setArray3(uniformName: string, array: number[]): Effect;
  119887. /**
  119888. * 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)
  119889. * @param uniformName Name of the variable.
  119890. * @param array array to be set.
  119891. * @returns this effect.
  119892. */
  119893. setArray4(uniformName: string, array: number[]): Effect;
  119894. /**
  119895. * Sets matrices on a uniform variable.
  119896. * @param uniformName Name of the variable.
  119897. * @param matrices matrices to be set.
  119898. * @returns this effect.
  119899. */
  119900. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  119901. /**
  119902. * Sets matrix on a uniform variable.
  119903. * @param uniformName Name of the variable.
  119904. * @param matrix matrix to be set.
  119905. * @returns this effect.
  119906. */
  119907. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  119908. /**
  119909. * 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)
  119910. * @param uniformName Name of the variable.
  119911. * @param matrix matrix to be set.
  119912. * @returns this effect.
  119913. */
  119914. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  119915. /**
  119916. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  119917. * @param uniformName Name of the variable.
  119918. * @param matrix matrix to be set.
  119919. * @returns this effect.
  119920. */
  119921. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  119922. /**
  119923. * Sets a float on a uniform variable.
  119924. * @param uniformName Name of the variable.
  119925. * @param value value to be set.
  119926. * @returns this effect.
  119927. */
  119928. setFloat(uniformName: string, value: number): Effect;
  119929. /**
  119930. * Sets a boolean on a uniform variable.
  119931. * @param uniformName Name of the variable.
  119932. * @param bool value to be set.
  119933. * @returns this effect.
  119934. */
  119935. setBool(uniformName: string, bool: boolean): Effect;
  119936. /**
  119937. * Sets a Vector2 on a uniform variable.
  119938. * @param uniformName Name of the variable.
  119939. * @param vector2 vector2 to be set.
  119940. * @returns this effect.
  119941. */
  119942. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  119943. /**
  119944. * Sets a float2 on a uniform variable.
  119945. * @param uniformName Name of the variable.
  119946. * @param x First float in float2.
  119947. * @param y Second float in float2.
  119948. * @returns this effect.
  119949. */
  119950. setFloat2(uniformName: string, x: number, y: number): Effect;
  119951. /**
  119952. * Sets a Vector3 on a uniform variable.
  119953. * @param uniformName Name of the variable.
  119954. * @param vector3 Value to be set.
  119955. * @returns this effect.
  119956. */
  119957. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  119958. /**
  119959. * Sets a float3 on a uniform variable.
  119960. * @param uniformName Name of the variable.
  119961. * @param x First float in float3.
  119962. * @param y Second float in float3.
  119963. * @param z Third float in float3.
  119964. * @returns this effect.
  119965. */
  119966. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  119967. /**
  119968. * Sets a Vector4 on a uniform variable.
  119969. * @param uniformName Name of the variable.
  119970. * @param vector4 Value to be set.
  119971. * @returns this effect.
  119972. */
  119973. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  119974. /**
  119975. * Sets a float4 on a uniform variable.
  119976. * @param uniformName Name of the variable.
  119977. * @param x First float in float4.
  119978. * @param y Second float in float4.
  119979. * @param z Third float in float4.
  119980. * @param w Fourth float in float4.
  119981. * @returns this effect.
  119982. */
  119983. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  119984. /**
  119985. * Sets a Color3 on a uniform variable.
  119986. * @param uniformName Name of the variable.
  119987. * @param color3 Value to be set.
  119988. * @returns this effect.
  119989. */
  119990. setColor3(uniformName: string, color3: IColor3Like): Effect;
  119991. /**
  119992. * Sets a Color4 on a uniform variable.
  119993. * @param uniformName Name of the variable.
  119994. * @param color3 Value to be set.
  119995. * @param alpha Alpha value to be set.
  119996. * @returns this effect.
  119997. */
  119998. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  119999. /**
  120000. * Sets a Color4 on a uniform variable
  120001. * @param uniformName defines the name of the variable
  120002. * @param color4 defines the value to be set
  120003. * @returns this effect.
  120004. */
  120005. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  120006. /** Release all associated resources */
  120007. dispose(): void;
  120008. /**
  120009. * This function will add a new shader to the shader store
  120010. * @param name the name of the shader
  120011. * @param pixelShader optional pixel shader content
  120012. * @param vertexShader optional vertex shader content
  120013. */
  120014. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  120015. /**
  120016. * Store of each shader (The can be looked up using effect.key)
  120017. */
  120018. static ShadersStore: {
  120019. [key: string]: string;
  120020. };
  120021. /**
  120022. * Store of each included file for a shader (The can be looked up using effect.key)
  120023. */
  120024. static IncludesShadersStore: {
  120025. [key: string]: string;
  120026. };
  120027. /**
  120028. * Resets the cache of effects.
  120029. */
  120030. static ResetCache(): void;
  120031. }
  120032. }
  120033. declare module BABYLON {
  120034. /**
  120035. * Interface used to describe the capabilities of the engine relatively to the current browser
  120036. */
  120037. export interface EngineCapabilities {
  120038. /** Maximum textures units per fragment shader */
  120039. maxTexturesImageUnits: number;
  120040. /** Maximum texture units per vertex shader */
  120041. maxVertexTextureImageUnits: number;
  120042. /** Maximum textures units in the entire pipeline */
  120043. maxCombinedTexturesImageUnits: number;
  120044. /** Maximum texture size */
  120045. maxTextureSize: number;
  120046. /** Maximum texture samples */
  120047. maxSamples?: number;
  120048. /** Maximum cube texture size */
  120049. maxCubemapTextureSize: number;
  120050. /** Maximum render texture size */
  120051. maxRenderTextureSize: number;
  120052. /** Maximum number of vertex attributes */
  120053. maxVertexAttribs: number;
  120054. /** Maximum number of varyings */
  120055. maxVaryingVectors: number;
  120056. /** Maximum number of uniforms per vertex shader */
  120057. maxVertexUniformVectors: number;
  120058. /** Maximum number of uniforms per fragment shader */
  120059. maxFragmentUniformVectors: number;
  120060. /** Defines if standard derivates (dx/dy) are supported */
  120061. standardDerivatives: boolean;
  120062. /** Defines if s3tc texture compression is supported */
  120063. s3tc?: WEBGL_compressed_texture_s3tc;
  120064. /** Defines if pvrtc texture compression is supported */
  120065. pvrtc: any;
  120066. /** Defines if etc1 texture compression is supported */
  120067. etc1: any;
  120068. /** Defines if etc2 texture compression is supported */
  120069. etc2: any;
  120070. /** Defines if astc texture compression is supported */
  120071. astc: any;
  120072. /** Defines if bptc texture compression is supported */
  120073. bptc: any;
  120074. /** Defines if float textures are supported */
  120075. textureFloat: boolean;
  120076. /** Defines if vertex array objects are supported */
  120077. vertexArrayObject: boolean;
  120078. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  120079. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  120080. /** Gets the maximum level of anisotropy supported */
  120081. maxAnisotropy: number;
  120082. /** Defines if instancing is supported */
  120083. instancedArrays: boolean;
  120084. /** Defines if 32 bits indices are supported */
  120085. uintIndices: boolean;
  120086. /** Defines if high precision shaders are supported */
  120087. highPrecisionShaderSupported: boolean;
  120088. /** Defines if depth reading in the fragment shader is supported */
  120089. fragmentDepthSupported: boolean;
  120090. /** Defines if float texture linear filtering is supported*/
  120091. textureFloatLinearFiltering: boolean;
  120092. /** Defines if rendering to float textures is supported */
  120093. textureFloatRender: boolean;
  120094. /** Defines if half float textures are supported*/
  120095. textureHalfFloat: boolean;
  120096. /** Defines if half float texture linear filtering is supported*/
  120097. textureHalfFloatLinearFiltering: boolean;
  120098. /** Defines if rendering to half float textures is supported */
  120099. textureHalfFloatRender: boolean;
  120100. /** Defines if textureLOD shader command is supported */
  120101. textureLOD: boolean;
  120102. /** Defines if draw buffers extension is supported */
  120103. drawBuffersExtension: boolean;
  120104. /** Defines if depth textures are supported */
  120105. depthTextureExtension: boolean;
  120106. /** Defines if float color buffer are supported */
  120107. colorBufferFloat: boolean;
  120108. /** Gets disjoint timer query extension (null if not supported) */
  120109. timerQuery?: EXT_disjoint_timer_query;
  120110. /** Defines if timestamp can be used with timer query */
  120111. canUseTimestampForTimerQuery: boolean;
  120112. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  120113. multiview?: any;
  120114. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  120115. oculusMultiview?: any;
  120116. /** Function used to let the system compiles shaders in background */
  120117. parallelShaderCompile?: {
  120118. COMPLETION_STATUS_KHR: number;
  120119. };
  120120. /** Max number of texture samples for MSAA */
  120121. maxMSAASamples: number;
  120122. /** Defines if the blend min max extension is supported */
  120123. blendMinMax: boolean;
  120124. }
  120125. }
  120126. declare module BABYLON {
  120127. /**
  120128. * @hidden
  120129. **/
  120130. export class DepthCullingState {
  120131. private _isDepthTestDirty;
  120132. private _isDepthMaskDirty;
  120133. private _isDepthFuncDirty;
  120134. private _isCullFaceDirty;
  120135. private _isCullDirty;
  120136. private _isZOffsetDirty;
  120137. private _isFrontFaceDirty;
  120138. private _depthTest;
  120139. private _depthMask;
  120140. private _depthFunc;
  120141. private _cull;
  120142. private _cullFace;
  120143. private _zOffset;
  120144. private _frontFace;
  120145. /**
  120146. * Initializes the state.
  120147. */
  120148. constructor();
  120149. get isDirty(): boolean;
  120150. get zOffset(): number;
  120151. set zOffset(value: number);
  120152. get cullFace(): Nullable<number>;
  120153. set cullFace(value: Nullable<number>);
  120154. get cull(): Nullable<boolean>;
  120155. set cull(value: Nullable<boolean>);
  120156. get depthFunc(): Nullable<number>;
  120157. set depthFunc(value: Nullable<number>);
  120158. get depthMask(): boolean;
  120159. set depthMask(value: boolean);
  120160. get depthTest(): boolean;
  120161. set depthTest(value: boolean);
  120162. get frontFace(): Nullable<number>;
  120163. set frontFace(value: Nullable<number>);
  120164. reset(): void;
  120165. apply(gl: WebGLRenderingContext): void;
  120166. }
  120167. }
  120168. declare module BABYLON {
  120169. /**
  120170. * @hidden
  120171. **/
  120172. export class StencilState {
  120173. /** 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 */
  120174. static readonly ALWAYS: number;
  120175. /** Passed to stencilOperation to specify that stencil value must be kept */
  120176. static readonly KEEP: number;
  120177. /** Passed to stencilOperation to specify that stencil value must be replaced */
  120178. static readonly REPLACE: number;
  120179. private _isStencilTestDirty;
  120180. private _isStencilMaskDirty;
  120181. private _isStencilFuncDirty;
  120182. private _isStencilOpDirty;
  120183. private _stencilTest;
  120184. private _stencilMask;
  120185. private _stencilFunc;
  120186. private _stencilFuncRef;
  120187. private _stencilFuncMask;
  120188. private _stencilOpStencilFail;
  120189. private _stencilOpDepthFail;
  120190. private _stencilOpStencilDepthPass;
  120191. get isDirty(): boolean;
  120192. get stencilFunc(): number;
  120193. set stencilFunc(value: number);
  120194. get stencilFuncRef(): number;
  120195. set stencilFuncRef(value: number);
  120196. get stencilFuncMask(): number;
  120197. set stencilFuncMask(value: number);
  120198. get stencilOpStencilFail(): number;
  120199. set stencilOpStencilFail(value: number);
  120200. get stencilOpDepthFail(): number;
  120201. set stencilOpDepthFail(value: number);
  120202. get stencilOpStencilDepthPass(): number;
  120203. set stencilOpStencilDepthPass(value: number);
  120204. get stencilMask(): number;
  120205. set stencilMask(value: number);
  120206. get stencilTest(): boolean;
  120207. set stencilTest(value: boolean);
  120208. constructor();
  120209. reset(): void;
  120210. apply(gl: WebGLRenderingContext): void;
  120211. }
  120212. }
  120213. declare module BABYLON {
  120214. /**
  120215. * @hidden
  120216. **/
  120217. export class AlphaState {
  120218. private _isAlphaBlendDirty;
  120219. private _isBlendFunctionParametersDirty;
  120220. private _isBlendEquationParametersDirty;
  120221. private _isBlendConstantsDirty;
  120222. private _alphaBlend;
  120223. private _blendFunctionParameters;
  120224. private _blendEquationParameters;
  120225. private _blendConstants;
  120226. /**
  120227. * Initializes the state.
  120228. */
  120229. constructor();
  120230. get isDirty(): boolean;
  120231. get alphaBlend(): boolean;
  120232. set alphaBlend(value: boolean);
  120233. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  120234. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  120235. setAlphaEquationParameters(rgb: number, alpha: number): void;
  120236. reset(): void;
  120237. apply(gl: WebGLRenderingContext): void;
  120238. }
  120239. }
  120240. declare module BABYLON {
  120241. /** @hidden */
  120242. export class WebGLShaderProcessor implements IShaderProcessor {
  120243. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  120244. }
  120245. }
  120246. declare module BABYLON {
  120247. /** @hidden */
  120248. export class WebGL2ShaderProcessor implements IShaderProcessor {
  120249. attributeProcessor(attribute: string): string;
  120250. varyingProcessor(varying: string, isFragment: boolean): string;
  120251. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120252. }
  120253. }
  120254. declare module BABYLON {
  120255. /**
  120256. * Interface for attribute information associated with buffer instanciation
  120257. */
  120258. export interface InstancingAttributeInfo {
  120259. /**
  120260. * Name of the GLSL attribute
  120261. * if attribute index is not specified, this is used to retrieve the index from the effect
  120262. */
  120263. attributeName: string;
  120264. /**
  120265. * Index/offset of the attribute in the vertex shader
  120266. * if not specified, this will be computes from the name.
  120267. */
  120268. index?: number;
  120269. /**
  120270. * size of the attribute, 1, 2, 3 or 4
  120271. */
  120272. attributeSize: number;
  120273. /**
  120274. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  120275. */
  120276. offset: number;
  120277. /**
  120278. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  120279. * default to 1
  120280. */
  120281. divisor?: number;
  120282. /**
  120283. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  120284. * default is FLOAT
  120285. */
  120286. attributeType?: number;
  120287. /**
  120288. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  120289. */
  120290. normalized?: boolean;
  120291. }
  120292. }
  120293. declare module BABYLON {
  120294. interface ThinEngine {
  120295. /**
  120296. * Update a video texture
  120297. * @param texture defines the texture to update
  120298. * @param video defines the video element to use
  120299. * @param invertY defines if data must be stored with Y axis inverted
  120300. */
  120301. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  120302. }
  120303. }
  120304. declare module BABYLON {
  120305. interface ThinEngine {
  120306. /**
  120307. * Creates a dynamic texture
  120308. * @param width defines the width of the texture
  120309. * @param height defines the height of the texture
  120310. * @param generateMipMaps defines if the engine should generate the mip levels
  120311. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  120312. * @returns the dynamic texture inside an InternalTexture
  120313. */
  120314. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  120315. /**
  120316. * Update the content of a dynamic texture
  120317. * @param texture defines the texture to update
  120318. * @param source defines the source containing the data
  120319. * @param invertY defines if data must be stored with Y axis inverted
  120320. * @param premulAlpha defines if alpha is stored as premultiplied
  120321. * @param format defines the format of the data
  120322. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120323. */
  120324. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  120325. }
  120326. }
  120327. declare module BABYLON {
  120328. /**
  120329. * Settings for finer control over video usage
  120330. */
  120331. export interface VideoTextureSettings {
  120332. /**
  120333. * Applies `autoplay` to video, if specified
  120334. */
  120335. autoPlay?: boolean;
  120336. /**
  120337. * Applies `muted` to video, if specified
  120338. */
  120339. muted?: boolean;
  120340. /**
  120341. * Applies `loop` to video, if specified
  120342. */
  120343. loop?: boolean;
  120344. /**
  120345. * Automatically updates internal texture from video at every frame in the render loop
  120346. */
  120347. autoUpdateTexture: boolean;
  120348. /**
  120349. * Image src displayed during the video loading or until the user interacts with the video.
  120350. */
  120351. poster?: string;
  120352. }
  120353. /**
  120354. * If you want to display a video in your scene, this is the special texture for that.
  120355. * This special texture works similar to other textures, with the exception of a few parameters.
  120356. * @see https://doc.babylonjs.com/how_to/video_texture
  120357. */
  120358. export class VideoTexture extends Texture {
  120359. /**
  120360. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  120361. */
  120362. readonly autoUpdateTexture: boolean;
  120363. /**
  120364. * The video instance used by the texture internally
  120365. */
  120366. readonly video: HTMLVideoElement;
  120367. private _onUserActionRequestedObservable;
  120368. /**
  120369. * Event triggerd when a dom action is required by the user to play the video.
  120370. * This happens due to recent changes in browser policies preventing video to auto start.
  120371. */
  120372. get onUserActionRequestedObservable(): Observable<Texture>;
  120373. private _generateMipMaps;
  120374. private _stillImageCaptured;
  120375. private _displayingPosterTexture;
  120376. private _settings;
  120377. private _createInternalTextureOnEvent;
  120378. private _frameId;
  120379. private _currentSrc;
  120380. /**
  120381. * Creates a video texture.
  120382. * If you want to display a video in your scene, this is the special texture for that.
  120383. * This special texture works similar to other textures, with the exception of a few parameters.
  120384. * @see https://doc.babylonjs.com/how_to/video_texture
  120385. * @param name optional name, will detect from video source, if not defined
  120386. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  120387. * @param scene is obviously the current scene.
  120388. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  120389. * @param invertY is false by default but can be used to invert video on Y axis
  120390. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  120391. * @param settings allows finer control over video usage
  120392. */
  120393. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  120394. private _getName;
  120395. private _getVideo;
  120396. private _createInternalTexture;
  120397. private reset;
  120398. /**
  120399. * @hidden Internal method to initiate `update`.
  120400. */
  120401. _rebuild(): void;
  120402. /**
  120403. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  120404. */
  120405. update(): void;
  120406. /**
  120407. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  120408. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  120409. */
  120410. updateTexture(isVisible: boolean): void;
  120411. protected _updateInternalTexture: () => void;
  120412. /**
  120413. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  120414. * @param url New url.
  120415. */
  120416. updateURL(url: string): void;
  120417. /**
  120418. * Clones the texture.
  120419. * @returns the cloned texture
  120420. */
  120421. clone(): VideoTexture;
  120422. /**
  120423. * Dispose the texture and release its associated resources.
  120424. */
  120425. dispose(): void;
  120426. /**
  120427. * Creates a video texture straight from a stream.
  120428. * @param scene Define the scene the texture should be created in
  120429. * @param stream Define the stream the texture should be created from
  120430. * @returns The created video texture as a promise
  120431. */
  120432. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  120433. /**
  120434. * Creates a video texture straight from your WebCam video feed.
  120435. * @param scene Define the scene the texture should be created in
  120436. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  120437. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  120438. * @returns The created video texture as a promise
  120439. */
  120440. static CreateFromWebCamAsync(scene: Scene, constraints: {
  120441. minWidth: number;
  120442. maxWidth: number;
  120443. minHeight: number;
  120444. maxHeight: number;
  120445. deviceId: string;
  120446. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  120447. /**
  120448. * Creates a video texture straight from your WebCam video feed.
  120449. * @param scene Define the scene the texture should be created in
  120450. * @param onReady Define a callback to triggered once the texture will be ready
  120451. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  120452. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  120453. */
  120454. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  120455. minWidth: number;
  120456. maxWidth: number;
  120457. minHeight: number;
  120458. maxHeight: number;
  120459. deviceId: string;
  120460. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  120461. }
  120462. }
  120463. declare module BABYLON {
  120464. /**
  120465. * Defines the interface used by objects working like Scene
  120466. * @hidden
  120467. */
  120468. export interface ISceneLike {
  120469. _addPendingData(data: any): void;
  120470. _removePendingData(data: any): void;
  120471. offlineProvider: IOfflineProvider;
  120472. }
  120473. /**
  120474. * Information about the current host
  120475. */
  120476. export interface HostInformation {
  120477. /**
  120478. * Defines if the current host is a mobile
  120479. */
  120480. isMobile: boolean;
  120481. }
  120482. /** Interface defining initialization parameters for Engine class */
  120483. export interface EngineOptions extends WebGLContextAttributes {
  120484. /**
  120485. * Defines if the engine should no exceed a specified device ratio
  120486. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  120487. */
  120488. limitDeviceRatio?: number;
  120489. /**
  120490. * Defines if webvr should be enabled automatically
  120491. * @see https://doc.babylonjs.com/how_to/webvr_camera
  120492. */
  120493. autoEnableWebVR?: boolean;
  120494. /**
  120495. * Defines if webgl2 should be turned off even if supported
  120496. * @see https://doc.babylonjs.com/features/webgl2
  120497. */
  120498. disableWebGL2Support?: boolean;
  120499. /**
  120500. * Defines if webaudio should be initialized as well
  120501. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120502. */
  120503. audioEngine?: boolean;
  120504. /**
  120505. * Defines if animations should run using a deterministic lock step
  120506. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120507. */
  120508. deterministicLockstep?: boolean;
  120509. /** Defines the maximum steps to use with deterministic lock step mode */
  120510. lockstepMaxSteps?: number;
  120511. /** Defines the seconds between each deterministic lock step */
  120512. timeStep?: number;
  120513. /**
  120514. * Defines that engine should ignore context lost events
  120515. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  120516. */
  120517. doNotHandleContextLost?: boolean;
  120518. /**
  120519. * Defines that engine should ignore modifying touch action attribute and style
  120520. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  120521. */
  120522. doNotHandleTouchAction?: boolean;
  120523. /**
  120524. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  120525. */
  120526. useHighPrecisionFloats?: boolean;
  120527. /**
  120528. * Make the canvas XR Compatible for XR sessions
  120529. */
  120530. xrCompatible?: boolean;
  120531. /**
  120532. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  120533. */
  120534. useHighPrecisionMatrix?: boolean;
  120535. /**
  120536. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  120537. */
  120538. failIfMajorPerformanceCaveat?: boolean;
  120539. }
  120540. /**
  120541. * The base engine class (root of all engines)
  120542. */
  120543. export class ThinEngine {
  120544. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  120545. static ExceptionList: ({
  120546. key: string;
  120547. capture: string;
  120548. captureConstraint: number;
  120549. targets: string[];
  120550. } | {
  120551. key: string;
  120552. capture: null;
  120553. captureConstraint: null;
  120554. targets: string[];
  120555. })[];
  120556. /** @hidden */
  120557. static _TextureLoaders: IInternalTextureLoader[];
  120558. /**
  120559. * Returns the current npm package of the sdk
  120560. */
  120561. static get NpmPackage(): string;
  120562. /**
  120563. * Returns the current version of the framework
  120564. */
  120565. static get Version(): string;
  120566. /**
  120567. * Returns a string describing the current engine
  120568. */
  120569. get description(): string;
  120570. /**
  120571. * Gets or sets the epsilon value used by collision engine
  120572. */
  120573. static CollisionsEpsilon: number;
  120574. /**
  120575. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  120576. */
  120577. static get ShadersRepository(): string;
  120578. static set ShadersRepository(value: string);
  120579. /** @hidden */
  120580. _shaderProcessor: IShaderProcessor;
  120581. /**
  120582. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  120583. */
  120584. forcePOTTextures: boolean;
  120585. /**
  120586. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  120587. */
  120588. isFullscreen: boolean;
  120589. /**
  120590. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  120591. */
  120592. cullBackFaces: boolean;
  120593. /**
  120594. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  120595. */
  120596. renderEvenInBackground: boolean;
  120597. /**
  120598. * Gets or sets a boolean indicating that cache can be kept between frames
  120599. */
  120600. preventCacheWipeBetweenFrames: boolean;
  120601. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  120602. validateShaderPrograms: boolean;
  120603. /**
  120604. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  120605. * This can provide greater z depth for distant objects.
  120606. */
  120607. useReverseDepthBuffer: boolean;
  120608. /**
  120609. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  120610. */
  120611. disableUniformBuffers: boolean;
  120612. /** @hidden */
  120613. _uniformBuffers: UniformBuffer[];
  120614. /**
  120615. * Gets a boolean indicating that the engine supports uniform buffers
  120616. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  120617. */
  120618. get supportsUniformBuffers(): boolean;
  120619. /** @hidden */
  120620. _gl: WebGLRenderingContext;
  120621. /** @hidden */
  120622. _webGLVersion: number;
  120623. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  120624. protected _windowIsBackground: boolean;
  120625. protected _creationOptions: EngineOptions;
  120626. protected _highPrecisionShadersAllowed: boolean;
  120627. /** @hidden */
  120628. get _shouldUseHighPrecisionShader(): boolean;
  120629. /**
  120630. * Gets a boolean indicating that only power of 2 textures are supported
  120631. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  120632. */
  120633. get needPOTTextures(): boolean;
  120634. /** @hidden */
  120635. _badOS: boolean;
  120636. /** @hidden */
  120637. _badDesktopOS: boolean;
  120638. private _hardwareScalingLevel;
  120639. /** @hidden */
  120640. _caps: EngineCapabilities;
  120641. private _isStencilEnable;
  120642. private _glVersion;
  120643. private _glRenderer;
  120644. private _glVendor;
  120645. /** @hidden */
  120646. _videoTextureSupported: boolean;
  120647. protected _renderingQueueLaunched: boolean;
  120648. protected _activeRenderLoops: (() => void)[];
  120649. /**
  120650. * Observable signaled when a context lost event is raised
  120651. */
  120652. onContextLostObservable: Observable<ThinEngine>;
  120653. /**
  120654. * Observable signaled when a context restored event is raised
  120655. */
  120656. onContextRestoredObservable: Observable<ThinEngine>;
  120657. private _onContextLost;
  120658. private _onContextRestored;
  120659. protected _contextWasLost: boolean;
  120660. /** @hidden */
  120661. _doNotHandleContextLost: boolean;
  120662. /**
  120663. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  120664. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  120665. */
  120666. get doNotHandleContextLost(): boolean;
  120667. set doNotHandleContextLost(value: boolean);
  120668. /**
  120669. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  120670. */
  120671. disableVertexArrayObjects: boolean;
  120672. /** @hidden */
  120673. protected _colorWrite: boolean;
  120674. /** @hidden */
  120675. protected _colorWriteChanged: boolean;
  120676. /** @hidden */
  120677. protected _depthCullingState: DepthCullingState;
  120678. /** @hidden */
  120679. protected _stencilState: StencilState;
  120680. /** @hidden */
  120681. _alphaState: AlphaState;
  120682. /** @hidden */
  120683. _alphaMode: number;
  120684. /** @hidden */
  120685. _alphaEquation: number;
  120686. /** @hidden */
  120687. _internalTexturesCache: InternalTexture[];
  120688. /** @hidden */
  120689. protected _activeChannel: number;
  120690. private _currentTextureChannel;
  120691. /** @hidden */
  120692. protected _boundTexturesCache: {
  120693. [key: string]: Nullable<InternalTexture>;
  120694. };
  120695. /** @hidden */
  120696. protected _currentEffect: Nullable<Effect>;
  120697. /** @hidden */
  120698. protected _currentProgram: Nullable<WebGLProgram>;
  120699. private _compiledEffects;
  120700. private _vertexAttribArraysEnabled;
  120701. /** @hidden */
  120702. protected _cachedViewport: Nullable<IViewportLike>;
  120703. private _cachedVertexArrayObject;
  120704. /** @hidden */
  120705. protected _cachedVertexBuffers: any;
  120706. /** @hidden */
  120707. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  120708. /** @hidden */
  120709. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  120710. /** @hidden */
  120711. _currentRenderTarget: Nullable<InternalTexture>;
  120712. private _uintIndicesCurrentlySet;
  120713. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  120714. /** @hidden */
  120715. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  120716. /** @hidden */
  120717. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  120718. private _currentBufferPointers;
  120719. private _currentInstanceLocations;
  120720. private _currentInstanceBuffers;
  120721. private _textureUnits;
  120722. /** @hidden */
  120723. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120724. /** @hidden */
  120725. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120726. /** @hidden */
  120727. _boundRenderFunction: any;
  120728. private _vaoRecordInProgress;
  120729. private _mustWipeVertexAttributes;
  120730. private _emptyTexture;
  120731. private _emptyCubeTexture;
  120732. private _emptyTexture3D;
  120733. private _emptyTexture2DArray;
  120734. /** @hidden */
  120735. _frameHandler: number;
  120736. private _nextFreeTextureSlots;
  120737. private _maxSimultaneousTextures;
  120738. private _activeRequests;
  120739. /** @hidden */
  120740. _transformTextureUrl: Nullable<(url: string) => string>;
  120741. /**
  120742. * Gets information about the current host
  120743. */
  120744. hostInformation: HostInformation;
  120745. protected get _supportsHardwareTextureRescaling(): boolean;
  120746. private _framebufferDimensionsObject;
  120747. /**
  120748. * sets the object from which width and height will be taken from when getting render width and height
  120749. * Will fallback to the gl object
  120750. * @param dimensions the framebuffer width and height that will be used.
  120751. */
  120752. set framebufferDimensionsObject(dimensions: Nullable<{
  120753. framebufferWidth: number;
  120754. framebufferHeight: number;
  120755. }>);
  120756. /**
  120757. * Gets the current viewport
  120758. */
  120759. get currentViewport(): Nullable<IViewportLike>;
  120760. /**
  120761. * Gets the default empty texture
  120762. */
  120763. get emptyTexture(): InternalTexture;
  120764. /**
  120765. * Gets the default empty 3D texture
  120766. */
  120767. get emptyTexture3D(): InternalTexture;
  120768. /**
  120769. * Gets the default empty 2D array texture
  120770. */
  120771. get emptyTexture2DArray(): InternalTexture;
  120772. /**
  120773. * Gets the default empty cube texture
  120774. */
  120775. get emptyCubeTexture(): InternalTexture;
  120776. /**
  120777. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  120778. */
  120779. readonly premultipliedAlpha: boolean;
  120780. /**
  120781. * Observable event triggered before each texture is initialized
  120782. */
  120783. onBeforeTextureInitObservable: Observable<Texture>;
  120784. /**
  120785. * Creates a new engine
  120786. * @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
  120787. * @param antialias defines enable antialiasing (default: false)
  120788. * @param options defines further options to be sent to the getContext() function
  120789. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  120790. */
  120791. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  120792. private _rebuildInternalTextures;
  120793. private _rebuildEffects;
  120794. /**
  120795. * Gets a boolean indicating if all created effects are ready
  120796. * @returns true if all effects are ready
  120797. */
  120798. areAllEffectsReady(): boolean;
  120799. protected _rebuildBuffers(): void;
  120800. protected _initGLContext(): void;
  120801. /**
  120802. * Gets version of the current webGL context
  120803. */
  120804. get webGLVersion(): number;
  120805. /**
  120806. * Gets a string identifying the name of the class
  120807. * @returns "Engine" string
  120808. */
  120809. getClassName(): string;
  120810. /**
  120811. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  120812. */
  120813. get isStencilEnable(): boolean;
  120814. /** @hidden */
  120815. _prepareWorkingCanvas(): void;
  120816. /**
  120817. * Reset the texture cache to empty state
  120818. */
  120819. resetTextureCache(): void;
  120820. /**
  120821. * Gets an object containing information about the current webGL context
  120822. * @returns an object containing the vender, the renderer and the version of the current webGL context
  120823. */
  120824. getGlInfo(): {
  120825. vendor: string;
  120826. renderer: string;
  120827. version: string;
  120828. };
  120829. /**
  120830. * Defines the hardware scaling level.
  120831. * By default the hardware scaling level is computed from the window device ratio.
  120832. * 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.
  120833. * @param level defines the level to use
  120834. */
  120835. setHardwareScalingLevel(level: number): void;
  120836. /**
  120837. * Gets the current hardware scaling level.
  120838. * By default the hardware scaling level is computed from the window device ratio.
  120839. * 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.
  120840. * @returns a number indicating the current hardware scaling level
  120841. */
  120842. getHardwareScalingLevel(): number;
  120843. /**
  120844. * Gets the list of loaded textures
  120845. * @returns an array containing all loaded textures
  120846. */
  120847. getLoadedTexturesCache(): InternalTexture[];
  120848. /**
  120849. * Gets the object containing all engine capabilities
  120850. * @returns the EngineCapabilities object
  120851. */
  120852. getCaps(): EngineCapabilities;
  120853. /**
  120854. * stop executing a render loop function and remove it from the execution array
  120855. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  120856. */
  120857. stopRenderLoop(renderFunction?: () => void): void;
  120858. /** @hidden */
  120859. _renderLoop(): void;
  120860. /**
  120861. * Gets the HTML canvas attached with the current webGL context
  120862. * @returns a HTML canvas
  120863. */
  120864. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  120865. /**
  120866. * Gets host window
  120867. * @returns the host window object
  120868. */
  120869. getHostWindow(): Nullable<Window>;
  120870. /**
  120871. * Gets the current render width
  120872. * @param useScreen defines if screen size must be used (or the current render target if any)
  120873. * @returns a number defining the current render width
  120874. */
  120875. getRenderWidth(useScreen?: boolean): number;
  120876. /**
  120877. * Gets the current render height
  120878. * @param useScreen defines if screen size must be used (or the current render target if any)
  120879. * @returns a number defining the current render height
  120880. */
  120881. getRenderHeight(useScreen?: boolean): number;
  120882. /**
  120883. * Can be used to override the current requestAnimationFrame requester.
  120884. * @hidden
  120885. */
  120886. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120887. /**
  120888. * Register and execute a render loop. The engine can have more than one render function
  120889. * @param renderFunction defines the function to continuously execute
  120890. */
  120891. runRenderLoop(renderFunction: () => void): void;
  120892. /**
  120893. * Clear the current render buffer or the current render target (if any is set up)
  120894. * @param color defines the color to use
  120895. * @param backBuffer defines if the back buffer must be cleared
  120896. * @param depth defines if the depth buffer must be cleared
  120897. * @param stencil defines if the stencil buffer must be cleared
  120898. */
  120899. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120900. private _viewportCached;
  120901. /** @hidden */
  120902. _viewport(x: number, y: number, width: number, height: number): void;
  120903. /**
  120904. * Set the WebGL's viewport
  120905. * @param viewport defines the viewport element to be used
  120906. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  120907. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  120908. */
  120909. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  120910. /**
  120911. * Begin a new frame
  120912. */
  120913. beginFrame(): void;
  120914. /**
  120915. * Enf the current frame
  120916. */
  120917. endFrame(): void;
  120918. /**
  120919. * Resize the view according to the canvas' size
  120920. */
  120921. resize(): void;
  120922. /**
  120923. * Force a specific size of the canvas
  120924. * @param width defines the new canvas' width
  120925. * @param height defines the new canvas' height
  120926. * @returns true if the size was changed
  120927. */
  120928. setSize(width: number, height: number): boolean;
  120929. /**
  120930. * Binds the frame buffer to the specified texture.
  120931. * @param texture The texture to render to or null for the default canvas
  120932. * @param faceIndex The face of the texture to render to in case of cube texture
  120933. * @param requiredWidth The width of the target to render to
  120934. * @param requiredHeight The height of the target to render to
  120935. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120936. * @param lodLevel defines the lod level to bind to the frame buffer
  120937. * @param layer defines the 2d array index to bind to frame buffer to
  120938. */
  120939. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  120940. /** @hidden */
  120941. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120942. /**
  120943. * Unbind the current render target texture from the webGL context
  120944. * @param texture defines the render target texture to unbind
  120945. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120946. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120947. */
  120948. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120949. /**
  120950. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  120951. */
  120952. flushFramebuffer(): void;
  120953. /**
  120954. * Unbind the current render target and bind the default framebuffer
  120955. */
  120956. restoreDefaultFramebuffer(): void;
  120957. /** @hidden */
  120958. protected _resetVertexBufferBinding(): void;
  120959. /**
  120960. * Creates a vertex buffer
  120961. * @param data the data for the vertex buffer
  120962. * @returns the new WebGL static buffer
  120963. */
  120964. createVertexBuffer(data: DataArray): DataBuffer;
  120965. private _createVertexBuffer;
  120966. /**
  120967. * Creates a dynamic vertex buffer
  120968. * @param data the data for the dynamic vertex buffer
  120969. * @returns the new WebGL dynamic buffer
  120970. */
  120971. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120972. protected _resetIndexBufferBinding(): void;
  120973. /**
  120974. * Creates a new index buffer
  120975. * @param indices defines the content of the index buffer
  120976. * @param updatable defines if the index buffer must be updatable
  120977. * @returns a new webGL buffer
  120978. */
  120979. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  120980. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  120981. /**
  120982. * Bind a webGL buffer to the webGL context
  120983. * @param buffer defines the buffer to bind
  120984. */
  120985. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  120986. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  120987. private bindBuffer;
  120988. /**
  120989. * update the bound buffer with the given data
  120990. * @param data defines the data to update
  120991. */
  120992. updateArrayBuffer(data: Float32Array): void;
  120993. private _vertexAttribPointer;
  120994. /** @hidden */
  120995. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  120996. private _bindVertexBuffersAttributes;
  120997. /**
  120998. * Records a vertex array object
  120999. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  121000. * @param vertexBuffers defines the list of vertex buffers to store
  121001. * @param indexBuffer defines the index buffer to store
  121002. * @param effect defines the effect to store
  121003. * @returns the new vertex array object
  121004. */
  121005. recordVertexArrayObject(vertexBuffers: {
  121006. [key: string]: VertexBuffer;
  121007. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  121008. /**
  121009. * Bind a specific vertex array object
  121010. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  121011. * @param vertexArrayObject defines the vertex array object to bind
  121012. * @param indexBuffer defines the index buffer to bind
  121013. */
  121014. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  121015. /**
  121016. * Bind webGl buffers directly to the webGL context
  121017. * @param vertexBuffer defines the vertex buffer to bind
  121018. * @param indexBuffer defines the index buffer to bind
  121019. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  121020. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  121021. * @param effect defines the effect associated with the vertex buffer
  121022. */
  121023. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  121024. private _unbindVertexArrayObject;
  121025. /**
  121026. * Bind a list of vertex buffers to the webGL context
  121027. * @param vertexBuffers defines the list of vertex buffers to bind
  121028. * @param indexBuffer defines the index buffer to bind
  121029. * @param effect defines the effect associated with the vertex buffers
  121030. */
  121031. bindBuffers(vertexBuffers: {
  121032. [key: string]: Nullable<VertexBuffer>;
  121033. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  121034. /**
  121035. * Unbind all instance attributes
  121036. */
  121037. unbindInstanceAttributes(): void;
  121038. /**
  121039. * Release and free the memory of a vertex array object
  121040. * @param vao defines the vertex array object to delete
  121041. */
  121042. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  121043. /** @hidden */
  121044. _releaseBuffer(buffer: DataBuffer): boolean;
  121045. protected _deleteBuffer(buffer: DataBuffer): void;
  121046. /**
  121047. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  121048. * @param instancesBuffer defines the webGL buffer to update and bind
  121049. * @param data defines the data to store in the buffer
  121050. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  121051. */
  121052. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  121053. /**
  121054. * Bind the content of a webGL buffer used with instantiation
  121055. * @param instancesBuffer defines the webGL buffer to bind
  121056. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  121057. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  121058. */
  121059. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  121060. /**
  121061. * Disable the instance attribute corresponding to the name in parameter
  121062. * @param name defines the name of the attribute to disable
  121063. */
  121064. disableInstanceAttributeByName(name: string): void;
  121065. /**
  121066. * Disable the instance attribute corresponding to the location in parameter
  121067. * @param attributeLocation defines the attribute location of the attribute to disable
  121068. */
  121069. disableInstanceAttribute(attributeLocation: number): void;
  121070. /**
  121071. * Disable the attribute corresponding to the location in parameter
  121072. * @param attributeLocation defines the attribute location of the attribute to disable
  121073. */
  121074. disableAttributeByIndex(attributeLocation: number): void;
  121075. /**
  121076. * Send a draw order
  121077. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121078. * @param indexStart defines the starting index
  121079. * @param indexCount defines the number of index to draw
  121080. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121081. */
  121082. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  121083. /**
  121084. * Draw a list of points
  121085. * @param verticesStart defines the index of first vertex to draw
  121086. * @param verticesCount defines the count of vertices to draw
  121087. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121088. */
  121089. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121090. /**
  121091. * Draw a list of unindexed primitives
  121092. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121093. * @param verticesStart defines the index of first vertex to draw
  121094. * @param verticesCount defines the count of vertices to draw
  121095. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121096. */
  121097. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121098. /**
  121099. * Draw a list of indexed primitives
  121100. * @param fillMode defines the primitive to use
  121101. * @param indexStart defines the starting index
  121102. * @param indexCount defines the number of index to draw
  121103. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121104. */
  121105. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121106. /**
  121107. * Draw a list of unindexed primitives
  121108. * @param fillMode defines the primitive to use
  121109. * @param verticesStart defines the index of first vertex to draw
  121110. * @param verticesCount defines the count of vertices to draw
  121111. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121112. */
  121113. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121114. private _drawMode;
  121115. /** @hidden */
  121116. protected _reportDrawCall(): void;
  121117. /** @hidden */
  121118. _releaseEffect(effect: Effect): void;
  121119. /** @hidden */
  121120. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121121. /**
  121122. * Create a new effect (used to store vertex/fragment shaders)
  121123. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  121124. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  121125. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  121126. * @param samplers defines an array of string used to represent textures
  121127. * @param defines defines the string containing the defines to use to compile the shaders
  121128. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  121129. * @param onCompiled defines a function to call when the effect creation is successful
  121130. * @param onError defines a function to call when the effect creation has failed
  121131. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  121132. * @returns the new Effect
  121133. */
  121134. 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;
  121135. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  121136. private _compileShader;
  121137. private _compileRawShader;
  121138. /** @hidden */
  121139. _getShaderSource(shader: WebGLShader): Nullable<string>;
  121140. /**
  121141. * Directly creates a webGL program
  121142. * @param pipelineContext defines the pipeline context to attach to
  121143. * @param vertexCode defines the vertex shader code to use
  121144. * @param fragmentCode defines the fragment shader code to use
  121145. * @param context defines the webGL context to use (if not set, the current one will be used)
  121146. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  121147. * @returns the new webGL program
  121148. */
  121149. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121150. /**
  121151. * Creates a webGL program
  121152. * @param pipelineContext defines the pipeline context to attach to
  121153. * @param vertexCode defines the vertex shader code to use
  121154. * @param fragmentCode defines the fragment shader code to use
  121155. * @param defines defines the string containing the defines to use to compile the shaders
  121156. * @param context defines the webGL context to use (if not set, the current one will be used)
  121157. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  121158. * @returns the new webGL program
  121159. */
  121160. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121161. /**
  121162. * Creates a new pipeline context
  121163. * @returns the new pipeline
  121164. */
  121165. createPipelineContext(): IPipelineContext;
  121166. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121167. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  121168. /** @hidden */
  121169. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  121170. /** @hidden */
  121171. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  121172. /** @hidden */
  121173. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  121174. /**
  121175. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  121176. * @param pipelineContext defines the pipeline context to use
  121177. * @param uniformsNames defines the list of uniform names
  121178. * @returns an array of webGL uniform locations
  121179. */
  121180. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  121181. /**
  121182. * Gets the lsit of active attributes for a given webGL program
  121183. * @param pipelineContext defines the pipeline context to use
  121184. * @param attributesNames defines the list of attribute names to get
  121185. * @returns an array of indices indicating the offset of each attribute
  121186. */
  121187. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121188. /**
  121189. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  121190. * @param effect defines the effect to activate
  121191. */
  121192. enableEffect(effect: Nullable<Effect>): void;
  121193. /**
  121194. * Set the value of an uniform to a number (int)
  121195. * @param uniform defines the webGL uniform location where to store the value
  121196. * @param value defines the int number to store
  121197. * @returns true if the value was set
  121198. */
  121199. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  121200. /**
  121201. * Set the value of an uniform to an array of int32
  121202. * @param uniform defines the webGL uniform location where to store the value
  121203. * @param array defines the array of int32 to store
  121204. * @returns true if the value was set
  121205. */
  121206. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121207. /**
  121208. * Set the value of an uniform to an array of int32 (stored as vec2)
  121209. * @param uniform defines the webGL uniform location where to store the value
  121210. * @param array defines the array of int32 to store
  121211. * @returns true if the value was set
  121212. */
  121213. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121214. /**
  121215. * Set the value of an uniform to an array of int32 (stored as vec3)
  121216. * @param uniform defines the webGL uniform location where to store the value
  121217. * @param array defines the array of int32 to store
  121218. * @returns true if the value was set
  121219. */
  121220. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121221. /**
  121222. * Set the value of an uniform to an array of int32 (stored as vec4)
  121223. * @param uniform defines the webGL uniform location where to store the value
  121224. * @param array defines the array of int32 to store
  121225. * @returns true if the value was set
  121226. */
  121227. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121228. /**
  121229. * Set the value of an uniform to an array of number
  121230. * @param uniform defines the webGL uniform location where to store the value
  121231. * @param array defines the array of number to store
  121232. * @returns true if the value was set
  121233. */
  121234. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121235. /**
  121236. * Set the value of an uniform to an array of number (stored as vec2)
  121237. * @param uniform defines the webGL uniform location where to store the value
  121238. * @param array defines the array of number to store
  121239. * @returns true if the value was set
  121240. */
  121241. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121242. /**
  121243. * Set the value of an uniform to an array of number (stored as vec3)
  121244. * @param uniform defines the webGL uniform location where to store the value
  121245. * @param array defines the array of number to store
  121246. * @returns true if the value was set
  121247. */
  121248. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121249. /**
  121250. * Set the value of an uniform to an array of number (stored as vec4)
  121251. * @param uniform defines the webGL uniform location where to store the value
  121252. * @param array defines the array of number to store
  121253. * @returns true if the value was set
  121254. */
  121255. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121256. /**
  121257. * Set the value of an uniform to an array of float32 (stored as matrices)
  121258. * @param uniform defines the webGL uniform location where to store the value
  121259. * @param matrices defines the array of float32 to store
  121260. * @returns true if the value was set
  121261. */
  121262. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  121263. /**
  121264. * Set the value of an uniform to a matrix (3x3)
  121265. * @param uniform defines the webGL uniform location where to store the value
  121266. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  121267. * @returns true if the value was set
  121268. */
  121269. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  121270. /**
  121271. * Set the value of an uniform to a matrix (2x2)
  121272. * @param uniform defines the webGL uniform location where to store the value
  121273. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  121274. * @returns true if the value was set
  121275. */
  121276. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  121277. /**
  121278. * Set the value of an uniform to a number (float)
  121279. * @param uniform defines the webGL uniform location where to store the value
  121280. * @param value defines the float number to store
  121281. * @returns true if the value was transfered
  121282. */
  121283. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  121284. /**
  121285. * Set the value of an uniform to a vec2
  121286. * @param uniform defines the webGL uniform location where to store the value
  121287. * @param x defines the 1st component of the value
  121288. * @param y defines the 2nd component of the value
  121289. * @returns true if the value was set
  121290. */
  121291. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  121292. /**
  121293. * Set the value of an uniform to a vec3
  121294. * @param uniform defines the webGL uniform location where to store the value
  121295. * @param x defines the 1st component of the value
  121296. * @param y defines the 2nd component of the value
  121297. * @param z defines the 3rd component of the value
  121298. * @returns true if the value was set
  121299. */
  121300. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  121301. /**
  121302. * Set the value of an uniform to a vec4
  121303. * @param uniform defines the webGL uniform location where to store the value
  121304. * @param x defines the 1st component of the value
  121305. * @param y defines the 2nd component of the value
  121306. * @param z defines the 3rd component of the value
  121307. * @param w defines the 4th component of the value
  121308. * @returns true if the value was set
  121309. */
  121310. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  121311. /**
  121312. * Apply all cached states (depth, culling, stencil and alpha)
  121313. */
  121314. applyStates(): void;
  121315. /**
  121316. * Enable or disable color writing
  121317. * @param enable defines the state to set
  121318. */
  121319. setColorWrite(enable: boolean): void;
  121320. /**
  121321. * Gets a boolean indicating if color writing is enabled
  121322. * @returns the current color writing state
  121323. */
  121324. getColorWrite(): boolean;
  121325. /**
  121326. * Gets the depth culling state manager
  121327. */
  121328. get depthCullingState(): DepthCullingState;
  121329. /**
  121330. * Gets the alpha state manager
  121331. */
  121332. get alphaState(): AlphaState;
  121333. /**
  121334. * Gets the stencil state manager
  121335. */
  121336. get stencilState(): StencilState;
  121337. /**
  121338. * Clears the list of texture accessible through engine.
  121339. * This can help preventing texture load conflict due to name collision.
  121340. */
  121341. clearInternalTexturesCache(): void;
  121342. /**
  121343. * Force the entire cache to be cleared
  121344. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  121345. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  121346. */
  121347. wipeCaches(bruteForce?: boolean): void;
  121348. /** @hidden */
  121349. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  121350. min: number;
  121351. mag: number;
  121352. };
  121353. /** @hidden */
  121354. _createTexture(): WebGLTexture;
  121355. /**
  121356. * Usually called from Texture.ts.
  121357. * Passed information to create a WebGLTexture
  121358. * @param url defines a value which contains one of the following:
  121359. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121360. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121361. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121362. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121363. * @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)
  121364. * @param scene needed for loading to the correct scene
  121365. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121366. * @param onLoad optional callback to be called upon successful completion
  121367. * @param onError optional callback to be called upon failure
  121368. * @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
  121369. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121370. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121371. * @param forcedExtension defines the extension to use to pick the right loader
  121372. * @param mimeType defines an optional mime type
  121373. * @param loaderOptions options to be passed to the loader
  121374. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121375. */
  121376. 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;
  121377. /**
  121378. * Loads an image as an HTMLImageElement.
  121379. * @param input url string, ArrayBuffer, or Blob to load
  121380. * @param onLoad callback called when the image successfully loads
  121381. * @param onError callback called when the image fails to load
  121382. * @param offlineProvider offline provider for caching
  121383. * @param mimeType optional mime type
  121384. * @returns the HTMLImageElement of the loaded image
  121385. * @hidden
  121386. */
  121387. 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>;
  121388. /**
  121389. * @hidden
  121390. */
  121391. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  121392. private _unpackFlipYCached;
  121393. /**
  121394. * In case you are sharing the context with other applications, it might
  121395. * be interested to not cache the unpack flip y state to ensure a consistent
  121396. * value would be set.
  121397. */
  121398. enableUnpackFlipYCached: boolean;
  121399. /** @hidden */
  121400. _unpackFlipY(value: boolean): void;
  121401. /** @hidden */
  121402. _getUnpackAlignement(): number;
  121403. private _getTextureTarget;
  121404. /**
  121405. * Update the sampling mode of a given texture
  121406. * @param samplingMode defines the required sampling mode
  121407. * @param texture defines the texture to update
  121408. * @param generateMipMaps defines whether to generate mipmaps for the texture
  121409. */
  121410. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  121411. /**
  121412. * Update the sampling mode of a given texture
  121413. * @param texture defines the texture to update
  121414. * @param wrapU defines the texture wrap mode of the u coordinates
  121415. * @param wrapV defines the texture wrap mode of the v coordinates
  121416. * @param wrapR defines the texture wrap mode of the r coordinates
  121417. */
  121418. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  121419. /** @hidden */
  121420. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  121421. width: number;
  121422. height: number;
  121423. layers?: number;
  121424. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  121425. /** @hidden */
  121426. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121427. /** @hidden */
  121428. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  121429. /**
  121430. * Update a portion of an internal texture
  121431. * @param texture defines the texture to update
  121432. * @param imageData defines the data to store into the texture
  121433. * @param xOffset defines the x coordinates of the update rectangle
  121434. * @param yOffset defines the y coordinates of the update rectangle
  121435. * @param width defines the width of the update rectangle
  121436. * @param height defines the height of the update rectangle
  121437. * @param faceIndex defines the face index if texture is a cube (0 by default)
  121438. * @param lod defines the lod level to update (0 by default)
  121439. */
  121440. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  121441. /** @hidden */
  121442. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121443. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  121444. private _prepareWebGLTexture;
  121445. /** @hidden */
  121446. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  121447. private _getDepthStencilBuffer;
  121448. /** @hidden */
  121449. _releaseFramebufferObjects(texture: InternalTexture): void;
  121450. /** @hidden */
  121451. _releaseTexture(texture: InternalTexture): void;
  121452. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121453. protected _setProgram(program: WebGLProgram): void;
  121454. protected _boundUniforms: {
  121455. [key: number]: WebGLUniformLocation;
  121456. };
  121457. /**
  121458. * Binds an effect to the webGL context
  121459. * @param effect defines the effect to bind
  121460. */
  121461. bindSamplers(effect: Effect): void;
  121462. private _activateCurrentTexture;
  121463. /** @hidden */
  121464. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  121465. /** @hidden */
  121466. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  121467. /**
  121468. * Unbind all textures from the webGL context
  121469. */
  121470. unbindAllTextures(): void;
  121471. /**
  121472. * Sets a texture to the according uniform.
  121473. * @param channel The texture channel
  121474. * @param uniform The uniform to set
  121475. * @param texture The texture to apply
  121476. */
  121477. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  121478. private _bindSamplerUniformToChannel;
  121479. private _getTextureWrapMode;
  121480. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121481. /**
  121482. * Sets an array of texture to the webGL context
  121483. * @param channel defines the channel where the texture array must be set
  121484. * @param uniform defines the associated uniform location
  121485. * @param textures defines the array of textures to bind
  121486. */
  121487. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  121488. /** @hidden */
  121489. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  121490. private _setTextureParameterFloat;
  121491. private _setTextureParameterInteger;
  121492. /**
  121493. * Unbind all vertex attributes from the webGL context
  121494. */
  121495. unbindAllAttributes(): void;
  121496. /**
  121497. * 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
  121498. */
  121499. releaseEffects(): void;
  121500. /**
  121501. * Dispose and release all associated resources
  121502. */
  121503. dispose(): void;
  121504. /**
  121505. * Attach a new callback raised when context lost event is fired
  121506. * @param callback defines the callback to call
  121507. */
  121508. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  121509. /**
  121510. * Attach a new callback raised when context restored event is fired
  121511. * @param callback defines the callback to call
  121512. */
  121513. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  121514. /**
  121515. * Get the current error code of the webGL context
  121516. * @returns the error code
  121517. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  121518. */
  121519. getError(): number;
  121520. private _canRenderToFloatFramebuffer;
  121521. private _canRenderToHalfFloatFramebuffer;
  121522. private _canRenderToFramebuffer;
  121523. /** @hidden */
  121524. _getWebGLTextureType(type: number): number;
  121525. /** @hidden */
  121526. _getInternalFormat(format: number): number;
  121527. /** @hidden */
  121528. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  121529. /** @hidden */
  121530. _getRGBAMultiSampleBufferFormat(type: number): number;
  121531. /** @hidden */
  121532. _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;
  121533. /**
  121534. * Loads a file from a url
  121535. * @param url url to load
  121536. * @param onSuccess callback called when the file successfully loads
  121537. * @param onProgress callback called while file is loading (if the server supports this mode)
  121538. * @param offlineProvider defines the offline provider for caching
  121539. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  121540. * @param onError callback called when the file fails to load
  121541. * @returns a file request object
  121542. * @hidden
  121543. */
  121544. 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;
  121545. /**
  121546. * Reads pixels from the current frame buffer. Please note that this function can be slow
  121547. * @param x defines the x coordinate of the rectangle where pixels must be read
  121548. * @param y defines the y coordinate of the rectangle where pixels must be read
  121549. * @param width defines the width of the rectangle where pixels must be read
  121550. * @param height defines the height of the rectangle where pixels must be read
  121551. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  121552. * @returns a Uint8Array containing RGBA colors
  121553. */
  121554. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  121555. private static _IsSupported;
  121556. private static _HasMajorPerformanceCaveat;
  121557. /**
  121558. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  121559. */
  121560. static get IsSupported(): boolean;
  121561. /**
  121562. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  121563. * @returns true if the engine can be created
  121564. * @ignorenaming
  121565. */
  121566. static isSupported(): boolean;
  121567. /**
  121568. * 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)
  121569. */
  121570. static get HasMajorPerformanceCaveat(): boolean;
  121571. /**
  121572. * Find the next highest power of two.
  121573. * @param x Number to start search from.
  121574. * @return Next highest power of two.
  121575. */
  121576. static CeilingPOT(x: number): number;
  121577. /**
  121578. * Find the next lowest power of two.
  121579. * @param x Number to start search from.
  121580. * @return Next lowest power of two.
  121581. */
  121582. static FloorPOT(x: number): number;
  121583. /**
  121584. * Find the nearest power of two.
  121585. * @param x Number to start search from.
  121586. * @return Next nearest power of two.
  121587. */
  121588. static NearestPOT(x: number): number;
  121589. /**
  121590. * Get the closest exponent of two
  121591. * @param value defines the value to approximate
  121592. * @param max defines the maximum value to return
  121593. * @param mode defines how to define the closest value
  121594. * @returns closest exponent of two of the given value
  121595. */
  121596. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  121597. /**
  121598. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  121599. * @param func - the function to be called
  121600. * @param requester - the object that will request the next frame. Falls back to window.
  121601. * @returns frame number
  121602. */
  121603. static QueueNewFrame(func: () => void, requester?: any): number;
  121604. /**
  121605. * Gets host document
  121606. * @returns the host document object
  121607. */
  121608. getHostDocument(): Nullable<Document>;
  121609. }
  121610. }
  121611. declare module BABYLON {
  121612. /**
  121613. * Defines the source of the internal texture
  121614. */
  121615. export enum InternalTextureSource {
  121616. /**
  121617. * The source of the texture data is unknown
  121618. */
  121619. Unknown = 0,
  121620. /**
  121621. * Texture data comes from an URL
  121622. */
  121623. Url = 1,
  121624. /**
  121625. * Texture data is only used for temporary storage
  121626. */
  121627. Temp = 2,
  121628. /**
  121629. * Texture data comes from raw data (ArrayBuffer)
  121630. */
  121631. Raw = 3,
  121632. /**
  121633. * Texture content is dynamic (video or dynamic texture)
  121634. */
  121635. Dynamic = 4,
  121636. /**
  121637. * Texture content is generated by rendering to it
  121638. */
  121639. RenderTarget = 5,
  121640. /**
  121641. * Texture content is part of a multi render target process
  121642. */
  121643. MultiRenderTarget = 6,
  121644. /**
  121645. * Texture data comes from a cube data file
  121646. */
  121647. Cube = 7,
  121648. /**
  121649. * Texture data comes from a raw cube data
  121650. */
  121651. CubeRaw = 8,
  121652. /**
  121653. * Texture data come from a prefiltered cube data file
  121654. */
  121655. CubePrefiltered = 9,
  121656. /**
  121657. * Texture content is raw 3D data
  121658. */
  121659. Raw3D = 10,
  121660. /**
  121661. * Texture content is raw 2D array data
  121662. */
  121663. Raw2DArray = 11,
  121664. /**
  121665. * Texture content is a depth texture
  121666. */
  121667. Depth = 12,
  121668. /**
  121669. * Texture data comes from a raw cube data encoded with RGBD
  121670. */
  121671. CubeRawRGBD = 13
  121672. }
  121673. /**
  121674. * Class used to store data associated with WebGL texture data for the engine
  121675. * This class should not be used directly
  121676. */
  121677. export class InternalTexture {
  121678. /** @hidden */
  121679. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  121680. /**
  121681. * Defines if the texture is ready
  121682. */
  121683. isReady: boolean;
  121684. /**
  121685. * Defines if the texture is a cube texture
  121686. */
  121687. isCube: boolean;
  121688. /**
  121689. * Defines if the texture contains 3D data
  121690. */
  121691. is3D: boolean;
  121692. /**
  121693. * Defines if the texture contains 2D array data
  121694. */
  121695. is2DArray: boolean;
  121696. /**
  121697. * Defines if the texture contains multiview data
  121698. */
  121699. isMultiview: boolean;
  121700. /**
  121701. * Gets the URL used to load this texture
  121702. */
  121703. url: string;
  121704. /** @hidden */
  121705. _originalUrl: string;
  121706. /**
  121707. * Gets the sampling mode of the texture
  121708. */
  121709. samplingMode: number;
  121710. /**
  121711. * Gets a boolean indicating if the texture needs mipmaps generation
  121712. */
  121713. generateMipMaps: boolean;
  121714. /**
  121715. * Gets the number of samples used by the texture (WebGL2+ only)
  121716. */
  121717. samples: number;
  121718. /**
  121719. * Gets the type of the texture (int, float...)
  121720. */
  121721. type: number;
  121722. /**
  121723. * Gets the format of the texture (RGB, RGBA...)
  121724. */
  121725. format: number;
  121726. /**
  121727. * Observable called when the texture is loaded
  121728. */
  121729. onLoadedObservable: Observable<InternalTexture>;
  121730. /**
  121731. * Gets the width of the texture
  121732. */
  121733. width: number;
  121734. /**
  121735. * Gets the height of the texture
  121736. */
  121737. height: number;
  121738. /**
  121739. * Gets the depth of the texture
  121740. */
  121741. depth: number;
  121742. /**
  121743. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  121744. */
  121745. baseWidth: number;
  121746. /**
  121747. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  121748. */
  121749. baseHeight: number;
  121750. /**
  121751. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  121752. */
  121753. baseDepth: number;
  121754. /**
  121755. * Gets a boolean indicating if the texture is inverted on Y axis
  121756. */
  121757. invertY: boolean;
  121758. /** @hidden */
  121759. _invertVScale: boolean;
  121760. /** @hidden */
  121761. _associatedChannel: number;
  121762. /** @hidden */
  121763. _source: InternalTextureSource;
  121764. /** @hidden */
  121765. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  121766. /** @hidden */
  121767. _bufferView: Nullable<ArrayBufferView>;
  121768. /** @hidden */
  121769. _bufferViewArray: Nullable<ArrayBufferView[]>;
  121770. /** @hidden */
  121771. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  121772. /** @hidden */
  121773. _size: number;
  121774. /** @hidden */
  121775. _extension: string;
  121776. /** @hidden */
  121777. _files: Nullable<string[]>;
  121778. /** @hidden */
  121779. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  121780. /** @hidden */
  121781. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  121782. /** @hidden */
  121783. _framebuffer: Nullable<WebGLFramebuffer>;
  121784. /** @hidden */
  121785. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  121786. /** @hidden */
  121787. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  121788. /** @hidden */
  121789. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  121790. /** @hidden */
  121791. _attachments: Nullable<number[]>;
  121792. /** @hidden */
  121793. _textureArray: Nullable<InternalTexture[]>;
  121794. /** @hidden */
  121795. _cachedCoordinatesMode: Nullable<number>;
  121796. /** @hidden */
  121797. _cachedWrapU: Nullable<number>;
  121798. /** @hidden */
  121799. _cachedWrapV: Nullable<number>;
  121800. /** @hidden */
  121801. _cachedWrapR: Nullable<number>;
  121802. /** @hidden */
  121803. _cachedAnisotropicFilteringLevel: Nullable<number>;
  121804. /** @hidden */
  121805. _isDisabled: boolean;
  121806. /** @hidden */
  121807. _compression: Nullable<string>;
  121808. /** @hidden */
  121809. _generateStencilBuffer: boolean;
  121810. /** @hidden */
  121811. _generateDepthBuffer: boolean;
  121812. /** @hidden */
  121813. _comparisonFunction: number;
  121814. /** @hidden */
  121815. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  121816. /** @hidden */
  121817. _lodGenerationScale: number;
  121818. /** @hidden */
  121819. _lodGenerationOffset: number;
  121820. /** @hidden */
  121821. _depthStencilTexture: Nullable<InternalTexture>;
  121822. /** @hidden */
  121823. _colorTextureArray: Nullable<WebGLTexture>;
  121824. /** @hidden */
  121825. _depthStencilTextureArray: Nullable<WebGLTexture>;
  121826. /** @hidden */
  121827. _lodTextureHigh: Nullable<BaseTexture>;
  121828. /** @hidden */
  121829. _lodTextureMid: Nullable<BaseTexture>;
  121830. /** @hidden */
  121831. _lodTextureLow: Nullable<BaseTexture>;
  121832. /** @hidden */
  121833. _isRGBD: boolean;
  121834. /** @hidden */
  121835. _linearSpecularLOD: boolean;
  121836. /** @hidden */
  121837. _irradianceTexture: Nullable<BaseTexture>;
  121838. /** @hidden */
  121839. _webGLTexture: Nullable<WebGLTexture>;
  121840. /** @hidden */
  121841. _references: number;
  121842. /** @hidden */
  121843. _gammaSpace: Nullable<boolean>;
  121844. private _engine;
  121845. /**
  121846. * Gets the Engine the texture belongs to.
  121847. * @returns The babylon engine
  121848. */
  121849. getEngine(): ThinEngine;
  121850. /**
  121851. * Gets the data source type of the texture
  121852. */
  121853. get source(): InternalTextureSource;
  121854. /**
  121855. * Creates a new InternalTexture
  121856. * @param engine defines the engine to use
  121857. * @param source defines the type of data that will be used
  121858. * @param delayAllocation if the texture allocation should be delayed (default: false)
  121859. */
  121860. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  121861. /**
  121862. * Increments the number of references (ie. the number of Texture that point to it)
  121863. */
  121864. incrementReferences(): void;
  121865. /**
  121866. * Change the size of the texture (not the size of the content)
  121867. * @param width defines the new width
  121868. * @param height defines the new height
  121869. * @param depth defines the new depth (1 by default)
  121870. */
  121871. updateSize(width: int, height: int, depth?: int): void;
  121872. /** @hidden */
  121873. _rebuild(): void;
  121874. /** @hidden */
  121875. _swapAndDie(target: InternalTexture): void;
  121876. /**
  121877. * Dispose the current allocated resources
  121878. */
  121879. dispose(): void;
  121880. }
  121881. }
  121882. declare module BABYLON {
  121883. /**
  121884. * Interface used to present a loading screen while loading a scene
  121885. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121886. */
  121887. export interface ILoadingScreen {
  121888. /**
  121889. * Function called to display the loading screen
  121890. */
  121891. displayLoadingUI: () => void;
  121892. /**
  121893. * Function called to hide the loading screen
  121894. */
  121895. hideLoadingUI: () => void;
  121896. /**
  121897. * Gets or sets the color to use for the background
  121898. */
  121899. loadingUIBackgroundColor: string;
  121900. /**
  121901. * Gets or sets the text to display while loading
  121902. */
  121903. loadingUIText: string;
  121904. }
  121905. /**
  121906. * Class used for the default loading screen
  121907. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121908. */
  121909. export class DefaultLoadingScreen implements ILoadingScreen {
  121910. private _renderingCanvas;
  121911. private _loadingText;
  121912. private _loadingDivBackgroundColor;
  121913. private _loadingDiv;
  121914. private _loadingTextDiv;
  121915. /** Gets or sets the logo url to use for the default loading screen */
  121916. static DefaultLogoUrl: string;
  121917. /** Gets or sets the spinner url to use for the default loading screen */
  121918. static DefaultSpinnerUrl: string;
  121919. /**
  121920. * Creates a new default loading screen
  121921. * @param _renderingCanvas defines the canvas used to render the scene
  121922. * @param _loadingText defines the default text to display
  121923. * @param _loadingDivBackgroundColor defines the default background color
  121924. */
  121925. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  121926. /**
  121927. * Function called to display the loading screen
  121928. */
  121929. displayLoadingUI(): void;
  121930. /**
  121931. * Function called to hide the loading screen
  121932. */
  121933. hideLoadingUI(): void;
  121934. /**
  121935. * Gets or sets the text to display while loading
  121936. */
  121937. set loadingUIText(text: string);
  121938. get loadingUIText(): string;
  121939. /**
  121940. * Gets or sets the color to use for the background
  121941. */
  121942. get loadingUIBackgroundColor(): string;
  121943. set loadingUIBackgroundColor(color: string);
  121944. private _resizeLoadingUI;
  121945. }
  121946. }
  121947. declare module BABYLON {
  121948. /**
  121949. * Interface for any object that can request an animation frame
  121950. */
  121951. export interface ICustomAnimationFrameRequester {
  121952. /**
  121953. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  121954. */
  121955. renderFunction?: Function;
  121956. /**
  121957. * Called to request the next frame to render to
  121958. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  121959. */
  121960. requestAnimationFrame: Function;
  121961. /**
  121962. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  121963. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  121964. */
  121965. requestID?: number;
  121966. }
  121967. }
  121968. declare module BABYLON {
  121969. /**
  121970. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  121971. */
  121972. export class PerformanceMonitor {
  121973. private _enabled;
  121974. private _rollingFrameTime;
  121975. private _lastFrameTimeMs;
  121976. /**
  121977. * constructor
  121978. * @param frameSampleSize The number of samples required to saturate the sliding window
  121979. */
  121980. constructor(frameSampleSize?: number);
  121981. /**
  121982. * Samples current frame
  121983. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  121984. */
  121985. sampleFrame(timeMs?: number): void;
  121986. /**
  121987. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121988. */
  121989. get averageFrameTime(): number;
  121990. /**
  121991. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121992. */
  121993. get averageFrameTimeVariance(): number;
  121994. /**
  121995. * Returns the frame time of the most recent frame
  121996. */
  121997. get instantaneousFrameTime(): number;
  121998. /**
  121999. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  122000. */
  122001. get averageFPS(): number;
  122002. /**
  122003. * Returns the average framerate in frames per second using the most recent frame time
  122004. */
  122005. get instantaneousFPS(): number;
  122006. /**
  122007. * Returns true if enough samples have been taken to completely fill the sliding window
  122008. */
  122009. get isSaturated(): boolean;
  122010. /**
  122011. * Enables contributions to the sliding window sample set
  122012. */
  122013. enable(): void;
  122014. /**
  122015. * Disables contributions to the sliding window sample set
  122016. * Samples will not be interpolated over the disabled period
  122017. */
  122018. disable(): void;
  122019. /**
  122020. * Returns true if sampling is enabled
  122021. */
  122022. get isEnabled(): boolean;
  122023. /**
  122024. * Resets performance monitor
  122025. */
  122026. reset(): void;
  122027. }
  122028. /**
  122029. * RollingAverage
  122030. *
  122031. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  122032. */
  122033. export class RollingAverage {
  122034. /**
  122035. * Current average
  122036. */
  122037. average: number;
  122038. /**
  122039. * Current variance
  122040. */
  122041. variance: number;
  122042. protected _samples: Array<number>;
  122043. protected _sampleCount: number;
  122044. protected _pos: number;
  122045. protected _m2: number;
  122046. /**
  122047. * constructor
  122048. * @param length The number of samples required to saturate the sliding window
  122049. */
  122050. constructor(length: number);
  122051. /**
  122052. * Adds a sample to the sample set
  122053. * @param v The sample value
  122054. */
  122055. add(v: number): void;
  122056. /**
  122057. * Returns previously added values or null if outside of history or outside the sliding window domain
  122058. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  122059. * @return Value previously recorded with add() or null if outside of range
  122060. */
  122061. history(i: number): number;
  122062. /**
  122063. * Returns true if enough samples have been taken to completely fill the sliding window
  122064. * @return true if sample-set saturated
  122065. */
  122066. isSaturated(): boolean;
  122067. /**
  122068. * Resets the rolling average (equivalent to 0 samples taken so far)
  122069. */
  122070. reset(): void;
  122071. /**
  122072. * Wraps a value around the sample range boundaries
  122073. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  122074. * @return Wrapped position in sample range
  122075. */
  122076. protected _wrapPosition(i: number): number;
  122077. }
  122078. }
  122079. declare module BABYLON {
  122080. /**
  122081. * This class is used to track a performance counter which is number based.
  122082. * The user has access to many properties which give statistics of different nature.
  122083. *
  122084. * The implementer can track two kinds of Performance Counter: time and count.
  122085. * 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.
  122086. * 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.
  122087. */
  122088. export class PerfCounter {
  122089. /**
  122090. * Gets or sets a global boolean to turn on and off all the counters
  122091. */
  122092. static Enabled: boolean;
  122093. /**
  122094. * Returns the smallest value ever
  122095. */
  122096. get min(): number;
  122097. /**
  122098. * Returns the biggest value ever
  122099. */
  122100. get max(): number;
  122101. /**
  122102. * Returns the average value since the performance counter is running
  122103. */
  122104. get average(): number;
  122105. /**
  122106. * Returns the average value of the last second the counter was monitored
  122107. */
  122108. get lastSecAverage(): number;
  122109. /**
  122110. * Returns the current value
  122111. */
  122112. get current(): number;
  122113. /**
  122114. * Gets the accumulated total
  122115. */
  122116. get total(): number;
  122117. /**
  122118. * Gets the total value count
  122119. */
  122120. get count(): number;
  122121. /**
  122122. * Creates a new counter
  122123. */
  122124. constructor();
  122125. /**
  122126. * Call this method to start monitoring a new frame.
  122127. * 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.
  122128. */
  122129. fetchNewFrame(): void;
  122130. /**
  122131. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  122132. * @param newCount the count value to add to the monitored count
  122133. * @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.
  122134. */
  122135. addCount(newCount: number, fetchResult: boolean): void;
  122136. /**
  122137. * Start monitoring this performance counter
  122138. */
  122139. beginMonitoring(): void;
  122140. /**
  122141. * Compute the time lapsed since the previous beginMonitoring() call.
  122142. * @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
  122143. */
  122144. endMonitoring(newFrame?: boolean): void;
  122145. private _fetchResult;
  122146. private _startMonitoringTime;
  122147. private _min;
  122148. private _max;
  122149. private _average;
  122150. private _current;
  122151. private _totalValueCount;
  122152. private _totalAccumulated;
  122153. private _lastSecAverage;
  122154. private _lastSecAccumulated;
  122155. private _lastSecTime;
  122156. private _lastSecValueCount;
  122157. }
  122158. }
  122159. declare module BABYLON {
  122160. interface ThinEngine {
  122161. /** @hidden */
  122162. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  122163. }
  122164. }
  122165. declare module BABYLON {
  122166. /**
  122167. * Class used to work with sound analyzer using fast fourier transform (FFT)
  122168. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122169. */
  122170. export class Analyser {
  122171. /**
  122172. * Gets or sets the smoothing
  122173. * @ignorenaming
  122174. */
  122175. SMOOTHING: number;
  122176. /**
  122177. * Gets or sets the FFT table size
  122178. * @ignorenaming
  122179. */
  122180. FFT_SIZE: number;
  122181. /**
  122182. * Gets or sets the bar graph amplitude
  122183. * @ignorenaming
  122184. */
  122185. BARGRAPHAMPLITUDE: number;
  122186. /**
  122187. * Gets or sets the position of the debug canvas
  122188. * @ignorenaming
  122189. */
  122190. DEBUGCANVASPOS: {
  122191. x: number;
  122192. y: number;
  122193. };
  122194. /**
  122195. * Gets or sets the debug canvas size
  122196. * @ignorenaming
  122197. */
  122198. DEBUGCANVASSIZE: {
  122199. width: number;
  122200. height: number;
  122201. };
  122202. private _byteFreqs;
  122203. private _byteTime;
  122204. private _floatFreqs;
  122205. private _webAudioAnalyser;
  122206. private _debugCanvas;
  122207. private _debugCanvasContext;
  122208. private _scene;
  122209. private _registerFunc;
  122210. private _audioEngine;
  122211. /**
  122212. * Creates a new analyser
  122213. * @param scene defines hosting scene
  122214. */
  122215. constructor(scene: Scene);
  122216. /**
  122217. * Get the number of data values you will have to play with for the visualization
  122218. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  122219. * @returns a number
  122220. */
  122221. getFrequencyBinCount(): number;
  122222. /**
  122223. * Gets the current frequency data as a byte array
  122224. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  122225. * @returns a Uint8Array
  122226. */
  122227. getByteFrequencyData(): Uint8Array;
  122228. /**
  122229. * Gets the current waveform as a byte array
  122230. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  122231. * @returns a Uint8Array
  122232. */
  122233. getByteTimeDomainData(): Uint8Array;
  122234. /**
  122235. * Gets the current frequency data as a float array
  122236. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  122237. * @returns a Float32Array
  122238. */
  122239. getFloatFrequencyData(): Float32Array;
  122240. /**
  122241. * Renders the debug canvas
  122242. */
  122243. drawDebugCanvas(): void;
  122244. /**
  122245. * Stops rendering the debug canvas and removes it
  122246. */
  122247. stopDebugCanvas(): void;
  122248. /**
  122249. * Connects two audio nodes
  122250. * @param inputAudioNode defines first node to connect
  122251. * @param outputAudioNode defines second node to connect
  122252. */
  122253. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  122254. /**
  122255. * Releases all associated resources
  122256. */
  122257. dispose(): void;
  122258. }
  122259. }
  122260. declare module BABYLON {
  122261. /**
  122262. * This represents an audio engine and it is responsible
  122263. * to play, synchronize and analyse sounds throughout the application.
  122264. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122265. */
  122266. export interface IAudioEngine extends IDisposable {
  122267. /**
  122268. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  122269. */
  122270. readonly canUseWebAudio: boolean;
  122271. /**
  122272. * Gets the current AudioContext if available.
  122273. */
  122274. readonly audioContext: Nullable<AudioContext>;
  122275. /**
  122276. * The master gain node defines the global audio volume of your audio engine.
  122277. */
  122278. readonly masterGain: GainNode;
  122279. /**
  122280. * Gets whether or not mp3 are supported by your browser.
  122281. */
  122282. readonly isMP3supported: boolean;
  122283. /**
  122284. * Gets whether or not ogg are supported by your browser.
  122285. */
  122286. readonly isOGGsupported: boolean;
  122287. /**
  122288. * Defines if Babylon should emit a warning if WebAudio is not supported.
  122289. * @ignoreNaming
  122290. */
  122291. WarnedWebAudioUnsupported: boolean;
  122292. /**
  122293. * Defines if the audio engine relies on a custom unlocked button.
  122294. * In this case, the embedded button will not be displayed.
  122295. */
  122296. useCustomUnlockedButton: boolean;
  122297. /**
  122298. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  122299. */
  122300. readonly unlocked: boolean;
  122301. /**
  122302. * Event raised when audio has been unlocked on the browser.
  122303. */
  122304. onAudioUnlockedObservable: Observable<IAudioEngine>;
  122305. /**
  122306. * Event raised when audio has been locked on the browser.
  122307. */
  122308. onAudioLockedObservable: Observable<IAudioEngine>;
  122309. /**
  122310. * Flags the audio engine in Locked state.
  122311. * This happens due to new browser policies preventing audio to autoplay.
  122312. */
  122313. lock(): void;
  122314. /**
  122315. * Unlocks the audio engine once a user action has been done on the dom.
  122316. * This is helpful to resume play once browser policies have been satisfied.
  122317. */
  122318. unlock(): void;
  122319. /**
  122320. * Gets the global volume sets on the master gain.
  122321. * @returns the global volume if set or -1 otherwise
  122322. */
  122323. getGlobalVolume(): number;
  122324. /**
  122325. * Sets the global volume of your experience (sets on the master gain).
  122326. * @param newVolume Defines the new global volume of the application
  122327. */
  122328. setGlobalVolume(newVolume: number): void;
  122329. /**
  122330. * Connect the audio engine to an audio analyser allowing some amazing
  122331. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122332. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122333. * @param analyser The analyser to connect to the engine
  122334. */
  122335. connectToAnalyser(analyser: Analyser): void;
  122336. }
  122337. }
  122338. declare module BABYLON {
  122339. /**
  122340. * Defines the interface used by display changed events
  122341. */
  122342. export interface IDisplayChangedEventArgs {
  122343. /** Gets the vrDisplay object (if any) */
  122344. vrDisplay: Nullable<any>;
  122345. /** Gets a boolean indicating if webVR is supported */
  122346. vrSupported: boolean;
  122347. }
  122348. /**
  122349. * Defines the interface used by objects containing a viewport (like a camera)
  122350. */
  122351. interface IViewportOwnerLike {
  122352. /**
  122353. * Gets or sets the viewport
  122354. */
  122355. viewport: IViewportLike;
  122356. }
  122357. /**
  122358. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  122359. */
  122360. export class Engine extends ThinEngine {
  122361. /** Defines that alpha blending is disabled */
  122362. static readonly ALPHA_DISABLE: number;
  122363. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  122364. static readonly ALPHA_ADD: number;
  122365. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  122366. static readonly ALPHA_COMBINE: number;
  122367. /** Defines that alpha blending to DEST - SRC * DEST */
  122368. static readonly ALPHA_SUBTRACT: number;
  122369. /** Defines that alpha blending to SRC * DEST */
  122370. static readonly ALPHA_MULTIPLY: number;
  122371. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  122372. static readonly ALPHA_MAXIMIZED: number;
  122373. /** Defines that alpha blending to SRC + DEST */
  122374. static readonly ALPHA_ONEONE: number;
  122375. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  122376. static readonly ALPHA_PREMULTIPLIED: number;
  122377. /**
  122378. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  122379. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  122380. */
  122381. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  122382. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  122383. static readonly ALPHA_INTERPOLATE: number;
  122384. /**
  122385. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  122386. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  122387. */
  122388. static readonly ALPHA_SCREENMODE: number;
  122389. /** Defines that the ressource is not delayed*/
  122390. static readonly DELAYLOADSTATE_NONE: number;
  122391. /** Defines that the ressource was successfully delay loaded */
  122392. static readonly DELAYLOADSTATE_LOADED: number;
  122393. /** Defines that the ressource is currently delay loading */
  122394. static readonly DELAYLOADSTATE_LOADING: number;
  122395. /** Defines that the ressource is delayed and has not started loading */
  122396. static readonly DELAYLOADSTATE_NOTLOADED: number;
  122397. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  122398. static readonly NEVER: number;
  122399. /** 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 */
  122400. static readonly ALWAYS: number;
  122401. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  122402. static readonly LESS: number;
  122403. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  122404. static readonly EQUAL: number;
  122405. /** 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 */
  122406. static readonly LEQUAL: number;
  122407. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  122408. static readonly GREATER: number;
  122409. /** 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 */
  122410. static readonly GEQUAL: number;
  122411. /** 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 */
  122412. static readonly NOTEQUAL: number;
  122413. /** Passed to stencilOperation to specify that stencil value must be kept */
  122414. static readonly KEEP: number;
  122415. /** Passed to stencilOperation to specify that stencil value must be replaced */
  122416. static readonly REPLACE: number;
  122417. /** Passed to stencilOperation to specify that stencil value must be incremented */
  122418. static readonly INCR: number;
  122419. /** Passed to stencilOperation to specify that stencil value must be decremented */
  122420. static readonly DECR: number;
  122421. /** Passed to stencilOperation to specify that stencil value must be inverted */
  122422. static readonly INVERT: number;
  122423. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  122424. static readonly INCR_WRAP: number;
  122425. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  122426. static readonly DECR_WRAP: number;
  122427. /** Texture is not repeating outside of 0..1 UVs */
  122428. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  122429. /** Texture is repeating outside of 0..1 UVs */
  122430. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  122431. /** Texture is repeating and mirrored */
  122432. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  122433. /** ALPHA */
  122434. static readonly TEXTUREFORMAT_ALPHA: number;
  122435. /** LUMINANCE */
  122436. static readonly TEXTUREFORMAT_LUMINANCE: number;
  122437. /** LUMINANCE_ALPHA */
  122438. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  122439. /** RGB */
  122440. static readonly TEXTUREFORMAT_RGB: number;
  122441. /** RGBA */
  122442. static readonly TEXTUREFORMAT_RGBA: number;
  122443. /** RED */
  122444. static readonly TEXTUREFORMAT_RED: number;
  122445. /** RED (2nd reference) */
  122446. static readonly TEXTUREFORMAT_R: number;
  122447. /** RG */
  122448. static readonly TEXTUREFORMAT_RG: number;
  122449. /** RED_INTEGER */
  122450. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  122451. /** RED_INTEGER (2nd reference) */
  122452. static readonly TEXTUREFORMAT_R_INTEGER: number;
  122453. /** RG_INTEGER */
  122454. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  122455. /** RGB_INTEGER */
  122456. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  122457. /** RGBA_INTEGER */
  122458. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  122459. /** UNSIGNED_BYTE */
  122460. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  122461. /** UNSIGNED_BYTE (2nd reference) */
  122462. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  122463. /** FLOAT */
  122464. static readonly TEXTURETYPE_FLOAT: number;
  122465. /** HALF_FLOAT */
  122466. static readonly TEXTURETYPE_HALF_FLOAT: number;
  122467. /** BYTE */
  122468. static readonly TEXTURETYPE_BYTE: number;
  122469. /** SHORT */
  122470. static readonly TEXTURETYPE_SHORT: number;
  122471. /** UNSIGNED_SHORT */
  122472. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  122473. /** INT */
  122474. static readonly TEXTURETYPE_INT: number;
  122475. /** UNSIGNED_INT */
  122476. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  122477. /** UNSIGNED_SHORT_4_4_4_4 */
  122478. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  122479. /** UNSIGNED_SHORT_5_5_5_1 */
  122480. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  122481. /** UNSIGNED_SHORT_5_6_5 */
  122482. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  122483. /** UNSIGNED_INT_2_10_10_10_REV */
  122484. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  122485. /** UNSIGNED_INT_24_8 */
  122486. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  122487. /** UNSIGNED_INT_10F_11F_11F_REV */
  122488. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  122489. /** UNSIGNED_INT_5_9_9_9_REV */
  122490. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  122491. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  122492. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122493. /** nearest is mag = nearest and min = nearest and mip = linear */
  122494. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  122495. /** Bilinear is mag = linear and min = linear and mip = nearest */
  122496. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  122497. /** Trilinear is mag = linear and min = linear and mip = linear */
  122498. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  122499. /** nearest is mag = nearest and min = nearest and mip = linear */
  122500. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  122501. /** Bilinear is mag = linear and min = linear and mip = nearest */
  122502. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  122503. /** Trilinear is mag = linear and min = linear and mip = linear */
  122504. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  122505. /** mag = nearest and min = nearest and mip = nearest */
  122506. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  122507. /** mag = nearest and min = linear and mip = nearest */
  122508. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  122509. /** mag = nearest and min = linear and mip = linear */
  122510. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  122511. /** mag = nearest and min = linear and mip = none */
  122512. static readonly TEXTURE_NEAREST_LINEAR: number;
  122513. /** mag = nearest and min = nearest and mip = none */
  122514. static readonly TEXTURE_NEAREST_NEAREST: number;
  122515. /** mag = linear and min = nearest and mip = nearest */
  122516. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  122517. /** mag = linear and min = nearest and mip = linear */
  122518. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  122519. /** mag = linear and min = linear and mip = none */
  122520. static readonly TEXTURE_LINEAR_LINEAR: number;
  122521. /** mag = linear and min = nearest and mip = none */
  122522. static readonly TEXTURE_LINEAR_NEAREST: number;
  122523. /** Explicit coordinates mode */
  122524. static readonly TEXTURE_EXPLICIT_MODE: number;
  122525. /** Spherical coordinates mode */
  122526. static readonly TEXTURE_SPHERICAL_MODE: number;
  122527. /** Planar coordinates mode */
  122528. static readonly TEXTURE_PLANAR_MODE: number;
  122529. /** Cubic coordinates mode */
  122530. static readonly TEXTURE_CUBIC_MODE: number;
  122531. /** Projection coordinates mode */
  122532. static readonly TEXTURE_PROJECTION_MODE: number;
  122533. /** Skybox coordinates mode */
  122534. static readonly TEXTURE_SKYBOX_MODE: number;
  122535. /** Inverse Cubic coordinates mode */
  122536. static readonly TEXTURE_INVCUBIC_MODE: number;
  122537. /** Equirectangular coordinates mode */
  122538. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  122539. /** Equirectangular Fixed coordinates mode */
  122540. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  122541. /** Equirectangular Fixed Mirrored coordinates mode */
  122542. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  122543. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  122544. static readonly SCALEMODE_FLOOR: number;
  122545. /** Defines that texture rescaling will look for the nearest power of 2 size */
  122546. static readonly SCALEMODE_NEAREST: number;
  122547. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  122548. static readonly SCALEMODE_CEILING: number;
  122549. /**
  122550. * Returns the current npm package of the sdk
  122551. */
  122552. static get NpmPackage(): string;
  122553. /**
  122554. * Returns the current version of the framework
  122555. */
  122556. static get Version(): string;
  122557. /** Gets the list of created engines */
  122558. static get Instances(): Engine[];
  122559. /**
  122560. * Gets the latest created engine
  122561. */
  122562. static get LastCreatedEngine(): Nullable<Engine>;
  122563. /**
  122564. * Gets the latest created scene
  122565. */
  122566. static get LastCreatedScene(): Nullable<Scene>;
  122567. /**
  122568. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  122569. * @param flag defines which part of the materials must be marked as dirty
  122570. * @param predicate defines a predicate used to filter which materials should be affected
  122571. */
  122572. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  122573. /**
  122574. * Method called to create the default loading screen.
  122575. * This can be overriden in your own app.
  122576. * @param canvas The rendering canvas element
  122577. * @returns The loading screen
  122578. */
  122579. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  122580. /**
  122581. * Method called to create the default rescale post process on each engine.
  122582. */
  122583. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  122584. /**
  122585. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  122586. **/
  122587. enableOfflineSupport: boolean;
  122588. /**
  122589. * 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)
  122590. **/
  122591. disableManifestCheck: boolean;
  122592. /**
  122593. * Gets the list of created scenes
  122594. */
  122595. scenes: Scene[];
  122596. /**
  122597. * Event raised when a new scene is created
  122598. */
  122599. onNewSceneAddedObservable: Observable<Scene>;
  122600. /**
  122601. * Gets the list of created postprocesses
  122602. */
  122603. postProcesses: PostProcess[];
  122604. /**
  122605. * Gets a boolean indicating if the pointer is currently locked
  122606. */
  122607. isPointerLock: boolean;
  122608. /**
  122609. * Observable event triggered each time the rendering canvas is resized
  122610. */
  122611. onResizeObservable: Observable<Engine>;
  122612. /**
  122613. * Observable event triggered each time the canvas loses focus
  122614. */
  122615. onCanvasBlurObservable: Observable<Engine>;
  122616. /**
  122617. * Observable event triggered each time the canvas gains focus
  122618. */
  122619. onCanvasFocusObservable: Observable<Engine>;
  122620. /**
  122621. * Observable event triggered each time the canvas receives pointerout event
  122622. */
  122623. onCanvasPointerOutObservable: Observable<PointerEvent>;
  122624. /**
  122625. * Observable raised when the engine begins a new frame
  122626. */
  122627. onBeginFrameObservable: Observable<Engine>;
  122628. /**
  122629. * If set, will be used to request the next animation frame for the render loop
  122630. */
  122631. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  122632. /**
  122633. * Observable raised when the engine ends the current frame
  122634. */
  122635. onEndFrameObservable: Observable<Engine>;
  122636. /**
  122637. * Observable raised when the engine is about to compile a shader
  122638. */
  122639. onBeforeShaderCompilationObservable: Observable<Engine>;
  122640. /**
  122641. * Observable raised when the engine has jsut compiled a shader
  122642. */
  122643. onAfterShaderCompilationObservable: Observable<Engine>;
  122644. /**
  122645. * Gets the audio engine
  122646. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122647. * @ignorenaming
  122648. */
  122649. static audioEngine: IAudioEngine;
  122650. /**
  122651. * Default AudioEngine factory responsible of creating the Audio Engine.
  122652. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  122653. */
  122654. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  122655. /**
  122656. * Default offline support factory responsible of creating a tool used to store data locally.
  122657. * By default, this will create a Database object if the workload has been embedded.
  122658. */
  122659. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  122660. private _loadingScreen;
  122661. private _pointerLockRequested;
  122662. private _rescalePostProcess;
  122663. private _deterministicLockstep;
  122664. private _lockstepMaxSteps;
  122665. private _timeStep;
  122666. protected get _supportsHardwareTextureRescaling(): boolean;
  122667. private _fps;
  122668. private _deltaTime;
  122669. /** @hidden */
  122670. _drawCalls: PerfCounter;
  122671. /** 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 */
  122672. canvasTabIndex: number;
  122673. /**
  122674. * Turn this value on if you want to pause FPS computation when in background
  122675. */
  122676. disablePerformanceMonitorInBackground: boolean;
  122677. private _performanceMonitor;
  122678. /**
  122679. * Gets the performance monitor attached to this engine
  122680. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122681. */
  122682. get performanceMonitor(): PerformanceMonitor;
  122683. private _onFocus;
  122684. private _onBlur;
  122685. private _onCanvasPointerOut;
  122686. private _onCanvasBlur;
  122687. private _onCanvasFocus;
  122688. private _onFullscreenChange;
  122689. private _onPointerLockChange;
  122690. /**
  122691. * Gets the HTML element used to attach event listeners
  122692. * @returns a HTML element
  122693. */
  122694. getInputElement(): Nullable<HTMLElement>;
  122695. /**
  122696. * Creates a new engine
  122697. * @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
  122698. * @param antialias defines enable antialiasing (default: false)
  122699. * @param options defines further options to be sent to the getContext() function
  122700. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  122701. */
  122702. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  122703. /**
  122704. * Gets current aspect ratio
  122705. * @param viewportOwner defines the camera to use to get the aspect ratio
  122706. * @param useScreen defines if screen size must be used (or the current render target if any)
  122707. * @returns a number defining the aspect ratio
  122708. */
  122709. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  122710. /**
  122711. * Gets current screen aspect ratio
  122712. * @returns a number defining the aspect ratio
  122713. */
  122714. getScreenAspectRatio(): number;
  122715. /**
  122716. * Gets the client rect of the HTML canvas attached with the current webGL context
  122717. * @returns a client rectanglee
  122718. */
  122719. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  122720. /**
  122721. * Gets the client rect of the HTML element used for events
  122722. * @returns a client rectanglee
  122723. */
  122724. getInputElementClientRect(): Nullable<ClientRect>;
  122725. /**
  122726. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  122727. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122728. * @returns true if engine is in deterministic lock step mode
  122729. */
  122730. isDeterministicLockStep(): boolean;
  122731. /**
  122732. * Gets the max steps when engine is running in deterministic lock step
  122733. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122734. * @returns the max steps
  122735. */
  122736. getLockstepMaxSteps(): number;
  122737. /**
  122738. * Returns the time in ms between steps when using deterministic lock step.
  122739. * @returns time step in (ms)
  122740. */
  122741. getTimeStep(): number;
  122742. /**
  122743. * Force the mipmap generation for the given render target texture
  122744. * @param texture defines the render target texture to use
  122745. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  122746. */
  122747. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  122748. /** States */
  122749. /**
  122750. * Set various states to the webGL context
  122751. * @param culling defines backface culling state
  122752. * @param zOffset defines the value to apply to zOffset (0 by default)
  122753. * @param force defines if states must be applied even if cache is up to date
  122754. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  122755. */
  122756. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122757. /**
  122758. * Set the z offset to apply to current rendering
  122759. * @param value defines the offset to apply
  122760. */
  122761. setZOffset(value: number): void;
  122762. /**
  122763. * Gets the current value of the zOffset
  122764. * @returns the current zOffset state
  122765. */
  122766. getZOffset(): number;
  122767. /**
  122768. * Enable or disable depth buffering
  122769. * @param enable defines the state to set
  122770. */
  122771. setDepthBuffer(enable: boolean): void;
  122772. /**
  122773. * Gets a boolean indicating if depth writing is enabled
  122774. * @returns the current depth writing state
  122775. */
  122776. getDepthWrite(): boolean;
  122777. /**
  122778. * Enable or disable depth writing
  122779. * @param enable defines the state to set
  122780. */
  122781. setDepthWrite(enable: boolean): void;
  122782. /**
  122783. * Gets a boolean indicating if stencil buffer is enabled
  122784. * @returns the current stencil buffer state
  122785. */
  122786. getStencilBuffer(): boolean;
  122787. /**
  122788. * Enable or disable the stencil buffer
  122789. * @param enable defines if the stencil buffer must be enabled or disabled
  122790. */
  122791. setStencilBuffer(enable: boolean): void;
  122792. /**
  122793. * Gets the current stencil mask
  122794. * @returns a number defining the new stencil mask to use
  122795. */
  122796. getStencilMask(): number;
  122797. /**
  122798. * Sets the current stencil mask
  122799. * @param mask defines the new stencil mask to use
  122800. */
  122801. setStencilMask(mask: number): void;
  122802. /**
  122803. * Gets the current stencil function
  122804. * @returns a number defining the stencil function to use
  122805. */
  122806. getStencilFunction(): number;
  122807. /**
  122808. * Gets the current stencil reference value
  122809. * @returns a number defining the stencil reference value to use
  122810. */
  122811. getStencilFunctionReference(): number;
  122812. /**
  122813. * Gets the current stencil mask
  122814. * @returns a number defining the stencil mask to use
  122815. */
  122816. getStencilFunctionMask(): number;
  122817. /**
  122818. * Sets the current stencil function
  122819. * @param stencilFunc defines the new stencil function to use
  122820. */
  122821. setStencilFunction(stencilFunc: number): void;
  122822. /**
  122823. * Sets the current stencil reference
  122824. * @param reference defines the new stencil reference to use
  122825. */
  122826. setStencilFunctionReference(reference: number): void;
  122827. /**
  122828. * Sets the current stencil mask
  122829. * @param mask defines the new stencil mask to use
  122830. */
  122831. setStencilFunctionMask(mask: number): void;
  122832. /**
  122833. * Gets the current stencil operation when stencil fails
  122834. * @returns a number defining stencil operation to use when stencil fails
  122835. */
  122836. getStencilOperationFail(): number;
  122837. /**
  122838. * Gets the current stencil operation when depth fails
  122839. * @returns a number defining stencil operation to use when depth fails
  122840. */
  122841. getStencilOperationDepthFail(): number;
  122842. /**
  122843. * Gets the current stencil operation when stencil passes
  122844. * @returns a number defining stencil operation to use when stencil passes
  122845. */
  122846. getStencilOperationPass(): number;
  122847. /**
  122848. * Sets the stencil operation to use when stencil fails
  122849. * @param operation defines the stencil operation to use when stencil fails
  122850. */
  122851. setStencilOperationFail(operation: number): void;
  122852. /**
  122853. * Sets the stencil operation to use when depth fails
  122854. * @param operation defines the stencil operation to use when depth fails
  122855. */
  122856. setStencilOperationDepthFail(operation: number): void;
  122857. /**
  122858. * Sets the stencil operation to use when stencil passes
  122859. * @param operation defines the stencil operation to use when stencil passes
  122860. */
  122861. setStencilOperationPass(operation: number): void;
  122862. /**
  122863. * Sets a boolean indicating if the dithering state is enabled or disabled
  122864. * @param value defines the dithering state
  122865. */
  122866. setDitheringState(value: boolean): void;
  122867. /**
  122868. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  122869. * @param value defines the rasterizer state
  122870. */
  122871. setRasterizerState(value: boolean): void;
  122872. /**
  122873. * Gets the current depth function
  122874. * @returns a number defining the depth function
  122875. */
  122876. getDepthFunction(): Nullable<number>;
  122877. /**
  122878. * Sets the current depth function
  122879. * @param depthFunc defines the function to use
  122880. */
  122881. setDepthFunction(depthFunc: number): void;
  122882. /**
  122883. * Sets the current depth function to GREATER
  122884. */
  122885. setDepthFunctionToGreater(): void;
  122886. /**
  122887. * Sets the current depth function to GEQUAL
  122888. */
  122889. setDepthFunctionToGreaterOrEqual(): void;
  122890. /**
  122891. * Sets the current depth function to LESS
  122892. */
  122893. setDepthFunctionToLess(): void;
  122894. /**
  122895. * Sets the current depth function to LEQUAL
  122896. */
  122897. setDepthFunctionToLessOrEqual(): void;
  122898. private _cachedStencilBuffer;
  122899. private _cachedStencilFunction;
  122900. private _cachedStencilMask;
  122901. private _cachedStencilOperationPass;
  122902. private _cachedStencilOperationFail;
  122903. private _cachedStencilOperationDepthFail;
  122904. private _cachedStencilReference;
  122905. /**
  122906. * Caches the the state of the stencil buffer
  122907. */
  122908. cacheStencilState(): void;
  122909. /**
  122910. * Restores the state of the stencil buffer
  122911. */
  122912. restoreStencilState(): void;
  122913. /**
  122914. * Directly set the WebGL Viewport
  122915. * @param x defines the x coordinate of the viewport (in screen space)
  122916. * @param y defines the y coordinate of the viewport (in screen space)
  122917. * @param width defines the width of the viewport (in screen space)
  122918. * @param height defines the height of the viewport (in screen space)
  122919. * @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
  122920. */
  122921. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  122922. /**
  122923. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  122924. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  122925. * @param y defines the y-coordinate of the corner of the clear rectangle
  122926. * @param width defines the width of the clear rectangle
  122927. * @param height defines the height of the clear rectangle
  122928. * @param clearColor defines the clear color
  122929. */
  122930. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  122931. /**
  122932. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  122933. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  122934. * @param y defines the y-coordinate of the corner of the clear rectangle
  122935. * @param width defines the width of the clear rectangle
  122936. * @param height defines the height of the clear rectangle
  122937. */
  122938. enableScissor(x: number, y: number, width: number, height: number): void;
  122939. /**
  122940. * Disable previously set scissor test rectangle
  122941. */
  122942. disableScissor(): void;
  122943. protected _reportDrawCall(): void;
  122944. /**
  122945. * Initializes a webVR display and starts listening to display change events
  122946. * The onVRDisplayChangedObservable will be notified upon these changes
  122947. * @returns The onVRDisplayChangedObservable
  122948. */
  122949. initWebVR(): Observable<IDisplayChangedEventArgs>;
  122950. /** @hidden */
  122951. _prepareVRComponent(): void;
  122952. /** @hidden */
  122953. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  122954. /** @hidden */
  122955. _submitVRFrame(): void;
  122956. /**
  122957. * Call this function to leave webVR mode
  122958. * Will do nothing if webVR is not supported or if there is no webVR device
  122959. * @see https://doc.babylonjs.com/how_to/webvr_camera
  122960. */
  122961. disableVR(): void;
  122962. /**
  122963. * Gets a boolean indicating that the system is in VR mode and is presenting
  122964. * @returns true if VR mode is engaged
  122965. */
  122966. isVRPresenting(): boolean;
  122967. /** @hidden */
  122968. _requestVRFrame(): void;
  122969. /** @hidden */
  122970. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  122971. /**
  122972. * Gets the source code of the vertex shader associated with a specific webGL program
  122973. * @param program defines the program to use
  122974. * @returns a string containing the source code of the vertex shader associated with the program
  122975. */
  122976. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  122977. /**
  122978. * Gets the source code of the fragment shader associated with a specific webGL program
  122979. * @param program defines the program to use
  122980. * @returns a string containing the source code of the fragment shader associated with the program
  122981. */
  122982. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  122983. /**
  122984. * Sets a depth stencil texture from a render target to the according uniform.
  122985. * @param channel The texture channel
  122986. * @param uniform The uniform to set
  122987. * @param texture The render target texture containing the depth stencil texture to apply
  122988. */
  122989. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  122990. /**
  122991. * Sets a texture to the webGL context from a postprocess
  122992. * @param channel defines the channel to use
  122993. * @param postProcess defines the source postprocess
  122994. */
  122995. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  122996. /**
  122997. * Binds the output of the passed in post process to the texture channel specified
  122998. * @param channel The channel the texture should be bound to
  122999. * @param postProcess The post process which's output should be bound
  123000. */
  123001. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  123002. protected _rebuildBuffers(): void;
  123003. /** @hidden */
  123004. _renderFrame(): void;
  123005. _renderLoop(): void;
  123006. /** @hidden */
  123007. _renderViews(): boolean;
  123008. /**
  123009. * Toggle full screen mode
  123010. * @param requestPointerLock defines if a pointer lock should be requested from the user
  123011. */
  123012. switchFullscreen(requestPointerLock: boolean): void;
  123013. /**
  123014. * Enters full screen mode
  123015. * @param requestPointerLock defines if a pointer lock should be requested from the user
  123016. */
  123017. enterFullscreen(requestPointerLock: boolean): void;
  123018. /**
  123019. * Exits full screen mode
  123020. */
  123021. exitFullscreen(): void;
  123022. /**
  123023. * Enters Pointerlock mode
  123024. */
  123025. enterPointerlock(): void;
  123026. /**
  123027. * Exits Pointerlock mode
  123028. */
  123029. exitPointerlock(): void;
  123030. /**
  123031. * Begin a new frame
  123032. */
  123033. beginFrame(): void;
  123034. /**
  123035. * Enf the current frame
  123036. */
  123037. endFrame(): void;
  123038. resize(): void;
  123039. /**
  123040. * Force a specific size of the canvas
  123041. * @param width defines the new canvas' width
  123042. * @param height defines the new canvas' height
  123043. * @returns true if the size was changed
  123044. */
  123045. setSize(width: number, height: number): boolean;
  123046. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  123047. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  123048. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  123049. _releaseTexture(texture: InternalTexture): void;
  123050. /**
  123051. * @hidden
  123052. * Rescales a texture
  123053. * @param source input texutre
  123054. * @param destination destination texture
  123055. * @param scene scene to use to render the resize
  123056. * @param internalFormat format to use when resizing
  123057. * @param onComplete callback to be called when resize has completed
  123058. */
  123059. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  123060. /**
  123061. * Gets the current framerate
  123062. * @returns a number representing the framerate
  123063. */
  123064. getFps(): number;
  123065. /**
  123066. * Gets the time spent between current and previous frame
  123067. * @returns a number representing the delta time in ms
  123068. */
  123069. getDeltaTime(): number;
  123070. private _measureFps;
  123071. /** @hidden */
  123072. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  123073. /**
  123074. * Updates the sample count of a render target texture
  123075. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  123076. * @param texture defines the texture to update
  123077. * @param samples defines the sample count to set
  123078. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  123079. */
  123080. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  123081. /**
  123082. * Updates a depth texture Comparison Mode and Function.
  123083. * If the comparison Function is equal to 0, the mode will be set to none.
  123084. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  123085. * @param texture The texture to set the comparison function for
  123086. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  123087. */
  123088. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  123089. /**
  123090. * Creates a webGL buffer to use with instanciation
  123091. * @param capacity defines the size of the buffer
  123092. * @returns the webGL buffer
  123093. */
  123094. createInstancesBuffer(capacity: number): DataBuffer;
  123095. /**
  123096. * Delete a webGL buffer used with instanciation
  123097. * @param buffer defines the webGL buffer to delete
  123098. */
  123099. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  123100. private _clientWaitAsync;
  123101. /** @hidden */
  123102. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  123103. dispose(): void;
  123104. private _disableTouchAction;
  123105. /**
  123106. * Display the loading screen
  123107. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123108. */
  123109. displayLoadingUI(): void;
  123110. /**
  123111. * Hide the loading screen
  123112. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123113. */
  123114. hideLoadingUI(): void;
  123115. /**
  123116. * Gets the current loading screen object
  123117. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123118. */
  123119. get loadingScreen(): ILoadingScreen;
  123120. /**
  123121. * Sets the current loading screen object
  123122. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123123. */
  123124. set loadingScreen(loadingScreen: ILoadingScreen);
  123125. /**
  123126. * Sets the current loading screen text
  123127. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123128. */
  123129. set loadingUIText(text: string);
  123130. /**
  123131. * Sets the current loading screen background color
  123132. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123133. */
  123134. set loadingUIBackgroundColor(color: string);
  123135. /** Pointerlock and fullscreen */
  123136. /**
  123137. * Ask the browser to promote the current element to pointerlock mode
  123138. * @param element defines the DOM element to promote
  123139. */
  123140. static _RequestPointerlock(element: HTMLElement): void;
  123141. /**
  123142. * Asks the browser to exit pointerlock mode
  123143. */
  123144. static _ExitPointerlock(): void;
  123145. /**
  123146. * Ask the browser to promote the current element to fullscreen rendering mode
  123147. * @param element defines the DOM element to promote
  123148. */
  123149. static _RequestFullscreen(element: HTMLElement): void;
  123150. /**
  123151. * Asks the browser to exit fullscreen mode
  123152. */
  123153. static _ExitFullscreen(): void;
  123154. }
  123155. }
  123156. declare module BABYLON {
  123157. /**
  123158. * The engine store class is responsible to hold all the instances of Engine and Scene created
  123159. * during the life time of the application.
  123160. */
  123161. export class EngineStore {
  123162. /** Gets the list of created engines */
  123163. static Instances: Engine[];
  123164. /** @hidden */
  123165. static _LastCreatedScene: Nullable<Scene>;
  123166. /**
  123167. * Gets the latest created engine
  123168. */
  123169. static get LastCreatedEngine(): Nullable<Engine>;
  123170. /**
  123171. * Gets the latest created scene
  123172. */
  123173. static get LastCreatedScene(): Nullable<Scene>;
  123174. /**
  123175. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  123176. * @ignorenaming
  123177. */
  123178. static UseFallbackTexture: boolean;
  123179. /**
  123180. * Texture content used if a texture cannot loaded
  123181. * @ignorenaming
  123182. */
  123183. static FallbackTexture: string;
  123184. }
  123185. }
  123186. declare module BABYLON {
  123187. /**
  123188. * Helper class that provides a small promise polyfill
  123189. */
  123190. export class PromisePolyfill {
  123191. /**
  123192. * Static function used to check if the polyfill is required
  123193. * If this is the case then the function will inject the polyfill to window.Promise
  123194. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  123195. */
  123196. static Apply(force?: boolean): void;
  123197. }
  123198. }
  123199. declare module BABYLON {
  123200. /**
  123201. * Interface for screenshot methods with describe argument called `size` as object with options
  123202. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  123203. */
  123204. export interface IScreenshotSize {
  123205. /**
  123206. * number in pixels for canvas height
  123207. */
  123208. height?: number;
  123209. /**
  123210. * multiplier allowing render at a higher or lower resolution
  123211. * If value is defined then height and width will be ignored and taken from camera
  123212. */
  123213. precision?: number;
  123214. /**
  123215. * number in pixels for canvas width
  123216. */
  123217. width?: number;
  123218. }
  123219. }
  123220. declare module BABYLON {
  123221. interface IColor4Like {
  123222. r: float;
  123223. g: float;
  123224. b: float;
  123225. a: float;
  123226. }
  123227. /**
  123228. * Class containing a set of static utilities functions
  123229. */
  123230. export class Tools {
  123231. /**
  123232. * Gets or sets the base URL to use to load assets
  123233. */
  123234. static get BaseUrl(): string;
  123235. static set BaseUrl(value: string);
  123236. /**
  123237. * Enable/Disable Custom HTTP Request Headers globally.
  123238. * default = false
  123239. * @see CustomRequestHeaders
  123240. */
  123241. static UseCustomRequestHeaders: boolean;
  123242. /**
  123243. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  123244. * i.e. when loading files, where the server/service expects an Authorization header
  123245. */
  123246. static CustomRequestHeaders: {
  123247. [key: string]: string;
  123248. };
  123249. /**
  123250. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  123251. */
  123252. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  123253. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  123254. /**
  123255. * Default behaviour for cors in the application.
  123256. * It can be a string if the expected behavior is identical in the entire app.
  123257. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  123258. */
  123259. static get CorsBehavior(): string | ((url: string | string[]) => string);
  123260. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  123261. /**
  123262. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  123263. * @ignorenaming
  123264. */
  123265. static get UseFallbackTexture(): boolean;
  123266. static set UseFallbackTexture(value: boolean);
  123267. /**
  123268. * Use this object to register external classes like custom textures or material
  123269. * to allow the laoders to instantiate them
  123270. */
  123271. static get RegisteredExternalClasses(): {
  123272. [key: string]: Object;
  123273. };
  123274. static set RegisteredExternalClasses(classes: {
  123275. [key: string]: Object;
  123276. });
  123277. /**
  123278. * Texture content used if a texture cannot loaded
  123279. * @ignorenaming
  123280. */
  123281. static get fallbackTexture(): string;
  123282. static set fallbackTexture(value: string);
  123283. /**
  123284. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  123285. * @param u defines the coordinate on X axis
  123286. * @param v defines the coordinate on Y axis
  123287. * @param width defines the width of the source data
  123288. * @param height defines the height of the source data
  123289. * @param pixels defines the source byte array
  123290. * @param color defines the output color
  123291. */
  123292. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  123293. /**
  123294. * Interpolates between a and b via alpha
  123295. * @param a The lower value (returned when alpha = 0)
  123296. * @param b The upper value (returned when alpha = 1)
  123297. * @param alpha The interpolation-factor
  123298. * @return The mixed value
  123299. */
  123300. static Mix(a: number, b: number, alpha: number): number;
  123301. /**
  123302. * Tries to instantiate a new object from a given class name
  123303. * @param className defines the class name to instantiate
  123304. * @returns the new object or null if the system was not able to do the instantiation
  123305. */
  123306. static Instantiate(className: string): any;
  123307. /**
  123308. * Provides a slice function that will work even on IE
  123309. * @param data defines the array to slice
  123310. * @param start defines the start of the data (optional)
  123311. * @param end defines the end of the data (optional)
  123312. * @returns the new sliced array
  123313. */
  123314. static Slice<T>(data: T, start?: number, end?: number): T;
  123315. /**
  123316. * Provides a slice function that will work even on IE
  123317. * The difference between this and Slice is that this will force-convert to array
  123318. * @param data defines the array to slice
  123319. * @param start defines the start of the data (optional)
  123320. * @param end defines the end of the data (optional)
  123321. * @returns the new sliced array
  123322. */
  123323. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  123324. /**
  123325. * Polyfill for setImmediate
  123326. * @param action defines the action to execute after the current execution block
  123327. */
  123328. static SetImmediate(action: () => void): void;
  123329. /**
  123330. * Function indicating if a number is an exponent of 2
  123331. * @param value defines the value to test
  123332. * @returns true if the value is an exponent of 2
  123333. */
  123334. static IsExponentOfTwo(value: number): boolean;
  123335. private static _tmpFloatArray;
  123336. /**
  123337. * Returns the nearest 32-bit single precision float representation of a Number
  123338. * @param value A Number. If the parameter is of a different type, it will get converted
  123339. * to a number or to NaN if it cannot be converted
  123340. * @returns number
  123341. */
  123342. static FloatRound(value: number): number;
  123343. /**
  123344. * Extracts the filename from a path
  123345. * @param path defines the path to use
  123346. * @returns the filename
  123347. */
  123348. static GetFilename(path: string): string;
  123349. /**
  123350. * Extracts the "folder" part of a path (everything before the filename).
  123351. * @param uri The URI to extract the info from
  123352. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  123353. * @returns The "folder" part of the path
  123354. */
  123355. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  123356. /**
  123357. * Extracts text content from a DOM element hierarchy
  123358. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  123359. */
  123360. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  123361. /**
  123362. * Convert an angle in radians to degrees
  123363. * @param angle defines the angle to convert
  123364. * @returns the angle in degrees
  123365. */
  123366. static ToDegrees(angle: number): number;
  123367. /**
  123368. * Convert an angle in degrees to radians
  123369. * @param angle defines the angle to convert
  123370. * @returns the angle in radians
  123371. */
  123372. static ToRadians(angle: number): number;
  123373. /**
  123374. * Returns an array if obj is not an array
  123375. * @param obj defines the object to evaluate as an array
  123376. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  123377. * @returns either obj directly if obj is an array or a new array containing obj
  123378. */
  123379. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  123380. /**
  123381. * Gets the pointer prefix to use
  123382. * @param engine defines the engine we are finding the prefix for
  123383. * @returns "pointer" if touch is enabled. Else returns "mouse"
  123384. */
  123385. static GetPointerPrefix(engine: Engine): string;
  123386. /**
  123387. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  123388. * @param url define the url we are trying
  123389. * @param element define the dom element where to configure the cors policy
  123390. */
  123391. static SetCorsBehavior(url: string | string[], element: {
  123392. crossOrigin: string | null;
  123393. }): void;
  123394. /**
  123395. * Removes unwanted characters from an url
  123396. * @param url defines the url to clean
  123397. * @returns the cleaned url
  123398. */
  123399. static CleanUrl(url: string): string;
  123400. /**
  123401. * Gets or sets a function used to pre-process url before using them to load assets
  123402. */
  123403. static get PreprocessUrl(): (url: string) => string;
  123404. static set PreprocessUrl(processor: (url: string) => string);
  123405. /**
  123406. * Loads an image as an HTMLImageElement.
  123407. * @param input url string, ArrayBuffer, or Blob to load
  123408. * @param onLoad callback called when the image successfully loads
  123409. * @param onError callback called when the image fails to load
  123410. * @param offlineProvider offline provider for caching
  123411. * @param mimeType optional mime type
  123412. * @returns the HTMLImageElement of the loaded image
  123413. */
  123414. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  123415. /**
  123416. * Loads a file from a url
  123417. * @param url url string, ArrayBuffer, or Blob to load
  123418. * @param onSuccess callback called when the file successfully loads
  123419. * @param onProgress callback called while file is loading (if the server supports this mode)
  123420. * @param offlineProvider defines the offline provider for caching
  123421. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123422. * @param onError callback called when the file fails to load
  123423. * @returns a file request object
  123424. */
  123425. 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;
  123426. /**
  123427. * Loads a file from a url
  123428. * @param url the file url to load
  123429. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123430. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  123431. */
  123432. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  123433. /**
  123434. * Load a script (identified by an url). When the url returns, the
  123435. * content of this file is added into a new script element, attached to the DOM (body element)
  123436. * @param scriptUrl defines the url of the script to laod
  123437. * @param onSuccess defines the callback called when the script is loaded
  123438. * @param onError defines the callback to call if an error occurs
  123439. * @param scriptId defines the id of the script element
  123440. */
  123441. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  123442. /**
  123443. * Load an asynchronous script (identified by an url). When the url returns, the
  123444. * content of this file is added into a new script element, attached to the DOM (body element)
  123445. * @param scriptUrl defines the url of the script to laod
  123446. * @param scriptId defines the id of the script element
  123447. * @returns a promise request object
  123448. */
  123449. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  123450. /**
  123451. * Loads a file from a blob
  123452. * @param fileToLoad defines the blob to use
  123453. * @param callback defines the callback to call when data is loaded
  123454. * @param progressCallback defines the callback to call during loading process
  123455. * @returns a file request object
  123456. */
  123457. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  123458. /**
  123459. * Reads a file from a File object
  123460. * @param file defines the file to load
  123461. * @param onSuccess defines the callback to call when data is loaded
  123462. * @param onProgress defines the callback to call during loading process
  123463. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  123464. * @param onError defines the callback to call when an error occurs
  123465. * @returns a file request object
  123466. */
  123467. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  123468. /**
  123469. * Creates a data url from a given string content
  123470. * @param content defines the content to convert
  123471. * @returns the new data url link
  123472. */
  123473. static FileAsURL(content: string): string;
  123474. /**
  123475. * Format the given number to a specific decimal format
  123476. * @param value defines the number to format
  123477. * @param decimals defines the number of decimals to use
  123478. * @returns the formatted string
  123479. */
  123480. static Format(value: number, decimals?: number): string;
  123481. /**
  123482. * Tries to copy an object by duplicating every property
  123483. * @param source defines the source object
  123484. * @param destination defines the target object
  123485. * @param doNotCopyList defines a list of properties to avoid
  123486. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  123487. */
  123488. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  123489. /**
  123490. * Gets a boolean indicating if the given object has no own property
  123491. * @param obj defines the object to test
  123492. * @returns true if object has no own property
  123493. */
  123494. static IsEmpty(obj: any): boolean;
  123495. /**
  123496. * Function used to register events at window level
  123497. * @param windowElement defines the Window object to use
  123498. * @param events defines the events to register
  123499. */
  123500. static RegisterTopRootEvents(windowElement: Window, events: {
  123501. name: string;
  123502. handler: Nullable<(e: FocusEvent) => any>;
  123503. }[]): void;
  123504. /**
  123505. * Function used to unregister events from window level
  123506. * @param windowElement defines the Window object to use
  123507. * @param events defines the events to unregister
  123508. */
  123509. static UnregisterTopRootEvents(windowElement: Window, events: {
  123510. name: string;
  123511. handler: Nullable<(e: FocusEvent) => any>;
  123512. }[]): void;
  123513. /**
  123514. * @ignore
  123515. */
  123516. static _ScreenshotCanvas: HTMLCanvasElement;
  123517. /**
  123518. * Dumps the current bound framebuffer
  123519. * @param width defines the rendering width
  123520. * @param height defines the rendering height
  123521. * @param engine defines the hosting engine
  123522. * @param successCallback defines the callback triggered once the data are available
  123523. * @param mimeType defines the mime type of the result
  123524. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  123525. */
  123526. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  123527. /**
  123528. * Converts the canvas data to blob.
  123529. * This acts as a polyfill for browsers not supporting the to blob function.
  123530. * @param canvas Defines the canvas to extract the data from
  123531. * @param successCallback Defines the callback triggered once the data are available
  123532. * @param mimeType Defines the mime type of the result
  123533. */
  123534. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  123535. /**
  123536. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  123537. * @param successCallback defines the callback triggered once the data are available
  123538. * @param mimeType defines the mime type of the result
  123539. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  123540. */
  123541. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  123542. /**
  123543. * Downloads a blob in the browser
  123544. * @param blob defines the blob to download
  123545. * @param fileName defines the name of the downloaded file
  123546. */
  123547. static Download(blob: Blob, fileName: string): void;
  123548. /**
  123549. * Will return the right value of the noPreventDefault variable
  123550. * Needed to keep backwards compatibility to the old API.
  123551. *
  123552. * @param args arguments passed to the attachControl function
  123553. * @returns the correct value for noPreventDefault
  123554. */
  123555. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  123556. /**
  123557. * Captures a screenshot of the current rendering
  123558. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123559. * @param engine defines the rendering engine
  123560. * @param camera defines the source camera
  123561. * @param size This parameter can be set to a single number or to an object with the
  123562. * following (optional) properties: precision, width, height. If a single number is passed,
  123563. * it will be used for both width and height. If an object is passed, the screenshot size
  123564. * will be derived from the parameters. The precision property is a multiplier allowing
  123565. * rendering at a higher or lower resolution
  123566. * @param successCallback defines the callback receives a single parameter which contains the
  123567. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123568. * src parameter of an <img> to display it
  123569. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123570. * Check your browser for supported MIME types
  123571. */
  123572. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  123573. /**
  123574. * Captures a screenshot of the current rendering
  123575. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123576. * @param engine defines the rendering engine
  123577. * @param camera defines the source camera
  123578. * @param size This parameter can be set to a single number or to an object with the
  123579. * following (optional) properties: precision, width, height. If a single number is passed,
  123580. * it will be used for both width and height. If an object is passed, the screenshot size
  123581. * will be derived from the parameters. The precision property is a multiplier allowing
  123582. * rendering at a higher or lower resolution
  123583. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123584. * Check your browser for supported MIME types
  123585. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123586. * to the src parameter of an <img> to display it
  123587. */
  123588. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  123589. /**
  123590. * Generates an image screenshot from the specified camera.
  123591. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123592. * @param engine The engine to use for rendering
  123593. * @param camera The camera to use for rendering
  123594. * @param size This parameter can be set to a single number or to an object with the
  123595. * following (optional) properties: precision, width, height. If a single number is passed,
  123596. * it will be used for both width and height. If an object is passed, the screenshot size
  123597. * will be derived from the parameters. The precision property is a multiplier allowing
  123598. * rendering at a higher or lower resolution
  123599. * @param successCallback The callback receives a single parameter which contains the
  123600. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123601. * src parameter of an <img> to display it
  123602. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123603. * Check your browser for supported MIME types
  123604. * @param samples Texture samples (default: 1)
  123605. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123606. * @param fileName A name for for the downloaded file.
  123607. */
  123608. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  123609. /**
  123610. * Generates an image screenshot from the specified camera.
  123611. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123612. * @param engine The engine to use for rendering
  123613. * @param camera The camera to use for rendering
  123614. * @param size This parameter can be set to a single number or to an object with the
  123615. * following (optional) properties: precision, width, height. If a single number is passed,
  123616. * it will be used for both width and height. If an object is passed, the screenshot size
  123617. * will be derived from the parameters. The precision property is a multiplier allowing
  123618. * rendering at a higher or lower resolution
  123619. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123620. * Check your browser for supported MIME types
  123621. * @param samples Texture samples (default: 1)
  123622. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123623. * @param fileName A name for for the downloaded file.
  123624. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123625. * to the src parameter of an <img> to display it
  123626. */
  123627. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  123628. /**
  123629. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  123630. * Be aware Math.random() could cause collisions, but:
  123631. * "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"
  123632. * @returns a pseudo random id
  123633. */
  123634. static RandomId(): string;
  123635. /**
  123636. * Test if the given uri is a base64 string
  123637. * @param uri The uri to test
  123638. * @return True if the uri is a base64 string or false otherwise
  123639. */
  123640. static IsBase64(uri: string): boolean;
  123641. /**
  123642. * Decode the given base64 uri.
  123643. * @param uri The uri to decode
  123644. * @return The decoded base64 data.
  123645. */
  123646. static DecodeBase64(uri: string): ArrayBuffer;
  123647. /**
  123648. * Gets the absolute url.
  123649. * @param url the input url
  123650. * @return the absolute url
  123651. */
  123652. static GetAbsoluteUrl(url: string): string;
  123653. /**
  123654. * No log
  123655. */
  123656. static readonly NoneLogLevel: number;
  123657. /**
  123658. * Only message logs
  123659. */
  123660. static readonly MessageLogLevel: number;
  123661. /**
  123662. * Only warning logs
  123663. */
  123664. static readonly WarningLogLevel: number;
  123665. /**
  123666. * Only error logs
  123667. */
  123668. static readonly ErrorLogLevel: number;
  123669. /**
  123670. * All logs
  123671. */
  123672. static readonly AllLogLevel: number;
  123673. /**
  123674. * Gets a value indicating the number of loading errors
  123675. * @ignorenaming
  123676. */
  123677. static get errorsCount(): number;
  123678. /**
  123679. * Callback called when a new log is added
  123680. */
  123681. static OnNewCacheEntry: (entry: string) => void;
  123682. /**
  123683. * Log a message to the console
  123684. * @param message defines the message to log
  123685. */
  123686. static Log(message: string): void;
  123687. /**
  123688. * Write a warning message to the console
  123689. * @param message defines the message to log
  123690. */
  123691. static Warn(message: string): void;
  123692. /**
  123693. * Write an error message to the console
  123694. * @param message defines the message to log
  123695. */
  123696. static Error(message: string): void;
  123697. /**
  123698. * Gets current log cache (list of logs)
  123699. */
  123700. static get LogCache(): string;
  123701. /**
  123702. * Clears the log cache
  123703. */
  123704. static ClearLogCache(): void;
  123705. /**
  123706. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  123707. */
  123708. static set LogLevels(level: number);
  123709. /**
  123710. * Checks if the window object exists
  123711. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  123712. */
  123713. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  123714. /**
  123715. * No performance log
  123716. */
  123717. static readonly PerformanceNoneLogLevel: number;
  123718. /**
  123719. * Use user marks to log performance
  123720. */
  123721. static readonly PerformanceUserMarkLogLevel: number;
  123722. /**
  123723. * Log performance to the console
  123724. */
  123725. static readonly PerformanceConsoleLogLevel: number;
  123726. private static _performance;
  123727. /**
  123728. * Sets the current performance log level
  123729. */
  123730. static set PerformanceLogLevel(level: number);
  123731. private static _StartPerformanceCounterDisabled;
  123732. private static _EndPerformanceCounterDisabled;
  123733. private static _StartUserMark;
  123734. private static _EndUserMark;
  123735. private static _StartPerformanceConsole;
  123736. private static _EndPerformanceConsole;
  123737. /**
  123738. * Starts a performance counter
  123739. */
  123740. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123741. /**
  123742. * Ends a specific performance coutner
  123743. */
  123744. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123745. /**
  123746. * Gets either window.performance.now() if supported or Date.now() else
  123747. */
  123748. static get Now(): number;
  123749. /**
  123750. * This method will return the name of the class used to create the instance of the given object.
  123751. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  123752. * @param object the object to get the class name from
  123753. * @param isType defines if the object is actually a type
  123754. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  123755. */
  123756. static GetClassName(object: any, isType?: boolean): string;
  123757. /**
  123758. * Gets the first element of an array satisfying a given predicate
  123759. * @param array defines the array to browse
  123760. * @param predicate defines the predicate to use
  123761. * @returns null if not found or the element
  123762. */
  123763. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  123764. /**
  123765. * This method will return the name of the full name of the class, including its owning module (if any).
  123766. * 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).
  123767. * @param object the object to get the class name from
  123768. * @param isType defines if the object is actually a type
  123769. * @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.
  123770. * @ignorenaming
  123771. */
  123772. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  123773. /**
  123774. * Returns a promise that resolves after the given amount of time.
  123775. * @param delay Number of milliseconds to delay
  123776. * @returns Promise that resolves after the given amount of time
  123777. */
  123778. static DelayAsync(delay: number): Promise<void>;
  123779. /**
  123780. * Utility function to detect if the current user agent is Safari
  123781. * @returns whether or not the current user agent is safari
  123782. */
  123783. static IsSafari(): boolean;
  123784. }
  123785. /**
  123786. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  123787. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  123788. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  123789. * @param name The name of the class, case should be preserved
  123790. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  123791. */
  123792. export function className(name: string, module?: string): (target: Object) => void;
  123793. /**
  123794. * An implementation of a loop for asynchronous functions.
  123795. */
  123796. export class AsyncLoop {
  123797. /**
  123798. * Defines the number of iterations for the loop
  123799. */
  123800. iterations: number;
  123801. /**
  123802. * Defines the current index of the loop.
  123803. */
  123804. index: number;
  123805. private _done;
  123806. private _fn;
  123807. private _successCallback;
  123808. /**
  123809. * Constructor.
  123810. * @param iterations the number of iterations.
  123811. * @param func the function to run each iteration
  123812. * @param successCallback the callback that will be called upon succesful execution
  123813. * @param offset starting offset.
  123814. */
  123815. constructor(
  123816. /**
  123817. * Defines the number of iterations for the loop
  123818. */
  123819. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  123820. /**
  123821. * Execute the next iteration. Must be called after the last iteration was finished.
  123822. */
  123823. executeNext(): void;
  123824. /**
  123825. * Break the loop and run the success callback.
  123826. */
  123827. breakLoop(): void;
  123828. /**
  123829. * Create and run an async loop.
  123830. * @param iterations the number of iterations.
  123831. * @param fn the function to run each iteration
  123832. * @param successCallback the callback that will be called upon succesful execution
  123833. * @param offset starting offset.
  123834. * @returns the created async loop object
  123835. */
  123836. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  123837. /**
  123838. * A for-loop that will run a given number of iterations synchronous and the rest async.
  123839. * @param iterations total number of iterations
  123840. * @param syncedIterations number of synchronous iterations in each async iteration.
  123841. * @param fn the function to call each iteration.
  123842. * @param callback a success call back that will be called when iterating stops.
  123843. * @param breakFunction a break condition (optional)
  123844. * @param timeout timeout settings for the setTimeout function. default - 0.
  123845. * @returns the created async loop object
  123846. */
  123847. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  123848. }
  123849. }
  123850. declare module BABYLON {
  123851. /**
  123852. * This class implement a typical dictionary using a string as key and the generic type T as value.
  123853. * The underlying implementation relies on an associative array to ensure the best performances.
  123854. * The value can be anything including 'null' but except 'undefined'
  123855. */
  123856. export class StringDictionary<T> {
  123857. /**
  123858. * This will clear this dictionary and copy the content from the 'source' one.
  123859. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  123860. * @param source the dictionary to take the content from and copy to this dictionary
  123861. */
  123862. copyFrom(source: StringDictionary<T>): void;
  123863. /**
  123864. * Get a value based from its key
  123865. * @param key the given key to get the matching value from
  123866. * @return the value if found, otherwise undefined is returned
  123867. */
  123868. get(key: string): T | undefined;
  123869. /**
  123870. * Get a value from its key or add it if it doesn't exist.
  123871. * This method will ensure you that a given key/data will be present in the dictionary.
  123872. * @param key the given key to get the matching value from
  123873. * @param factory the factory that will create the value if the key is not present in the dictionary.
  123874. * The factory will only be invoked if there's no data for the given key.
  123875. * @return the value corresponding to the key.
  123876. */
  123877. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  123878. /**
  123879. * Get a value from its key if present in the dictionary otherwise add it
  123880. * @param key the key to get the value from
  123881. * @param val if there's no such key/value pair in the dictionary add it with this value
  123882. * @return the value corresponding to the key
  123883. */
  123884. getOrAdd(key: string, val: T): T;
  123885. /**
  123886. * Check if there's a given key in the dictionary
  123887. * @param key the key to check for
  123888. * @return true if the key is present, false otherwise
  123889. */
  123890. contains(key: string): boolean;
  123891. /**
  123892. * Add a new key and its corresponding value
  123893. * @param key the key to add
  123894. * @param value the value corresponding to the key
  123895. * @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
  123896. */
  123897. add(key: string, value: T): boolean;
  123898. /**
  123899. * Update a specific value associated to a key
  123900. * @param key defines the key to use
  123901. * @param value defines the value to store
  123902. * @returns true if the value was updated (or false if the key was not found)
  123903. */
  123904. set(key: string, value: T): boolean;
  123905. /**
  123906. * Get the element of the given key and remove it from the dictionary
  123907. * @param key defines the key to search
  123908. * @returns the value associated with the key or null if not found
  123909. */
  123910. getAndRemove(key: string): Nullable<T>;
  123911. /**
  123912. * Remove a key/value from the dictionary.
  123913. * @param key the key to remove
  123914. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  123915. */
  123916. remove(key: string): boolean;
  123917. /**
  123918. * Clear the whole content of the dictionary
  123919. */
  123920. clear(): void;
  123921. /**
  123922. * Gets the current count
  123923. */
  123924. get count(): number;
  123925. /**
  123926. * Execute a callback on each key/val of the dictionary.
  123927. * Note that you can remove any element in this dictionary in the callback implementation
  123928. * @param callback the callback to execute on a given key/value pair
  123929. */
  123930. forEach(callback: (key: string, val: T) => void): void;
  123931. /**
  123932. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  123933. * If the callback returns null or undefined the method will iterate to the next key/value pair
  123934. * Note that you can remove any element in this dictionary in the callback implementation
  123935. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  123936. * @returns the first item
  123937. */
  123938. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  123939. private _count;
  123940. private _data;
  123941. }
  123942. }
  123943. declare module BABYLON {
  123944. /** @hidden */
  123945. export interface ICollisionCoordinator {
  123946. createCollider(): Collider;
  123947. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  123948. init(scene: Scene): void;
  123949. }
  123950. /** @hidden */
  123951. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  123952. private _scene;
  123953. private _scaledPosition;
  123954. private _scaledVelocity;
  123955. private _finalPosition;
  123956. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  123957. createCollider(): Collider;
  123958. init(scene: Scene): void;
  123959. private _collideWithWorld;
  123960. }
  123961. }
  123962. declare module BABYLON {
  123963. /**
  123964. * Class used to manage all inputs for the scene.
  123965. */
  123966. export class InputManager {
  123967. /** The distance in pixel that you have to move to prevent some events */
  123968. static DragMovementThreshold: number;
  123969. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  123970. static LongPressDelay: number;
  123971. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  123972. static DoubleClickDelay: number;
  123973. /** If you need to check double click without raising a single click at first click, enable this flag */
  123974. static ExclusiveDoubleClickMode: boolean;
  123975. /** 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. */
  123976. private _alreadyAttached;
  123977. private _alreadyAttachedTo;
  123978. private _wheelEventName;
  123979. private _onPointerMove;
  123980. private _onPointerDown;
  123981. private _onPointerUp;
  123982. private _initClickEvent;
  123983. private _initActionManager;
  123984. private _delayedSimpleClick;
  123985. private _delayedSimpleClickTimeout;
  123986. private _previousDelayedSimpleClickTimeout;
  123987. private _meshPickProceed;
  123988. private _previousButtonPressed;
  123989. private _currentPickResult;
  123990. private _previousPickResult;
  123991. private _totalPointersPressed;
  123992. private _doubleClickOccured;
  123993. private _pointerOverMesh;
  123994. private _pickedDownMesh;
  123995. private _pickedUpMesh;
  123996. private _pointerX;
  123997. private _pointerY;
  123998. private _unTranslatedPointerX;
  123999. private _unTranslatedPointerY;
  124000. private _startingPointerPosition;
  124001. private _previousStartingPointerPosition;
  124002. private _startingPointerTime;
  124003. private _previousStartingPointerTime;
  124004. private _pointerCaptures;
  124005. private _meshUnderPointerId;
  124006. private _onKeyDown;
  124007. private _onKeyUp;
  124008. private _keyboardIsAttached;
  124009. private _onCanvasFocusObserver;
  124010. private _onCanvasBlurObserver;
  124011. private _scene;
  124012. /**
  124013. * Creates a new InputManager
  124014. * @param scene defines the hosting scene
  124015. */
  124016. constructor(scene: Scene);
  124017. /**
  124018. * Gets the mesh that is currently under the pointer
  124019. */
  124020. get meshUnderPointer(): Nullable<AbstractMesh>;
  124021. /**
  124022. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  124023. * @param pointerId the pointer id to use
  124024. * @returns The mesh under this pointer id or null if not found
  124025. */
  124026. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  124027. /**
  124028. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  124029. */
  124030. get unTranslatedPointer(): Vector2;
  124031. /**
  124032. * Gets or sets the current on-screen X position of the pointer
  124033. */
  124034. get pointerX(): number;
  124035. set pointerX(value: number);
  124036. /**
  124037. * Gets or sets the current on-screen Y position of the pointer
  124038. */
  124039. get pointerY(): number;
  124040. set pointerY(value: number);
  124041. private _updatePointerPosition;
  124042. private _processPointerMove;
  124043. private _setRayOnPointerInfo;
  124044. private _checkPrePointerObservable;
  124045. /**
  124046. * Use this method to simulate a pointer move on a mesh
  124047. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124048. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124049. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124050. */
  124051. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  124052. /**
  124053. * Use this method to simulate a pointer down on a mesh
  124054. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124055. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124056. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124057. */
  124058. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  124059. private _processPointerDown;
  124060. /** @hidden */
  124061. _isPointerSwiping(): boolean;
  124062. /**
  124063. * Use this method to simulate a pointer up on a mesh
  124064. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124065. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124066. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124067. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  124068. */
  124069. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  124070. private _processPointerUp;
  124071. /**
  124072. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  124073. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  124074. * @returns true if the pointer was captured
  124075. */
  124076. isPointerCaptured(pointerId?: number): boolean;
  124077. /**
  124078. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  124079. * @param attachUp defines if you want to attach events to pointerup
  124080. * @param attachDown defines if you want to attach events to pointerdown
  124081. * @param attachMove defines if you want to attach events to pointermove
  124082. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  124083. */
  124084. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  124085. /**
  124086. * Detaches all event handlers
  124087. */
  124088. detachControl(): void;
  124089. /**
  124090. * Force the value of meshUnderPointer
  124091. * @param mesh defines the mesh to use
  124092. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  124093. */
  124094. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  124095. /**
  124096. * Gets the mesh under the pointer
  124097. * @returns a Mesh or null if no mesh is under the pointer
  124098. */
  124099. getPointerOverMesh(): Nullable<AbstractMesh>;
  124100. }
  124101. }
  124102. declare module BABYLON {
  124103. /**
  124104. * This class defines the direct association between an animation and a target
  124105. */
  124106. export class TargetedAnimation {
  124107. /**
  124108. * Animation to perform
  124109. */
  124110. animation: Animation;
  124111. /**
  124112. * Target to animate
  124113. */
  124114. target: any;
  124115. /**
  124116. * Returns the string "TargetedAnimation"
  124117. * @returns "TargetedAnimation"
  124118. */
  124119. getClassName(): string;
  124120. /**
  124121. * Serialize the object
  124122. * @returns the JSON object representing the current entity
  124123. */
  124124. serialize(): any;
  124125. }
  124126. /**
  124127. * Use this class to create coordinated animations on multiple targets
  124128. */
  124129. export class AnimationGroup implements IDisposable {
  124130. /** The name of the animation group */
  124131. name: string;
  124132. private _scene;
  124133. private _targetedAnimations;
  124134. private _animatables;
  124135. private _from;
  124136. private _to;
  124137. private _isStarted;
  124138. private _isPaused;
  124139. private _speedRatio;
  124140. private _loopAnimation;
  124141. private _isAdditive;
  124142. /**
  124143. * Gets or sets the unique id of the node
  124144. */
  124145. uniqueId: number;
  124146. /**
  124147. * This observable will notify when one animation have ended
  124148. */
  124149. onAnimationEndObservable: Observable<TargetedAnimation>;
  124150. /**
  124151. * Observer raised when one animation loops
  124152. */
  124153. onAnimationLoopObservable: Observable<TargetedAnimation>;
  124154. /**
  124155. * Observer raised when all animations have looped
  124156. */
  124157. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  124158. /**
  124159. * This observable will notify when all animations have ended.
  124160. */
  124161. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  124162. /**
  124163. * This observable will notify when all animations have paused.
  124164. */
  124165. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  124166. /**
  124167. * This observable will notify when all animations are playing.
  124168. */
  124169. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  124170. /**
  124171. * Gets the first frame
  124172. */
  124173. get from(): number;
  124174. /**
  124175. * Gets the last frame
  124176. */
  124177. get to(): number;
  124178. /**
  124179. * Define if the animations are started
  124180. */
  124181. get isStarted(): boolean;
  124182. /**
  124183. * Gets a value indicating that the current group is playing
  124184. */
  124185. get isPlaying(): boolean;
  124186. /**
  124187. * Gets or sets the speed ratio to use for all animations
  124188. */
  124189. get speedRatio(): number;
  124190. /**
  124191. * Gets or sets the speed ratio to use for all animations
  124192. */
  124193. set speedRatio(value: number);
  124194. /**
  124195. * Gets or sets if all animations should loop or not
  124196. */
  124197. get loopAnimation(): boolean;
  124198. set loopAnimation(value: boolean);
  124199. /**
  124200. * Gets or sets if all animations should be evaluated additively
  124201. */
  124202. get isAdditive(): boolean;
  124203. set isAdditive(value: boolean);
  124204. /**
  124205. * Gets the targeted animations for this animation group
  124206. */
  124207. get targetedAnimations(): Array<TargetedAnimation>;
  124208. /**
  124209. * returning the list of animatables controlled by this animation group.
  124210. */
  124211. get animatables(): Array<Animatable>;
  124212. /**
  124213. * Gets the list of target animations
  124214. */
  124215. get children(): TargetedAnimation[];
  124216. /**
  124217. * Instantiates a new Animation Group.
  124218. * This helps managing several animations at once.
  124219. * @see https://doc.babylonjs.com/how_to/group
  124220. * @param name Defines the name of the group
  124221. * @param scene Defines the scene the group belongs to
  124222. */
  124223. constructor(
  124224. /** The name of the animation group */
  124225. name: string, scene?: Nullable<Scene>);
  124226. /**
  124227. * Add an animation (with its target) in the group
  124228. * @param animation defines the animation we want to add
  124229. * @param target defines the target of the animation
  124230. * @returns the TargetedAnimation object
  124231. */
  124232. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  124233. /**
  124234. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  124235. * It can add constant keys at begin or end
  124236. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  124237. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  124238. * @returns the animation group
  124239. */
  124240. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  124241. private _animationLoopCount;
  124242. private _animationLoopFlags;
  124243. private _processLoop;
  124244. /**
  124245. * Start all animations on given targets
  124246. * @param loop defines if animations must loop
  124247. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  124248. * @param from defines the from key (optional)
  124249. * @param to defines the to key (optional)
  124250. * @param isAdditive defines the additive state for the resulting animatables (optional)
  124251. * @returns the current animation group
  124252. */
  124253. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  124254. /**
  124255. * Pause all animations
  124256. * @returns the animation group
  124257. */
  124258. pause(): AnimationGroup;
  124259. /**
  124260. * Play all animations to initial state
  124261. * This function will start() the animations if they were not started or will restart() them if they were paused
  124262. * @param loop defines if animations must loop
  124263. * @returns the animation group
  124264. */
  124265. play(loop?: boolean): AnimationGroup;
  124266. /**
  124267. * Reset all animations to initial state
  124268. * @returns the animation group
  124269. */
  124270. reset(): AnimationGroup;
  124271. /**
  124272. * Restart animations from key 0
  124273. * @returns the animation group
  124274. */
  124275. restart(): AnimationGroup;
  124276. /**
  124277. * Stop all animations
  124278. * @returns the animation group
  124279. */
  124280. stop(): AnimationGroup;
  124281. /**
  124282. * Set animation weight for all animatables
  124283. * @param weight defines the weight to use
  124284. * @return the animationGroup
  124285. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  124286. */
  124287. setWeightForAllAnimatables(weight: number): AnimationGroup;
  124288. /**
  124289. * Synchronize and normalize all animatables with a source animatable
  124290. * @param root defines the root animatable to synchronize with
  124291. * @return the animationGroup
  124292. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  124293. */
  124294. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  124295. /**
  124296. * Goes to a specific frame in this animation group
  124297. * @param frame the frame number to go to
  124298. * @return the animationGroup
  124299. */
  124300. goToFrame(frame: number): AnimationGroup;
  124301. /**
  124302. * Dispose all associated resources
  124303. */
  124304. dispose(): void;
  124305. private _checkAnimationGroupEnded;
  124306. /**
  124307. * Clone the current animation group and returns a copy
  124308. * @param newName defines the name of the new group
  124309. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  124310. * @returns the new aniamtion group
  124311. */
  124312. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  124313. /**
  124314. * Serializes the animationGroup to an object
  124315. * @returns Serialized object
  124316. */
  124317. serialize(): any;
  124318. /**
  124319. * Returns a new AnimationGroup object parsed from the source provided.
  124320. * @param parsedAnimationGroup defines the source
  124321. * @param scene defines the scene that will receive the animationGroup
  124322. * @returns a new AnimationGroup
  124323. */
  124324. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  124325. /**
  124326. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  124327. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  124328. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  124329. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  124330. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  124331. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  124332. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  124333. */
  124334. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  124335. /**
  124336. * Returns the string "AnimationGroup"
  124337. * @returns "AnimationGroup"
  124338. */
  124339. getClassName(): string;
  124340. /**
  124341. * Creates a detailled string about the object
  124342. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  124343. * @returns a string representing the object
  124344. */
  124345. toString(fullDetails?: boolean): string;
  124346. }
  124347. }
  124348. declare module BABYLON {
  124349. /**
  124350. * Define an interface for all classes that will hold resources
  124351. */
  124352. export interface IDisposable {
  124353. /**
  124354. * Releases all held resources
  124355. */
  124356. dispose(): void;
  124357. }
  124358. /** Interface defining initialization parameters for Scene class */
  124359. export interface SceneOptions {
  124360. /**
  124361. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  124362. * It will improve performance when the number of geometries becomes important.
  124363. */
  124364. useGeometryUniqueIdsMap?: boolean;
  124365. /**
  124366. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  124367. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  124368. */
  124369. useMaterialMeshMap?: boolean;
  124370. /**
  124371. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  124372. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  124373. */
  124374. useClonedMeshMap?: boolean;
  124375. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  124376. virtual?: boolean;
  124377. }
  124378. /**
  124379. * Represents a scene to be rendered by the engine.
  124380. * @see https://doc.babylonjs.com/features/scene
  124381. */
  124382. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  124383. /** The fog is deactivated */
  124384. static readonly FOGMODE_NONE: number;
  124385. /** The fog density is following an exponential function */
  124386. static readonly FOGMODE_EXP: number;
  124387. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  124388. static readonly FOGMODE_EXP2: number;
  124389. /** The fog density is following a linear function. */
  124390. static readonly FOGMODE_LINEAR: number;
  124391. /**
  124392. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  124393. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124394. */
  124395. static MinDeltaTime: number;
  124396. /**
  124397. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  124398. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124399. */
  124400. static MaxDeltaTime: number;
  124401. /**
  124402. * Factory used to create the default material.
  124403. * @param name The name of the material to create
  124404. * @param scene The scene to create the material for
  124405. * @returns The default material
  124406. */
  124407. static DefaultMaterialFactory(scene: Scene): Material;
  124408. /**
  124409. * Factory used to create the a collision coordinator.
  124410. * @returns The collision coordinator
  124411. */
  124412. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  124413. /** @hidden */
  124414. _inputManager: InputManager;
  124415. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  124416. cameraToUseForPointers: Nullable<Camera>;
  124417. /** @hidden */
  124418. readonly _isScene: boolean;
  124419. /** @hidden */
  124420. _blockEntityCollection: boolean;
  124421. /**
  124422. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  124423. */
  124424. autoClear: boolean;
  124425. /**
  124426. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  124427. */
  124428. autoClearDepthAndStencil: boolean;
  124429. /**
  124430. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  124431. */
  124432. clearColor: Color4;
  124433. /**
  124434. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  124435. */
  124436. ambientColor: Color3;
  124437. /**
  124438. * This is use to store the default BRDF lookup for PBR materials in your scene.
  124439. * It should only be one of the following (if not the default embedded one):
  124440. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124441. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  124442. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124443. * The material properties need to be setup according to the type of texture in use.
  124444. */
  124445. environmentBRDFTexture: BaseTexture;
  124446. /**
  124447. * Texture used in all pbr material as the reflection texture.
  124448. * As in the majority of the scene they are the same (exception for multi room and so on),
  124449. * this is easier to reference from here than from all the materials.
  124450. */
  124451. get environmentTexture(): Nullable<BaseTexture>;
  124452. /**
  124453. * Texture used in all pbr material as the reflection texture.
  124454. * As in the majority of the scene they are the same (exception for multi room and so on),
  124455. * this is easier to set here than in all the materials.
  124456. */
  124457. set environmentTexture(value: Nullable<BaseTexture>);
  124458. /** @hidden */
  124459. protected _environmentIntensity: number;
  124460. /**
  124461. * Intensity of the environment in all pbr material.
  124462. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  124463. * As in the majority of the scene they are the same (exception for multi room and so on),
  124464. * this is easier to reference from here than from all the materials.
  124465. */
  124466. get environmentIntensity(): number;
  124467. /**
  124468. * Intensity of the environment in all pbr material.
  124469. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  124470. * As in the majority of the scene they are the same (exception for multi room and so on),
  124471. * this is easier to set here than in all the materials.
  124472. */
  124473. set environmentIntensity(value: number);
  124474. /** @hidden */
  124475. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124476. /**
  124477. * Default image processing configuration used either in the rendering
  124478. * Forward main pass or through the imageProcessingPostProcess if present.
  124479. * As in the majority of the scene they are the same (exception for multi camera),
  124480. * this is easier to reference from here than from all the materials and post process.
  124481. *
  124482. * No setter as we it is a shared configuration, you can set the values instead.
  124483. */
  124484. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124485. private _forceWireframe;
  124486. /**
  124487. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  124488. */
  124489. set forceWireframe(value: boolean);
  124490. get forceWireframe(): boolean;
  124491. private _skipFrustumClipping;
  124492. /**
  124493. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  124494. */
  124495. set skipFrustumClipping(value: boolean);
  124496. get skipFrustumClipping(): boolean;
  124497. private _forcePointsCloud;
  124498. /**
  124499. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  124500. */
  124501. set forcePointsCloud(value: boolean);
  124502. get forcePointsCloud(): boolean;
  124503. /**
  124504. * Gets or sets the active clipplane 1
  124505. */
  124506. clipPlane: Nullable<Plane>;
  124507. /**
  124508. * Gets or sets the active clipplane 2
  124509. */
  124510. clipPlane2: Nullable<Plane>;
  124511. /**
  124512. * Gets or sets the active clipplane 3
  124513. */
  124514. clipPlane3: Nullable<Plane>;
  124515. /**
  124516. * Gets or sets the active clipplane 4
  124517. */
  124518. clipPlane4: Nullable<Plane>;
  124519. /**
  124520. * Gets or sets the active clipplane 5
  124521. */
  124522. clipPlane5: Nullable<Plane>;
  124523. /**
  124524. * Gets or sets the active clipplane 6
  124525. */
  124526. clipPlane6: Nullable<Plane>;
  124527. /**
  124528. * Gets or sets a boolean indicating if animations are enabled
  124529. */
  124530. animationsEnabled: boolean;
  124531. private _animationPropertiesOverride;
  124532. /**
  124533. * Gets or sets the animation properties override
  124534. */
  124535. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  124536. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  124537. /**
  124538. * Gets or sets a boolean indicating if a constant deltatime has to be used
  124539. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  124540. */
  124541. useConstantAnimationDeltaTime: boolean;
  124542. /**
  124543. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  124544. * Please note that it requires to run a ray cast through the scene on every frame
  124545. */
  124546. constantlyUpdateMeshUnderPointer: boolean;
  124547. /**
  124548. * Defines the HTML cursor to use when hovering over interactive elements
  124549. */
  124550. hoverCursor: string;
  124551. /**
  124552. * Defines the HTML default cursor to use (empty by default)
  124553. */
  124554. defaultCursor: string;
  124555. /**
  124556. * Defines whether cursors are handled by the scene.
  124557. */
  124558. doNotHandleCursors: boolean;
  124559. /**
  124560. * This is used to call preventDefault() on pointer down
  124561. * in order to block unwanted artifacts like system double clicks
  124562. */
  124563. preventDefaultOnPointerDown: boolean;
  124564. /**
  124565. * This is used to call preventDefault() on pointer up
  124566. * in order to block unwanted artifacts like system double clicks
  124567. */
  124568. preventDefaultOnPointerUp: boolean;
  124569. /**
  124570. * Gets or sets user defined metadata
  124571. */
  124572. metadata: any;
  124573. /**
  124574. * For internal use only. Please do not use.
  124575. */
  124576. reservedDataStore: any;
  124577. /**
  124578. * Gets the name of the plugin used to load this scene (null by default)
  124579. */
  124580. loadingPluginName: string;
  124581. /**
  124582. * Use this array to add regular expressions used to disable offline support for specific urls
  124583. */
  124584. disableOfflineSupportExceptionRules: RegExp[];
  124585. /**
  124586. * An event triggered when the scene is disposed.
  124587. */
  124588. onDisposeObservable: Observable<Scene>;
  124589. private _onDisposeObserver;
  124590. /** Sets a function to be executed when this scene is disposed. */
  124591. set onDispose(callback: () => void);
  124592. /**
  124593. * An event triggered before rendering the scene (right after animations and physics)
  124594. */
  124595. onBeforeRenderObservable: Observable<Scene>;
  124596. private _onBeforeRenderObserver;
  124597. /** Sets a function to be executed before rendering this scene */
  124598. set beforeRender(callback: Nullable<() => void>);
  124599. /**
  124600. * An event triggered after rendering the scene
  124601. */
  124602. onAfterRenderObservable: Observable<Scene>;
  124603. /**
  124604. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  124605. */
  124606. onAfterRenderCameraObservable: Observable<Camera>;
  124607. private _onAfterRenderObserver;
  124608. /** Sets a function to be executed after rendering this scene */
  124609. set afterRender(callback: Nullable<() => void>);
  124610. /**
  124611. * An event triggered before animating the scene
  124612. */
  124613. onBeforeAnimationsObservable: Observable<Scene>;
  124614. /**
  124615. * An event triggered after animations processing
  124616. */
  124617. onAfterAnimationsObservable: Observable<Scene>;
  124618. /**
  124619. * An event triggered before draw calls are ready to be sent
  124620. */
  124621. onBeforeDrawPhaseObservable: Observable<Scene>;
  124622. /**
  124623. * An event triggered after draw calls have been sent
  124624. */
  124625. onAfterDrawPhaseObservable: Observable<Scene>;
  124626. /**
  124627. * An event triggered when the scene is ready
  124628. */
  124629. onReadyObservable: Observable<Scene>;
  124630. /**
  124631. * An event triggered before rendering a camera
  124632. */
  124633. onBeforeCameraRenderObservable: Observable<Camera>;
  124634. private _onBeforeCameraRenderObserver;
  124635. /** Sets a function to be executed before rendering a camera*/
  124636. set beforeCameraRender(callback: () => void);
  124637. /**
  124638. * An event triggered after rendering a camera
  124639. */
  124640. onAfterCameraRenderObservable: Observable<Camera>;
  124641. private _onAfterCameraRenderObserver;
  124642. /** Sets a function to be executed after rendering a camera*/
  124643. set afterCameraRender(callback: () => void);
  124644. /**
  124645. * An event triggered when active meshes evaluation is about to start
  124646. */
  124647. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  124648. /**
  124649. * An event triggered when active meshes evaluation is done
  124650. */
  124651. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  124652. /**
  124653. * An event triggered when particles rendering is about to start
  124654. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124655. */
  124656. onBeforeParticlesRenderingObservable: Observable<Scene>;
  124657. /**
  124658. * An event triggered when particles rendering is done
  124659. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124660. */
  124661. onAfterParticlesRenderingObservable: Observable<Scene>;
  124662. /**
  124663. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  124664. */
  124665. onDataLoadedObservable: Observable<Scene>;
  124666. /**
  124667. * An event triggered when a camera is created
  124668. */
  124669. onNewCameraAddedObservable: Observable<Camera>;
  124670. /**
  124671. * An event triggered when a camera is removed
  124672. */
  124673. onCameraRemovedObservable: Observable<Camera>;
  124674. /**
  124675. * An event triggered when a light is created
  124676. */
  124677. onNewLightAddedObservable: Observable<Light>;
  124678. /**
  124679. * An event triggered when a light is removed
  124680. */
  124681. onLightRemovedObservable: Observable<Light>;
  124682. /**
  124683. * An event triggered when a geometry is created
  124684. */
  124685. onNewGeometryAddedObservable: Observable<Geometry>;
  124686. /**
  124687. * An event triggered when a geometry is removed
  124688. */
  124689. onGeometryRemovedObservable: Observable<Geometry>;
  124690. /**
  124691. * An event triggered when a transform node is created
  124692. */
  124693. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  124694. /**
  124695. * An event triggered when a transform node is removed
  124696. */
  124697. onTransformNodeRemovedObservable: Observable<TransformNode>;
  124698. /**
  124699. * An event triggered when a mesh is created
  124700. */
  124701. onNewMeshAddedObservable: Observable<AbstractMesh>;
  124702. /**
  124703. * An event triggered when a mesh is removed
  124704. */
  124705. onMeshRemovedObservable: Observable<AbstractMesh>;
  124706. /**
  124707. * An event triggered when a skeleton is created
  124708. */
  124709. onNewSkeletonAddedObservable: Observable<Skeleton>;
  124710. /**
  124711. * An event triggered when a skeleton is removed
  124712. */
  124713. onSkeletonRemovedObservable: Observable<Skeleton>;
  124714. /**
  124715. * An event triggered when a material is created
  124716. */
  124717. onNewMaterialAddedObservable: Observable<Material>;
  124718. /**
  124719. * An event triggered when a multi material is created
  124720. */
  124721. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  124722. /**
  124723. * An event triggered when a material is removed
  124724. */
  124725. onMaterialRemovedObservable: Observable<Material>;
  124726. /**
  124727. * An event triggered when a multi material is removed
  124728. */
  124729. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  124730. /**
  124731. * An event triggered when a texture is created
  124732. */
  124733. onNewTextureAddedObservable: Observable<BaseTexture>;
  124734. /**
  124735. * An event triggered when a texture is removed
  124736. */
  124737. onTextureRemovedObservable: Observable<BaseTexture>;
  124738. /**
  124739. * An event triggered when render targets are about to be rendered
  124740. * Can happen multiple times per frame.
  124741. */
  124742. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  124743. /**
  124744. * An event triggered when render targets were rendered.
  124745. * Can happen multiple times per frame.
  124746. */
  124747. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  124748. /**
  124749. * An event triggered before calculating deterministic simulation step
  124750. */
  124751. onBeforeStepObservable: Observable<Scene>;
  124752. /**
  124753. * An event triggered after calculating deterministic simulation step
  124754. */
  124755. onAfterStepObservable: Observable<Scene>;
  124756. /**
  124757. * An event triggered when the activeCamera property is updated
  124758. */
  124759. onActiveCameraChanged: Observable<Scene>;
  124760. /**
  124761. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  124762. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124763. * 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)
  124764. */
  124765. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124766. /**
  124767. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  124768. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124769. * 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)
  124770. */
  124771. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124772. /**
  124773. * This Observable will when a mesh has been imported into the scene.
  124774. */
  124775. onMeshImportedObservable: Observable<AbstractMesh>;
  124776. /**
  124777. * This Observable will when an animation file has been imported into the scene.
  124778. */
  124779. onAnimationFileImportedObservable: Observable<Scene>;
  124780. /**
  124781. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  124782. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  124783. */
  124784. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  124785. /** @hidden */
  124786. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  124787. /**
  124788. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  124789. */
  124790. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  124791. /**
  124792. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  124793. */
  124794. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  124795. /**
  124796. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  124797. */
  124798. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  124799. /** Callback called when a pointer move is detected */
  124800. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124801. /** Callback called when a pointer down is detected */
  124802. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124803. /** Callback called when a pointer up is detected */
  124804. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  124805. /** Callback called when a pointer pick is detected */
  124806. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  124807. /**
  124808. * 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).
  124809. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  124810. */
  124811. onPrePointerObservable: Observable<PointerInfoPre>;
  124812. /**
  124813. * Observable event triggered each time an input event is received from the rendering canvas
  124814. */
  124815. onPointerObservable: Observable<PointerInfo>;
  124816. /**
  124817. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  124818. */
  124819. get unTranslatedPointer(): Vector2;
  124820. /**
  124821. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  124822. */
  124823. static get DragMovementThreshold(): number;
  124824. static set DragMovementThreshold(value: number);
  124825. /**
  124826. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  124827. */
  124828. static get LongPressDelay(): number;
  124829. static set LongPressDelay(value: number);
  124830. /**
  124831. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  124832. */
  124833. static get DoubleClickDelay(): number;
  124834. static set DoubleClickDelay(value: number);
  124835. /** If you need to check double click without raising a single click at first click, enable this flag */
  124836. static get ExclusiveDoubleClickMode(): boolean;
  124837. static set ExclusiveDoubleClickMode(value: boolean);
  124838. /** @hidden */
  124839. _mirroredCameraPosition: Nullable<Vector3>;
  124840. /**
  124841. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  124842. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  124843. */
  124844. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  124845. /**
  124846. * Observable event triggered each time an keyboard event is received from the hosting window
  124847. */
  124848. onKeyboardObservable: Observable<KeyboardInfo>;
  124849. private _useRightHandedSystem;
  124850. /**
  124851. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  124852. */
  124853. set useRightHandedSystem(value: boolean);
  124854. get useRightHandedSystem(): boolean;
  124855. private _timeAccumulator;
  124856. private _currentStepId;
  124857. private _currentInternalStep;
  124858. /**
  124859. * Sets the step Id used by deterministic lock step
  124860. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124861. * @param newStepId defines the step Id
  124862. */
  124863. setStepId(newStepId: number): void;
  124864. /**
  124865. * Gets the step Id used by deterministic lock step
  124866. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124867. * @returns the step Id
  124868. */
  124869. getStepId(): number;
  124870. /**
  124871. * Gets the internal step used by deterministic lock step
  124872. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124873. * @returns the internal step
  124874. */
  124875. getInternalStep(): number;
  124876. private _fogEnabled;
  124877. /**
  124878. * Gets or sets a boolean indicating if fog is enabled on this scene
  124879. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124880. * (Default is true)
  124881. */
  124882. set fogEnabled(value: boolean);
  124883. get fogEnabled(): boolean;
  124884. private _fogMode;
  124885. /**
  124886. * Gets or sets the fog mode to use
  124887. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124888. * | mode | value |
  124889. * | --- | --- |
  124890. * | FOGMODE_NONE | 0 |
  124891. * | FOGMODE_EXP | 1 |
  124892. * | FOGMODE_EXP2 | 2 |
  124893. * | FOGMODE_LINEAR | 3 |
  124894. */
  124895. set fogMode(value: number);
  124896. get fogMode(): number;
  124897. /**
  124898. * Gets or sets the fog color to use
  124899. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124900. * (Default is Color3(0.2, 0.2, 0.3))
  124901. */
  124902. fogColor: Color3;
  124903. /**
  124904. * Gets or sets the fog density to use
  124905. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124906. * (Default is 0.1)
  124907. */
  124908. fogDensity: number;
  124909. /**
  124910. * Gets or sets the fog start distance to use
  124911. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124912. * (Default is 0)
  124913. */
  124914. fogStart: number;
  124915. /**
  124916. * Gets or sets the fog end distance to use
  124917. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124918. * (Default is 1000)
  124919. */
  124920. fogEnd: number;
  124921. /**
  124922. * Flag indicating that the frame buffer binding is handled by another component
  124923. */
  124924. prePass: boolean;
  124925. private _shadowsEnabled;
  124926. /**
  124927. * Gets or sets a boolean indicating if shadows are enabled on this scene
  124928. */
  124929. set shadowsEnabled(value: boolean);
  124930. get shadowsEnabled(): boolean;
  124931. private _lightsEnabled;
  124932. /**
  124933. * Gets or sets a boolean indicating if lights are enabled on this scene
  124934. */
  124935. set lightsEnabled(value: boolean);
  124936. get lightsEnabled(): boolean;
  124937. /** All of the active cameras added to this scene. */
  124938. activeCameras: Camera[];
  124939. /** @hidden */
  124940. _activeCamera: Nullable<Camera>;
  124941. /** Gets or sets the current active camera */
  124942. get activeCamera(): Nullable<Camera>;
  124943. set activeCamera(value: Nullable<Camera>);
  124944. private _defaultMaterial;
  124945. /** The default material used on meshes when no material is affected */
  124946. get defaultMaterial(): Material;
  124947. /** The default material used on meshes when no material is affected */
  124948. set defaultMaterial(value: Material);
  124949. private _texturesEnabled;
  124950. /**
  124951. * Gets or sets a boolean indicating if textures are enabled on this scene
  124952. */
  124953. set texturesEnabled(value: boolean);
  124954. get texturesEnabled(): boolean;
  124955. /**
  124956. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  124957. */
  124958. physicsEnabled: boolean;
  124959. /**
  124960. * Gets or sets a boolean indicating if particles are enabled on this scene
  124961. */
  124962. particlesEnabled: boolean;
  124963. /**
  124964. * Gets or sets a boolean indicating if sprites are enabled on this scene
  124965. */
  124966. spritesEnabled: boolean;
  124967. private _skeletonsEnabled;
  124968. /**
  124969. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  124970. */
  124971. set skeletonsEnabled(value: boolean);
  124972. get skeletonsEnabled(): boolean;
  124973. /**
  124974. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  124975. */
  124976. lensFlaresEnabled: boolean;
  124977. /**
  124978. * Gets or sets a boolean indicating if collisions are enabled on this scene
  124979. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  124980. */
  124981. collisionsEnabled: boolean;
  124982. private _collisionCoordinator;
  124983. /** @hidden */
  124984. get collisionCoordinator(): ICollisionCoordinator;
  124985. /**
  124986. * Defines the gravity applied to this scene (used only for collisions)
  124987. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  124988. */
  124989. gravity: Vector3;
  124990. /**
  124991. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  124992. */
  124993. postProcessesEnabled: boolean;
  124994. /**
  124995. * Gets the current postprocess manager
  124996. */
  124997. postProcessManager: PostProcessManager;
  124998. /**
  124999. * Gets or sets a boolean indicating if render targets are enabled on this scene
  125000. */
  125001. renderTargetsEnabled: boolean;
  125002. /**
  125003. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  125004. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  125005. */
  125006. dumpNextRenderTargets: boolean;
  125007. /**
  125008. * The list of user defined render targets added to the scene
  125009. */
  125010. customRenderTargets: RenderTargetTexture[];
  125011. /**
  125012. * Defines if texture loading must be delayed
  125013. * If true, textures will only be loaded when they need to be rendered
  125014. */
  125015. useDelayedTextureLoading: boolean;
  125016. /**
  125017. * Gets the list of meshes imported to the scene through SceneLoader
  125018. */
  125019. importedMeshesFiles: String[];
  125020. /**
  125021. * Gets or sets a boolean indicating if probes are enabled on this scene
  125022. */
  125023. probesEnabled: boolean;
  125024. /**
  125025. * Gets or sets the current offline provider to use to store scene data
  125026. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  125027. */
  125028. offlineProvider: IOfflineProvider;
  125029. /**
  125030. * Gets or sets the action manager associated with the scene
  125031. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  125032. */
  125033. actionManager: AbstractActionManager;
  125034. private _meshesForIntersections;
  125035. /**
  125036. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  125037. */
  125038. proceduralTexturesEnabled: boolean;
  125039. private _engine;
  125040. private _totalVertices;
  125041. /** @hidden */
  125042. _activeIndices: PerfCounter;
  125043. /** @hidden */
  125044. _activeParticles: PerfCounter;
  125045. /** @hidden */
  125046. _activeBones: PerfCounter;
  125047. private _animationRatio;
  125048. /** @hidden */
  125049. _animationTimeLast: number;
  125050. /** @hidden */
  125051. _animationTime: number;
  125052. /**
  125053. * Gets or sets a general scale for animation speed
  125054. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  125055. */
  125056. animationTimeScale: number;
  125057. /** @hidden */
  125058. _cachedMaterial: Nullable<Material>;
  125059. /** @hidden */
  125060. _cachedEffect: Nullable<Effect>;
  125061. /** @hidden */
  125062. _cachedVisibility: Nullable<number>;
  125063. private _renderId;
  125064. private _frameId;
  125065. private _executeWhenReadyTimeoutId;
  125066. private _intermediateRendering;
  125067. private _viewUpdateFlag;
  125068. private _projectionUpdateFlag;
  125069. /** @hidden */
  125070. _toBeDisposed: Nullable<IDisposable>[];
  125071. private _activeRequests;
  125072. /** @hidden */
  125073. _pendingData: any[];
  125074. private _isDisposed;
  125075. /**
  125076. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  125077. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  125078. */
  125079. dispatchAllSubMeshesOfActiveMeshes: boolean;
  125080. private _activeMeshes;
  125081. private _processedMaterials;
  125082. private _renderTargets;
  125083. /** @hidden */
  125084. _activeParticleSystems: SmartArray<IParticleSystem>;
  125085. private _activeSkeletons;
  125086. private _softwareSkinnedMeshes;
  125087. private _renderingManager;
  125088. /** @hidden */
  125089. _activeAnimatables: Animatable[];
  125090. private _transformMatrix;
  125091. private _sceneUbo;
  125092. /** @hidden */
  125093. _viewMatrix: Matrix;
  125094. private _projectionMatrix;
  125095. /** @hidden */
  125096. _forcedViewPosition: Nullable<Vector3>;
  125097. /** @hidden */
  125098. _frustumPlanes: Plane[];
  125099. /**
  125100. * Gets the list of frustum planes (built from the active camera)
  125101. */
  125102. get frustumPlanes(): Plane[];
  125103. /**
  125104. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  125105. * This is useful if there are more lights that the maximum simulteanous authorized
  125106. */
  125107. requireLightSorting: boolean;
  125108. /** @hidden */
  125109. readonly useMaterialMeshMap: boolean;
  125110. /** @hidden */
  125111. readonly useClonedMeshMap: boolean;
  125112. private _externalData;
  125113. private _uid;
  125114. /**
  125115. * @hidden
  125116. * Backing store of defined scene components.
  125117. */
  125118. _components: ISceneComponent[];
  125119. /**
  125120. * @hidden
  125121. * Backing store of defined scene components.
  125122. */
  125123. _serializableComponents: ISceneSerializableComponent[];
  125124. /**
  125125. * List of components to register on the next registration step.
  125126. */
  125127. private _transientComponents;
  125128. /**
  125129. * Registers the transient components if needed.
  125130. */
  125131. private _registerTransientComponents;
  125132. /**
  125133. * @hidden
  125134. * Add a component to the scene.
  125135. * Note that the ccomponent could be registered on th next frame if this is called after
  125136. * the register component stage.
  125137. * @param component Defines the component to add to the scene
  125138. */
  125139. _addComponent(component: ISceneComponent): void;
  125140. /**
  125141. * @hidden
  125142. * Gets a component from the scene.
  125143. * @param name defines the name of the component to retrieve
  125144. * @returns the component or null if not present
  125145. */
  125146. _getComponent(name: string): Nullable<ISceneComponent>;
  125147. /**
  125148. * @hidden
  125149. * Defines the actions happening before camera updates.
  125150. */
  125151. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  125152. /**
  125153. * @hidden
  125154. * Defines the actions happening before clear the canvas.
  125155. */
  125156. _beforeClearStage: Stage<SimpleStageAction>;
  125157. /**
  125158. * @hidden
  125159. * Defines the actions when collecting render targets for the frame.
  125160. */
  125161. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  125162. /**
  125163. * @hidden
  125164. * Defines the actions happening for one camera in the frame.
  125165. */
  125166. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  125167. /**
  125168. * @hidden
  125169. * Defines the actions happening during the per mesh ready checks.
  125170. */
  125171. _isReadyForMeshStage: Stage<MeshStageAction>;
  125172. /**
  125173. * @hidden
  125174. * Defines the actions happening before evaluate active mesh checks.
  125175. */
  125176. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  125177. /**
  125178. * @hidden
  125179. * Defines the actions happening during the evaluate sub mesh checks.
  125180. */
  125181. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  125182. /**
  125183. * @hidden
  125184. * Defines the actions happening during the active mesh stage.
  125185. */
  125186. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  125187. /**
  125188. * @hidden
  125189. * Defines the actions happening during the per camera render target step.
  125190. */
  125191. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  125192. /**
  125193. * @hidden
  125194. * Defines the actions happening just before the active camera is drawing.
  125195. */
  125196. _beforeCameraDrawStage: Stage<CameraStageAction>;
  125197. /**
  125198. * @hidden
  125199. * Defines the actions happening just before a render target is drawing.
  125200. */
  125201. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  125202. /**
  125203. * @hidden
  125204. * Defines the actions happening just before a rendering group is drawing.
  125205. */
  125206. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  125207. /**
  125208. * @hidden
  125209. * Defines the actions happening just before a mesh is drawing.
  125210. */
  125211. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  125212. /**
  125213. * @hidden
  125214. * Defines the actions happening just after a mesh has been drawn.
  125215. */
  125216. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  125217. /**
  125218. * @hidden
  125219. * Defines the actions happening just after a rendering group has been drawn.
  125220. */
  125221. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  125222. /**
  125223. * @hidden
  125224. * Defines the actions happening just after the active camera has been drawn.
  125225. */
  125226. _afterCameraDrawStage: Stage<CameraStageAction>;
  125227. /**
  125228. * @hidden
  125229. * Defines the actions happening just after a render target has been drawn.
  125230. */
  125231. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  125232. /**
  125233. * @hidden
  125234. * Defines the actions happening just after rendering all cameras and computing intersections.
  125235. */
  125236. _afterRenderStage: Stage<SimpleStageAction>;
  125237. /**
  125238. * @hidden
  125239. * Defines the actions happening when a pointer move event happens.
  125240. */
  125241. _pointerMoveStage: Stage<PointerMoveStageAction>;
  125242. /**
  125243. * @hidden
  125244. * Defines the actions happening when a pointer down event happens.
  125245. */
  125246. _pointerDownStage: Stage<PointerUpDownStageAction>;
  125247. /**
  125248. * @hidden
  125249. * Defines the actions happening when a pointer up event happens.
  125250. */
  125251. _pointerUpStage: Stage<PointerUpDownStageAction>;
  125252. /**
  125253. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  125254. */
  125255. private geometriesByUniqueId;
  125256. /**
  125257. * Creates a new Scene
  125258. * @param engine defines the engine to use to render this scene
  125259. * @param options defines the scene options
  125260. */
  125261. constructor(engine: Engine, options?: SceneOptions);
  125262. /**
  125263. * Gets a string identifying the name of the class
  125264. * @returns "Scene" string
  125265. */
  125266. getClassName(): string;
  125267. private _defaultMeshCandidates;
  125268. /**
  125269. * @hidden
  125270. */
  125271. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  125272. private _defaultSubMeshCandidates;
  125273. /**
  125274. * @hidden
  125275. */
  125276. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  125277. /**
  125278. * Sets the default candidate providers for the scene.
  125279. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  125280. * and getCollidingSubMeshCandidates to their default function
  125281. */
  125282. setDefaultCandidateProviders(): void;
  125283. /**
  125284. * Gets the mesh that is currently under the pointer
  125285. */
  125286. get meshUnderPointer(): Nullable<AbstractMesh>;
  125287. /**
  125288. * Gets or sets the current on-screen X position of the pointer
  125289. */
  125290. get pointerX(): number;
  125291. set pointerX(value: number);
  125292. /**
  125293. * Gets or sets the current on-screen Y position of the pointer
  125294. */
  125295. get pointerY(): number;
  125296. set pointerY(value: number);
  125297. /**
  125298. * Gets the cached material (ie. the latest rendered one)
  125299. * @returns the cached material
  125300. */
  125301. getCachedMaterial(): Nullable<Material>;
  125302. /**
  125303. * Gets the cached effect (ie. the latest rendered one)
  125304. * @returns the cached effect
  125305. */
  125306. getCachedEffect(): Nullable<Effect>;
  125307. /**
  125308. * Gets the cached visibility state (ie. the latest rendered one)
  125309. * @returns the cached visibility state
  125310. */
  125311. getCachedVisibility(): Nullable<number>;
  125312. /**
  125313. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  125314. * @param material defines the current material
  125315. * @param effect defines the current effect
  125316. * @param visibility defines the current visibility state
  125317. * @returns true if one parameter is not cached
  125318. */
  125319. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  125320. /**
  125321. * Gets the engine associated with the scene
  125322. * @returns an Engine
  125323. */
  125324. getEngine(): Engine;
  125325. /**
  125326. * Gets the total number of vertices rendered per frame
  125327. * @returns the total number of vertices rendered per frame
  125328. */
  125329. getTotalVertices(): number;
  125330. /**
  125331. * Gets the performance counter for total vertices
  125332. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125333. */
  125334. get totalVerticesPerfCounter(): PerfCounter;
  125335. /**
  125336. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  125337. * @returns the total number of active indices rendered per frame
  125338. */
  125339. getActiveIndices(): number;
  125340. /**
  125341. * Gets the performance counter for active indices
  125342. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125343. */
  125344. get totalActiveIndicesPerfCounter(): PerfCounter;
  125345. /**
  125346. * Gets the total number of active particles rendered per frame
  125347. * @returns the total number of active particles rendered per frame
  125348. */
  125349. getActiveParticles(): number;
  125350. /**
  125351. * Gets the performance counter for active particles
  125352. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125353. */
  125354. get activeParticlesPerfCounter(): PerfCounter;
  125355. /**
  125356. * Gets the total number of active bones rendered per frame
  125357. * @returns the total number of active bones rendered per frame
  125358. */
  125359. getActiveBones(): number;
  125360. /**
  125361. * Gets the performance counter for active bones
  125362. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125363. */
  125364. get activeBonesPerfCounter(): PerfCounter;
  125365. /**
  125366. * Gets the array of active meshes
  125367. * @returns an array of AbstractMesh
  125368. */
  125369. getActiveMeshes(): SmartArray<AbstractMesh>;
  125370. /**
  125371. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  125372. * @returns a number
  125373. */
  125374. getAnimationRatio(): number;
  125375. /**
  125376. * Gets an unique Id for the current render phase
  125377. * @returns a number
  125378. */
  125379. getRenderId(): number;
  125380. /**
  125381. * Gets an unique Id for the current frame
  125382. * @returns a number
  125383. */
  125384. getFrameId(): number;
  125385. /** Call this function if you want to manually increment the render Id*/
  125386. incrementRenderId(): void;
  125387. private _createUbo;
  125388. /**
  125389. * Use this method to simulate a pointer move on a mesh
  125390. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125391. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125392. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125393. * @returns the current scene
  125394. */
  125395. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  125396. /**
  125397. * Use this method to simulate a pointer down on a mesh
  125398. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125399. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125400. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125401. * @returns the current scene
  125402. */
  125403. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  125404. /**
  125405. * Use this method to simulate a pointer up on a mesh
  125406. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125407. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125408. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125409. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  125410. * @returns the current scene
  125411. */
  125412. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  125413. /**
  125414. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  125415. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  125416. * @returns true if the pointer was captured
  125417. */
  125418. isPointerCaptured(pointerId?: number): boolean;
  125419. /**
  125420. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  125421. * @param attachUp defines if you want to attach events to pointerup
  125422. * @param attachDown defines if you want to attach events to pointerdown
  125423. * @param attachMove defines if you want to attach events to pointermove
  125424. */
  125425. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  125426. /** Detaches all event handlers*/
  125427. detachControl(): void;
  125428. /**
  125429. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  125430. * Delay loaded resources are not taking in account
  125431. * @return true if all required resources are ready
  125432. */
  125433. isReady(): boolean;
  125434. /** Resets all cached information relative to material (including effect and visibility) */
  125435. resetCachedMaterial(): void;
  125436. /**
  125437. * Registers a function to be called before every frame render
  125438. * @param func defines the function to register
  125439. */
  125440. registerBeforeRender(func: () => void): void;
  125441. /**
  125442. * Unregisters a function called before every frame render
  125443. * @param func defines the function to unregister
  125444. */
  125445. unregisterBeforeRender(func: () => void): void;
  125446. /**
  125447. * Registers a function to be called after every frame render
  125448. * @param func defines the function to register
  125449. */
  125450. registerAfterRender(func: () => void): void;
  125451. /**
  125452. * Unregisters a function called after every frame render
  125453. * @param func defines the function to unregister
  125454. */
  125455. unregisterAfterRender(func: () => void): void;
  125456. private _executeOnceBeforeRender;
  125457. /**
  125458. * The provided function will run before render once and will be disposed afterwards.
  125459. * A timeout delay can be provided so that the function will be executed in N ms.
  125460. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  125461. * @param func The function to be executed.
  125462. * @param timeout optional delay in ms
  125463. */
  125464. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  125465. /** @hidden */
  125466. _addPendingData(data: any): void;
  125467. /** @hidden */
  125468. _removePendingData(data: any): void;
  125469. /**
  125470. * Returns the number of items waiting to be loaded
  125471. * @returns the number of items waiting to be loaded
  125472. */
  125473. getWaitingItemsCount(): number;
  125474. /**
  125475. * Returns a boolean indicating if the scene is still loading data
  125476. */
  125477. get isLoading(): boolean;
  125478. /**
  125479. * Registers a function to be executed when the scene is ready
  125480. * @param {Function} func - the function to be executed
  125481. */
  125482. executeWhenReady(func: () => void): void;
  125483. /**
  125484. * Returns a promise that resolves when the scene is ready
  125485. * @returns A promise that resolves when the scene is ready
  125486. */
  125487. whenReadyAsync(): Promise<void>;
  125488. /** @hidden */
  125489. _checkIsReady(): void;
  125490. /**
  125491. * Gets all animatable attached to the scene
  125492. */
  125493. get animatables(): Animatable[];
  125494. /**
  125495. * Resets the last animation time frame.
  125496. * Useful to override when animations start running when loading a scene for the first time.
  125497. */
  125498. resetLastAnimationTimeFrame(): void;
  125499. /**
  125500. * Gets the current view matrix
  125501. * @returns a Matrix
  125502. */
  125503. getViewMatrix(): Matrix;
  125504. /**
  125505. * Gets the current projection matrix
  125506. * @returns a Matrix
  125507. */
  125508. getProjectionMatrix(): Matrix;
  125509. /**
  125510. * Gets the current transform matrix
  125511. * @returns a Matrix made of View * Projection
  125512. */
  125513. getTransformMatrix(): Matrix;
  125514. /**
  125515. * Sets the current transform matrix
  125516. * @param viewL defines the View matrix to use
  125517. * @param projectionL defines the Projection matrix to use
  125518. * @param viewR defines the right View matrix to use (if provided)
  125519. * @param projectionR defines the right Projection matrix to use (if provided)
  125520. */
  125521. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  125522. /**
  125523. * Gets the uniform buffer used to store scene data
  125524. * @returns a UniformBuffer
  125525. */
  125526. getSceneUniformBuffer(): UniformBuffer;
  125527. /**
  125528. * Gets an unique (relatively to the current scene) Id
  125529. * @returns an unique number for the scene
  125530. */
  125531. getUniqueId(): number;
  125532. /**
  125533. * Add a mesh to the list of scene's meshes
  125534. * @param newMesh defines the mesh to add
  125535. * @param recursive if all child meshes should also be added to the scene
  125536. */
  125537. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  125538. /**
  125539. * Remove a mesh for the list of scene's meshes
  125540. * @param toRemove defines the mesh to remove
  125541. * @param recursive if all child meshes should also be removed from the scene
  125542. * @returns the index where the mesh was in the mesh list
  125543. */
  125544. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  125545. /**
  125546. * Add a transform node to the list of scene's transform nodes
  125547. * @param newTransformNode defines the transform node to add
  125548. */
  125549. addTransformNode(newTransformNode: TransformNode): void;
  125550. /**
  125551. * Remove a transform node for the list of scene's transform nodes
  125552. * @param toRemove defines the transform node to remove
  125553. * @returns the index where the transform node was in the transform node list
  125554. */
  125555. removeTransformNode(toRemove: TransformNode): number;
  125556. /**
  125557. * Remove a skeleton for the list of scene's skeletons
  125558. * @param toRemove defines the skeleton to remove
  125559. * @returns the index where the skeleton was in the skeleton list
  125560. */
  125561. removeSkeleton(toRemove: Skeleton): number;
  125562. /**
  125563. * Remove a morph target for the list of scene's morph targets
  125564. * @param toRemove defines the morph target to remove
  125565. * @returns the index where the morph target was in the morph target list
  125566. */
  125567. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  125568. /**
  125569. * Remove a light for the list of scene's lights
  125570. * @param toRemove defines the light to remove
  125571. * @returns the index where the light was in the light list
  125572. */
  125573. removeLight(toRemove: Light): number;
  125574. /**
  125575. * Remove a camera for the list of scene's cameras
  125576. * @param toRemove defines the camera to remove
  125577. * @returns the index where the camera was in the camera list
  125578. */
  125579. removeCamera(toRemove: Camera): number;
  125580. /**
  125581. * Remove a particle system for the list of scene's particle systems
  125582. * @param toRemove defines the particle system to remove
  125583. * @returns the index where the particle system was in the particle system list
  125584. */
  125585. removeParticleSystem(toRemove: IParticleSystem): number;
  125586. /**
  125587. * Remove a animation for the list of scene's animations
  125588. * @param toRemove defines the animation to remove
  125589. * @returns the index where the animation was in the animation list
  125590. */
  125591. removeAnimation(toRemove: Animation): number;
  125592. /**
  125593. * Will stop the animation of the given target
  125594. * @param target - the target
  125595. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  125596. * @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)
  125597. */
  125598. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  125599. /**
  125600. * Removes the given animation group from this scene.
  125601. * @param toRemove The animation group to remove
  125602. * @returns The index of the removed animation group
  125603. */
  125604. removeAnimationGroup(toRemove: AnimationGroup): number;
  125605. /**
  125606. * Removes the given multi-material from this scene.
  125607. * @param toRemove The multi-material to remove
  125608. * @returns The index of the removed multi-material
  125609. */
  125610. removeMultiMaterial(toRemove: MultiMaterial): number;
  125611. /**
  125612. * Removes the given material from this scene.
  125613. * @param toRemove The material to remove
  125614. * @returns The index of the removed material
  125615. */
  125616. removeMaterial(toRemove: Material): number;
  125617. /**
  125618. * Removes the given action manager from this scene.
  125619. * @param toRemove The action manager to remove
  125620. * @returns The index of the removed action manager
  125621. */
  125622. removeActionManager(toRemove: AbstractActionManager): number;
  125623. /**
  125624. * Removes the given texture from this scene.
  125625. * @param toRemove The texture to remove
  125626. * @returns The index of the removed texture
  125627. */
  125628. removeTexture(toRemove: BaseTexture): number;
  125629. /**
  125630. * Adds the given light to this scene
  125631. * @param newLight The light to add
  125632. */
  125633. addLight(newLight: Light): void;
  125634. /**
  125635. * Sorts the list list based on light priorities
  125636. */
  125637. sortLightsByPriority(): void;
  125638. /**
  125639. * Adds the given camera to this scene
  125640. * @param newCamera The camera to add
  125641. */
  125642. addCamera(newCamera: Camera): void;
  125643. /**
  125644. * Adds the given skeleton to this scene
  125645. * @param newSkeleton The skeleton to add
  125646. */
  125647. addSkeleton(newSkeleton: Skeleton): void;
  125648. /**
  125649. * Adds the given particle system to this scene
  125650. * @param newParticleSystem The particle system to add
  125651. */
  125652. addParticleSystem(newParticleSystem: IParticleSystem): void;
  125653. /**
  125654. * Adds the given animation to this scene
  125655. * @param newAnimation The animation to add
  125656. */
  125657. addAnimation(newAnimation: Animation): void;
  125658. /**
  125659. * Adds the given animation group to this scene.
  125660. * @param newAnimationGroup The animation group to add
  125661. */
  125662. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  125663. /**
  125664. * Adds the given multi-material to this scene
  125665. * @param newMultiMaterial The multi-material to add
  125666. */
  125667. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  125668. /**
  125669. * Adds the given material to this scene
  125670. * @param newMaterial The material to add
  125671. */
  125672. addMaterial(newMaterial: Material): void;
  125673. /**
  125674. * Adds the given morph target to this scene
  125675. * @param newMorphTargetManager The morph target to add
  125676. */
  125677. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  125678. /**
  125679. * Adds the given geometry to this scene
  125680. * @param newGeometry The geometry to add
  125681. */
  125682. addGeometry(newGeometry: Geometry): void;
  125683. /**
  125684. * Adds the given action manager to this scene
  125685. * @param newActionManager The action manager to add
  125686. */
  125687. addActionManager(newActionManager: AbstractActionManager): void;
  125688. /**
  125689. * Adds the given texture to this scene.
  125690. * @param newTexture The texture to add
  125691. */
  125692. addTexture(newTexture: BaseTexture): void;
  125693. /**
  125694. * Switch active camera
  125695. * @param newCamera defines the new active camera
  125696. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  125697. */
  125698. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  125699. /**
  125700. * sets the active camera of the scene using its ID
  125701. * @param id defines the camera's ID
  125702. * @return the new active camera or null if none found.
  125703. */
  125704. setActiveCameraByID(id: string): Nullable<Camera>;
  125705. /**
  125706. * sets the active camera of the scene using its name
  125707. * @param name defines the camera's name
  125708. * @returns the new active camera or null if none found.
  125709. */
  125710. setActiveCameraByName(name: string): Nullable<Camera>;
  125711. /**
  125712. * get an animation group using its name
  125713. * @param name defines the material's name
  125714. * @return the animation group or null if none found.
  125715. */
  125716. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  125717. /**
  125718. * Get a material using its unique id
  125719. * @param uniqueId defines the material's unique id
  125720. * @return the material or null if none found.
  125721. */
  125722. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  125723. /**
  125724. * get a material using its id
  125725. * @param id defines the material's ID
  125726. * @return the material or null if none found.
  125727. */
  125728. getMaterialByID(id: string): Nullable<Material>;
  125729. /**
  125730. * Gets a the last added material using a given id
  125731. * @param id defines the material's ID
  125732. * @return the last material with the given id or null if none found.
  125733. */
  125734. getLastMaterialByID(id: string): Nullable<Material>;
  125735. /**
  125736. * Gets a material using its name
  125737. * @param name defines the material's name
  125738. * @return the material or null if none found.
  125739. */
  125740. getMaterialByName(name: string): Nullable<Material>;
  125741. /**
  125742. * Get a texture using its unique id
  125743. * @param uniqueId defines the texture's unique id
  125744. * @return the texture or null if none found.
  125745. */
  125746. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  125747. /**
  125748. * Gets a camera using its id
  125749. * @param id defines the id to look for
  125750. * @returns the camera or null if not found
  125751. */
  125752. getCameraByID(id: string): Nullable<Camera>;
  125753. /**
  125754. * Gets a camera using its unique id
  125755. * @param uniqueId defines the unique id to look for
  125756. * @returns the camera or null if not found
  125757. */
  125758. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  125759. /**
  125760. * Gets a camera using its name
  125761. * @param name defines the camera's name
  125762. * @return the camera or null if none found.
  125763. */
  125764. getCameraByName(name: string): Nullable<Camera>;
  125765. /**
  125766. * Gets a bone using its id
  125767. * @param id defines the bone's id
  125768. * @return the bone or null if not found
  125769. */
  125770. getBoneByID(id: string): Nullable<Bone>;
  125771. /**
  125772. * Gets a bone using its id
  125773. * @param name defines the bone's name
  125774. * @return the bone or null if not found
  125775. */
  125776. getBoneByName(name: string): Nullable<Bone>;
  125777. /**
  125778. * Gets a light node using its name
  125779. * @param name defines the the light's name
  125780. * @return the light or null if none found.
  125781. */
  125782. getLightByName(name: string): Nullable<Light>;
  125783. /**
  125784. * Gets a light node using its id
  125785. * @param id defines the light's id
  125786. * @return the light or null if none found.
  125787. */
  125788. getLightByID(id: string): Nullable<Light>;
  125789. /**
  125790. * Gets a light node using its scene-generated unique ID
  125791. * @param uniqueId defines the light's unique id
  125792. * @return the light or null if none found.
  125793. */
  125794. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  125795. /**
  125796. * Gets a particle system by id
  125797. * @param id defines the particle system id
  125798. * @return the corresponding system or null if none found
  125799. */
  125800. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  125801. /**
  125802. * Gets a geometry using its ID
  125803. * @param id defines the geometry's id
  125804. * @return the geometry or null if none found.
  125805. */
  125806. getGeometryByID(id: string): Nullable<Geometry>;
  125807. private _getGeometryByUniqueID;
  125808. /**
  125809. * Add a new geometry to this scene
  125810. * @param geometry defines the geometry to be added to the scene.
  125811. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  125812. * @return a boolean defining if the geometry was added or not
  125813. */
  125814. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  125815. /**
  125816. * Removes an existing geometry
  125817. * @param geometry defines the geometry to be removed from the scene
  125818. * @return a boolean defining if the geometry was removed or not
  125819. */
  125820. removeGeometry(geometry: Geometry): boolean;
  125821. /**
  125822. * Gets the list of geometries attached to the scene
  125823. * @returns an array of Geometry
  125824. */
  125825. getGeometries(): Geometry[];
  125826. /**
  125827. * Gets the first added mesh found of a given ID
  125828. * @param id defines the id to search for
  125829. * @return the mesh found or null if not found at all
  125830. */
  125831. getMeshByID(id: string): Nullable<AbstractMesh>;
  125832. /**
  125833. * Gets a list of meshes using their id
  125834. * @param id defines the id to search for
  125835. * @returns a list of meshes
  125836. */
  125837. getMeshesByID(id: string): Array<AbstractMesh>;
  125838. /**
  125839. * Gets the first added transform node found of a given ID
  125840. * @param id defines the id to search for
  125841. * @return the found transform node or null if not found at all.
  125842. */
  125843. getTransformNodeByID(id: string): Nullable<TransformNode>;
  125844. /**
  125845. * Gets a transform node with its auto-generated unique id
  125846. * @param uniqueId efines the unique id to search for
  125847. * @return the found transform node or null if not found at all.
  125848. */
  125849. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  125850. /**
  125851. * Gets a list of transform nodes using their id
  125852. * @param id defines the id to search for
  125853. * @returns a list of transform nodes
  125854. */
  125855. getTransformNodesByID(id: string): Array<TransformNode>;
  125856. /**
  125857. * Gets a mesh with its auto-generated unique id
  125858. * @param uniqueId defines the unique id to search for
  125859. * @return the found mesh or null if not found at all.
  125860. */
  125861. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  125862. /**
  125863. * Gets a the last added mesh using a given id
  125864. * @param id defines the id to search for
  125865. * @return the found mesh or null if not found at all.
  125866. */
  125867. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  125868. /**
  125869. * Gets a the last added node (Mesh, Camera, Light) using a given id
  125870. * @param id defines the id to search for
  125871. * @return the found node or null if not found at all
  125872. */
  125873. getLastEntryByID(id: string): Nullable<Node>;
  125874. /**
  125875. * Gets a node (Mesh, Camera, Light) using a given id
  125876. * @param id defines the id to search for
  125877. * @return the found node or null if not found at all
  125878. */
  125879. getNodeByID(id: string): Nullable<Node>;
  125880. /**
  125881. * Gets a node (Mesh, Camera, Light) using a given name
  125882. * @param name defines the name to search for
  125883. * @return the found node or null if not found at all.
  125884. */
  125885. getNodeByName(name: string): Nullable<Node>;
  125886. /**
  125887. * Gets a mesh using a given name
  125888. * @param name defines the name to search for
  125889. * @return the found mesh or null if not found at all.
  125890. */
  125891. getMeshByName(name: string): Nullable<AbstractMesh>;
  125892. /**
  125893. * Gets a transform node using a given name
  125894. * @param name defines the name to search for
  125895. * @return the found transform node or null if not found at all.
  125896. */
  125897. getTransformNodeByName(name: string): Nullable<TransformNode>;
  125898. /**
  125899. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  125900. * @param id defines the id to search for
  125901. * @return the found skeleton or null if not found at all.
  125902. */
  125903. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  125904. /**
  125905. * Gets a skeleton using a given auto generated unique id
  125906. * @param uniqueId defines the unique id to search for
  125907. * @return the found skeleton or null if not found at all.
  125908. */
  125909. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  125910. /**
  125911. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  125912. * @param id defines the id to search for
  125913. * @return the found skeleton or null if not found at all.
  125914. */
  125915. getSkeletonById(id: string): Nullable<Skeleton>;
  125916. /**
  125917. * Gets a skeleton using a given name
  125918. * @param name defines the name to search for
  125919. * @return the found skeleton or null if not found at all.
  125920. */
  125921. getSkeletonByName(name: string): Nullable<Skeleton>;
  125922. /**
  125923. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  125924. * @param id defines the id to search for
  125925. * @return the found morph target manager or null if not found at all.
  125926. */
  125927. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  125928. /**
  125929. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  125930. * @param id defines the id to search for
  125931. * @return the found morph target or null if not found at all.
  125932. */
  125933. getMorphTargetById(id: string): Nullable<MorphTarget>;
  125934. /**
  125935. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  125936. * @param name defines the name to search for
  125937. * @return the found morph target or null if not found at all.
  125938. */
  125939. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  125940. /**
  125941. * Gets a post process using a given name (if many are found, this function will pick the first one)
  125942. * @param name defines the name to search for
  125943. * @return the found post process or null if not found at all.
  125944. */
  125945. getPostProcessByName(name: string): Nullable<PostProcess>;
  125946. /**
  125947. * Gets a boolean indicating if the given mesh is active
  125948. * @param mesh defines the mesh to look for
  125949. * @returns true if the mesh is in the active list
  125950. */
  125951. isActiveMesh(mesh: AbstractMesh): boolean;
  125952. /**
  125953. * Return a unique id as a string which can serve as an identifier for the scene
  125954. */
  125955. get uid(): string;
  125956. /**
  125957. * Add an externaly attached data from its key.
  125958. * This method call will fail and return false, if such key already exists.
  125959. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  125960. * @param key the unique key that identifies the data
  125961. * @param data the data object to associate to the key for this Engine instance
  125962. * @return true if no such key were already present and the data was added successfully, false otherwise
  125963. */
  125964. addExternalData<T>(key: string, data: T): boolean;
  125965. /**
  125966. * Get an externaly attached data from its key
  125967. * @param key the unique key that identifies the data
  125968. * @return the associated data, if present (can be null), or undefined if not present
  125969. */
  125970. getExternalData<T>(key: string): Nullable<T>;
  125971. /**
  125972. * Get an externaly attached data from its key, create it using a factory if it's not already present
  125973. * @param key the unique key that identifies the data
  125974. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  125975. * @return the associated data, can be null if the factory returned null.
  125976. */
  125977. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  125978. /**
  125979. * Remove an externaly attached data from the Engine instance
  125980. * @param key the unique key that identifies the data
  125981. * @return true if the data was successfully removed, false if it doesn't exist
  125982. */
  125983. removeExternalData(key: string): boolean;
  125984. private _evaluateSubMesh;
  125985. /**
  125986. * Clear the processed materials smart array preventing retention point in material dispose.
  125987. */
  125988. freeProcessedMaterials(): void;
  125989. private _preventFreeActiveMeshesAndRenderingGroups;
  125990. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  125991. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  125992. * when disposing several meshes in a row or a hierarchy of meshes.
  125993. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  125994. */
  125995. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  125996. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  125997. /**
  125998. * Clear the active meshes smart array preventing retention point in mesh dispose.
  125999. */
  126000. freeActiveMeshes(): void;
  126001. /**
  126002. * Clear the info related to rendering groups preventing retention points during dispose.
  126003. */
  126004. freeRenderingGroups(): void;
  126005. /** @hidden */
  126006. _isInIntermediateRendering(): boolean;
  126007. /**
  126008. * Lambda returning the list of potentially active meshes.
  126009. */
  126010. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  126011. /**
  126012. * Lambda returning the list of potentially active sub meshes.
  126013. */
  126014. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  126015. /**
  126016. * Lambda returning the list of potentially intersecting sub meshes.
  126017. */
  126018. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  126019. /**
  126020. * Lambda returning the list of potentially colliding sub meshes.
  126021. */
  126022. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  126023. /** @hidden */
  126024. _activeMeshesFrozen: boolean;
  126025. private _skipEvaluateActiveMeshesCompletely;
  126026. /**
  126027. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  126028. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  126029. * @param onSuccess optional success callback
  126030. * @param onError optional error callback
  126031. * @returns the current scene
  126032. */
  126033. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  126034. /**
  126035. * Use this function to restart evaluating active meshes on every frame
  126036. * @returns the current scene
  126037. */
  126038. unfreezeActiveMeshes(): Scene;
  126039. private _evaluateActiveMeshes;
  126040. private _activeMesh;
  126041. /**
  126042. * Update the transform matrix to update from the current active camera
  126043. * @param force defines a boolean used to force the update even if cache is up to date
  126044. */
  126045. updateTransformMatrix(force?: boolean): void;
  126046. private _bindFrameBuffer;
  126047. /** @hidden */
  126048. _allowPostProcessClearColor: boolean;
  126049. /** @hidden */
  126050. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  126051. private _processSubCameras;
  126052. private _checkIntersections;
  126053. /** @hidden */
  126054. _advancePhysicsEngineStep(step: number): void;
  126055. /**
  126056. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  126057. */
  126058. getDeterministicFrameTime: () => number;
  126059. /** @hidden */
  126060. _animate(): void;
  126061. /** Execute all animations (for a frame) */
  126062. animate(): void;
  126063. /**
  126064. * Render the scene
  126065. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  126066. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  126067. */
  126068. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  126069. /**
  126070. * Freeze all materials
  126071. * A frozen material will not be updatable but should be faster to render
  126072. */
  126073. freezeMaterials(): void;
  126074. /**
  126075. * Unfreeze all materials
  126076. * A frozen material will not be updatable but should be faster to render
  126077. */
  126078. unfreezeMaterials(): void;
  126079. /**
  126080. * Releases all held ressources
  126081. */
  126082. dispose(): void;
  126083. /**
  126084. * Gets if the scene is already disposed
  126085. */
  126086. get isDisposed(): boolean;
  126087. /**
  126088. * Call this function to reduce memory footprint of the scene.
  126089. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  126090. */
  126091. clearCachedVertexData(): void;
  126092. /**
  126093. * This function will remove the local cached buffer data from texture.
  126094. * It will save memory but will prevent the texture from being rebuilt
  126095. */
  126096. cleanCachedTextureBuffer(): void;
  126097. /**
  126098. * Get the world extend vectors with an optional filter
  126099. *
  126100. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  126101. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  126102. */
  126103. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  126104. min: Vector3;
  126105. max: Vector3;
  126106. };
  126107. /**
  126108. * Creates a ray that can be used to pick in the scene
  126109. * @param x defines the x coordinate of the origin (on-screen)
  126110. * @param y defines the y coordinate of the origin (on-screen)
  126111. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  126112. * @param camera defines the camera to use for the picking
  126113. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  126114. * @returns a Ray
  126115. */
  126116. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  126117. /**
  126118. * Creates a ray that can be used to pick in the scene
  126119. * @param x defines the x coordinate of the origin (on-screen)
  126120. * @param y defines the y coordinate of the origin (on-screen)
  126121. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  126122. * @param result defines the ray where to store the picking ray
  126123. * @param camera defines the camera to use for the picking
  126124. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  126125. * @returns the current scene
  126126. */
  126127. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  126128. /**
  126129. * Creates a ray that can be used to pick in the scene
  126130. * @param x defines the x coordinate of the origin (on-screen)
  126131. * @param y defines the y coordinate of the origin (on-screen)
  126132. * @param camera defines the camera to use for the picking
  126133. * @returns a Ray
  126134. */
  126135. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  126136. /**
  126137. * Creates a ray that can be used to pick in the scene
  126138. * @param x defines the x coordinate of the origin (on-screen)
  126139. * @param y defines the y coordinate of the origin (on-screen)
  126140. * @param result defines the ray where to store the picking ray
  126141. * @param camera defines the camera to use for the picking
  126142. * @returns the current scene
  126143. */
  126144. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  126145. /** Launch a ray to try to pick a mesh in the scene
  126146. * @param x position on screen
  126147. * @param y position on screen
  126148. * @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
  126149. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126150. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126151. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126152. * @returns a PickingInfo
  126153. */
  126154. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  126155. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  126156. * @param x position on screen
  126157. * @param y position on screen
  126158. * @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
  126159. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126160. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126161. * @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)
  126162. */
  126163. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  126164. /** Use the given ray to pick a mesh in the scene
  126165. * @param ray The ray to use to pick meshes
  126166. * @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
  126167. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126168. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126169. * @returns a PickingInfo
  126170. */
  126171. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  126172. /**
  126173. * Launch a ray to try to pick a mesh in the scene
  126174. * @param x X position on screen
  126175. * @param y Y position on screen
  126176. * @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
  126177. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126178. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126179. * @returns an array of PickingInfo
  126180. */
  126181. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  126182. /**
  126183. * Launch a ray to try to pick a mesh in the scene
  126184. * @param ray Ray to use
  126185. * @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
  126186. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126187. * @returns an array of PickingInfo
  126188. */
  126189. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  126190. /**
  126191. * Force the value of meshUnderPointer
  126192. * @param mesh defines the mesh to use
  126193. * @param pointerId optional pointer id when using more than one pointer
  126194. */
  126195. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  126196. /**
  126197. * Gets the mesh under the pointer
  126198. * @returns a Mesh or null if no mesh is under the pointer
  126199. */
  126200. getPointerOverMesh(): Nullable<AbstractMesh>;
  126201. /** @hidden */
  126202. _rebuildGeometries(): void;
  126203. /** @hidden */
  126204. _rebuildTextures(): void;
  126205. private _getByTags;
  126206. /**
  126207. * Get a list of meshes by tags
  126208. * @param tagsQuery defines the tags query to use
  126209. * @param forEach defines a predicate used to filter results
  126210. * @returns an array of Mesh
  126211. */
  126212. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  126213. /**
  126214. * Get a list of cameras by tags
  126215. * @param tagsQuery defines the tags query to use
  126216. * @param forEach defines a predicate used to filter results
  126217. * @returns an array of Camera
  126218. */
  126219. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  126220. /**
  126221. * Get a list of lights by tags
  126222. * @param tagsQuery defines the tags query to use
  126223. * @param forEach defines a predicate used to filter results
  126224. * @returns an array of Light
  126225. */
  126226. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  126227. /**
  126228. * Get a list of materials by tags
  126229. * @param tagsQuery defines the tags query to use
  126230. * @param forEach defines a predicate used to filter results
  126231. * @returns an array of Material
  126232. */
  126233. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  126234. /**
  126235. * Get a list of transform nodes by tags
  126236. * @param tagsQuery defines the tags query to use
  126237. * @param forEach defines a predicate used to filter results
  126238. * @returns an array of TransformNode
  126239. */
  126240. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  126241. /**
  126242. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  126243. * This allowed control for front to back rendering or reversly depending of the special needs.
  126244. *
  126245. * @param renderingGroupId The rendering group id corresponding to its index
  126246. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  126247. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  126248. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  126249. */
  126250. 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;
  126251. /**
  126252. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  126253. *
  126254. * @param renderingGroupId The rendering group id corresponding to its index
  126255. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  126256. * @param depth Automatically clears depth between groups if true and autoClear is true.
  126257. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  126258. */
  126259. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  126260. /**
  126261. * Gets the current auto clear configuration for one rendering group of the rendering
  126262. * manager.
  126263. * @param index the rendering group index to get the information for
  126264. * @returns The auto clear setup for the requested rendering group
  126265. */
  126266. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  126267. private _blockMaterialDirtyMechanism;
  126268. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  126269. get blockMaterialDirtyMechanism(): boolean;
  126270. set blockMaterialDirtyMechanism(value: boolean);
  126271. /**
  126272. * Will flag all materials as dirty to trigger new shader compilation
  126273. * @param flag defines the flag used to specify which material part must be marked as dirty
  126274. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  126275. */
  126276. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  126277. /** @hidden */
  126278. _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;
  126279. /** @hidden */
  126280. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  126281. /** @hidden */
  126282. _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;
  126283. /** @hidden */
  126284. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  126285. /** @hidden */
  126286. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  126287. /** @hidden */
  126288. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  126289. }
  126290. }
  126291. declare module BABYLON {
  126292. /**
  126293. * Set of assets to keep when moving a scene into an asset container.
  126294. */
  126295. export class KeepAssets extends AbstractScene {
  126296. }
  126297. /**
  126298. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  126299. */
  126300. export class InstantiatedEntries {
  126301. /**
  126302. * List of new root nodes (eg. nodes with no parent)
  126303. */
  126304. rootNodes: TransformNode[];
  126305. /**
  126306. * List of new skeletons
  126307. */
  126308. skeletons: Skeleton[];
  126309. /**
  126310. * List of new animation groups
  126311. */
  126312. animationGroups: AnimationGroup[];
  126313. }
  126314. /**
  126315. * Container with a set of assets that can be added or removed from a scene.
  126316. */
  126317. export class AssetContainer extends AbstractScene {
  126318. private _wasAddedToScene;
  126319. /**
  126320. * The scene the AssetContainer belongs to.
  126321. */
  126322. scene: Scene;
  126323. /**
  126324. * Instantiates an AssetContainer.
  126325. * @param scene The scene the AssetContainer belongs to.
  126326. */
  126327. constructor(scene: Scene);
  126328. /**
  126329. * Instantiate or clone all meshes and add the new ones to the scene.
  126330. * Skeletons and animation groups will all be cloned
  126331. * @param nameFunction defines an optional function used to get new names for clones
  126332. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  126333. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  126334. */
  126335. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  126336. /**
  126337. * Adds all the assets from the container to the scene.
  126338. */
  126339. addAllToScene(): void;
  126340. /**
  126341. * Removes all the assets in the container from the scene
  126342. */
  126343. removeAllFromScene(): void;
  126344. /**
  126345. * Disposes all the assets in the container
  126346. */
  126347. dispose(): void;
  126348. private _moveAssets;
  126349. /**
  126350. * Removes all the assets contained in the scene and adds them to the container.
  126351. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  126352. */
  126353. moveAllFromScene(keepAssets?: KeepAssets): void;
  126354. /**
  126355. * 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.
  126356. * @returns the root mesh
  126357. */
  126358. createRootMesh(): Mesh;
  126359. /**
  126360. * Merge animations (direct and animation groups) from this asset container into a scene
  126361. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126362. * @param animatables set of animatables to retarget to a node from the scene
  126363. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  126364. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  126365. */
  126366. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  126367. }
  126368. }
  126369. declare module BABYLON {
  126370. /**
  126371. * Defines how the parser contract is defined.
  126372. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  126373. */
  126374. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  126375. /**
  126376. * Defines how the individual parser contract is defined.
  126377. * These parser can parse an individual asset
  126378. */
  126379. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  126380. /**
  126381. * Base class of the scene acting as a container for the different elements composing a scene.
  126382. * This class is dynamically extended by the different components of the scene increasing
  126383. * flexibility and reducing coupling
  126384. */
  126385. export abstract class AbstractScene {
  126386. /**
  126387. * Stores the list of available parsers in the application.
  126388. */
  126389. private static _BabylonFileParsers;
  126390. /**
  126391. * Stores the list of available individual parsers in the application.
  126392. */
  126393. private static _IndividualBabylonFileParsers;
  126394. /**
  126395. * Adds a parser in the list of available ones
  126396. * @param name Defines the name of the parser
  126397. * @param parser Defines the parser to add
  126398. */
  126399. static AddParser(name: string, parser: BabylonFileParser): void;
  126400. /**
  126401. * Gets a general parser from the list of avaialble ones
  126402. * @param name Defines the name of the parser
  126403. * @returns the requested parser or null
  126404. */
  126405. static GetParser(name: string): Nullable<BabylonFileParser>;
  126406. /**
  126407. * Adds n individual parser in the list of available ones
  126408. * @param name Defines the name of the parser
  126409. * @param parser Defines the parser to add
  126410. */
  126411. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  126412. /**
  126413. * Gets an individual parser from the list of avaialble ones
  126414. * @param name Defines the name of the parser
  126415. * @returns the requested parser or null
  126416. */
  126417. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  126418. /**
  126419. * Parser json data and populate both a scene and its associated container object
  126420. * @param jsonData Defines the data to parse
  126421. * @param scene Defines the scene to parse the data for
  126422. * @param container Defines the container attached to the parsing sequence
  126423. * @param rootUrl Defines the root url of the data
  126424. */
  126425. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  126426. /**
  126427. * Gets the list of root nodes (ie. nodes with no parent)
  126428. */
  126429. rootNodes: Node[];
  126430. /** All of the cameras added to this scene
  126431. * @see https://doc.babylonjs.com/babylon101/cameras
  126432. */
  126433. cameras: Camera[];
  126434. /**
  126435. * All of the lights added to this scene
  126436. * @see https://doc.babylonjs.com/babylon101/lights
  126437. */
  126438. lights: Light[];
  126439. /**
  126440. * All of the (abstract) meshes added to this scene
  126441. */
  126442. meshes: AbstractMesh[];
  126443. /**
  126444. * The list of skeletons added to the scene
  126445. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  126446. */
  126447. skeletons: Skeleton[];
  126448. /**
  126449. * All of the particle systems added to this scene
  126450. * @see https://doc.babylonjs.com/babylon101/particles
  126451. */
  126452. particleSystems: IParticleSystem[];
  126453. /**
  126454. * Gets a list of Animations associated with the scene
  126455. */
  126456. animations: Animation[];
  126457. /**
  126458. * All of the animation groups added to this scene
  126459. * @see https://doc.babylonjs.com/how_to/group
  126460. */
  126461. animationGroups: AnimationGroup[];
  126462. /**
  126463. * All of the multi-materials added to this scene
  126464. * @see https://doc.babylonjs.com/how_to/multi_materials
  126465. */
  126466. multiMaterials: MultiMaterial[];
  126467. /**
  126468. * All of the materials added to this scene
  126469. * In the context of a Scene, it is not supposed to be modified manually.
  126470. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  126471. * Note also that the order of the Material within the array is not significant and might change.
  126472. * @see https://doc.babylonjs.com/babylon101/materials
  126473. */
  126474. materials: Material[];
  126475. /**
  126476. * The list of morph target managers added to the scene
  126477. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  126478. */
  126479. morphTargetManagers: MorphTargetManager[];
  126480. /**
  126481. * The list of geometries used in the scene.
  126482. */
  126483. geometries: Geometry[];
  126484. /**
  126485. * All of the tranform nodes added to this scene
  126486. * In the context of a Scene, it is not supposed to be modified manually.
  126487. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  126488. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  126489. * @see https://doc.babylonjs.com/how_to/transformnode
  126490. */
  126491. transformNodes: TransformNode[];
  126492. /**
  126493. * ActionManagers available on the scene.
  126494. */
  126495. actionManagers: AbstractActionManager[];
  126496. /**
  126497. * Textures to keep.
  126498. */
  126499. textures: BaseTexture[];
  126500. /** @hidden */
  126501. protected _environmentTexture: Nullable<BaseTexture>;
  126502. /**
  126503. * Texture used in all pbr material as the reflection texture.
  126504. * As in the majority of the scene they are the same (exception for multi room and so on),
  126505. * this is easier to reference from here than from all the materials.
  126506. */
  126507. get environmentTexture(): Nullable<BaseTexture>;
  126508. set environmentTexture(value: Nullable<BaseTexture>);
  126509. /**
  126510. * The list of postprocesses added to the scene
  126511. */
  126512. postProcesses: PostProcess[];
  126513. /**
  126514. * @returns all meshes, lights, cameras, transformNodes and bones
  126515. */
  126516. getNodes(): Array<Node>;
  126517. }
  126518. }
  126519. declare module BABYLON {
  126520. /**
  126521. * Interface used to define options for Sound class
  126522. */
  126523. export interface ISoundOptions {
  126524. /**
  126525. * Does the sound autoplay once loaded.
  126526. */
  126527. autoplay?: boolean;
  126528. /**
  126529. * Does the sound loop after it finishes playing once.
  126530. */
  126531. loop?: boolean;
  126532. /**
  126533. * Sound's volume
  126534. */
  126535. volume?: number;
  126536. /**
  126537. * Is it a spatial sound?
  126538. */
  126539. spatialSound?: boolean;
  126540. /**
  126541. * Maximum distance to hear that sound
  126542. */
  126543. maxDistance?: number;
  126544. /**
  126545. * Uses user defined attenuation function
  126546. */
  126547. useCustomAttenuation?: boolean;
  126548. /**
  126549. * Define the roll off factor of spatial sounds.
  126550. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126551. */
  126552. rolloffFactor?: number;
  126553. /**
  126554. * Define the reference distance the sound should be heard perfectly.
  126555. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126556. */
  126557. refDistance?: number;
  126558. /**
  126559. * Define the distance attenuation model the sound will follow.
  126560. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126561. */
  126562. distanceModel?: string;
  126563. /**
  126564. * Defines the playback speed (1 by default)
  126565. */
  126566. playbackRate?: number;
  126567. /**
  126568. * Defines if the sound is from a streaming source
  126569. */
  126570. streaming?: boolean;
  126571. /**
  126572. * Defines an optional length (in seconds) inside the sound file
  126573. */
  126574. length?: number;
  126575. /**
  126576. * Defines an optional offset (in seconds) inside the sound file
  126577. */
  126578. offset?: number;
  126579. /**
  126580. * If true, URLs will not be required to state the audio file codec to use.
  126581. */
  126582. skipCodecCheck?: boolean;
  126583. }
  126584. }
  126585. declare module BABYLON {
  126586. /**
  126587. * Defines a sound that can be played in the application.
  126588. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  126589. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126590. */
  126591. export class Sound {
  126592. /**
  126593. * The name of the sound in the scene.
  126594. */
  126595. name: string;
  126596. /**
  126597. * Does the sound autoplay once loaded.
  126598. */
  126599. autoplay: boolean;
  126600. /**
  126601. * Does the sound loop after it finishes playing once.
  126602. */
  126603. loop: boolean;
  126604. /**
  126605. * Does the sound use a custom attenuation curve to simulate the falloff
  126606. * happening when the source gets further away from the camera.
  126607. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126608. */
  126609. useCustomAttenuation: boolean;
  126610. /**
  126611. * The sound track id this sound belongs to.
  126612. */
  126613. soundTrackId: number;
  126614. /**
  126615. * Is this sound currently played.
  126616. */
  126617. isPlaying: boolean;
  126618. /**
  126619. * Is this sound currently paused.
  126620. */
  126621. isPaused: boolean;
  126622. /**
  126623. * Does this sound enables spatial sound.
  126624. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126625. */
  126626. spatialSound: boolean;
  126627. /**
  126628. * Define the reference distance the sound should be heard perfectly.
  126629. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126630. */
  126631. refDistance: number;
  126632. /**
  126633. * Define the roll off factor of spatial sounds.
  126634. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126635. */
  126636. rolloffFactor: number;
  126637. /**
  126638. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  126639. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126640. */
  126641. maxDistance: number;
  126642. /**
  126643. * Define the distance attenuation model the sound will follow.
  126644. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126645. */
  126646. distanceModel: string;
  126647. /**
  126648. * @hidden
  126649. * Back Compat
  126650. **/
  126651. onended: () => any;
  126652. /**
  126653. * Gets or sets an object used to store user defined information for the sound.
  126654. */
  126655. metadata: any;
  126656. /**
  126657. * Observable event when the current playing sound finishes.
  126658. */
  126659. onEndedObservable: Observable<Sound>;
  126660. /**
  126661. * Gets the current time for the sound.
  126662. */
  126663. get currentTime(): number;
  126664. private _panningModel;
  126665. private _playbackRate;
  126666. private _streaming;
  126667. private _startTime;
  126668. private _startOffset;
  126669. private _position;
  126670. /** @hidden */
  126671. _positionInEmitterSpace: boolean;
  126672. private _localDirection;
  126673. private _volume;
  126674. private _isReadyToPlay;
  126675. private _isDirectional;
  126676. private _readyToPlayCallback;
  126677. private _audioBuffer;
  126678. private _soundSource;
  126679. private _streamingSource;
  126680. private _soundPanner;
  126681. private _soundGain;
  126682. private _inputAudioNode;
  126683. private _outputAudioNode;
  126684. private _coneInnerAngle;
  126685. private _coneOuterAngle;
  126686. private _coneOuterGain;
  126687. private _scene;
  126688. private _connectedTransformNode;
  126689. private _customAttenuationFunction;
  126690. private _registerFunc;
  126691. private _isOutputConnected;
  126692. private _htmlAudioElement;
  126693. private _urlType;
  126694. private _length?;
  126695. private _offset?;
  126696. /** @hidden */
  126697. static _SceneComponentInitialization: (scene: Scene) => void;
  126698. /**
  126699. * Create a sound and attach it to a scene
  126700. * @param name Name of your sound
  126701. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  126702. * @param scene defines the scene the sound belongs to
  126703. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  126704. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  126705. */
  126706. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  126707. /**
  126708. * Release the sound and its associated resources
  126709. */
  126710. dispose(): void;
  126711. /**
  126712. * Gets if the sounds is ready to be played or not.
  126713. * @returns true if ready, otherwise false
  126714. */
  126715. isReady(): boolean;
  126716. private _soundLoaded;
  126717. /**
  126718. * Sets the data of the sound from an audiobuffer
  126719. * @param audioBuffer The audioBuffer containing the data
  126720. */
  126721. setAudioBuffer(audioBuffer: AudioBuffer): void;
  126722. /**
  126723. * Updates the current sounds options such as maxdistance, loop...
  126724. * @param options A JSON object containing values named as the object properties
  126725. */
  126726. updateOptions(options: ISoundOptions): void;
  126727. private _createSpatialParameters;
  126728. private _updateSpatialParameters;
  126729. /**
  126730. * Switch the panning model to HRTF:
  126731. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  126732. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126733. */
  126734. switchPanningModelToHRTF(): void;
  126735. /**
  126736. * Switch the panning model to Equal Power:
  126737. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  126738. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126739. */
  126740. switchPanningModelToEqualPower(): void;
  126741. private _switchPanningModel;
  126742. /**
  126743. * Connect this sound to a sound track audio node like gain...
  126744. * @param soundTrackAudioNode the sound track audio node to connect to
  126745. */
  126746. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  126747. /**
  126748. * Transform this sound into a directional source
  126749. * @param coneInnerAngle Size of the inner cone in degree
  126750. * @param coneOuterAngle Size of the outer cone in degree
  126751. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  126752. */
  126753. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  126754. /**
  126755. * Gets or sets the inner angle for the directional cone.
  126756. */
  126757. get directionalConeInnerAngle(): number;
  126758. /**
  126759. * Gets or sets the inner angle for the directional cone.
  126760. */
  126761. set directionalConeInnerAngle(value: number);
  126762. /**
  126763. * Gets or sets the outer angle for the directional cone.
  126764. */
  126765. get directionalConeOuterAngle(): number;
  126766. /**
  126767. * Gets or sets the outer angle for the directional cone.
  126768. */
  126769. set directionalConeOuterAngle(value: number);
  126770. /**
  126771. * Sets the position of the emitter if spatial sound is enabled
  126772. * @param newPosition Defines the new posisiton
  126773. */
  126774. setPosition(newPosition: Vector3): void;
  126775. /**
  126776. * Sets the local direction of the emitter if spatial sound is enabled
  126777. * @param newLocalDirection Defines the new local direction
  126778. */
  126779. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  126780. private _updateDirection;
  126781. /** @hidden */
  126782. updateDistanceFromListener(): void;
  126783. /**
  126784. * Sets a new custom attenuation function for the sound.
  126785. * @param callback Defines the function used for the attenuation
  126786. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126787. */
  126788. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  126789. /**
  126790. * Play the sound
  126791. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  126792. * @param offset (optional) Start the sound at a specific time in seconds
  126793. * @param length (optional) Sound duration (in seconds)
  126794. */
  126795. play(time?: number, offset?: number, length?: number): void;
  126796. private _onended;
  126797. /**
  126798. * Stop the sound
  126799. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  126800. */
  126801. stop(time?: number): void;
  126802. /**
  126803. * Put the sound in pause
  126804. */
  126805. pause(): void;
  126806. /**
  126807. * Sets a dedicated volume for this sounds
  126808. * @param newVolume Define the new volume of the sound
  126809. * @param time Define time for gradual change to new volume
  126810. */
  126811. setVolume(newVolume: number, time?: number): void;
  126812. /**
  126813. * Set the sound play back rate
  126814. * @param newPlaybackRate Define the playback rate the sound should be played at
  126815. */
  126816. setPlaybackRate(newPlaybackRate: number): void;
  126817. /**
  126818. * Gets the volume of the sound.
  126819. * @returns the volume of the sound
  126820. */
  126821. getVolume(): number;
  126822. /**
  126823. * Attach the sound to a dedicated mesh
  126824. * @param transformNode The transform node to connect the sound with
  126825. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126826. */
  126827. attachToMesh(transformNode: TransformNode): void;
  126828. /**
  126829. * Detach the sound from the previously attached mesh
  126830. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126831. */
  126832. detachFromMesh(): void;
  126833. private _onRegisterAfterWorldMatrixUpdate;
  126834. /**
  126835. * Clone the current sound in the scene.
  126836. * @returns the new sound clone
  126837. */
  126838. clone(): Nullable<Sound>;
  126839. /**
  126840. * Gets the current underlying audio buffer containing the data
  126841. * @returns the audio buffer
  126842. */
  126843. getAudioBuffer(): Nullable<AudioBuffer>;
  126844. /**
  126845. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  126846. * @returns the source node
  126847. */
  126848. getSoundSource(): Nullable<AudioBufferSourceNode>;
  126849. /**
  126850. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  126851. * @returns the gain node
  126852. */
  126853. getSoundGain(): Nullable<GainNode>;
  126854. /**
  126855. * Serializes the Sound in a JSON representation
  126856. * @returns the JSON representation of the sound
  126857. */
  126858. serialize(): any;
  126859. /**
  126860. * Parse a JSON representation of a sound to innstantiate in a given scene
  126861. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  126862. * @param scene Define the scene the new parsed sound should be created in
  126863. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  126864. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  126865. * @returns the newly parsed sound
  126866. */
  126867. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  126868. }
  126869. }
  126870. declare module BABYLON {
  126871. /**
  126872. * This defines an action helpful to play a defined sound on a triggered action.
  126873. */
  126874. export class PlaySoundAction extends Action {
  126875. private _sound;
  126876. /**
  126877. * Instantiate the action
  126878. * @param triggerOptions defines the trigger options
  126879. * @param sound defines the sound to play
  126880. * @param condition defines the trigger related conditions
  126881. */
  126882. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  126883. /** @hidden */
  126884. _prepare(): void;
  126885. /**
  126886. * Execute the action and play the sound.
  126887. */
  126888. execute(): void;
  126889. /**
  126890. * Serializes the actions and its related information.
  126891. * @param parent defines the object to serialize in
  126892. * @returns the serialized object
  126893. */
  126894. serialize(parent: any): any;
  126895. }
  126896. /**
  126897. * This defines an action helpful to stop a defined sound on a triggered action.
  126898. */
  126899. export class StopSoundAction extends Action {
  126900. private _sound;
  126901. /**
  126902. * Instantiate the action
  126903. * @param triggerOptions defines the trigger options
  126904. * @param sound defines the sound to stop
  126905. * @param condition defines the trigger related conditions
  126906. */
  126907. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  126908. /** @hidden */
  126909. _prepare(): void;
  126910. /**
  126911. * Execute the action and stop the sound.
  126912. */
  126913. execute(): void;
  126914. /**
  126915. * Serializes the actions and its related information.
  126916. * @param parent defines the object to serialize in
  126917. * @returns the serialized object
  126918. */
  126919. serialize(parent: any): any;
  126920. }
  126921. }
  126922. declare module BABYLON {
  126923. /**
  126924. * This defines an action responsible to change the value of a property
  126925. * by interpolating between its current value and the newly set one once triggered.
  126926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  126927. */
  126928. export class InterpolateValueAction extends Action {
  126929. /**
  126930. * Defines the path of the property where the value should be interpolated
  126931. */
  126932. propertyPath: string;
  126933. /**
  126934. * Defines the target value at the end of the interpolation.
  126935. */
  126936. value: any;
  126937. /**
  126938. * Defines the time it will take for the property to interpolate to the value.
  126939. */
  126940. duration: number;
  126941. /**
  126942. * Defines if the other scene animations should be stopped when the action has been triggered
  126943. */
  126944. stopOtherAnimations?: boolean;
  126945. /**
  126946. * Defines a callback raised once the interpolation animation has been done.
  126947. */
  126948. onInterpolationDone?: () => void;
  126949. /**
  126950. * Observable triggered once the interpolation animation has been done.
  126951. */
  126952. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  126953. private _target;
  126954. private _effectiveTarget;
  126955. private _property;
  126956. /**
  126957. * Instantiate the action
  126958. * @param triggerOptions defines the trigger options
  126959. * @param target defines the object containing the value to interpolate
  126960. * @param propertyPath defines the path to the property in the target object
  126961. * @param value defines the target value at the end of the interpolation
  126962. * @param duration deines the time it will take for the property to interpolate to the value.
  126963. * @param condition defines the trigger related conditions
  126964. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  126965. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  126966. */
  126967. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  126968. /** @hidden */
  126969. _prepare(): void;
  126970. /**
  126971. * Execute the action starts the value interpolation.
  126972. */
  126973. execute(): void;
  126974. /**
  126975. * Serializes the actions and its related information.
  126976. * @param parent defines the object to serialize in
  126977. * @returns the serialized object
  126978. */
  126979. serialize(parent: any): any;
  126980. }
  126981. }
  126982. declare module BABYLON {
  126983. /**
  126984. * This represents the default audio engine used in babylon.
  126985. * It is responsible to play, synchronize and analyse sounds throughout the application.
  126986. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126987. */
  126988. export class AudioEngine implements IAudioEngine {
  126989. private _audioContext;
  126990. private _audioContextInitialized;
  126991. private _muteButton;
  126992. private _hostElement;
  126993. /**
  126994. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  126995. */
  126996. canUseWebAudio: boolean;
  126997. /**
  126998. * The master gain node defines the global audio volume of your audio engine.
  126999. */
  127000. masterGain: GainNode;
  127001. /**
  127002. * Defines if Babylon should emit a warning if WebAudio is not supported.
  127003. * @ignoreNaming
  127004. */
  127005. WarnedWebAudioUnsupported: boolean;
  127006. /**
  127007. * Gets whether or not mp3 are supported by your browser.
  127008. */
  127009. isMP3supported: boolean;
  127010. /**
  127011. * Gets whether or not ogg are supported by your browser.
  127012. */
  127013. isOGGsupported: boolean;
  127014. /**
  127015. * Gets whether audio has been unlocked on the device.
  127016. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  127017. * a user interaction has happened.
  127018. */
  127019. unlocked: boolean;
  127020. /**
  127021. * Defines if the audio engine relies on a custom unlocked button.
  127022. * In this case, the embedded button will not be displayed.
  127023. */
  127024. useCustomUnlockedButton: boolean;
  127025. /**
  127026. * Event raised when audio has been unlocked on the browser.
  127027. */
  127028. onAudioUnlockedObservable: Observable<IAudioEngine>;
  127029. /**
  127030. * Event raised when audio has been locked on the browser.
  127031. */
  127032. onAudioLockedObservable: Observable<IAudioEngine>;
  127033. /**
  127034. * Gets the current AudioContext if available.
  127035. */
  127036. get audioContext(): Nullable<AudioContext>;
  127037. private _connectedAnalyser;
  127038. /**
  127039. * Instantiates a new audio engine.
  127040. *
  127041. * There should be only one per page as some browsers restrict the number
  127042. * of audio contexts you can create.
  127043. * @param hostElement defines the host element where to display the mute icon if necessary
  127044. */
  127045. constructor(hostElement?: Nullable<HTMLElement>);
  127046. /**
  127047. * Flags the audio engine in Locked state.
  127048. * This happens due to new browser policies preventing audio to autoplay.
  127049. */
  127050. lock(): void;
  127051. /**
  127052. * Unlocks the audio engine once a user action has been done on the dom.
  127053. * This is helpful to resume play once browser policies have been satisfied.
  127054. */
  127055. unlock(): void;
  127056. private _resumeAudioContext;
  127057. private _initializeAudioContext;
  127058. private _tryToRun;
  127059. private _triggerRunningState;
  127060. private _triggerSuspendedState;
  127061. private _displayMuteButton;
  127062. private _moveButtonToTopLeft;
  127063. private _onResize;
  127064. private _hideMuteButton;
  127065. /**
  127066. * Destroy and release the resources associated with the audio ccontext.
  127067. */
  127068. dispose(): void;
  127069. /**
  127070. * Gets the global volume sets on the master gain.
  127071. * @returns the global volume if set or -1 otherwise
  127072. */
  127073. getGlobalVolume(): number;
  127074. /**
  127075. * Sets the global volume of your experience (sets on the master gain).
  127076. * @param newVolume Defines the new global volume of the application
  127077. */
  127078. setGlobalVolume(newVolume: number): void;
  127079. /**
  127080. * Connect the audio engine to an audio analyser allowing some amazing
  127081. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  127082. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  127083. * @param analyser The analyser to connect to the engine
  127084. */
  127085. connectToAnalyser(analyser: Analyser): void;
  127086. }
  127087. }
  127088. declare module BABYLON {
  127089. /**
  127090. * Options allowed during the creation of a sound track.
  127091. */
  127092. export interface ISoundTrackOptions {
  127093. /**
  127094. * The volume the sound track should take during creation
  127095. */
  127096. volume?: number;
  127097. /**
  127098. * Define if the sound track is the main sound track of the scene
  127099. */
  127100. mainTrack?: boolean;
  127101. }
  127102. /**
  127103. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  127104. * It will be also used in a future release to apply effects on a specific track.
  127105. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  127106. */
  127107. export class SoundTrack {
  127108. /**
  127109. * The unique identifier of the sound track in the scene.
  127110. */
  127111. id: number;
  127112. /**
  127113. * The list of sounds included in the sound track.
  127114. */
  127115. soundCollection: Array<Sound>;
  127116. private _outputAudioNode;
  127117. private _scene;
  127118. private _connectedAnalyser;
  127119. private _options;
  127120. private _isInitialized;
  127121. /**
  127122. * Creates a new sound track.
  127123. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  127124. * @param scene Define the scene the sound track belongs to
  127125. * @param options
  127126. */
  127127. constructor(scene: Scene, options?: ISoundTrackOptions);
  127128. private _initializeSoundTrackAudioGraph;
  127129. /**
  127130. * Release the sound track and its associated resources
  127131. */
  127132. dispose(): void;
  127133. /**
  127134. * Adds a sound to this sound track
  127135. * @param sound define the cound to add
  127136. * @ignoreNaming
  127137. */
  127138. addSound(sound: Sound): void;
  127139. /**
  127140. * Removes a sound to this sound track
  127141. * @param sound define the cound to remove
  127142. * @ignoreNaming
  127143. */
  127144. removeSound(sound: Sound): void;
  127145. /**
  127146. * Set a global volume for the full sound track.
  127147. * @param newVolume Define the new volume of the sound track
  127148. */
  127149. setVolume(newVolume: number): void;
  127150. /**
  127151. * Switch the panning model to HRTF:
  127152. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  127153. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  127154. */
  127155. switchPanningModelToHRTF(): void;
  127156. /**
  127157. * Switch the panning model to Equal Power:
  127158. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  127159. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  127160. */
  127161. switchPanningModelToEqualPower(): void;
  127162. /**
  127163. * Connect the sound track to an audio analyser allowing some amazing
  127164. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  127165. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  127166. * @param analyser The analyser to connect to the engine
  127167. */
  127168. connectToAnalyser(analyser: Analyser): void;
  127169. }
  127170. }
  127171. declare module BABYLON {
  127172. interface AbstractScene {
  127173. /**
  127174. * The list of sounds used in the scene.
  127175. */
  127176. sounds: Nullable<Array<Sound>>;
  127177. }
  127178. interface Scene {
  127179. /**
  127180. * @hidden
  127181. * Backing field
  127182. */
  127183. _mainSoundTrack: SoundTrack;
  127184. /**
  127185. * The main sound track played by the scene.
  127186. * It cotains your primary collection of sounds.
  127187. */
  127188. mainSoundTrack: SoundTrack;
  127189. /**
  127190. * The list of sound tracks added to the scene
  127191. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127192. */
  127193. soundTracks: Nullable<Array<SoundTrack>>;
  127194. /**
  127195. * Gets a sound using a given name
  127196. * @param name defines the name to search for
  127197. * @return the found sound or null if not found at all.
  127198. */
  127199. getSoundByName(name: string): Nullable<Sound>;
  127200. /**
  127201. * Gets or sets if audio support is enabled
  127202. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127203. */
  127204. audioEnabled: boolean;
  127205. /**
  127206. * Gets or sets if audio will be output to headphones
  127207. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127208. */
  127209. headphone: boolean;
  127210. /**
  127211. * Gets or sets custom audio listener position provider
  127212. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127213. */
  127214. audioListenerPositionProvider: Nullable<() => Vector3>;
  127215. /**
  127216. * Gets or sets a refresh rate when using 3D audio positioning
  127217. */
  127218. audioPositioningRefreshRate: number;
  127219. }
  127220. /**
  127221. * Defines the sound scene component responsible to manage any sounds
  127222. * in a given scene.
  127223. */
  127224. export class AudioSceneComponent implements ISceneSerializableComponent {
  127225. private static _CameraDirectionLH;
  127226. private static _CameraDirectionRH;
  127227. /**
  127228. * The component name helpfull to identify the component in the list of scene components.
  127229. */
  127230. readonly name: string;
  127231. /**
  127232. * The scene the component belongs to.
  127233. */
  127234. scene: Scene;
  127235. private _audioEnabled;
  127236. /**
  127237. * Gets whether audio is enabled or not.
  127238. * Please use related enable/disable method to switch state.
  127239. */
  127240. get audioEnabled(): boolean;
  127241. private _headphone;
  127242. /**
  127243. * Gets whether audio is outputing to headphone or not.
  127244. * Please use the according Switch methods to change output.
  127245. */
  127246. get headphone(): boolean;
  127247. /**
  127248. * Gets or sets a refresh rate when using 3D audio positioning
  127249. */
  127250. audioPositioningRefreshRate: number;
  127251. private _audioListenerPositionProvider;
  127252. /**
  127253. * Gets the current audio listener position provider
  127254. */
  127255. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  127256. /**
  127257. * Sets a custom listener position for all sounds in the scene
  127258. * By default, this is the position of the first active camera
  127259. */
  127260. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  127261. /**
  127262. * Creates a new instance of the component for the given scene
  127263. * @param scene Defines the scene to register the component in
  127264. */
  127265. constructor(scene: Scene);
  127266. /**
  127267. * Registers the component in a given scene
  127268. */
  127269. register(): void;
  127270. /**
  127271. * Rebuilds the elements related to this component in case of
  127272. * context lost for instance.
  127273. */
  127274. rebuild(): void;
  127275. /**
  127276. * Serializes the component data to the specified json object
  127277. * @param serializationObject The object to serialize to
  127278. */
  127279. serialize(serializationObject: any): void;
  127280. /**
  127281. * Adds all the elements from the container to the scene
  127282. * @param container the container holding the elements
  127283. */
  127284. addFromContainer(container: AbstractScene): void;
  127285. /**
  127286. * Removes all the elements in the container from the scene
  127287. * @param container contains the elements to remove
  127288. * @param dispose if the removed element should be disposed (default: false)
  127289. */
  127290. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127291. /**
  127292. * Disposes the component and the associated ressources.
  127293. */
  127294. dispose(): void;
  127295. /**
  127296. * Disables audio in the associated scene.
  127297. */
  127298. disableAudio(): void;
  127299. /**
  127300. * Enables audio in the associated scene.
  127301. */
  127302. enableAudio(): void;
  127303. /**
  127304. * Switch audio to headphone output.
  127305. */
  127306. switchAudioModeForHeadphones(): void;
  127307. /**
  127308. * Switch audio to normal speakers.
  127309. */
  127310. switchAudioModeForNormalSpeakers(): void;
  127311. private _cachedCameraDirection;
  127312. private _cachedCameraPosition;
  127313. private _lastCheck;
  127314. private _afterRender;
  127315. }
  127316. }
  127317. declare module BABYLON {
  127318. /**
  127319. * Wraps one or more Sound objects and selects one with random weight for playback.
  127320. */
  127321. export class WeightedSound {
  127322. /** When true a Sound will be selected and played when the current playing Sound completes. */
  127323. loop: boolean;
  127324. private _coneInnerAngle;
  127325. private _coneOuterAngle;
  127326. private _volume;
  127327. /** A Sound is currently playing. */
  127328. isPlaying: boolean;
  127329. /** A Sound is currently paused. */
  127330. isPaused: boolean;
  127331. private _sounds;
  127332. private _weights;
  127333. private _currentIndex?;
  127334. /**
  127335. * Creates a new WeightedSound from the list of sounds given.
  127336. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  127337. * @param sounds Array of Sounds that will be selected from.
  127338. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  127339. */
  127340. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  127341. /**
  127342. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  127343. */
  127344. get directionalConeInnerAngle(): number;
  127345. /**
  127346. * The size of cone in degress for a directional sound in which there will be no attenuation.
  127347. */
  127348. set directionalConeInnerAngle(value: number);
  127349. /**
  127350. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  127351. * Listener angles between innerAngle and outerAngle will falloff linearly.
  127352. */
  127353. get directionalConeOuterAngle(): number;
  127354. /**
  127355. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  127356. * Listener angles between innerAngle and outerAngle will falloff linearly.
  127357. */
  127358. set directionalConeOuterAngle(value: number);
  127359. /**
  127360. * Playback volume.
  127361. */
  127362. get volume(): number;
  127363. /**
  127364. * Playback volume.
  127365. */
  127366. set volume(value: number);
  127367. private _onended;
  127368. /**
  127369. * Suspend playback
  127370. */
  127371. pause(): void;
  127372. /**
  127373. * Stop playback
  127374. */
  127375. stop(): void;
  127376. /**
  127377. * Start playback.
  127378. * @param startOffset Position the clip head at a specific time in seconds.
  127379. */
  127380. play(startOffset?: number): void;
  127381. }
  127382. }
  127383. declare module BABYLON {
  127384. /**
  127385. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  127386. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  127387. */
  127388. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  127389. /**
  127390. * Gets the name of the behavior.
  127391. */
  127392. get name(): string;
  127393. /**
  127394. * The easing function used by animations
  127395. */
  127396. static EasingFunction: BackEase;
  127397. /**
  127398. * The easing mode used by animations
  127399. */
  127400. static EasingMode: number;
  127401. /**
  127402. * The duration of the animation, in milliseconds
  127403. */
  127404. transitionDuration: number;
  127405. /**
  127406. * Length of the distance animated by the transition when lower radius is reached
  127407. */
  127408. lowerRadiusTransitionRange: number;
  127409. /**
  127410. * Length of the distance animated by the transition when upper radius is reached
  127411. */
  127412. upperRadiusTransitionRange: number;
  127413. private _autoTransitionRange;
  127414. /**
  127415. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  127416. */
  127417. get autoTransitionRange(): boolean;
  127418. /**
  127419. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  127420. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  127421. */
  127422. set autoTransitionRange(value: boolean);
  127423. private _attachedCamera;
  127424. private _onAfterCheckInputsObserver;
  127425. private _onMeshTargetChangedObserver;
  127426. /**
  127427. * Initializes the behavior.
  127428. */
  127429. init(): void;
  127430. /**
  127431. * Attaches the behavior to its arc rotate camera.
  127432. * @param camera Defines the camera to attach the behavior to
  127433. */
  127434. attach(camera: ArcRotateCamera): void;
  127435. /**
  127436. * Detaches the behavior from its current arc rotate camera.
  127437. */
  127438. detach(): void;
  127439. private _radiusIsAnimating;
  127440. private _radiusBounceTransition;
  127441. private _animatables;
  127442. private _cachedWheelPrecision;
  127443. /**
  127444. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  127445. * @param radiusLimit The limit to check against.
  127446. * @return Bool to indicate if at limit.
  127447. */
  127448. private _isRadiusAtLimit;
  127449. /**
  127450. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  127451. * @param radiusDelta The delta by which to animate to. Can be negative.
  127452. */
  127453. private _applyBoundRadiusAnimation;
  127454. /**
  127455. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  127456. */
  127457. protected _clearAnimationLocks(): void;
  127458. /**
  127459. * Stops and removes all animations that have been applied to the camera
  127460. */
  127461. stopAllAnimations(): void;
  127462. }
  127463. }
  127464. declare module BABYLON {
  127465. /**
  127466. * 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.
  127467. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  127468. */
  127469. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  127470. /**
  127471. * Gets the name of the behavior.
  127472. */
  127473. get name(): string;
  127474. private _mode;
  127475. private _radiusScale;
  127476. private _positionScale;
  127477. private _defaultElevation;
  127478. private _elevationReturnTime;
  127479. private _elevationReturnWaitTime;
  127480. private _zoomStopsAnimation;
  127481. private _framingTime;
  127482. /**
  127483. * The easing function used by animations
  127484. */
  127485. static EasingFunction: ExponentialEase;
  127486. /**
  127487. * The easing mode used by animations
  127488. */
  127489. static EasingMode: number;
  127490. /**
  127491. * Sets the current mode used by the behavior
  127492. */
  127493. set mode(mode: number);
  127494. /**
  127495. * Gets current mode used by the behavior.
  127496. */
  127497. get mode(): number;
  127498. /**
  127499. * Sets the scale applied to the radius (1 by default)
  127500. */
  127501. set radiusScale(radius: number);
  127502. /**
  127503. * Gets the scale applied to the radius
  127504. */
  127505. get radiusScale(): number;
  127506. /**
  127507. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  127508. */
  127509. set positionScale(scale: number);
  127510. /**
  127511. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  127512. */
  127513. get positionScale(): number;
  127514. /**
  127515. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  127516. * behaviour is triggered, in radians.
  127517. */
  127518. set defaultElevation(elevation: number);
  127519. /**
  127520. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  127521. * behaviour is triggered, in radians.
  127522. */
  127523. get defaultElevation(): number;
  127524. /**
  127525. * Sets the time (in milliseconds) taken to return to the default beta position.
  127526. * Negative value indicates camera should not return to default.
  127527. */
  127528. set elevationReturnTime(speed: number);
  127529. /**
  127530. * Gets the time (in milliseconds) taken to return to the default beta position.
  127531. * Negative value indicates camera should not return to default.
  127532. */
  127533. get elevationReturnTime(): number;
  127534. /**
  127535. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  127536. */
  127537. set elevationReturnWaitTime(time: number);
  127538. /**
  127539. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  127540. */
  127541. get elevationReturnWaitTime(): number;
  127542. /**
  127543. * Sets the flag that indicates if user zooming should stop animation.
  127544. */
  127545. set zoomStopsAnimation(flag: boolean);
  127546. /**
  127547. * Gets the flag that indicates if user zooming should stop animation.
  127548. */
  127549. get zoomStopsAnimation(): boolean;
  127550. /**
  127551. * Sets the transition time when framing the mesh, in milliseconds
  127552. */
  127553. set framingTime(time: number);
  127554. /**
  127555. * Gets the transition time when framing the mesh, in milliseconds
  127556. */
  127557. get framingTime(): number;
  127558. /**
  127559. * Define if the behavior should automatically change the configured
  127560. * camera limits and sensibilities.
  127561. */
  127562. autoCorrectCameraLimitsAndSensibility: boolean;
  127563. private _onPrePointerObservableObserver;
  127564. private _onAfterCheckInputsObserver;
  127565. private _onMeshTargetChangedObserver;
  127566. private _attachedCamera;
  127567. private _isPointerDown;
  127568. private _lastInteractionTime;
  127569. /**
  127570. * Initializes the behavior.
  127571. */
  127572. init(): void;
  127573. /**
  127574. * Attaches the behavior to its arc rotate camera.
  127575. * @param camera Defines the camera to attach the behavior to
  127576. */
  127577. attach(camera: ArcRotateCamera): void;
  127578. /**
  127579. * Detaches the behavior from its current arc rotate camera.
  127580. */
  127581. detach(): void;
  127582. private _animatables;
  127583. private _betaIsAnimating;
  127584. private _betaTransition;
  127585. private _radiusTransition;
  127586. private _vectorTransition;
  127587. /**
  127588. * Targets the given mesh and updates zoom level accordingly.
  127589. * @param mesh The mesh to target.
  127590. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127591. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127592. */
  127593. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127594. /**
  127595. * Targets the given mesh with its children and updates zoom level accordingly.
  127596. * @param mesh The mesh to target.
  127597. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127598. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127599. */
  127600. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127601. /**
  127602. * Targets the given meshes with their children and updates zoom level accordingly.
  127603. * @param meshes The mesh to target.
  127604. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127605. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127606. */
  127607. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127608. /**
  127609. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  127610. * @param minimumWorld Determines the smaller position of the bounding box extend
  127611. * @param maximumWorld Determines the bigger position of the bounding box extend
  127612. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127613. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127614. */
  127615. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127616. /**
  127617. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  127618. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  127619. * frustum width.
  127620. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  127621. * to fully enclose the mesh in the viewing frustum.
  127622. */
  127623. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  127624. /**
  127625. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  127626. * is automatically returned to its default position (expected to be above ground plane).
  127627. */
  127628. private _maintainCameraAboveGround;
  127629. /**
  127630. * Returns the frustum slope based on the canvas ratio and camera FOV
  127631. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  127632. */
  127633. private _getFrustumSlope;
  127634. /**
  127635. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  127636. */
  127637. private _clearAnimationLocks;
  127638. /**
  127639. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127640. */
  127641. private _applyUserInteraction;
  127642. /**
  127643. * Stops and removes all animations that have been applied to the camera
  127644. */
  127645. stopAllAnimations(): void;
  127646. /**
  127647. * Gets a value indicating if the user is moving the camera
  127648. */
  127649. get isUserIsMoving(): boolean;
  127650. /**
  127651. * The camera can move all the way towards the mesh.
  127652. */
  127653. static IgnoreBoundsSizeMode: number;
  127654. /**
  127655. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  127656. */
  127657. static FitFrustumSidesMode: number;
  127658. }
  127659. }
  127660. declare module BABYLON {
  127661. /**
  127662. * Base class for Camera Pointer Inputs.
  127663. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  127664. * for example usage.
  127665. */
  127666. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  127667. /**
  127668. * Defines the camera the input is attached to.
  127669. */
  127670. abstract camera: Camera;
  127671. /**
  127672. * Whether keyboard modifier keys are pressed at time of last mouse event.
  127673. */
  127674. protected _altKey: boolean;
  127675. protected _ctrlKey: boolean;
  127676. protected _metaKey: boolean;
  127677. protected _shiftKey: boolean;
  127678. /**
  127679. * Which mouse buttons were pressed at time of last mouse event.
  127680. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  127681. */
  127682. protected _buttonsPressed: number;
  127683. /**
  127684. * Defines the buttons associated with the input to handle camera move.
  127685. */
  127686. buttons: number[];
  127687. /**
  127688. * Attach the input controls to a specific dom element to get the input from.
  127689. * @param element Defines the element the controls should be listened from
  127690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127691. */
  127692. attachControl(noPreventDefault?: boolean): void;
  127693. /**
  127694. * Detach the current controls from the specified dom element.
  127695. */
  127696. detachControl(): void;
  127697. /**
  127698. * Gets the class name of the current input.
  127699. * @returns the class name
  127700. */
  127701. getClassName(): string;
  127702. /**
  127703. * Get the friendly name associated with the input class.
  127704. * @returns the input friendly name
  127705. */
  127706. getSimpleName(): string;
  127707. /**
  127708. * Called on pointer POINTERDOUBLETAP event.
  127709. * Override this method to provide functionality on POINTERDOUBLETAP event.
  127710. */
  127711. protected onDoubleTap(type: string): void;
  127712. /**
  127713. * Called on pointer POINTERMOVE event if only a single touch is active.
  127714. * Override this method to provide functionality.
  127715. */
  127716. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127717. /**
  127718. * Called on pointer POINTERMOVE event if multiple touches are active.
  127719. * Override this method to provide functionality.
  127720. */
  127721. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127722. /**
  127723. * Called on JS contextmenu event.
  127724. * Override this method to provide functionality.
  127725. */
  127726. protected onContextMenu(evt: PointerEvent): void;
  127727. /**
  127728. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127729. * press.
  127730. * Override this method to provide functionality.
  127731. */
  127732. protected onButtonDown(evt: PointerEvent): void;
  127733. /**
  127734. * Called each time a new POINTERUP event occurs. Ie, for each button
  127735. * release.
  127736. * Override this method to provide functionality.
  127737. */
  127738. protected onButtonUp(evt: PointerEvent): void;
  127739. /**
  127740. * Called when window becomes inactive.
  127741. * Override this method to provide functionality.
  127742. */
  127743. protected onLostFocus(): void;
  127744. private _pointerInput;
  127745. private _observer;
  127746. private _onLostFocus;
  127747. private pointA;
  127748. private pointB;
  127749. }
  127750. }
  127751. declare module BABYLON {
  127752. /**
  127753. * Manage the pointers inputs to control an arc rotate camera.
  127754. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127755. */
  127756. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  127757. /**
  127758. * Defines the camera the input is attached to.
  127759. */
  127760. camera: ArcRotateCamera;
  127761. /**
  127762. * Gets the class name of the current input.
  127763. * @returns the class name
  127764. */
  127765. getClassName(): string;
  127766. /**
  127767. * Defines the buttons associated with the input to handle camera move.
  127768. */
  127769. buttons: number[];
  127770. /**
  127771. * Defines the pointer angular sensibility along the X axis or how fast is
  127772. * the camera rotating.
  127773. */
  127774. angularSensibilityX: number;
  127775. /**
  127776. * Defines the pointer angular sensibility along the Y axis or how fast is
  127777. * the camera rotating.
  127778. */
  127779. angularSensibilityY: number;
  127780. /**
  127781. * Defines the pointer pinch precision or how fast is the camera zooming.
  127782. */
  127783. pinchPrecision: number;
  127784. /**
  127785. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  127786. * from 0.
  127787. * It defines the percentage of current camera.radius to use as delta when
  127788. * pinch zoom is used.
  127789. */
  127790. pinchDeltaPercentage: number;
  127791. /**
  127792. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  127793. * that any object in the plane at the camera's target point will scale
  127794. * perfectly with finger motion.
  127795. * Overrides pinchDeltaPercentage and pinchPrecision.
  127796. */
  127797. useNaturalPinchZoom: boolean;
  127798. /**
  127799. * Defines the pointer panning sensibility or how fast is the camera moving.
  127800. */
  127801. panningSensibility: number;
  127802. /**
  127803. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  127804. */
  127805. multiTouchPanning: boolean;
  127806. /**
  127807. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  127808. * zoom (pinch) through multitouch.
  127809. */
  127810. multiTouchPanAndZoom: boolean;
  127811. /**
  127812. * Revers pinch action direction.
  127813. */
  127814. pinchInwards: boolean;
  127815. private _isPanClick;
  127816. private _twoFingerActivityCount;
  127817. private _isPinching;
  127818. /**
  127819. * Called on pointer POINTERMOVE event if only a single touch is active.
  127820. */
  127821. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127822. /**
  127823. * Called on pointer POINTERDOUBLETAP event.
  127824. */
  127825. protected onDoubleTap(type: string): void;
  127826. /**
  127827. * Called on pointer POINTERMOVE event if multiple touches are active.
  127828. */
  127829. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127830. /**
  127831. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127832. * press.
  127833. */
  127834. protected onButtonDown(evt: PointerEvent): void;
  127835. /**
  127836. * Called each time a new POINTERUP event occurs. Ie, for each button
  127837. * release.
  127838. */
  127839. protected onButtonUp(evt: PointerEvent): void;
  127840. /**
  127841. * Called when window becomes inactive.
  127842. */
  127843. protected onLostFocus(): void;
  127844. }
  127845. }
  127846. declare module BABYLON {
  127847. /**
  127848. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  127849. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127850. */
  127851. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  127852. /**
  127853. * Defines the camera the input is attached to.
  127854. */
  127855. camera: ArcRotateCamera;
  127856. /**
  127857. * Defines the list of key codes associated with the up action (increase alpha)
  127858. */
  127859. keysUp: number[];
  127860. /**
  127861. * Defines the list of key codes associated with the down action (decrease alpha)
  127862. */
  127863. keysDown: number[];
  127864. /**
  127865. * Defines the list of key codes associated with the left action (increase beta)
  127866. */
  127867. keysLeft: number[];
  127868. /**
  127869. * Defines the list of key codes associated with the right action (decrease beta)
  127870. */
  127871. keysRight: number[];
  127872. /**
  127873. * Defines the list of key codes associated with the reset action.
  127874. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  127875. */
  127876. keysReset: number[];
  127877. /**
  127878. * Defines the panning sensibility of the inputs.
  127879. * (How fast is the camera panning)
  127880. */
  127881. panningSensibility: number;
  127882. /**
  127883. * Defines the zooming sensibility of the inputs.
  127884. * (How fast is the camera zooming)
  127885. */
  127886. zoomingSensibility: number;
  127887. /**
  127888. * Defines whether maintaining the alt key down switch the movement mode from
  127889. * orientation to zoom.
  127890. */
  127891. useAltToZoom: boolean;
  127892. /**
  127893. * Rotation speed of the camera
  127894. */
  127895. angularSpeed: number;
  127896. private _keys;
  127897. private _ctrlPressed;
  127898. private _altPressed;
  127899. private _onCanvasBlurObserver;
  127900. private _onKeyboardObserver;
  127901. private _engine;
  127902. private _scene;
  127903. /**
  127904. * Attach the input controls to a specific dom element to get the input from.
  127905. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127906. */
  127907. attachControl(noPreventDefault?: boolean): void;
  127908. /**
  127909. * Detach the current controls from the specified dom element.
  127910. */
  127911. detachControl(): void;
  127912. /**
  127913. * Update the current camera state depending on the inputs that have been used this frame.
  127914. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127915. */
  127916. checkInputs(): void;
  127917. /**
  127918. * Gets the class name of the current intput.
  127919. * @returns the class name
  127920. */
  127921. getClassName(): string;
  127922. /**
  127923. * Get the friendly name associated with the input class.
  127924. * @returns the input friendly name
  127925. */
  127926. getSimpleName(): string;
  127927. }
  127928. }
  127929. declare module BABYLON {
  127930. /**
  127931. * Manage the mouse wheel inputs to control an arc rotate camera.
  127932. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127933. */
  127934. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  127935. /**
  127936. * Defines the camera the input is attached to.
  127937. */
  127938. camera: ArcRotateCamera;
  127939. /**
  127940. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  127941. */
  127942. wheelPrecision: number;
  127943. /**
  127944. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  127945. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  127946. */
  127947. wheelDeltaPercentage: number;
  127948. private _wheel;
  127949. private _observer;
  127950. private computeDeltaFromMouseWheelLegacyEvent;
  127951. /**
  127952. * Attach the input controls to a specific dom element to get the input from.
  127953. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127954. */
  127955. attachControl(noPreventDefault?: boolean): void;
  127956. /**
  127957. * Detach the current controls from the specified dom element.
  127958. */
  127959. detachControl(): void;
  127960. /**
  127961. * Gets the class name of the current intput.
  127962. * @returns the class name
  127963. */
  127964. getClassName(): string;
  127965. /**
  127966. * Get the friendly name associated with the input class.
  127967. * @returns the input friendly name
  127968. */
  127969. getSimpleName(): string;
  127970. }
  127971. }
  127972. declare module BABYLON {
  127973. /**
  127974. * Default Inputs manager for the ArcRotateCamera.
  127975. * It groups all the default supported inputs for ease of use.
  127976. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127977. */
  127978. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  127979. /**
  127980. * Instantiates a new ArcRotateCameraInputsManager.
  127981. * @param camera Defines the camera the inputs belong to
  127982. */
  127983. constructor(camera: ArcRotateCamera);
  127984. /**
  127985. * Add mouse wheel input support to the input manager.
  127986. * @returns the current input manager
  127987. */
  127988. addMouseWheel(): ArcRotateCameraInputsManager;
  127989. /**
  127990. * Add pointers input support to the input manager.
  127991. * @returns the current input manager
  127992. */
  127993. addPointers(): ArcRotateCameraInputsManager;
  127994. /**
  127995. * Add keyboard input support to the input manager.
  127996. * @returns the current input manager
  127997. */
  127998. addKeyboard(): ArcRotateCameraInputsManager;
  127999. }
  128000. }
  128001. declare module BABYLON {
  128002. /**
  128003. * This represents an orbital type of camera.
  128004. *
  128005. * 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.
  128006. * 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.
  128007. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  128008. */
  128009. export class ArcRotateCamera extends TargetCamera {
  128010. /**
  128011. * Defines the rotation angle of the camera along the longitudinal axis.
  128012. */
  128013. alpha: number;
  128014. /**
  128015. * Defines the rotation angle of the camera along the latitudinal axis.
  128016. */
  128017. beta: number;
  128018. /**
  128019. * Defines the radius of the camera from it s target point.
  128020. */
  128021. radius: number;
  128022. protected _target: Vector3;
  128023. protected _targetHost: Nullable<AbstractMesh>;
  128024. /**
  128025. * Defines the target point of the camera.
  128026. * The camera looks towards it form the radius distance.
  128027. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  128028. */
  128029. get target(): Vector3;
  128030. set target(value: Vector3);
  128031. /**
  128032. * Define the current local position of the camera in the scene
  128033. */
  128034. get position(): Vector3;
  128035. set position(newPosition: Vector3);
  128036. protected _upToYMatrix: Matrix;
  128037. protected _YToUpMatrix: Matrix;
  128038. /**
  128039. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  128040. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  128041. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  128042. */
  128043. set upVector(vec: Vector3);
  128044. get upVector(): Vector3;
  128045. /**
  128046. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  128047. */
  128048. setMatUp(): void;
  128049. /**
  128050. * Current inertia value on the longitudinal axis.
  128051. * The bigger this number the longer it will take for the camera to stop.
  128052. */
  128053. inertialAlphaOffset: number;
  128054. /**
  128055. * Current inertia value on the latitudinal axis.
  128056. * The bigger this number the longer it will take for the camera to stop.
  128057. */
  128058. inertialBetaOffset: number;
  128059. /**
  128060. * Current inertia value on the radius axis.
  128061. * The bigger this number the longer it will take for the camera to stop.
  128062. */
  128063. inertialRadiusOffset: number;
  128064. /**
  128065. * Minimum allowed angle on the longitudinal axis.
  128066. * This can help limiting how the Camera is able to move in the scene.
  128067. */
  128068. lowerAlphaLimit: Nullable<number>;
  128069. /**
  128070. * Maximum allowed angle on the longitudinal axis.
  128071. * This can help limiting how the Camera is able to move in the scene.
  128072. */
  128073. upperAlphaLimit: Nullable<number>;
  128074. /**
  128075. * Minimum allowed angle on the latitudinal axis.
  128076. * This can help limiting how the Camera is able to move in the scene.
  128077. */
  128078. lowerBetaLimit: number;
  128079. /**
  128080. * Maximum allowed angle on the latitudinal axis.
  128081. * This can help limiting how the Camera is able to move in the scene.
  128082. */
  128083. upperBetaLimit: number;
  128084. /**
  128085. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  128086. * This can help limiting how the Camera is able to move in the scene.
  128087. */
  128088. lowerRadiusLimit: Nullable<number>;
  128089. /**
  128090. * Maximum allowed distance of the camera to the target (The camera can not get further).
  128091. * This can help limiting how the Camera is able to move in the scene.
  128092. */
  128093. upperRadiusLimit: Nullable<number>;
  128094. /**
  128095. * Defines the current inertia value used during panning of the camera along the X axis.
  128096. */
  128097. inertialPanningX: number;
  128098. /**
  128099. * Defines the current inertia value used during panning of the camera along the Y axis.
  128100. */
  128101. inertialPanningY: number;
  128102. /**
  128103. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  128104. * Basically if your fingers moves away from more than this distance you will be considered
  128105. * in pinch mode.
  128106. */
  128107. pinchToPanMaxDistance: number;
  128108. /**
  128109. * Defines the maximum distance the camera can pan.
  128110. * This could help keeping the cammera always in your scene.
  128111. */
  128112. panningDistanceLimit: Nullable<number>;
  128113. /**
  128114. * Defines the target of the camera before paning.
  128115. */
  128116. panningOriginTarget: Vector3;
  128117. /**
  128118. * Defines the value of the inertia used during panning.
  128119. * 0 would mean stop inertia and one would mean no decelleration at all.
  128120. */
  128121. panningInertia: number;
  128122. /**
  128123. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  128124. */
  128125. get angularSensibilityX(): number;
  128126. set angularSensibilityX(value: number);
  128127. /**
  128128. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  128129. */
  128130. get angularSensibilityY(): number;
  128131. set angularSensibilityY(value: number);
  128132. /**
  128133. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  128134. */
  128135. get pinchPrecision(): number;
  128136. set pinchPrecision(value: number);
  128137. /**
  128138. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  128139. * It will be used instead of pinchDeltaPrecision if different from 0.
  128140. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  128141. */
  128142. get pinchDeltaPercentage(): number;
  128143. set pinchDeltaPercentage(value: number);
  128144. /**
  128145. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  128146. * and pinch delta percentage.
  128147. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  128148. * that any object in the plane at the camera's target point will scale
  128149. * perfectly with finger motion.
  128150. */
  128151. get useNaturalPinchZoom(): boolean;
  128152. set useNaturalPinchZoom(value: boolean);
  128153. /**
  128154. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  128155. */
  128156. get panningSensibility(): number;
  128157. set panningSensibility(value: number);
  128158. /**
  128159. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  128160. */
  128161. get keysUp(): number[];
  128162. set keysUp(value: number[]);
  128163. /**
  128164. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  128165. */
  128166. get keysDown(): number[];
  128167. set keysDown(value: number[]);
  128168. /**
  128169. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  128170. */
  128171. get keysLeft(): number[];
  128172. set keysLeft(value: number[]);
  128173. /**
  128174. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  128175. */
  128176. get keysRight(): number[];
  128177. set keysRight(value: number[]);
  128178. /**
  128179. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  128180. */
  128181. get wheelPrecision(): number;
  128182. set wheelPrecision(value: number);
  128183. /**
  128184. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  128185. * It will be used instead of pinchDeltaPrecision if different from 0.
  128186. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  128187. */
  128188. get wheelDeltaPercentage(): number;
  128189. set wheelDeltaPercentage(value: number);
  128190. /**
  128191. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  128192. */
  128193. zoomOnFactor: number;
  128194. /**
  128195. * Defines a screen offset for the camera position.
  128196. */
  128197. targetScreenOffset: Vector2;
  128198. /**
  128199. * Allows the camera to be completely reversed.
  128200. * If false the camera can not arrive upside down.
  128201. */
  128202. allowUpsideDown: boolean;
  128203. /**
  128204. * Define if double tap/click is used to restore the previously saved state of the camera.
  128205. */
  128206. useInputToRestoreState: boolean;
  128207. /** @hidden */
  128208. _viewMatrix: Matrix;
  128209. /** @hidden */
  128210. _useCtrlForPanning: boolean;
  128211. /** @hidden */
  128212. _panningMouseButton: number;
  128213. /**
  128214. * Defines the input associated to the camera.
  128215. */
  128216. inputs: ArcRotateCameraInputsManager;
  128217. /** @hidden */
  128218. _reset: () => void;
  128219. /**
  128220. * Defines the allowed panning axis.
  128221. */
  128222. panningAxis: Vector3;
  128223. protected _localDirection: Vector3;
  128224. protected _transformedDirection: Vector3;
  128225. private _bouncingBehavior;
  128226. /**
  128227. * Gets the bouncing behavior of the camera if it has been enabled.
  128228. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  128229. */
  128230. get bouncingBehavior(): Nullable<BouncingBehavior>;
  128231. /**
  128232. * Defines if the bouncing behavior of the camera is enabled on the camera.
  128233. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  128234. */
  128235. get useBouncingBehavior(): boolean;
  128236. set useBouncingBehavior(value: boolean);
  128237. private _framingBehavior;
  128238. /**
  128239. * Gets the framing behavior of the camera if it has been enabled.
  128240. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  128241. */
  128242. get framingBehavior(): Nullable<FramingBehavior>;
  128243. /**
  128244. * Defines if the framing behavior of the camera is enabled on the camera.
  128245. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  128246. */
  128247. get useFramingBehavior(): boolean;
  128248. set useFramingBehavior(value: boolean);
  128249. private _autoRotationBehavior;
  128250. /**
  128251. * Gets the auto rotation behavior of the camera if it has been enabled.
  128252. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128253. */
  128254. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  128255. /**
  128256. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  128257. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128258. */
  128259. get useAutoRotationBehavior(): boolean;
  128260. set useAutoRotationBehavior(value: boolean);
  128261. /**
  128262. * Observable triggered when the mesh target has been changed on the camera.
  128263. */
  128264. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  128265. /**
  128266. * Event raised when the camera is colliding with a mesh.
  128267. */
  128268. onCollide: (collidedMesh: AbstractMesh) => void;
  128269. /**
  128270. * Defines whether the camera should check collision with the objects oh the scene.
  128271. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  128272. */
  128273. checkCollisions: boolean;
  128274. /**
  128275. * Defines the collision radius of the camera.
  128276. * This simulates a sphere around the camera.
  128277. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  128278. */
  128279. collisionRadius: Vector3;
  128280. protected _collider: Collider;
  128281. protected _previousPosition: Vector3;
  128282. protected _collisionVelocity: Vector3;
  128283. protected _newPosition: Vector3;
  128284. protected _previousAlpha: number;
  128285. protected _previousBeta: number;
  128286. protected _previousRadius: number;
  128287. protected _collisionTriggered: boolean;
  128288. protected _targetBoundingCenter: Nullable<Vector3>;
  128289. private _computationVector;
  128290. /**
  128291. * Instantiates a new ArcRotateCamera in a given scene
  128292. * @param name Defines the name of the camera
  128293. * @param alpha Defines the camera rotation along the logitudinal axis
  128294. * @param beta Defines the camera rotation along the latitudinal axis
  128295. * @param radius Defines the camera distance from its target
  128296. * @param target Defines the camera target
  128297. * @param scene Defines the scene the camera belongs to
  128298. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  128299. */
  128300. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128301. /** @hidden */
  128302. _initCache(): void;
  128303. /** @hidden */
  128304. _updateCache(ignoreParentClass?: boolean): void;
  128305. protected _getTargetPosition(): Vector3;
  128306. private _storedAlpha;
  128307. private _storedBeta;
  128308. private _storedRadius;
  128309. private _storedTarget;
  128310. private _storedTargetScreenOffset;
  128311. /**
  128312. * Stores the current state of the camera (alpha, beta, radius and target)
  128313. * @returns the camera itself
  128314. */
  128315. storeState(): Camera;
  128316. /**
  128317. * @hidden
  128318. * Restored camera state. You must call storeState() first
  128319. */
  128320. _restoreStateValues(): boolean;
  128321. /** @hidden */
  128322. _isSynchronizedViewMatrix(): boolean;
  128323. /**
  128324. * Attach the input controls to a specific dom element to get the input from.
  128325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128326. */
  128327. attachControl(noPreventDefault?: boolean): void;
  128328. /**
  128329. * Attach the input controls to a specific dom element to get the input from.
  128330. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  128331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128332. */
  128333. attachControl(ignored: any, noPreventDefault?: boolean): void;
  128334. /**
  128335. * Attached controls to the current camera.
  128336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128337. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128338. */
  128339. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  128340. /**
  128341. * Attached controls to the current camera.
  128342. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  128343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128344. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128345. */
  128346. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  128347. /**
  128348. * Attached controls to the current camera.
  128349. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128350. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128351. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  128352. */
  128353. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  128354. /**
  128355. * Detach the current controls from the specified dom element.
  128356. */
  128357. detachControl(): void;
  128358. /**
  128359. * Detach the current controls from the specified dom element.
  128360. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  128361. */
  128362. detachControl(ignored: any): void;
  128363. /** @hidden */
  128364. _checkInputs(): void;
  128365. protected _checkLimits(): void;
  128366. /**
  128367. * Rebuilds angles (alpha, beta) and radius from the give position and target
  128368. */
  128369. rebuildAnglesAndRadius(): void;
  128370. /**
  128371. * Use a position to define the current camera related information like alpha, beta and radius
  128372. * @param position Defines the position to set the camera at
  128373. */
  128374. setPosition(position: Vector3): void;
  128375. /**
  128376. * Defines the target the camera should look at.
  128377. * This will automatically adapt alpha beta and radius to fit within the new target.
  128378. * @param target Defines the new target as a Vector or a mesh
  128379. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  128380. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  128381. */
  128382. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  128383. /** @hidden */
  128384. _getViewMatrix(): Matrix;
  128385. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  128386. /**
  128387. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  128388. * @param meshes Defines the mesh to zoom on
  128389. * @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)
  128390. */
  128391. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  128392. /**
  128393. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  128394. * The target will be changed but the radius
  128395. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  128396. * @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)
  128397. */
  128398. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  128399. min: Vector3;
  128400. max: Vector3;
  128401. distance: number;
  128402. }, doNotUpdateMaxZ?: boolean): void;
  128403. /**
  128404. * @override
  128405. * Override Camera.createRigCamera
  128406. */
  128407. createRigCamera(name: string, cameraIndex: number): Camera;
  128408. /**
  128409. * @hidden
  128410. * @override
  128411. * Override Camera._updateRigCameras
  128412. */
  128413. _updateRigCameras(): void;
  128414. /**
  128415. * Destroy the camera and release the current resources hold by it.
  128416. */
  128417. dispose(): void;
  128418. /**
  128419. * Gets the current object class name.
  128420. * @return the class name
  128421. */
  128422. getClassName(): string;
  128423. }
  128424. }
  128425. declare module BABYLON {
  128426. /**
  128427. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  128428. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128429. */
  128430. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  128431. /**
  128432. * Gets the name of the behavior.
  128433. */
  128434. get name(): string;
  128435. private _zoomStopsAnimation;
  128436. private _idleRotationSpeed;
  128437. private _idleRotationWaitTime;
  128438. private _idleRotationSpinupTime;
  128439. /**
  128440. * Sets the flag that indicates if user zooming should stop animation.
  128441. */
  128442. set zoomStopsAnimation(flag: boolean);
  128443. /**
  128444. * Gets the flag that indicates if user zooming should stop animation.
  128445. */
  128446. get zoomStopsAnimation(): boolean;
  128447. /**
  128448. * Sets the default speed at which the camera rotates around the model.
  128449. */
  128450. set idleRotationSpeed(speed: number);
  128451. /**
  128452. * Gets the default speed at which the camera rotates around the model.
  128453. */
  128454. get idleRotationSpeed(): number;
  128455. /**
  128456. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  128457. */
  128458. set idleRotationWaitTime(time: number);
  128459. /**
  128460. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  128461. */
  128462. get idleRotationWaitTime(): number;
  128463. /**
  128464. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  128465. */
  128466. set idleRotationSpinupTime(time: number);
  128467. /**
  128468. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  128469. */
  128470. get idleRotationSpinupTime(): number;
  128471. /**
  128472. * Gets a value indicating if the camera is currently rotating because of this behavior
  128473. */
  128474. get rotationInProgress(): boolean;
  128475. private _onPrePointerObservableObserver;
  128476. private _onAfterCheckInputsObserver;
  128477. private _attachedCamera;
  128478. private _isPointerDown;
  128479. private _lastFrameTime;
  128480. private _lastInteractionTime;
  128481. private _cameraRotationSpeed;
  128482. /**
  128483. * Initializes the behavior.
  128484. */
  128485. init(): void;
  128486. /**
  128487. * Attaches the behavior to its arc rotate camera.
  128488. * @param camera Defines the camera to attach the behavior to
  128489. */
  128490. attach(camera: ArcRotateCamera): void;
  128491. /**
  128492. * Detaches the behavior from its current arc rotate camera.
  128493. */
  128494. detach(): void;
  128495. /**
  128496. * Returns true if user is scrolling.
  128497. * @return true if user is scrolling.
  128498. */
  128499. private _userIsZooming;
  128500. private _lastFrameRadius;
  128501. private _shouldAnimationStopForInteraction;
  128502. /**
  128503. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  128504. */
  128505. private _applyUserInteraction;
  128506. private _userIsMoving;
  128507. }
  128508. }
  128509. declare module BABYLON {
  128510. /**
  128511. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  128512. */
  128513. export class AttachToBoxBehavior implements Behavior<Mesh> {
  128514. private ui;
  128515. /**
  128516. * The name of the behavior
  128517. */
  128518. name: string;
  128519. /**
  128520. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  128521. */
  128522. distanceAwayFromFace: number;
  128523. /**
  128524. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  128525. */
  128526. distanceAwayFromBottomOfFace: number;
  128527. private _faceVectors;
  128528. private _target;
  128529. private _scene;
  128530. private _onRenderObserver;
  128531. private _tmpMatrix;
  128532. private _tmpVector;
  128533. /**
  128534. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  128535. * @param ui The transform node that should be attched to the mesh
  128536. */
  128537. constructor(ui: TransformNode);
  128538. /**
  128539. * Initializes the behavior
  128540. */
  128541. init(): void;
  128542. private _closestFace;
  128543. private _zeroVector;
  128544. private _lookAtTmpMatrix;
  128545. private _lookAtToRef;
  128546. /**
  128547. * Attaches the AttachToBoxBehavior to the passed in mesh
  128548. * @param target The mesh that the specified node will be attached to
  128549. */
  128550. attach(target: Mesh): void;
  128551. /**
  128552. * Detaches the behavior from the mesh
  128553. */
  128554. detach(): void;
  128555. }
  128556. }
  128557. declare module BABYLON {
  128558. /**
  128559. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  128560. */
  128561. export class FadeInOutBehavior implements Behavior<Mesh> {
  128562. /**
  128563. * Time in milliseconds to delay before fading in (Default: 0)
  128564. */
  128565. delay: number;
  128566. /**
  128567. * Time in milliseconds for the mesh to fade in (Default: 300)
  128568. */
  128569. fadeInTime: number;
  128570. private _millisecondsPerFrame;
  128571. private _hovered;
  128572. private _hoverValue;
  128573. private _ownerNode;
  128574. /**
  128575. * Instatiates the FadeInOutBehavior
  128576. */
  128577. constructor();
  128578. /**
  128579. * The name of the behavior
  128580. */
  128581. get name(): string;
  128582. /**
  128583. * Initializes the behavior
  128584. */
  128585. init(): void;
  128586. /**
  128587. * Attaches the fade behavior on the passed in mesh
  128588. * @param ownerNode The mesh that will be faded in/out once attached
  128589. */
  128590. attach(ownerNode: Mesh): void;
  128591. /**
  128592. * Detaches the behavior from the mesh
  128593. */
  128594. detach(): void;
  128595. /**
  128596. * Triggers the mesh to begin fading in or out
  128597. * @param value if the object should fade in or out (true to fade in)
  128598. */
  128599. fadeIn(value: boolean): void;
  128600. private _update;
  128601. private _setAllVisibility;
  128602. }
  128603. }
  128604. declare module BABYLON {
  128605. /**
  128606. * Class containing a set of static utilities functions for managing Pivots
  128607. * @hidden
  128608. */
  128609. export class PivotTools {
  128610. private static _PivotCached;
  128611. private static _OldPivotPoint;
  128612. private static _PivotTranslation;
  128613. private static _PivotTmpVector;
  128614. private static _PivotPostMultiplyPivotMatrix;
  128615. /** @hidden */
  128616. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  128617. /** @hidden */
  128618. static _RestorePivotPoint(mesh: AbstractMesh): void;
  128619. }
  128620. }
  128621. declare module BABYLON {
  128622. /**
  128623. * Class containing static functions to help procedurally build meshes
  128624. */
  128625. export class PlaneBuilder {
  128626. /**
  128627. * Creates a plane mesh
  128628. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  128629. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  128630. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  128631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128634. * @param name defines the name of the mesh
  128635. * @param options defines the options used to create the mesh
  128636. * @param scene defines the hosting scene
  128637. * @returns the plane mesh
  128638. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  128639. */
  128640. static CreatePlane(name: string, options: {
  128641. size?: number;
  128642. width?: number;
  128643. height?: number;
  128644. sideOrientation?: number;
  128645. frontUVs?: Vector4;
  128646. backUVs?: Vector4;
  128647. updatable?: boolean;
  128648. sourcePlane?: Plane;
  128649. }, scene?: Nullable<Scene>): Mesh;
  128650. }
  128651. }
  128652. declare module BABYLON {
  128653. /**
  128654. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  128655. */
  128656. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  128657. private static _AnyMouseID;
  128658. /**
  128659. * Abstract mesh the behavior is set on
  128660. */
  128661. attachedNode: AbstractMesh;
  128662. private _dragPlane;
  128663. private _scene;
  128664. private _pointerObserver;
  128665. private _beforeRenderObserver;
  128666. private static _planeScene;
  128667. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  128668. /**
  128669. * 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)
  128670. */
  128671. maxDragAngle: number;
  128672. /**
  128673. * @hidden
  128674. */
  128675. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  128676. /**
  128677. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  128678. */
  128679. currentDraggingPointerID: number;
  128680. /**
  128681. * The last position where the pointer hit the drag plane in world space
  128682. */
  128683. lastDragPosition: Vector3;
  128684. /**
  128685. * If the behavior is currently in a dragging state
  128686. */
  128687. dragging: boolean;
  128688. /**
  128689. * 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)
  128690. */
  128691. dragDeltaRatio: number;
  128692. /**
  128693. * If the drag plane orientation should be updated during the dragging (Default: true)
  128694. */
  128695. updateDragPlane: boolean;
  128696. private _debugMode;
  128697. private _moving;
  128698. /**
  128699. * Fires each time the attached mesh is dragged with the pointer
  128700. * * delta between last drag position and current drag position in world space
  128701. * * dragDistance along the drag axis
  128702. * * dragPlaneNormal normal of the current drag plane used during the drag
  128703. * * dragPlanePoint in world space where the drag intersects the drag plane
  128704. */
  128705. onDragObservable: Observable<{
  128706. delta: Vector3;
  128707. dragPlanePoint: Vector3;
  128708. dragPlaneNormal: Vector3;
  128709. dragDistance: number;
  128710. pointerId: number;
  128711. }>;
  128712. /**
  128713. * Fires each time a drag begins (eg. mouse down on mesh)
  128714. */
  128715. onDragStartObservable: Observable<{
  128716. dragPlanePoint: Vector3;
  128717. pointerId: number;
  128718. }>;
  128719. /**
  128720. * Fires each time a drag ends (eg. mouse release after drag)
  128721. */
  128722. onDragEndObservable: Observable<{
  128723. dragPlanePoint: Vector3;
  128724. pointerId: number;
  128725. }>;
  128726. /**
  128727. * If the attached mesh should be moved when dragged
  128728. */
  128729. moveAttached: boolean;
  128730. /**
  128731. * If the drag behavior will react to drag events (Default: true)
  128732. */
  128733. enabled: boolean;
  128734. /**
  128735. * If pointer events should start and release the drag (Default: true)
  128736. */
  128737. startAndReleaseDragOnPointerEvents: boolean;
  128738. /**
  128739. * If camera controls should be detached during the drag
  128740. */
  128741. detachCameraControls: boolean;
  128742. /**
  128743. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  128744. */
  128745. useObjectOrientationForDragging: boolean;
  128746. private _options;
  128747. /**
  128748. * Gets the options used by the behavior
  128749. */
  128750. get options(): {
  128751. dragAxis?: Vector3;
  128752. dragPlaneNormal?: Vector3;
  128753. };
  128754. /**
  128755. * Sets the options used by the behavior
  128756. */
  128757. set options(options: {
  128758. dragAxis?: Vector3;
  128759. dragPlaneNormal?: Vector3;
  128760. });
  128761. /**
  128762. * Creates a pointer drag behavior that can be attached to a mesh
  128763. * @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)
  128764. */
  128765. constructor(options?: {
  128766. dragAxis?: Vector3;
  128767. dragPlaneNormal?: Vector3;
  128768. });
  128769. /**
  128770. * Predicate to determine if it is valid to move the object to a new position when it is moved
  128771. */
  128772. validateDrag: (targetPosition: Vector3) => boolean;
  128773. /**
  128774. * The name of the behavior
  128775. */
  128776. get name(): string;
  128777. /**
  128778. * Initializes the behavior
  128779. */
  128780. init(): void;
  128781. private _tmpVector;
  128782. private _alternatePickedPoint;
  128783. private _worldDragAxis;
  128784. private _targetPosition;
  128785. private _attachedToElement;
  128786. /**
  128787. * Attaches the drag behavior the passed in mesh
  128788. * @param ownerNode The mesh that will be dragged around once attached
  128789. * @param predicate Predicate to use for pick filtering
  128790. */
  128791. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  128792. /**
  128793. * Force relase the drag action by code.
  128794. */
  128795. releaseDrag(): void;
  128796. private _startDragRay;
  128797. private _lastPointerRay;
  128798. /**
  128799. * Simulates the start of a pointer drag event on the behavior
  128800. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  128801. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  128802. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  128803. */
  128804. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128805. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128806. private _dragDelta;
  128807. protected _moveDrag(ray: Ray): void;
  128808. private _pickWithRayOnDragPlane;
  128809. private _pointA;
  128810. private _pointC;
  128811. private _localAxis;
  128812. private _lookAt;
  128813. private _updateDragPlanePosition;
  128814. /**
  128815. * Detaches the behavior from the mesh
  128816. */
  128817. detach(): void;
  128818. }
  128819. }
  128820. declare module BABYLON {
  128821. /**
  128822. * A behavior that when attached to a mesh will allow the mesh to be scaled
  128823. */
  128824. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  128825. private _dragBehaviorA;
  128826. private _dragBehaviorB;
  128827. private _startDistance;
  128828. private _initialScale;
  128829. private _targetScale;
  128830. private _ownerNode;
  128831. private _sceneRenderObserver;
  128832. /**
  128833. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  128834. */
  128835. constructor();
  128836. /**
  128837. * The name of the behavior
  128838. */
  128839. get name(): string;
  128840. /**
  128841. * Initializes the behavior
  128842. */
  128843. init(): void;
  128844. private _getCurrentDistance;
  128845. /**
  128846. * Attaches the scale behavior the passed in mesh
  128847. * @param ownerNode The mesh that will be scaled around once attached
  128848. */
  128849. attach(ownerNode: Mesh): void;
  128850. /**
  128851. * Detaches the behavior from the mesh
  128852. */
  128853. detach(): void;
  128854. }
  128855. }
  128856. declare module BABYLON {
  128857. /**
  128858. * 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
  128859. */
  128860. export class SixDofDragBehavior implements Behavior<Mesh> {
  128861. private static _virtualScene;
  128862. private _ownerNode;
  128863. private _sceneRenderObserver;
  128864. private _scene;
  128865. private _targetPosition;
  128866. private _virtualOriginMesh;
  128867. private _virtualDragMesh;
  128868. private _pointerObserver;
  128869. private _moving;
  128870. private _startingOrientation;
  128871. private _attachedToElement;
  128872. /**
  128873. * 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)
  128874. */
  128875. private zDragFactor;
  128876. /**
  128877. * If the object should rotate to face the drag origin
  128878. */
  128879. rotateDraggedObject: boolean;
  128880. /**
  128881. * If the behavior is currently in a dragging state
  128882. */
  128883. dragging: boolean;
  128884. /**
  128885. * 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)
  128886. */
  128887. dragDeltaRatio: number;
  128888. /**
  128889. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  128890. */
  128891. currentDraggingPointerID: number;
  128892. /**
  128893. * If camera controls should be detached during the drag
  128894. */
  128895. detachCameraControls: boolean;
  128896. /**
  128897. * Fires each time a drag starts
  128898. */
  128899. onDragStartObservable: Observable<{}>;
  128900. /**
  128901. * Fires each time a drag happens
  128902. */
  128903. onDragObservable: Observable<void>;
  128904. /**
  128905. * Fires each time a drag ends (eg. mouse release after drag)
  128906. */
  128907. onDragEndObservable: Observable<{}>;
  128908. /**
  128909. * 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
  128910. */
  128911. constructor();
  128912. /**
  128913. * The name of the behavior
  128914. */
  128915. get name(): string;
  128916. /**
  128917. * Initializes the behavior
  128918. */
  128919. init(): void;
  128920. /**
  128921. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  128922. */
  128923. private get _pointerCamera();
  128924. /**
  128925. * Attaches the scale behavior the passed in mesh
  128926. * @param ownerNode The mesh that will be scaled around once attached
  128927. */
  128928. attach(ownerNode: Mesh): void;
  128929. /**
  128930. * Detaches the behavior from the mesh
  128931. */
  128932. detach(): void;
  128933. }
  128934. }
  128935. declare module BABYLON {
  128936. /**
  128937. * Class used to apply inverse kinematics to bones
  128938. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  128939. */
  128940. export class BoneIKController {
  128941. private static _tmpVecs;
  128942. private static _tmpQuat;
  128943. private static _tmpMats;
  128944. /**
  128945. * Gets or sets the target mesh
  128946. */
  128947. targetMesh: AbstractMesh;
  128948. /** Gets or sets the mesh used as pole */
  128949. poleTargetMesh: AbstractMesh;
  128950. /**
  128951. * Gets or sets the bone used as pole
  128952. */
  128953. poleTargetBone: Nullable<Bone>;
  128954. /**
  128955. * Gets or sets the target position
  128956. */
  128957. targetPosition: Vector3;
  128958. /**
  128959. * Gets or sets the pole target position
  128960. */
  128961. poleTargetPosition: Vector3;
  128962. /**
  128963. * Gets or sets the pole target local offset
  128964. */
  128965. poleTargetLocalOffset: Vector3;
  128966. /**
  128967. * Gets or sets the pole angle
  128968. */
  128969. poleAngle: number;
  128970. /**
  128971. * Gets or sets the mesh associated with the controller
  128972. */
  128973. mesh: AbstractMesh;
  128974. /**
  128975. * 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)
  128976. */
  128977. slerpAmount: number;
  128978. private _bone1Quat;
  128979. private _bone1Mat;
  128980. private _bone2Ang;
  128981. private _bone1;
  128982. private _bone2;
  128983. private _bone1Length;
  128984. private _bone2Length;
  128985. private _maxAngle;
  128986. private _maxReach;
  128987. private _rightHandedSystem;
  128988. private _bendAxis;
  128989. private _slerping;
  128990. private _adjustRoll;
  128991. /**
  128992. * Gets or sets maximum allowed angle
  128993. */
  128994. get maxAngle(): number;
  128995. set maxAngle(value: number);
  128996. /**
  128997. * Creates a new BoneIKController
  128998. * @param mesh defines the mesh to control
  128999. * @param bone defines the bone to control
  129000. * @param options defines options to set up the controller
  129001. */
  129002. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  129003. targetMesh?: AbstractMesh;
  129004. poleTargetMesh?: AbstractMesh;
  129005. poleTargetBone?: Bone;
  129006. poleTargetLocalOffset?: Vector3;
  129007. poleAngle?: number;
  129008. bendAxis?: Vector3;
  129009. maxAngle?: number;
  129010. slerpAmount?: number;
  129011. });
  129012. private _setMaxAngle;
  129013. /**
  129014. * Force the controller to update the bones
  129015. */
  129016. update(): void;
  129017. }
  129018. }
  129019. declare module BABYLON {
  129020. /**
  129021. * Class used to make a bone look toward a point in space
  129022. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  129023. */
  129024. export class BoneLookController {
  129025. private static _tmpVecs;
  129026. private static _tmpQuat;
  129027. private static _tmpMats;
  129028. /**
  129029. * The target Vector3 that the bone will look at
  129030. */
  129031. target: Vector3;
  129032. /**
  129033. * The mesh that the bone is attached to
  129034. */
  129035. mesh: AbstractMesh;
  129036. /**
  129037. * The bone that will be looking to the target
  129038. */
  129039. bone: Bone;
  129040. /**
  129041. * The up axis of the coordinate system that is used when the bone is rotated
  129042. */
  129043. upAxis: Vector3;
  129044. /**
  129045. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  129046. */
  129047. upAxisSpace: Space;
  129048. /**
  129049. * Used to make an adjustment to the yaw of the bone
  129050. */
  129051. adjustYaw: number;
  129052. /**
  129053. * Used to make an adjustment to the pitch of the bone
  129054. */
  129055. adjustPitch: number;
  129056. /**
  129057. * Used to make an adjustment to the roll of the bone
  129058. */
  129059. adjustRoll: number;
  129060. /**
  129061. * 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)
  129062. */
  129063. slerpAmount: number;
  129064. private _minYaw;
  129065. private _maxYaw;
  129066. private _minPitch;
  129067. private _maxPitch;
  129068. private _minYawSin;
  129069. private _minYawCos;
  129070. private _maxYawSin;
  129071. private _maxYawCos;
  129072. private _midYawConstraint;
  129073. private _minPitchTan;
  129074. private _maxPitchTan;
  129075. private _boneQuat;
  129076. private _slerping;
  129077. private _transformYawPitch;
  129078. private _transformYawPitchInv;
  129079. private _firstFrameSkipped;
  129080. private _yawRange;
  129081. private _fowardAxis;
  129082. /**
  129083. * Gets or sets the minimum yaw angle that the bone can look to
  129084. */
  129085. get minYaw(): number;
  129086. set minYaw(value: number);
  129087. /**
  129088. * Gets or sets the maximum yaw angle that the bone can look to
  129089. */
  129090. get maxYaw(): number;
  129091. set maxYaw(value: number);
  129092. /**
  129093. * Gets or sets the minimum pitch angle that the bone can look to
  129094. */
  129095. get minPitch(): number;
  129096. set minPitch(value: number);
  129097. /**
  129098. * Gets or sets the maximum pitch angle that the bone can look to
  129099. */
  129100. get maxPitch(): number;
  129101. set maxPitch(value: number);
  129102. /**
  129103. * Create a BoneLookController
  129104. * @param mesh the mesh that the bone belongs to
  129105. * @param bone the bone that will be looking to the target
  129106. * @param target the target Vector3 to look at
  129107. * @param options optional settings:
  129108. * * maxYaw: the maximum angle the bone will yaw to
  129109. * * minYaw: the minimum angle the bone will yaw to
  129110. * * maxPitch: the maximum angle the bone will pitch to
  129111. * * minPitch: the minimum angle the bone will yaw to
  129112. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  129113. * * upAxis: the up axis of the coordinate system
  129114. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  129115. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  129116. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  129117. * * adjustYaw: used to make an adjustment to the yaw of the bone
  129118. * * adjustPitch: used to make an adjustment to the pitch of the bone
  129119. * * adjustRoll: used to make an adjustment to the roll of the bone
  129120. **/
  129121. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  129122. maxYaw?: number;
  129123. minYaw?: number;
  129124. maxPitch?: number;
  129125. minPitch?: number;
  129126. slerpAmount?: number;
  129127. upAxis?: Vector3;
  129128. upAxisSpace?: Space;
  129129. yawAxis?: Vector3;
  129130. pitchAxis?: Vector3;
  129131. adjustYaw?: number;
  129132. adjustPitch?: number;
  129133. adjustRoll?: number;
  129134. });
  129135. /**
  129136. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  129137. */
  129138. update(): void;
  129139. private _getAngleDiff;
  129140. private _getAngleBetween;
  129141. private _isAngleBetween;
  129142. }
  129143. }
  129144. declare module BABYLON {
  129145. /**
  129146. * Manage the gamepad inputs to control an arc rotate camera.
  129147. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129148. */
  129149. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  129150. /**
  129151. * Defines the camera the input is attached to.
  129152. */
  129153. camera: ArcRotateCamera;
  129154. /**
  129155. * Defines the gamepad the input is gathering event from.
  129156. */
  129157. gamepad: Nullable<Gamepad>;
  129158. /**
  129159. * Defines the gamepad rotation sensiblity.
  129160. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129161. */
  129162. gamepadRotationSensibility: number;
  129163. /**
  129164. * Defines the gamepad move sensiblity.
  129165. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129166. */
  129167. gamepadMoveSensibility: number;
  129168. private _yAxisScale;
  129169. /**
  129170. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  129171. */
  129172. get invertYAxis(): boolean;
  129173. set invertYAxis(value: boolean);
  129174. private _onGamepadConnectedObserver;
  129175. private _onGamepadDisconnectedObserver;
  129176. /**
  129177. * Attach the input controls to a specific dom element to get the input from.
  129178. */
  129179. attachControl(): void;
  129180. /**
  129181. * Detach the current controls from the specified dom element.
  129182. */
  129183. detachControl(): void;
  129184. /**
  129185. * Update the current camera state depending on the inputs that have been used this frame.
  129186. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129187. */
  129188. checkInputs(): void;
  129189. /**
  129190. * Gets the class name of the current intput.
  129191. * @returns the class name
  129192. */
  129193. getClassName(): string;
  129194. /**
  129195. * Get the friendly name associated with the input class.
  129196. * @returns the input friendly name
  129197. */
  129198. getSimpleName(): string;
  129199. }
  129200. }
  129201. declare module BABYLON {
  129202. interface ArcRotateCameraInputsManager {
  129203. /**
  129204. * Add orientation input support to the input manager.
  129205. * @returns the current input manager
  129206. */
  129207. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  129208. }
  129209. /**
  129210. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  129211. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129212. */
  129213. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  129214. /**
  129215. * Defines the camera the input is attached to.
  129216. */
  129217. camera: ArcRotateCamera;
  129218. /**
  129219. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  129220. */
  129221. alphaCorrection: number;
  129222. /**
  129223. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  129224. */
  129225. gammaCorrection: number;
  129226. private _alpha;
  129227. private _gamma;
  129228. private _dirty;
  129229. private _deviceOrientationHandler;
  129230. /**
  129231. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  129232. */
  129233. constructor();
  129234. /**
  129235. * Attach the input controls to a specific dom element to get the input from.
  129236. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129237. */
  129238. attachControl(noPreventDefault?: boolean): void;
  129239. /** @hidden */
  129240. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  129241. /**
  129242. * Update the current camera state depending on the inputs that have been used this frame.
  129243. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129244. */
  129245. checkInputs(): void;
  129246. /**
  129247. * Detach the current controls from the specified dom element.
  129248. */
  129249. detachControl(): void;
  129250. /**
  129251. * Gets the class name of the current intput.
  129252. * @returns the class name
  129253. */
  129254. getClassName(): string;
  129255. /**
  129256. * Get the friendly name associated with the input class.
  129257. * @returns the input friendly name
  129258. */
  129259. getSimpleName(): string;
  129260. }
  129261. }
  129262. declare module BABYLON {
  129263. /**
  129264. * Listen to mouse events to control the camera.
  129265. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129266. */
  129267. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  129268. /**
  129269. * Defines the camera the input is attached to.
  129270. */
  129271. camera: FlyCamera;
  129272. /**
  129273. * Defines if touch is enabled. (Default is true.)
  129274. */
  129275. touchEnabled: boolean;
  129276. /**
  129277. * Defines the buttons associated with the input to handle camera rotation.
  129278. */
  129279. buttons: number[];
  129280. /**
  129281. * Assign buttons for Yaw control.
  129282. */
  129283. buttonsYaw: number[];
  129284. /**
  129285. * Assign buttons for Pitch control.
  129286. */
  129287. buttonsPitch: number[];
  129288. /**
  129289. * Assign buttons for Roll control.
  129290. */
  129291. buttonsRoll: number[];
  129292. /**
  129293. * Detect if any button is being pressed while mouse is moved.
  129294. * -1 = Mouse locked.
  129295. * 0 = Left button.
  129296. * 1 = Middle Button.
  129297. * 2 = Right Button.
  129298. */
  129299. activeButton: number;
  129300. /**
  129301. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  129302. * Higher values reduce its sensitivity.
  129303. */
  129304. angularSensibility: number;
  129305. private _observer;
  129306. private _rollObserver;
  129307. private previousPosition;
  129308. private noPreventDefault;
  129309. private element;
  129310. /**
  129311. * Listen to mouse events to control the camera.
  129312. * @param touchEnabled Define if touch is enabled. (Default is true.)
  129313. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129314. */
  129315. constructor(touchEnabled?: boolean);
  129316. /**
  129317. * Attach the mouse control to the HTML DOM element.
  129318. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  129319. */
  129320. attachControl(noPreventDefault?: boolean): void;
  129321. /**
  129322. * Detach the current controls from the specified dom element.
  129323. */
  129324. detachControl(): void;
  129325. /**
  129326. * Gets the class name of the current input.
  129327. * @returns the class name.
  129328. */
  129329. getClassName(): string;
  129330. /**
  129331. * Get the friendly name associated with the input class.
  129332. * @returns the input's friendly name.
  129333. */
  129334. getSimpleName(): string;
  129335. private _pointerInput;
  129336. private _onMouseMove;
  129337. /**
  129338. * Rotate camera by mouse offset.
  129339. */
  129340. private rotateCamera;
  129341. }
  129342. }
  129343. declare module BABYLON {
  129344. /**
  129345. * Default Inputs manager for the FlyCamera.
  129346. * It groups all the default supported inputs for ease of use.
  129347. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129348. */
  129349. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  129350. /**
  129351. * Instantiates a new FlyCameraInputsManager.
  129352. * @param camera Defines the camera the inputs belong to.
  129353. */
  129354. constructor(camera: FlyCamera);
  129355. /**
  129356. * Add keyboard input support to the input manager.
  129357. * @returns the new FlyCameraKeyboardMoveInput().
  129358. */
  129359. addKeyboard(): FlyCameraInputsManager;
  129360. /**
  129361. * Add mouse input support to the input manager.
  129362. * @param touchEnabled Enable touch screen support.
  129363. * @returns the new FlyCameraMouseInput().
  129364. */
  129365. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  129366. }
  129367. }
  129368. declare module BABYLON {
  129369. /**
  129370. * This is a flying camera, designed for 3D movement and rotation in all directions,
  129371. * such as in a 3D Space Shooter or a Flight Simulator.
  129372. */
  129373. export class FlyCamera extends TargetCamera {
  129374. /**
  129375. * Define the collision ellipsoid of the camera.
  129376. * This is helpful for simulating a camera body, like a player's body.
  129377. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  129378. */
  129379. ellipsoid: Vector3;
  129380. /**
  129381. * Define an offset for the position of the ellipsoid around the camera.
  129382. * This can be helpful if the camera is attached away from the player's body center,
  129383. * such as at its head.
  129384. */
  129385. ellipsoidOffset: Vector3;
  129386. /**
  129387. * Enable or disable collisions of the camera with the rest of the scene objects.
  129388. */
  129389. checkCollisions: boolean;
  129390. /**
  129391. * Enable or disable gravity on the camera.
  129392. */
  129393. applyGravity: boolean;
  129394. /**
  129395. * Define the current direction the camera is moving to.
  129396. */
  129397. cameraDirection: Vector3;
  129398. /**
  129399. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  129400. * This overrides and empties cameraRotation.
  129401. */
  129402. rotationQuaternion: Quaternion;
  129403. /**
  129404. * Track Roll to maintain the wanted Rolling when looking around.
  129405. */
  129406. _trackRoll: number;
  129407. /**
  129408. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  129409. */
  129410. rollCorrect: number;
  129411. /**
  129412. * Mimic a banked turn, Rolling the camera when Yawing.
  129413. * It's recommended to use rollCorrect = 10 for faster banking correction.
  129414. */
  129415. bankedTurn: boolean;
  129416. /**
  129417. * Limit in radians for how much Roll banking will add. (Default: 90°)
  129418. */
  129419. bankedTurnLimit: number;
  129420. /**
  129421. * Value of 0 disables the banked Roll.
  129422. * Value of 1 is equal to the Yaw angle in radians.
  129423. */
  129424. bankedTurnMultiplier: number;
  129425. /**
  129426. * The inputs manager loads all the input sources, such as keyboard and mouse.
  129427. */
  129428. inputs: FlyCameraInputsManager;
  129429. /**
  129430. * Gets the input sensibility for mouse input.
  129431. * Higher values reduce sensitivity.
  129432. */
  129433. get angularSensibility(): number;
  129434. /**
  129435. * Sets the input sensibility for a mouse input.
  129436. * Higher values reduce sensitivity.
  129437. */
  129438. set angularSensibility(value: number);
  129439. /**
  129440. * Get the keys for camera movement forward.
  129441. */
  129442. get keysForward(): number[];
  129443. /**
  129444. * Set the keys for camera movement forward.
  129445. */
  129446. set keysForward(value: number[]);
  129447. /**
  129448. * Get the keys for camera movement backward.
  129449. */
  129450. get keysBackward(): number[];
  129451. set keysBackward(value: number[]);
  129452. /**
  129453. * Get the keys for camera movement up.
  129454. */
  129455. get keysUp(): number[];
  129456. /**
  129457. * Set the keys for camera movement up.
  129458. */
  129459. set keysUp(value: number[]);
  129460. /**
  129461. * Get the keys for camera movement down.
  129462. */
  129463. get keysDown(): number[];
  129464. /**
  129465. * Set the keys for camera movement down.
  129466. */
  129467. set keysDown(value: number[]);
  129468. /**
  129469. * Get the keys for camera movement left.
  129470. */
  129471. get keysLeft(): number[];
  129472. /**
  129473. * Set the keys for camera movement left.
  129474. */
  129475. set keysLeft(value: number[]);
  129476. /**
  129477. * Set the keys for camera movement right.
  129478. */
  129479. get keysRight(): number[];
  129480. /**
  129481. * Set the keys for camera movement right.
  129482. */
  129483. set keysRight(value: number[]);
  129484. /**
  129485. * Event raised when the camera collides with a mesh in the scene.
  129486. */
  129487. onCollide: (collidedMesh: AbstractMesh) => void;
  129488. private _collider;
  129489. private _needMoveForGravity;
  129490. private _oldPosition;
  129491. private _diffPosition;
  129492. private _newPosition;
  129493. /** @hidden */
  129494. _localDirection: Vector3;
  129495. /** @hidden */
  129496. _transformedDirection: Vector3;
  129497. /**
  129498. * Instantiates a FlyCamera.
  129499. * This is a flying camera, designed for 3D movement and rotation in all directions,
  129500. * such as in a 3D Space Shooter or a Flight Simulator.
  129501. * @param name Define the name of the camera in the scene.
  129502. * @param position Define the starting position of the camera in the scene.
  129503. * @param scene Define the scene the camera belongs to.
  129504. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  129505. */
  129506. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  129507. /**
  129508. * Attach the input controls to a specific dom element to get the input from.
  129509. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129510. */
  129511. attachControl(noPreventDefault?: boolean): void;
  129512. /**
  129513. * Detach a control from the HTML DOM element.
  129514. * The camera will stop reacting to that input.
  129515. */
  129516. detachControl(): void;
  129517. private _collisionMask;
  129518. /**
  129519. * Get the mask that the camera ignores in collision events.
  129520. */
  129521. get collisionMask(): number;
  129522. /**
  129523. * Set the mask that the camera ignores in collision events.
  129524. */
  129525. set collisionMask(mask: number);
  129526. /** @hidden */
  129527. _collideWithWorld(displacement: Vector3): void;
  129528. /** @hidden */
  129529. private _onCollisionPositionChange;
  129530. /** @hidden */
  129531. _checkInputs(): void;
  129532. /** @hidden */
  129533. _decideIfNeedsToMove(): boolean;
  129534. /** @hidden */
  129535. _updatePosition(): void;
  129536. /**
  129537. * Restore the Roll to its target value at the rate specified.
  129538. * @param rate - Higher means slower restoring.
  129539. * @hidden
  129540. */
  129541. restoreRoll(rate: number): void;
  129542. /**
  129543. * Destroy the camera and release the current resources held by it.
  129544. */
  129545. dispose(): void;
  129546. /**
  129547. * Get the current object class name.
  129548. * @returns the class name.
  129549. */
  129550. getClassName(): string;
  129551. }
  129552. }
  129553. declare module BABYLON {
  129554. /**
  129555. * Listen to keyboard events to control the camera.
  129556. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129557. */
  129558. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  129559. /**
  129560. * Defines the camera the input is attached to.
  129561. */
  129562. camera: FlyCamera;
  129563. /**
  129564. * The list of keyboard keys used to control the forward move of the camera.
  129565. */
  129566. keysForward: number[];
  129567. /**
  129568. * The list of keyboard keys used to control the backward move of the camera.
  129569. */
  129570. keysBackward: number[];
  129571. /**
  129572. * The list of keyboard keys used to control the forward move of the camera.
  129573. */
  129574. keysUp: number[];
  129575. /**
  129576. * The list of keyboard keys used to control the backward move of the camera.
  129577. */
  129578. keysDown: number[];
  129579. /**
  129580. * The list of keyboard keys used to control the right strafe move of the camera.
  129581. */
  129582. keysRight: number[];
  129583. /**
  129584. * The list of keyboard keys used to control the left strafe move of the camera.
  129585. */
  129586. keysLeft: number[];
  129587. private _keys;
  129588. private _onCanvasBlurObserver;
  129589. private _onKeyboardObserver;
  129590. private _engine;
  129591. private _scene;
  129592. /**
  129593. * Attach the input controls to a specific dom element to get the input from.
  129594. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129595. */
  129596. attachControl(noPreventDefault?: boolean): void;
  129597. /**
  129598. * Detach the current controls from the specified dom element.
  129599. */
  129600. detachControl(): void;
  129601. /**
  129602. * Gets the class name of the current intput.
  129603. * @returns the class name
  129604. */
  129605. getClassName(): string;
  129606. /** @hidden */
  129607. _onLostFocus(e: FocusEvent): void;
  129608. /**
  129609. * Get the friendly name associated with the input class.
  129610. * @returns the input friendly name
  129611. */
  129612. getSimpleName(): string;
  129613. /**
  129614. * Update the current camera state depending on the inputs that have been used this frame.
  129615. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129616. */
  129617. checkInputs(): void;
  129618. }
  129619. }
  129620. declare module BABYLON {
  129621. /**
  129622. * Manage the mouse wheel inputs to control a follow camera.
  129623. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129624. */
  129625. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  129626. /**
  129627. * Defines the camera the input is attached to.
  129628. */
  129629. camera: FollowCamera;
  129630. /**
  129631. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  129632. */
  129633. axisControlRadius: boolean;
  129634. /**
  129635. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  129636. */
  129637. axisControlHeight: boolean;
  129638. /**
  129639. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  129640. */
  129641. axisControlRotation: boolean;
  129642. /**
  129643. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  129644. * relation to mouseWheel events.
  129645. */
  129646. wheelPrecision: number;
  129647. /**
  129648. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  129649. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  129650. */
  129651. wheelDeltaPercentage: number;
  129652. private _wheel;
  129653. private _observer;
  129654. /**
  129655. * Attach the input controls to a specific dom element to get the input from.
  129656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129657. */
  129658. attachControl(noPreventDefault?: boolean): void;
  129659. /**
  129660. * Detach the current controls from the specified dom element.
  129661. */
  129662. detachControl(): void;
  129663. /**
  129664. * Gets the class name of the current intput.
  129665. * @returns the class name
  129666. */
  129667. getClassName(): string;
  129668. /**
  129669. * Get the friendly name associated with the input class.
  129670. * @returns the input friendly name
  129671. */
  129672. getSimpleName(): string;
  129673. }
  129674. }
  129675. declare module BABYLON {
  129676. /**
  129677. * Manage the pointers inputs to control an follow camera.
  129678. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129679. */
  129680. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  129681. /**
  129682. * Defines the camera the input is attached to.
  129683. */
  129684. camera: FollowCamera;
  129685. /**
  129686. * Gets the class name of the current input.
  129687. * @returns the class name
  129688. */
  129689. getClassName(): string;
  129690. /**
  129691. * Defines the pointer angular sensibility along the X axis or how fast is
  129692. * the camera rotating.
  129693. * A negative number will reverse the axis direction.
  129694. */
  129695. angularSensibilityX: number;
  129696. /**
  129697. * Defines the pointer angular sensibility along the Y axis or how fast is
  129698. * the camera rotating.
  129699. * A negative number will reverse the axis direction.
  129700. */
  129701. angularSensibilityY: number;
  129702. /**
  129703. * Defines the pointer pinch precision or how fast is the camera zooming.
  129704. * A negative number will reverse the axis direction.
  129705. */
  129706. pinchPrecision: number;
  129707. /**
  129708. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  129709. * from 0.
  129710. * It defines the percentage of current camera.radius to use as delta when
  129711. * pinch zoom is used.
  129712. */
  129713. pinchDeltaPercentage: number;
  129714. /**
  129715. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  129716. */
  129717. axisXControlRadius: boolean;
  129718. /**
  129719. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  129720. */
  129721. axisXControlHeight: boolean;
  129722. /**
  129723. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  129724. */
  129725. axisXControlRotation: boolean;
  129726. /**
  129727. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  129728. */
  129729. axisYControlRadius: boolean;
  129730. /**
  129731. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  129732. */
  129733. axisYControlHeight: boolean;
  129734. /**
  129735. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  129736. */
  129737. axisYControlRotation: boolean;
  129738. /**
  129739. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  129740. */
  129741. axisPinchControlRadius: boolean;
  129742. /**
  129743. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  129744. */
  129745. axisPinchControlHeight: boolean;
  129746. /**
  129747. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  129748. */
  129749. axisPinchControlRotation: boolean;
  129750. /**
  129751. * Log error messages if basic misconfiguration has occurred.
  129752. */
  129753. warningEnable: boolean;
  129754. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  129755. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  129756. private _warningCounter;
  129757. private _warning;
  129758. }
  129759. }
  129760. declare module BABYLON {
  129761. /**
  129762. * Default Inputs manager for the FollowCamera.
  129763. * It groups all the default supported inputs for ease of use.
  129764. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129765. */
  129766. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  129767. /**
  129768. * Instantiates a new FollowCameraInputsManager.
  129769. * @param camera Defines the camera the inputs belong to
  129770. */
  129771. constructor(camera: FollowCamera);
  129772. /**
  129773. * Add keyboard input support to the input manager.
  129774. * @returns the current input manager
  129775. */
  129776. addKeyboard(): FollowCameraInputsManager;
  129777. /**
  129778. * Add mouse wheel input support to the input manager.
  129779. * @returns the current input manager
  129780. */
  129781. addMouseWheel(): FollowCameraInputsManager;
  129782. /**
  129783. * Add pointers input support to the input manager.
  129784. * @returns the current input manager
  129785. */
  129786. addPointers(): FollowCameraInputsManager;
  129787. /**
  129788. * Add orientation input support to the input manager.
  129789. * @returns the current input manager
  129790. */
  129791. addVRDeviceOrientation(): FollowCameraInputsManager;
  129792. }
  129793. }
  129794. declare module BABYLON {
  129795. /**
  129796. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  129797. * an arc rotate version arcFollowCamera are available.
  129798. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129799. */
  129800. export class FollowCamera extends TargetCamera {
  129801. /**
  129802. * Distance the follow camera should follow an object at
  129803. */
  129804. radius: number;
  129805. /**
  129806. * Minimum allowed distance of the camera to the axis of rotation
  129807. * (The camera can not get closer).
  129808. * This can help limiting how the Camera is able to move in the scene.
  129809. */
  129810. lowerRadiusLimit: Nullable<number>;
  129811. /**
  129812. * Maximum allowed distance of the camera to the axis of rotation
  129813. * (The camera can not get further).
  129814. * This can help limiting how the Camera is able to move in the scene.
  129815. */
  129816. upperRadiusLimit: Nullable<number>;
  129817. /**
  129818. * Define a rotation offset between the camera and the object it follows
  129819. */
  129820. rotationOffset: number;
  129821. /**
  129822. * Minimum allowed angle to camera position relative to target object.
  129823. * This can help limiting how the Camera is able to move in the scene.
  129824. */
  129825. lowerRotationOffsetLimit: Nullable<number>;
  129826. /**
  129827. * Maximum allowed angle to camera position relative to target object.
  129828. * This can help limiting how the Camera is able to move in the scene.
  129829. */
  129830. upperRotationOffsetLimit: Nullable<number>;
  129831. /**
  129832. * Define a height offset between the camera and the object it follows.
  129833. * It can help following an object from the top (like a car chaing a plane)
  129834. */
  129835. heightOffset: number;
  129836. /**
  129837. * Minimum allowed height of camera position relative to target object.
  129838. * This can help limiting how the Camera is able to move in the scene.
  129839. */
  129840. lowerHeightOffsetLimit: Nullable<number>;
  129841. /**
  129842. * Maximum allowed height of camera position relative to target object.
  129843. * This can help limiting how the Camera is able to move in the scene.
  129844. */
  129845. upperHeightOffsetLimit: Nullable<number>;
  129846. /**
  129847. * Define how fast the camera can accelerate to follow it s target.
  129848. */
  129849. cameraAcceleration: number;
  129850. /**
  129851. * Define the speed limit of the camera following an object.
  129852. */
  129853. maxCameraSpeed: number;
  129854. /**
  129855. * Define the target of the camera.
  129856. */
  129857. lockedTarget: Nullable<AbstractMesh>;
  129858. /**
  129859. * Defines the input associated with the camera.
  129860. */
  129861. inputs: FollowCameraInputsManager;
  129862. /**
  129863. * Instantiates the follow camera.
  129864. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129865. * @param name Define the name of the camera in the scene
  129866. * @param position Define the position of the camera
  129867. * @param scene Define the scene the camera belong to
  129868. * @param lockedTarget Define the target of the camera
  129869. */
  129870. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  129871. private _follow;
  129872. /**
  129873. * Attach the input controls to a specific dom element to get the input from.
  129874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129875. */
  129876. attachControl(noPreventDefault?: boolean): void;
  129877. /**
  129878. * Detach the current controls from the specified dom element.
  129879. */
  129880. detachControl(): void;
  129881. /** @hidden */
  129882. _checkInputs(): void;
  129883. private _checkLimits;
  129884. /**
  129885. * Gets the camera class name.
  129886. * @returns the class name
  129887. */
  129888. getClassName(): string;
  129889. }
  129890. /**
  129891. * Arc Rotate version of the follow camera.
  129892. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  129893. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129894. */
  129895. export class ArcFollowCamera extends TargetCamera {
  129896. /** The longitudinal angle of the camera */
  129897. alpha: number;
  129898. /** The latitudinal angle of the camera */
  129899. beta: number;
  129900. /** The radius of the camera from its target */
  129901. radius: number;
  129902. private _cartesianCoordinates;
  129903. /** Define the camera target (the mesh it should follow) */
  129904. private _meshTarget;
  129905. /**
  129906. * Instantiates a new ArcFollowCamera
  129907. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129908. * @param name Define the name of the camera
  129909. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  129910. * @param beta Define the rotation angle of the camera around the elevation axis
  129911. * @param radius Define the radius of the camera from its target point
  129912. * @param target Define the target of the camera
  129913. * @param scene Define the scene the camera belongs to
  129914. */
  129915. constructor(name: string,
  129916. /** The longitudinal angle of the camera */
  129917. alpha: number,
  129918. /** The latitudinal angle of the camera */
  129919. beta: number,
  129920. /** The radius of the camera from its target */
  129921. radius: number,
  129922. /** Define the camera target (the mesh it should follow) */
  129923. target: Nullable<AbstractMesh>, scene: Scene);
  129924. private _follow;
  129925. /** @hidden */
  129926. _checkInputs(): void;
  129927. /**
  129928. * Returns the class name of the object.
  129929. * It is mostly used internally for serialization purposes.
  129930. */
  129931. getClassName(): string;
  129932. }
  129933. }
  129934. declare module BABYLON {
  129935. /**
  129936. * Manage the keyboard inputs to control the movement of a follow camera.
  129937. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129938. */
  129939. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  129940. /**
  129941. * Defines the camera the input is attached to.
  129942. */
  129943. camera: FollowCamera;
  129944. /**
  129945. * Defines the list of key codes associated with the up action (increase heightOffset)
  129946. */
  129947. keysHeightOffsetIncr: number[];
  129948. /**
  129949. * Defines the list of key codes associated with the down action (decrease heightOffset)
  129950. */
  129951. keysHeightOffsetDecr: number[];
  129952. /**
  129953. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  129954. */
  129955. keysHeightOffsetModifierAlt: boolean;
  129956. /**
  129957. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  129958. */
  129959. keysHeightOffsetModifierCtrl: boolean;
  129960. /**
  129961. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  129962. */
  129963. keysHeightOffsetModifierShift: boolean;
  129964. /**
  129965. * Defines the list of key codes associated with the left action (increase rotationOffset)
  129966. */
  129967. keysRotationOffsetIncr: number[];
  129968. /**
  129969. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  129970. */
  129971. keysRotationOffsetDecr: number[];
  129972. /**
  129973. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  129974. */
  129975. keysRotationOffsetModifierAlt: boolean;
  129976. /**
  129977. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  129978. */
  129979. keysRotationOffsetModifierCtrl: boolean;
  129980. /**
  129981. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  129982. */
  129983. keysRotationOffsetModifierShift: boolean;
  129984. /**
  129985. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  129986. */
  129987. keysRadiusIncr: number[];
  129988. /**
  129989. * Defines the list of key codes associated with the zoom-out action (increase radius)
  129990. */
  129991. keysRadiusDecr: number[];
  129992. /**
  129993. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  129994. */
  129995. keysRadiusModifierAlt: boolean;
  129996. /**
  129997. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  129998. */
  129999. keysRadiusModifierCtrl: boolean;
  130000. /**
  130001. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  130002. */
  130003. keysRadiusModifierShift: boolean;
  130004. /**
  130005. * Defines the rate of change of heightOffset.
  130006. */
  130007. heightSensibility: number;
  130008. /**
  130009. * Defines the rate of change of rotationOffset.
  130010. */
  130011. rotationSensibility: number;
  130012. /**
  130013. * Defines the rate of change of radius.
  130014. */
  130015. radiusSensibility: number;
  130016. private _keys;
  130017. private _ctrlPressed;
  130018. private _altPressed;
  130019. private _shiftPressed;
  130020. private _onCanvasBlurObserver;
  130021. private _onKeyboardObserver;
  130022. private _engine;
  130023. private _scene;
  130024. /**
  130025. * Attach the input controls to a specific dom element to get the input from.
  130026. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  130027. */
  130028. attachControl(noPreventDefault?: boolean): void;
  130029. /**
  130030. * Detach the current controls from the specified dom element.
  130031. */
  130032. detachControl(): void;
  130033. /**
  130034. * Update the current camera state depending on the inputs that have been used this frame.
  130035. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130036. */
  130037. checkInputs(): void;
  130038. /**
  130039. * Gets the class name of the current input.
  130040. * @returns the class name
  130041. */
  130042. getClassName(): string;
  130043. /**
  130044. * Get the friendly name associated with the input class.
  130045. * @returns the input friendly name
  130046. */
  130047. getSimpleName(): string;
  130048. /**
  130049. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  130050. * allow modification of the heightOffset value.
  130051. */
  130052. private _modifierHeightOffset;
  130053. /**
  130054. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  130055. * allow modification of the rotationOffset value.
  130056. */
  130057. private _modifierRotationOffset;
  130058. /**
  130059. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  130060. * allow modification of the radius value.
  130061. */
  130062. private _modifierRadius;
  130063. }
  130064. }
  130065. declare module BABYLON {
  130066. interface FreeCameraInputsManager {
  130067. /**
  130068. * @hidden
  130069. */
  130070. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  130071. /**
  130072. * Add orientation input support to the input manager.
  130073. * @returns the current input manager
  130074. */
  130075. addDeviceOrientation(): FreeCameraInputsManager;
  130076. }
  130077. /**
  130078. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  130079. * Screen rotation is taken into account.
  130080. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130081. */
  130082. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  130083. private _camera;
  130084. private _screenOrientationAngle;
  130085. private _constantTranform;
  130086. private _screenQuaternion;
  130087. private _alpha;
  130088. private _beta;
  130089. private _gamma;
  130090. /**
  130091. * Can be used to detect if a device orientation sensor is available on a device
  130092. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  130093. * @returns a promise that will resolve on orientation change
  130094. */
  130095. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  130096. /**
  130097. * @hidden
  130098. */
  130099. _onDeviceOrientationChangedObservable: Observable<void>;
  130100. /**
  130101. * Instantiates a new input
  130102. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130103. */
  130104. constructor();
  130105. /**
  130106. * Define the camera controlled by the input.
  130107. */
  130108. get camera(): FreeCamera;
  130109. set camera(camera: FreeCamera);
  130110. /**
  130111. * Attach the input controls to a specific dom element to get the input from.
  130112. */
  130113. attachControl(): void;
  130114. private _orientationChanged;
  130115. private _deviceOrientation;
  130116. /**
  130117. * Detach the current controls from the specified dom element.
  130118. */
  130119. detachControl(): void;
  130120. /**
  130121. * Update the current camera state depending on the inputs that have been used this frame.
  130122. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130123. */
  130124. checkInputs(): void;
  130125. /**
  130126. * Gets the class name of the current intput.
  130127. * @returns the class name
  130128. */
  130129. getClassName(): string;
  130130. /**
  130131. * Get the friendly name associated with the input class.
  130132. * @returns the input friendly name
  130133. */
  130134. getSimpleName(): string;
  130135. }
  130136. }
  130137. declare module BABYLON {
  130138. /**
  130139. * Manage the gamepad inputs to control a free camera.
  130140. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130141. */
  130142. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  130143. /**
  130144. * Define the camera the input is attached to.
  130145. */
  130146. camera: FreeCamera;
  130147. /**
  130148. * Define the Gamepad controlling the input
  130149. */
  130150. gamepad: Nullable<Gamepad>;
  130151. /**
  130152. * Defines the gamepad rotation sensiblity.
  130153. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  130154. */
  130155. gamepadAngularSensibility: number;
  130156. /**
  130157. * Defines the gamepad move sensiblity.
  130158. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  130159. */
  130160. gamepadMoveSensibility: number;
  130161. private _yAxisScale;
  130162. /**
  130163. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  130164. */
  130165. get invertYAxis(): boolean;
  130166. set invertYAxis(value: boolean);
  130167. private _onGamepadConnectedObserver;
  130168. private _onGamepadDisconnectedObserver;
  130169. private _cameraTransform;
  130170. private _deltaTransform;
  130171. private _vector3;
  130172. private _vector2;
  130173. /**
  130174. * Attach the input controls to a specific dom element to get the input from.
  130175. */
  130176. attachControl(): void;
  130177. /**
  130178. * Detach the current controls from the specified dom element.
  130179. */
  130180. detachControl(): void;
  130181. /**
  130182. * Update the current camera state depending on the inputs that have been used this frame.
  130183. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130184. */
  130185. checkInputs(): void;
  130186. /**
  130187. * Gets the class name of the current intput.
  130188. * @returns the class name
  130189. */
  130190. getClassName(): string;
  130191. /**
  130192. * Get the friendly name associated with the input class.
  130193. * @returns the input friendly name
  130194. */
  130195. getSimpleName(): string;
  130196. }
  130197. }
  130198. declare module BABYLON {
  130199. /**
  130200. * Defines the potential axis of a Joystick
  130201. */
  130202. export enum JoystickAxis {
  130203. /** X axis */
  130204. X = 0,
  130205. /** Y axis */
  130206. Y = 1,
  130207. /** Z axis */
  130208. Z = 2
  130209. }
  130210. /**
  130211. * Represents the different customization options available
  130212. * for VirtualJoystick
  130213. */
  130214. interface VirtualJoystickCustomizations {
  130215. /**
  130216. * Size of the joystick's puck
  130217. */
  130218. puckSize: number;
  130219. /**
  130220. * Size of the joystick's container
  130221. */
  130222. containerSize: number;
  130223. /**
  130224. * Color of the joystick && puck
  130225. */
  130226. color: string;
  130227. /**
  130228. * Image URL for the joystick's puck
  130229. */
  130230. puckImage?: string;
  130231. /**
  130232. * Image URL for the joystick's container
  130233. */
  130234. containerImage?: string;
  130235. /**
  130236. * Defines the unmoving position of the joystick container
  130237. */
  130238. position?: {
  130239. x: number;
  130240. y: number;
  130241. };
  130242. /**
  130243. * Defines whether or not the joystick container is always visible
  130244. */
  130245. alwaysVisible: boolean;
  130246. /**
  130247. * Defines whether or not to limit the movement of the puck to the joystick's container
  130248. */
  130249. limitToContainer: boolean;
  130250. }
  130251. /**
  130252. * Class used to define virtual joystick (used in touch mode)
  130253. */
  130254. export class VirtualJoystick {
  130255. /**
  130256. * Gets or sets a boolean indicating that left and right values must be inverted
  130257. */
  130258. reverseLeftRight: boolean;
  130259. /**
  130260. * Gets or sets a boolean indicating that up and down values must be inverted
  130261. */
  130262. reverseUpDown: boolean;
  130263. /**
  130264. * Gets the offset value for the position (ie. the change of the position value)
  130265. */
  130266. deltaPosition: Vector3;
  130267. /**
  130268. * Gets a boolean indicating if the virtual joystick was pressed
  130269. */
  130270. pressed: boolean;
  130271. /**
  130272. * Canvas the virtual joystick will render onto, default z-index of this is 5
  130273. */
  130274. static Canvas: Nullable<HTMLCanvasElement>;
  130275. /**
  130276. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  130277. */
  130278. limitToContainer: boolean;
  130279. private static _globalJoystickIndex;
  130280. private static _alwaysVisibleSticks;
  130281. private static vjCanvasContext;
  130282. private static vjCanvasWidth;
  130283. private static vjCanvasHeight;
  130284. private static halfWidth;
  130285. private static _GetDefaultOptions;
  130286. private _action;
  130287. private _axisTargetedByLeftAndRight;
  130288. private _axisTargetedByUpAndDown;
  130289. private _joystickSensibility;
  130290. private _inversedSensibility;
  130291. private _joystickPointerID;
  130292. private _joystickColor;
  130293. private _joystickPointerPos;
  130294. private _joystickPreviousPointerPos;
  130295. private _joystickPointerStartPos;
  130296. private _deltaJoystickVector;
  130297. private _leftJoystick;
  130298. private _touches;
  130299. private _joystickPosition;
  130300. private _alwaysVisible;
  130301. private _puckImage;
  130302. private _containerImage;
  130303. private _joystickPuckSize;
  130304. private _joystickContainerSize;
  130305. private _clearPuckSize;
  130306. private _clearContainerSize;
  130307. private _clearPuckSizeOffset;
  130308. private _clearContainerSizeOffset;
  130309. private _onPointerDownHandlerRef;
  130310. private _onPointerMoveHandlerRef;
  130311. private _onPointerUpHandlerRef;
  130312. private _onResize;
  130313. /**
  130314. * Creates a new virtual joystick
  130315. * @param leftJoystick defines that the joystick is for left hand (false by default)
  130316. * @param customizations Defines the options we want to customize the VirtualJoystick
  130317. */
  130318. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  130319. /**
  130320. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  130321. * @param newJoystickSensibility defines the new sensibility
  130322. */
  130323. setJoystickSensibility(newJoystickSensibility: number): void;
  130324. private _onPointerDown;
  130325. private _onPointerMove;
  130326. private _onPointerUp;
  130327. /**
  130328. * Change the color of the virtual joystick
  130329. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  130330. */
  130331. setJoystickColor(newColor: string): void;
  130332. /**
  130333. * Size of the joystick's container
  130334. */
  130335. set containerSize(newSize: number);
  130336. get containerSize(): number;
  130337. /**
  130338. * Size of the joystick's puck
  130339. */
  130340. set puckSize(newSize: number);
  130341. get puckSize(): number;
  130342. /**
  130343. * Clears the set position of the joystick
  130344. */
  130345. clearPosition(): void;
  130346. /**
  130347. * Defines whether or not the joystick container is always visible
  130348. */
  130349. set alwaysVisible(value: boolean);
  130350. get alwaysVisible(): boolean;
  130351. /**
  130352. * Sets the constant position of the Joystick container
  130353. * @param x X axis coordinate
  130354. * @param y Y axis coordinate
  130355. */
  130356. setPosition(x: number, y: number): void;
  130357. /**
  130358. * Defines a callback to call when the joystick is touched
  130359. * @param action defines the callback
  130360. */
  130361. setActionOnTouch(action: () => any): void;
  130362. /**
  130363. * Defines which axis you'd like to control for left & right
  130364. * @param axis defines the axis to use
  130365. */
  130366. setAxisForLeftRight(axis: JoystickAxis): void;
  130367. /**
  130368. * Defines which axis you'd like to control for up & down
  130369. * @param axis defines the axis to use
  130370. */
  130371. setAxisForUpDown(axis: JoystickAxis): void;
  130372. /**
  130373. * Clears the canvas from the previous puck / container draw
  130374. */
  130375. private _clearPreviousDraw;
  130376. /**
  130377. * Loads `urlPath` to be used for the container's image
  130378. * @param urlPath defines the urlPath of an image to use
  130379. */
  130380. setContainerImage(urlPath: string): void;
  130381. /**
  130382. * Loads `urlPath` to be used for the puck's image
  130383. * @param urlPath defines the urlPath of an image to use
  130384. */
  130385. setPuckImage(urlPath: string): void;
  130386. /**
  130387. * Draws the Virtual Joystick's container
  130388. */
  130389. private _drawContainer;
  130390. /**
  130391. * Draws the Virtual Joystick's puck
  130392. */
  130393. private _drawPuck;
  130394. private _drawVirtualJoystick;
  130395. /**
  130396. * Release internal HTML canvas
  130397. */
  130398. releaseCanvas(): void;
  130399. }
  130400. }
  130401. declare module BABYLON {
  130402. interface FreeCameraInputsManager {
  130403. /**
  130404. * Add virtual joystick input support to the input manager.
  130405. * @returns the current input manager
  130406. */
  130407. addVirtualJoystick(): FreeCameraInputsManager;
  130408. }
  130409. /**
  130410. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  130411. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130412. */
  130413. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  130414. /**
  130415. * Defines the camera the input is attached to.
  130416. */
  130417. camera: FreeCamera;
  130418. private _leftjoystick;
  130419. private _rightjoystick;
  130420. /**
  130421. * Gets the left stick of the virtual joystick.
  130422. * @returns The virtual Joystick
  130423. */
  130424. getLeftJoystick(): VirtualJoystick;
  130425. /**
  130426. * Gets the right stick of the virtual joystick.
  130427. * @returns The virtual Joystick
  130428. */
  130429. getRightJoystick(): VirtualJoystick;
  130430. /**
  130431. * Update the current camera state depending on the inputs that have been used this frame.
  130432. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130433. */
  130434. checkInputs(): void;
  130435. /**
  130436. * Attach the input controls to a specific dom element to get the input from.
  130437. */
  130438. attachControl(): void;
  130439. /**
  130440. * Detach the current controls from the specified dom element.
  130441. */
  130442. detachControl(): void;
  130443. /**
  130444. * Gets the class name of the current intput.
  130445. * @returns the class name
  130446. */
  130447. getClassName(): string;
  130448. /**
  130449. * Get the friendly name associated with the input class.
  130450. * @returns the input friendly name
  130451. */
  130452. getSimpleName(): string;
  130453. }
  130454. }
  130455. declare module BABYLON {
  130456. /**
  130457. * This represents a FPS type of camera controlled by touch.
  130458. * This is like a universal camera minus the Gamepad controls.
  130459. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130460. */
  130461. export class TouchCamera extends FreeCamera {
  130462. /**
  130463. * Defines the touch sensibility for rotation.
  130464. * The higher the faster.
  130465. */
  130466. get touchAngularSensibility(): number;
  130467. set touchAngularSensibility(value: number);
  130468. /**
  130469. * Defines the touch sensibility for move.
  130470. * The higher the faster.
  130471. */
  130472. get touchMoveSensibility(): number;
  130473. set touchMoveSensibility(value: number);
  130474. /**
  130475. * Instantiates a new touch camera.
  130476. * This represents a FPS type of camera controlled by touch.
  130477. * This is like a universal camera minus the Gamepad controls.
  130478. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130479. * @param name Define the name of the camera in the scene
  130480. * @param position Define the start position of the camera in the scene
  130481. * @param scene Define the scene the camera belongs to
  130482. */
  130483. constructor(name: string, position: Vector3, scene: Scene);
  130484. /**
  130485. * Gets the current object class name.
  130486. * @return the class name
  130487. */
  130488. getClassName(): string;
  130489. /** @hidden */
  130490. _setupInputs(): void;
  130491. }
  130492. }
  130493. declare module BABYLON {
  130494. /**
  130495. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  130496. * being tilted forward or back and left or right.
  130497. */
  130498. export class DeviceOrientationCamera extends FreeCamera {
  130499. private _initialQuaternion;
  130500. private _quaternionCache;
  130501. private _tmpDragQuaternion;
  130502. private _disablePointerInputWhenUsingDeviceOrientation;
  130503. /**
  130504. * Creates a new device orientation camera
  130505. * @param name The name of the camera
  130506. * @param position The start position camera
  130507. * @param scene The scene the camera belongs to
  130508. */
  130509. constructor(name: string, position: Vector3, scene: Scene);
  130510. /**
  130511. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  130512. */
  130513. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  130514. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  130515. private _dragFactor;
  130516. /**
  130517. * Enabled turning on the y axis when the orientation sensor is active
  130518. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  130519. */
  130520. enableHorizontalDragging(dragFactor?: number): void;
  130521. /**
  130522. * Gets the current instance class name ("DeviceOrientationCamera").
  130523. * This helps avoiding instanceof at run time.
  130524. * @returns the class name
  130525. */
  130526. getClassName(): string;
  130527. /**
  130528. * @hidden
  130529. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  130530. */
  130531. _checkInputs(): void;
  130532. /**
  130533. * Reset the camera to its default orientation on the specified axis only.
  130534. * @param axis The axis to reset
  130535. */
  130536. resetToCurrentRotation(axis?: Axis): void;
  130537. }
  130538. }
  130539. declare module BABYLON {
  130540. /**
  130541. * Defines supported buttons for XBox360 compatible gamepads
  130542. */
  130543. export enum Xbox360Button {
  130544. /** A */
  130545. A = 0,
  130546. /** B */
  130547. B = 1,
  130548. /** X */
  130549. X = 2,
  130550. /** Y */
  130551. Y = 3,
  130552. /** Left button */
  130553. LB = 4,
  130554. /** Right button */
  130555. RB = 5,
  130556. /** Back */
  130557. Back = 8,
  130558. /** Start */
  130559. Start = 9,
  130560. /** Left stick */
  130561. LeftStick = 10,
  130562. /** Right stick */
  130563. RightStick = 11
  130564. }
  130565. /** Defines values for XBox360 DPad */
  130566. export enum Xbox360Dpad {
  130567. /** Up */
  130568. Up = 12,
  130569. /** Down */
  130570. Down = 13,
  130571. /** Left */
  130572. Left = 14,
  130573. /** Right */
  130574. Right = 15
  130575. }
  130576. /**
  130577. * Defines a XBox360 gamepad
  130578. */
  130579. export class Xbox360Pad extends Gamepad {
  130580. private _leftTrigger;
  130581. private _rightTrigger;
  130582. private _onlefttriggerchanged;
  130583. private _onrighttriggerchanged;
  130584. private _onbuttondown;
  130585. private _onbuttonup;
  130586. private _ondpaddown;
  130587. private _ondpadup;
  130588. /** Observable raised when a button is pressed */
  130589. onButtonDownObservable: Observable<Xbox360Button>;
  130590. /** Observable raised when a button is released */
  130591. onButtonUpObservable: Observable<Xbox360Button>;
  130592. /** Observable raised when a pad is pressed */
  130593. onPadDownObservable: Observable<Xbox360Dpad>;
  130594. /** Observable raised when a pad is released */
  130595. onPadUpObservable: Observable<Xbox360Dpad>;
  130596. private _buttonA;
  130597. private _buttonB;
  130598. private _buttonX;
  130599. private _buttonY;
  130600. private _buttonBack;
  130601. private _buttonStart;
  130602. private _buttonLB;
  130603. private _buttonRB;
  130604. private _buttonLeftStick;
  130605. private _buttonRightStick;
  130606. private _dPadUp;
  130607. private _dPadDown;
  130608. private _dPadLeft;
  130609. private _dPadRight;
  130610. private _isXboxOnePad;
  130611. /**
  130612. * Creates a new XBox360 gamepad object
  130613. * @param id defines the id of this gamepad
  130614. * @param index defines its index
  130615. * @param gamepad defines the internal HTML gamepad object
  130616. * @param xboxOne defines if it is a XBox One gamepad
  130617. */
  130618. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  130619. /**
  130620. * Defines the callback to call when left trigger is pressed
  130621. * @param callback defines the callback to use
  130622. */
  130623. onlefttriggerchanged(callback: (value: number) => void): void;
  130624. /**
  130625. * Defines the callback to call when right trigger is pressed
  130626. * @param callback defines the callback to use
  130627. */
  130628. onrighttriggerchanged(callback: (value: number) => void): void;
  130629. /**
  130630. * Gets the left trigger value
  130631. */
  130632. get leftTrigger(): number;
  130633. /**
  130634. * Sets the left trigger value
  130635. */
  130636. set leftTrigger(newValue: number);
  130637. /**
  130638. * Gets the right trigger value
  130639. */
  130640. get rightTrigger(): number;
  130641. /**
  130642. * Sets the right trigger value
  130643. */
  130644. set rightTrigger(newValue: number);
  130645. /**
  130646. * Defines the callback to call when a button is pressed
  130647. * @param callback defines the callback to use
  130648. */
  130649. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  130650. /**
  130651. * Defines the callback to call when a button is released
  130652. * @param callback defines the callback to use
  130653. */
  130654. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  130655. /**
  130656. * Defines the callback to call when a pad is pressed
  130657. * @param callback defines the callback to use
  130658. */
  130659. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  130660. /**
  130661. * Defines the callback to call when a pad is released
  130662. * @param callback defines the callback to use
  130663. */
  130664. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  130665. private _setButtonValue;
  130666. private _setDPadValue;
  130667. /**
  130668. * Gets the value of the `A` button
  130669. */
  130670. get buttonA(): number;
  130671. /**
  130672. * Sets the value of the `A` button
  130673. */
  130674. set buttonA(value: number);
  130675. /**
  130676. * Gets the value of the `B` button
  130677. */
  130678. get buttonB(): number;
  130679. /**
  130680. * Sets the value of the `B` button
  130681. */
  130682. set buttonB(value: number);
  130683. /**
  130684. * Gets the value of the `X` button
  130685. */
  130686. get buttonX(): number;
  130687. /**
  130688. * Sets the value of the `X` button
  130689. */
  130690. set buttonX(value: number);
  130691. /**
  130692. * Gets the value of the `Y` button
  130693. */
  130694. get buttonY(): number;
  130695. /**
  130696. * Sets the value of the `Y` button
  130697. */
  130698. set buttonY(value: number);
  130699. /**
  130700. * Gets the value of the `Start` button
  130701. */
  130702. get buttonStart(): number;
  130703. /**
  130704. * Sets the value of the `Start` button
  130705. */
  130706. set buttonStart(value: number);
  130707. /**
  130708. * Gets the value of the `Back` button
  130709. */
  130710. get buttonBack(): number;
  130711. /**
  130712. * Sets the value of the `Back` button
  130713. */
  130714. set buttonBack(value: number);
  130715. /**
  130716. * Gets the value of the `Left` button
  130717. */
  130718. get buttonLB(): number;
  130719. /**
  130720. * Sets the value of the `Left` button
  130721. */
  130722. set buttonLB(value: number);
  130723. /**
  130724. * Gets the value of the `Right` button
  130725. */
  130726. get buttonRB(): number;
  130727. /**
  130728. * Sets the value of the `Right` button
  130729. */
  130730. set buttonRB(value: number);
  130731. /**
  130732. * Gets the value of the Left joystick
  130733. */
  130734. get buttonLeftStick(): number;
  130735. /**
  130736. * Sets the value of the Left joystick
  130737. */
  130738. set buttonLeftStick(value: number);
  130739. /**
  130740. * Gets the value of the Right joystick
  130741. */
  130742. get buttonRightStick(): number;
  130743. /**
  130744. * Sets the value of the Right joystick
  130745. */
  130746. set buttonRightStick(value: number);
  130747. /**
  130748. * Gets the value of D-pad up
  130749. */
  130750. get dPadUp(): number;
  130751. /**
  130752. * Sets the value of D-pad up
  130753. */
  130754. set dPadUp(value: number);
  130755. /**
  130756. * Gets the value of D-pad down
  130757. */
  130758. get dPadDown(): number;
  130759. /**
  130760. * Sets the value of D-pad down
  130761. */
  130762. set dPadDown(value: number);
  130763. /**
  130764. * Gets the value of D-pad left
  130765. */
  130766. get dPadLeft(): number;
  130767. /**
  130768. * Sets the value of D-pad left
  130769. */
  130770. set dPadLeft(value: number);
  130771. /**
  130772. * Gets the value of D-pad right
  130773. */
  130774. get dPadRight(): number;
  130775. /**
  130776. * Sets the value of D-pad right
  130777. */
  130778. set dPadRight(value: number);
  130779. /**
  130780. * Force the gamepad to synchronize with device values
  130781. */
  130782. update(): void;
  130783. /**
  130784. * Disposes the gamepad
  130785. */
  130786. dispose(): void;
  130787. }
  130788. }
  130789. declare module BABYLON {
  130790. /**
  130791. * Defines supported buttons for DualShock compatible gamepads
  130792. */
  130793. export enum DualShockButton {
  130794. /** Cross */
  130795. Cross = 0,
  130796. /** Circle */
  130797. Circle = 1,
  130798. /** Square */
  130799. Square = 2,
  130800. /** Triangle */
  130801. Triangle = 3,
  130802. /** L1 */
  130803. L1 = 4,
  130804. /** R1 */
  130805. R1 = 5,
  130806. /** Share */
  130807. Share = 8,
  130808. /** Options */
  130809. Options = 9,
  130810. /** Left stick */
  130811. LeftStick = 10,
  130812. /** Right stick */
  130813. RightStick = 11
  130814. }
  130815. /** Defines values for DualShock DPad */
  130816. export enum DualShockDpad {
  130817. /** Up */
  130818. Up = 12,
  130819. /** Down */
  130820. Down = 13,
  130821. /** Left */
  130822. Left = 14,
  130823. /** Right */
  130824. Right = 15
  130825. }
  130826. /**
  130827. * Defines a DualShock gamepad
  130828. */
  130829. export class DualShockPad extends Gamepad {
  130830. private _leftTrigger;
  130831. private _rightTrigger;
  130832. private _onlefttriggerchanged;
  130833. private _onrighttriggerchanged;
  130834. private _onbuttondown;
  130835. private _onbuttonup;
  130836. private _ondpaddown;
  130837. private _ondpadup;
  130838. /** Observable raised when a button is pressed */
  130839. onButtonDownObservable: Observable<DualShockButton>;
  130840. /** Observable raised when a button is released */
  130841. onButtonUpObservable: Observable<DualShockButton>;
  130842. /** Observable raised when a pad is pressed */
  130843. onPadDownObservable: Observable<DualShockDpad>;
  130844. /** Observable raised when a pad is released */
  130845. onPadUpObservable: Observable<DualShockDpad>;
  130846. private _buttonCross;
  130847. private _buttonCircle;
  130848. private _buttonSquare;
  130849. private _buttonTriangle;
  130850. private _buttonShare;
  130851. private _buttonOptions;
  130852. private _buttonL1;
  130853. private _buttonR1;
  130854. private _buttonLeftStick;
  130855. private _buttonRightStick;
  130856. private _dPadUp;
  130857. private _dPadDown;
  130858. private _dPadLeft;
  130859. private _dPadRight;
  130860. /**
  130861. * Creates a new DualShock gamepad object
  130862. * @param id defines the id of this gamepad
  130863. * @param index defines its index
  130864. * @param gamepad defines the internal HTML gamepad object
  130865. */
  130866. constructor(id: string, index: number, gamepad: any);
  130867. /**
  130868. * Defines the callback to call when left trigger is pressed
  130869. * @param callback defines the callback to use
  130870. */
  130871. onlefttriggerchanged(callback: (value: number) => void): void;
  130872. /**
  130873. * Defines the callback to call when right trigger is pressed
  130874. * @param callback defines the callback to use
  130875. */
  130876. onrighttriggerchanged(callback: (value: number) => void): void;
  130877. /**
  130878. * Gets the left trigger value
  130879. */
  130880. get leftTrigger(): number;
  130881. /**
  130882. * Sets the left trigger value
  130883. */
  130884. set leftTrigger(newValue: number);
  130885. /**
  130886. * Gets the right trigger value
  130887. */
  130888. get rightTrigger(): number;
  130889. /**
  130890. * Sets the right trigger value
  130891. */
  130892. set rightTrigger(newValue: number);
  130893. /**
  130894. * Defines the callback to call when a button is pressed
  130895. * @param callback defines the callback to use
  130896. */
  130897. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  130898. /**
  130899. * Defines the callback to call when a button is released
  130900. * @param callback defines the callback to use
  130901. */
  130902. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  130903. /**
  130904. * Defines the callback to call when a pad is pressed
  130905. * @param callback defines the callback to use
  130906. */
  130907. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  130908. /**
  130909. * Defines the callback to call when a pad is released
  130910. * @param callback defines the callback to use
  130911. */
  130912. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  130913. private _setButtonValue;
  130914. private _setDPadValue;
  130915. /**
  130916. * Gets the value of the `Cross` button
  130917. */
  130918. get buttonCross(): number;
  130919. /**
  130920. * Sets the value of the `Cross` button
  130921. */
  130922. set buttonCross(value: number);
  130923. /**
  130924. * Gets the value of the `Circle` button
  130925. */
  130926. get buttonCircle(): number;
  130927. /**
  130928. * Sets the value of the `Circle` button
  130929. */
  130930. set buttonCircle(value: number);
  130931. /**
  130932. * Gets the value of the `Square` button
  130933. */
  130934. get buttonSquare(): number;
  130935. /**
  130936. * Sets the value of the `Square` button
  130937. */
  130938. set buttonSquare(value: number);
  130939. /**
  130940. * Gets the value of the `Triangle` button
  130941. */
  130942. get buttonTriangle(): number;
  130943. /**
  130944. * Sets the value of the `Triangle` button
  130945. */
  130946. set buttonTriangle(value: number);
  130947. /**
  130948. * Gets the value of the `Options` button
  130949. */
  130950. get buttonOptions(): number;
  130951. /**
  130952. * Sets the value of the `Options` button
  130953. */
  130954. set buttonOptions(value: number);
  130955. /**
  130956. * Gets the value of the `Share` button
  130957. */
  130958. get buttonShare(): number;
  130959. /**
  130960. * Sets the value of the `Share` button
  130961. */
  130962. set buttonShare(value: number);
  130963. /**
  130964. * Gets the value of the `L1` button
  130965. */
  130966. get buttonL1(): number;
  130967. /**
  130968. * Sets the value of the `L1` button
  130969. */
  130970. set buttonL1(value: number);
  130971. /**
  130972. * Gets the value of the `R1` button
  130973. */
  130974. get buttonR1(): number;
  130975. /**
  130976. * Sets the value of the `R1` button
  130977. */
  130978. set buttonR1(value: number);
  130979. /**
  130980. * Gets the value of the Left joystick
  130981. */
  130982. get buttonLeftStick(): number;
  130983. /**
  130984. * Sets the value of the Left joystick
  130985. */
  130986. set buttonLeftStick(value: number);
  130987. /**
  130988. * Gets the value of the Right joystick
  130989. */
  130990. get buttonRightStick(): number;
  130991. /**
  130992. * Sets the value of the Right joystick
  130993. */
  130994. set buttonRightStick(value: number);
  130995. /**
  130996. * Gets the value of D-pad up
  130997. */
  130998. get dPadUp(): number;
  130999. /**
  131000. * Sets the value of D-pad up
  131001. */
  131002. set dPadUp(value: number);
  131003. /**
  131004. * Gets the value of D-pad down
  131005. */
  131006. get dPadDown(): number;
  131007. /**
  131008. * Sets the value of D-pad down
  131009. */
  131010. set dPadDown(value: number);
  131011. /**
  131012. * Gets the value of D-pad left
  131013. */
  131014. get dPadLeft(): number;
  131015. /**
  131016. * Sets the value of D-pad left
  131017. */
  131018. set dPadLeft(value: number);
  131019. /**
  131020. * Gets the value of D-pad right
  131021. */
  131022. get dPadRight(): number;
  131023. /**
  131024. * Sets the value of D-pad right
  131025. */
  131026. set dPadRight(value: number);
  131027. /**
  131028. * Force the gamepad to synchronize with device values
  131029. */
  131030. update(): void;
  131031. /**
  131032. * Disposes the gamepad
  131033. */
  131034. dispose(): void;
  131035. }
  131036. }
  131037. declare module BABYLON {
  131038. /**
  131039. * Manager for handling gamepads
  131040. */
  131041. export class GamepadManager {
  131042. private _scene?;
  131043. private _babylonGamepads;
  131044. private _oneGamepadConnected;
  131045. /** @hidden */
  131046. _isMonitoring: boolean;
  131047. private _gamepadEventSupported;
  131048. private _gamepadSupport?;
  131049. /**
  131050. * observable to be triggered when the gamepad controller has been connected
  131051. */
  131052. onGamepadConnectedObservable: Observable<Gamepad>;
  131053. /**
  131054. * observable to be triggered when the gamepad controller has been disconnected
  131055. */
  131056. onGamepadDisconnectedObservable: Observable<Gamepad>;
  131057. private _onGamepadConnectedEvent;
  131058. private _onGamepadDisconnectedEvent;
  131059. /**
  131060. * Initializes the gamepad manager
  131061. * @param _scene BabylonJS scene
  131062. */
  131063. constructor(_scene?: Scene | undefined);
  131064. /**
  131065. * The gamepads in the game pad manager
  131066. */
  131067. get gamepads(): Gamepad[];
  131068. /**
  131069. * Get the gamepad controllers based on type
  131070. * @param type The type of gamepad controller
  131071. * @returns Nullable gamepad
  131072. */
  131073. getGamepadByType(type?: number): Nullable<Gamepad>;
  131074. /**
  131075. * Disposes the gamepad manager
  131076. */
  131077. dispose(): void;
  131078. private _addNewGamepad;
  131079. private _startMonitoringGamepads;
  131080. private _stopMonitoringGamepads;
  131081. /** @hidden */
  131082. _checkGamepadsStatus(): void;
  131083. private _updateGamepadObjects;
  131084. }
  131085. }
  131086. declare module BABYLON {
  131087. interface Scene {
  131088. /** @hidden */
  131089. _gamepadManager: Nullable<GamepadManager>;
  131090. /**
  131091. * Gets the gamepad manager associated with the scene
  131092. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  131093. */
  131094. gamepadManager: GamepadManager;
  131095. }
  131096. /**
  131097. * Interface representing a free camera inputs manager
  131098. */
  131099. interface FreeCameraInputsManager {
  131100. /**
  131101. * Adds gamepad input support to the FreeCameraInputsManager.
  131102. * @returns the FreeCameraInputsManager
  131103. */
  131104. addGamepad(): FreeCameraInputsManager;
  131105. }
  131106. /**
  131107. * Interface representing an arc rotate camera inputs manager
  131108. */
  131109. interface ArcRotateCameraInputsManager {
  131110. /**
  131111. * Adds gamepad input support to the ArcRotateCamera InputManager.
  131112. * @returns the camera inputs manager
  131113. */
  131114. addGamepad(): ArcRotateCameraInputsManager;
  131115. }
  131116. /**
  131117. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  131118. */
  131119. export class GamepadSystemSceneComponent implements ISceneComponent {
  131120. /**
  131121. * The component name helpfull to identify the component in the list of scene components.
  131122. */
  131123. readonly name: string;
  131124. /**
  131125. * The scene the component belongs to.
  131126. */
  131127. scene: Scene;
  131128. /**
  131129. * Creates a new instance of the component for the given scene
  131130. * @param scene Defines the scene to register the component in
  131131. */
  131132. constructor(scene: Scene);
  131133. /**
  131134. * Registers the component in a given scene
  131135. */
  131136. register(): void;
  131137. /**
  131138. * Rebuilds the elements related to this component in case of
  131139. * context lost for instance.
  131140. */
  131141. rebuild(): void;
  131142. /**
  131143. * Disposes the component and the associated ressources
  131144. */
  131145. dispose(): void;
  131146. private _beforeCameraUpdate;
  131147. }
  131148. }
  131149. declare module BABYLON {
  131150. /**
  131151. * 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,
  131152. * which still works and will still be found in many Playgrounds.
  131153. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131154. */
  131155. export class UniversalCamera extends TouchCamera {
  131156. /**
  131157. * Defines the gamepad rotation sensiblity.
  131158. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  131159. */
  131160. get gamepadAngularSensibility(): number;
  131161. set gamepadAngularSensibility(value: number);
  131162. /**
  131163. * Defines the gamepad move sensiblity.
  131164. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  131165. */
  131166. get gamepadMoveSensibility(): number;
  131167. set gamepadMoveSensibility(value: number);
  131168. /**
  131169. * 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,
  131170. * which still works and will still be found in many Playgrounds.
  131171. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131172. * @param name Define the name of the camera in the scene
  131173. * @param position Define the start position of the camera in the scene
  131174. * @param scene Define the scene the camera belongs to
  131175. */
  131176. constructor(name: string, position: Vector3, scene: Scene);
  131177. /**
  131178. * Gets the current object class name.
  131179. * @return the class name
  131180. */
  131181. getClassName(): string;
  131182. }
  131183. }
  131184. declare module BABYLON {
  131185. /**
  131186. * This represents a FPS type of camera. This is only here for back compat purpose.
  131187. * Please use the UniversalCamera instead as both are identical.
  131188. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131189. */
  131190. export class GamepadCamera extends UniversalCamera {
  131191. /**
  131192. * Instantiates a new Gamepad Camera
  131193. * This represents a FPS type of camera. This is only here for back compat purpose.
  131194. * Please use the UniversalCamera instead as both are identical.
  131195. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131196. * @param name Define the name of the camera in the scene
  131197. * @param position Define the start position of the camera in the scene
  131198. * @param scene Define the scene the camera belongs to
  131199. */
  131200. constructor(name: string, position: Vector3, scene: Scene);
  131201. /**
  131202. * Gets the current object class name.
  131203. * @return the class name
  131204. */
  131205. getClassName(): string;
  131206. }
  131207. }
  131208. declare module BABYLON {
  131209. /** @hidden */
  131210. export var passPixelShader: {
  131211. name: string;
  131212. shader: string;
  131213. };
  131214. }
  131215. declare module BABYLON {
  131216. /** @hidden */
  131217. export var passCubePixelShader: {
  131218. name: string;
  131219. shader: string;
  131220. };
  131221. }
  131222. declare module BABYLON {
  131223. /**
  131224. * PassPostProcess which produces an output the same as it's input
  131225. */
  131226. export class PassPostProcess extends PostProcess {
  131227. /**
  131228. * Gets a string identifying the name of the class
  131229. * @returns "PassPostProcess" string
  131230. */
  131231. getClassName(): string;
  131232. /**
  131233. * Creates the PassPostProcess
  131234. * @param name The name of the effect.
  131235. * @param options The required width/height ratio to downsize to before computing the render pass.
  131236. * @param camera The camera to apply the render pass to.
  131237. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131238. * @param engine The engine which the post process will be applied. (default: current engine)
  131239. * @param reusable If the post process can be reused on the same frame. (default: false)
  131240. * @param textureType The type of texture to be used when performing the post processing.
  131241. * @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)
  131242. */
  131243. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131244. /** @hidden */
  131245. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  131246. }
  131247. /**
  131248. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  131249. */
  131250. export class PassCubePostProcess extends PostProcess {
  131251. private _face;
  131252. /**
  131253. * Gets or sets the cube face to display.
  131254. * * 0 is +X
  131255. * * 1 is -X
  131256. * * 2 is +Y
  131257. * * 3 is -Y
  131258. * * 4 is +Z
  131259. * * 5 is -Z
  131260. */
  131261. get face(): number;
  131262. set face(value: number);
  131263. /**
  131264. * Gets a string identifying the name of the class
  131265. * @returns "PassCubePostProcess" string
  131266. */
  131267. getClassName(): string;
  131268. /**
  131269. * Creates the PassCubePostProcess
  131270. * @param name The name of the effect.
  131271. * @param options The required width/height ratio to downsize to before computing the render pass.
  131272. * @param camera The camera to apply the render pass to.
  131273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131274. * @param engine The engine which the post process will be applied. (default: current engine)
  131275. * @param reusable If the post process can be reused on the same frame. (default: false)
  131276. * @param textureType The type of texture to be used when performing the post processing.
  131277. * @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)
  131278. */
  131279. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131280. /** @hidden */
  131281. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  131282. }
  131283. }
  131284. declare module BABYLON {
  131285. /** @hidden */
  131286. export var anaglyphPixelShader: {
  131287. name: string;
  131288. shader: string;
  131289. };
  131290. }
  131291. declare module BABYLON {
  131292. /**
  131293. * Postprocess used to generate anaglyphic rendering
  131294. */
  131295. export class AnaglyphPostProcess extends PostProcess {
  131296. private _passedProcess;
  131297. /**
  131298. * Gets a string identifying the name of the class
  131299. * @returns "AnaglyphPostProcess" string
  131300. */
  131301. getClassName(): string;
  131302. /**
  131303. * Creates a new AnaglyphPostProcess
  131304. * @param name defines postprocess name
  131305. * @param options defines creation options or target ratio scale
  131306. * @param rigCameras defines cameras using this postprocess
  131307. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  131308. * @param engine defines hosting engine
  131309. * @param reusable defines if the postprocess will be reused multiple times per frame
  131310. */
  131311. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  131312. }
  131313. }
  131314. declare module BABYLON {
  131315. /**
  131316. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  131317. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131318. */
  131319. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  131320. /**
  131321. * Creates a new AnaglyphArcRotateCamera
  131322. * @param name defines camera name
  131323. * @param alpha defines alpha angle (in radians)
  131324. * @param beta defines beta angle (in radians)
  131325. * @param radius defines radius
  131326. * @param target defines camera target
  131327. * @param interaxialDistance defines distance between each color axis
  131328. * @param scene defines the hosting scene
  131329. */
  131330. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  131331. /**
  131332. * Gets camera class name
  131333. * @returns AnaglyphArcRotateCamera
  131334. */
  131335. getClassName(): string;
  131336. }
  131337. }
  131338. declare module BABYLON {
  131339. /**
  131340. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  131341. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131342. */
  131343. export class AnaglyphFreeCamera extends FreeCamera {
  131344. /**
  131345. * Creates a new AnaglyphFreeCamera
  131346. * @param name defines camera name
  131347. * @param position defines initial position
  131348. * @param interaxialDistance defines distance between each color axis
  131349. * @param scene defines the hosting scene
  131350. */
  131351. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131352. /**
  131353. * Gets camera class name
  131354. * @returns AnaglyphFreeCamera
  131355. */
  131356. getClassName(): string;
  131357. }
  131358. }
  131359. declare module BABYLON {
  131360. /**
  131361. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  131362. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131363. */
  131364. export class AnaglyphGamepadCamera extends GamepadCamera {
  131365. /**
  131366. * Creates a new AnaglyphGamepadCamera
  131367. * @param name defines camera name
  131368. * @param position defines initial position
  131369. * @param interaxialDistance defines distance between each color axis
  131370. * @param scene defines the hosting scene
  131371. */
  131372. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131373. /**
  131374. * Gets camera class name
  131375. * @returns AnaglyphGamepadCamera
  131376. */
  131377. getClassName(): string;
  131378. }
  131379. }
  131380. declare module BABYLON {
  131381. /**
  131382. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  131383. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131384. */
  131385. export class AnaglyphUniversalCamera extends UniversalCamera {
  131386. /**
  131387. * Creates a new AnaglyphUniversalCamera
  131388. * @param name defines camera name
  131389. * @param position defines initial position
  131390. * @param interaxialDistance defines distance between each color axis
  131391. * @param scene defines the hosting scene
  131392. */
  131393. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131394. /**
  131395. * Gets camera class name
  131396. * @returns AnaglyphUniversalCamera
  131397. */
  131398. getClassName(): string;
  131399. }
  131400. }
  131401. declare module BABYLON {
  131402. /**
  131403. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  131404. * @see https://doc.babylonjs.com/features/cameras
  131405. */
  131406. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  131407. /**
  131408. * Creates a new StereoscopicArcRotateCamera
  131409. * @param name defines camera name
  131410. * @param alpha defines alpha angle (in radians)
  131411. * @param beta defines beta angle (in radians)
  131412. * @param radius defines radius
  131413. * @param target defines camera target
  131414. * @param interaxialDistance defines distance between each color axis
  131415. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131416. * @param scene defines the hosting scene
  131417. */
  131418. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131419. /**
  131420. * Gets camera class name
  131421. * @returns StereoscopicArcRotateCamera
  131422. */
  131423. getClassName(): string;
  131424. }
  131425. }
  131426. declare module BABYLON {
  131427. /**
  131428. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  131429. * @see https://doc.babylonjs.com/features/cameras
  131430. */
  131431. export class StereoscopicFreeCamera extends FreeCamera {
  131432. /**
  131433. * Creates a new StereoscopicFreeCamera
  131434. * @param name defines camera name
  131435. * @param position defines initial position
  131436. * @param interaxialDistance defines distance between each color axis
  131437. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131438. * @param scene defines the hosting scene
  131439. */
  131440. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131441. /**
  131442. * Gets camera class name
  131443. * @returns StereoscopicFreeCamera
  131444. */
  131445. getClassName(): string;
  131446. }
  131447. }
  131448. declare module BABYLON {
  131449. /**
  131450. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  131451. * @see https://doc.babylonjs.com/features/cameras
  131452. */
  131453. export class StereoscopicGamepadCamera extends GamepadCamera {
  131454. /**
  131455. * Creates a new StereoscopicGamepadCamera
  131456. * @param name defines camera name
  131457. * @param position defines initial position
  131458. * @param interaxialDistance defines distance between each color axis
  131459. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131460. * @param scene defines the hosting scene
  131461. */
  131462. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131463. /**
  131464. * Gets camera class name
  131465. * @returns StereoscopicGamepadCamera
  131466. */
  131467. getClassName(): string;
  131468. }
  131469. }
  131470. declare module BABYLON {
  131471. /**
  131472. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  131473. * @see https://doc.babylonjs.com/features/cameras
  131474. */
  131475. export class StereoscopicUniversalCamera extends UniversalCamera {
  131476. /**
  131477. * Creates a new StereoscopicUniversalCamera
  131478. * @param name defines camera name
  131479. * @param position defines initial position
  131480. * @param interaxialDistance defines distance between each color axis
  131481. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131482. * @param scene defines the hosting scene
  131483. */
  131484. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131485. /**
  131486. * Gets camera class name
  131487. * @returns StereoscopicUniversalCamera
  131488. */
  131489. getClassName(): string;
  131490. }
  131491. }
  131492. declare module BABYLON {
  131493. /**
  131494. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  131495. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  131496. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  131497. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  131498. */
  131499. export class VirtualJoysticksCamera extends FreeCamera {
  131500. /**
  131501. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  131502. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  131503. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  131504. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  131505. * @param name Define the name of the camera in the scene
  131506. * @param position Define the start position of the camera in the scene
  131507. * @param scene Define the scene the camera belongs to
  131508. */
  131509. constructor(name: string, position: Vector3, scene: Scene);
  131510. /**
  131511. * Gets the current object class name.
  131512. * @return the class name
  131513. */
  131514. getClassName(): string;
  131515. }
  131516. }
  131517. declare module BABYLON {
  131518. /**
  131519. * This represents all the required metrics to create a VR camera.
  131520. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  131521. */
  131522. export class VRCameraMetrics {
  131523. /**
  131524. * Define the horizontal resolution off the screen.
  131525. */
  131526. hResolution: number;
  131527. /**
  131528. * Define the vertical resolution off the screen.
  131529. */
  131530. vResolution: number;
  131531. /**
  131532. * Define the horizontal screen size.
  131533. */
  131534. hScreenSize: number;
  131535. /**
  131536. * Define the vertical screen size.
  131537. */
  131538. vScreenSize: number;
  131539. /**
  131540. * Define the vertical screen center position.
  131541. */
  131542. vScreenCenter: number;
  131543. /**
  131544. * Define the distance of the eyes to the screen.
  131545. */
  131546. eyeToScreenDistance: number;
  131547. /**
  131548. * Define the distance between both lenses
  131549. */
  131550. lensSeparationDistance: number;
  131551. /**
  131552. * Define the distance between both viewer's eyes.
  131553. */
  131554. interpupillaryDistance: number;
  131555. /**
  131556. * Define the distortion factor of the VR postprocess.
  131557. * Please, touch with care.
  131558. */
  131559. distortionK: number[];
  131560. /**
  131561. * Define the chromatic aberration correction factors for the VR post process.
  131562. */
  131563. chromaAbCorrection: number[];
  131564. /**
  131565. * Define the scale factor of the post process.
  131566. * The smaller the better but the slower.
  131567. */
  131568. postProcessScaleFactor: number;
  131569. /**
  131570. * Define an offset for the lens center.
  131571. */
  131572. lensCenterOffset: number;
  131573. /**
  131574. * Define if the current vr camera should compensate the distortion of the lense or not.
  131575. */
  131576. compensateDistortion: boolean;
  131577. /**
  131578. * Defines if multiview should be enabled when rendering (Default: false)
  131579. */
  131580. multiviewEnabled: boolean;
  131581. /**
  131582. * Gets the rendering aspect ratio based on the provided resolutions.
  131583. */
  131584. get aspectRatio(): number;
  131585. /**
  131586. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  131587. */
  131588. get aspectRatioFov(): number;
  131589. /**
  131590. * @hidden
  131591. */
  131592. get leftHMatrix(): Matrix;
  131593. /**
  131594. * @hidden
  131595. */
  131596. get rightHMatrix(): Matrix;
  131597. /**
  131598. * @hidden
  131599. */
  131600. get leftPreViewMatrix(): Matrix;
  131601. /**
  131602. * @hidden
  131603. */
  131604. get rightPreViewMatrix(): Matrix;
  131605. /**
  131606. * Get the default VRMetrics based on the most generic setup.
  131607. * @returns the default vr metrics
  131608. */
  131609. static GetDefault(): VRCameraMetrics;
  131610. }
  131611. }
  131612. declare module BABYLON {
  131613. /** @hidden */
  131614. export var vrDistortionCorrectionPixelShader: {
  131615. name: string;
  131616. shader: string;
  131617. };
  131618. }
  131619. declare module BABYLON {
  131620. /**
  131621. * VRDistortionCorrectionPostProcess used for mobile VR
  131622. */
  131623. export class VRDistortionCorrectionPostProcess extends PostProcess {
  131624. private _isRightEye;
  131625. private _distortionFactors;
  131626. private _postProcessScaleFactor;
  131627. private _lensCenterOffset;
  131628. private _scaleIn;
  131629. private _scaleFactor;
  131630. private _lensCenter;
  131631. /**
  131632. * Gets a string identifying the name of the class
  131633. * @returns "VRDistortionCorrectionPostProcess" string
  131634. */
  131635. getClassName(): string;
  131636. /**
  131637. * Initializes the VRDistortionCorrectionPostProcess
  131638. * @param name The name of the effect.
  131639. * @param camera The camera to apply the render pass to.
  131640. * @param isRightEye If this is for the right eye distortion
  131641. * @param vrMetrics All the required metrics for the VR camera
  131642. */
  131643. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  131644. }
  131645. }
  131646. declare module BABYLON {
  131647. /**
  131648. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  131649. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131650. */
  131651. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  131652. /**
  131653. * Creates a new VRDeviceOrientationArcRotateCamera
  131654. * @param name defines camera name
  131655. * @param alpha defines the camera rotation along the logitudinal axis
  131656. * @param beta defines the camera rotation along the latitudinal axis
  131657. * @param radius defines the camera distance from its target
  131658. * @param target defines the camera target
  131659. * @param scene defines the scene the camera belongs to
  131660. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131661. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131662. */
  131663. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131664. /**
  131665. * Gets camera class name
  131666. * @returns VRDeviceOrientationArcRotateCamera
  131667. */
  131668. getClassName(): string;
  131669. }
  131670. }
  131671. declare module BABYLON {
  131672. /**
  131673. * Camera used to simulate VR rendering (based on FreeCamera)
  131674. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131675. */
  131676. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  131677. /**
  131678. * Creates a new VRDeviceOrientationFreeCamera
  131679. * @param name defines camera name
  131680. * @param position defines the start position of the camera
  131681. * @param scene defines the scene the camera belongs to
  131682. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131683. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131684. */
  131685. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131686. /**
  131687. * Gets camera class name
  131688. * @returns VRDeviceOrientationFreeCamera
  131689. */
  131690. getClassName(): string;
  131691. }
  131692. }
  131693. declare module BABYLON {
  131694. /**
  131695. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  131696. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131697. */
  131698. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  131699. /**
  131700. * Creates a new VRDeviceOrientationGamepadCamera
  131701. * @param name defines camera name
  131702. * @param position defines the start position of the camera
  131703. * @param scene defines the scene the camera belongs to
  131704. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131705. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131706. */
  131707. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131708. /**
  131709. * Gets camera class name
  131710. * @returns VRDeviceOrientationGamepadCamera
  131711. */
  131712. getClassName(): string;
  131713. }
  131714. }
  131715. declare module BABYLON {
  131716. /**
  131717. * A class extending Texture allowing drawing on a texture
  131718. * @see https://doc.babylonjs.com/how_to/dynamictexture
  131719. */
  131720. export class DynamicTexture extends Texture {
  131721. private _generateMipMaps;
  131722. private _canvas;
  131723. private _context;
  131724. /**
  131725. * Creates a DynamicTexture
  131726. * @param name defines the name of the texture
  131727. * @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
  131728. * @param scene defines the scene where you want the texture
  131729. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  131730. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131731. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  131732. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  131733. */
  131734. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  131735. /**
  131736. * Get the current class name of the texture useful for serialization or dynamic coding.
  131737. * @returns "DynamicTexture"
  131738. */
  131739. getClassName(): string;
  131740. /**
  131741. * Gets the current state of canRescale
  131742. */
  131743. get canRescale(): boolean;
  131744. private _recreate;
  131745. /**
  131746. * Scales the texture
  131747. * @param ratio the scale factor to apply to both width and height
  131748. */
  131749. scale(ratio: number): void;
  131750. /**
  131751. * Resizes the texture
  131752. * @param width the new width
  131753. * @param height the new height
  131754. */
  131755. scaleTo(width: number, height: number): void;
  131756. /**
  131757. * Gets the context of the canvas used by the texture
  131758. * @returns the canvas context of the dynamic texture
  131759. */
  131760. getContext(): CanvasRenderingContext2D;
  131761. /**
  131762. * Clears the texture
  131763. */
  131764. clear(): void;
  131765. /**
  131766. * Updates the texture
  131767. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131768. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  131769. */
  131770. update(invertY?: boolean, premulAlpha?: boolean): void;
  131771. /**
  131772. * Draws text onto the texture
  131773. * @param text defines the text to be drawn
  131774. * @param x defines the placement of the text from the left
  131775. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  131776. * @param font defines the font to be used with font-style, font-size, font-name
  131777. * @param color defines the color used for the text
  131778. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  131779. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131780. * @param update defines whether texture is immediately update (default is true)
  131781. */
  131782. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  131783. /**
  131784. * Clones the texture
  131785. * @returns the clone of the texture.
  131786. */
  131787. clone(): DynamicTexture;
  131788. /**
  131789. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  131790. * @returns a serialized dynamic texture object
  131791. */
  131792. serialize(): any;
  131793. private _IsCanvasElement;
  131794. /** @hidden */
  131795. _rebuild(): void;
  131796. }
  131797. }
  131798. declare module BABYLON {
  131799. /**
  131800. * Class containing static functions to help procedurally build meshes
  131801. */
  131802. export class GroundBuilder {
  131803. /**
  131804. * Creates a ground mesh
  131805. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  131806. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  131807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131808. * @param name defines the name of the mesh
  131809. * @param options defines the options used to create the mesh
  131810. * @param scene defines the hosting scene
  131811. * @returns the ground mesh
  131812. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  131813. */
  131814. static CreateGround(name: string, options: {
  131815. width?: number;
  131816. height?: number;
  131817. subdivisions?: number;
  131818. subdivisionsX?: number;
  131819. subdivisionsY?: number;
  131820. updatable?: boolean;
  131821. }, scene: any): Mesh;
  131822. /**
  131823. * Creates a tiled ground mesh
  131824. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  131825. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  131826. * * 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
  131827. * * 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
  131828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131829. * @param name defines the name of the mesh
  131830. * @param options defines the options used to create the mesh
  131831. * @param scene defines the hosting scene
  131832. * @returns the tiled ground mesh
  131833. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  131834. */
  131835. static CreateTiledGround(name: string, options: {
  131836. xmin: number;
  131837. zmin: number;
  131838. xmax: number;
  131839. zmax: number;
  131840. subdivisions?: {
  131841. w: number;
  131842. h: number;
  131843. };
  131844. precision?: {
  131845. w: number;
  131846. h: number;
  131847. };
  131848. updatable?: boolean;
  131849. }, scene?: Nullable<Scene>): Mesh;
  131850. /**
  131851. * Creates a ground mesh from a height map
  131852. * * The parameter `url` sets the URL of the height map image resource.
  131853. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  131854. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  131855. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  131856. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  131857. * * 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.
  131858. * * 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).
  131859. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  131860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131861. * @param name defines the name of the mesh
  131862. * @param url defines the url to the height map
  131863. * @param options defines the options used to create the mesh
  131864. * @param scene defines the hosting scene
  131865. * @returns the ground mesh
  131866. * @see https://doc.babylonjs.com/babylon101/height_map
  131867. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  131868. */
  131869. static CreateGroundFromHeightMap(name: string, url: string, options: {
  131870. width?: number;
  131871. height?: number;
  131872. subdivisions?: number;
  131873. minHeight?: number;
  131874. maxHeight?: number;
  131875. colorFilter?: Color3;
  131876. alphaFilter?: number;
  131877. updatable?: boolean;
  131878. onReady?: (mesh: GroundMesh) => void;
  131879. }, scene?: Nullable<Scene>): GroundMesh;
  131880. }
  131881. }
  131882. declare module BABYLON {
  131883. /**
  131884. * Class containing static functions to help procedurally build meshes
  131885. */
  131886. export class TorusBuilder {
  131887. /**
  131888. * Creates a torus mesh
  131889. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  131890. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  131891. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  131892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131895. * @param name defines the name of the mesh
  131896. * @param options defines the options used to create the mesh
  131897. * @param scene defines the hosting scene
  131898. * @returns the torus mesh
  131899. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  131900. */
  131901. static CreateTorus(name: string, options: {
  131902. diameter?: number;
  131903. thickness?: number;
  131904. tessellation?: number;
  131905. updatable?: boolean;
  131906. sideOrientation?: number;
  131907. frontUVs?: Vector4;
  131908. backUVs?: Vector4;
  131909. }, scene: any): Mesh;
  131910. }
  131911. }
  131912. declare module BABYLON {
  131913. /**
  131914. * Class containing static functions to help procedurally build meshes
  131915. */
  131916. export class CylinderBuilder {
  131917. /**
  131918. * Creates a cylinder or a cone mesh
  131919. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  131920. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  131921. * * 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.
  131922. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  131923. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  131924. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  131925. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  131926. * * 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).
  131927. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  131928. * * 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).
  131929. * * 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
  131930. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  131931. * * 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
  131932. * * 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.
  131933. * * If `enclose` is false, a ring surface is one element.
  131934. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  131935. * * 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
  131936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131939. * @param name defines the name of the mesh
  131940. * @param options defines the options used to create the mesh
  131941. * @param scene defines the hosting scene
  131942. * @returns the cylinder mesh
  131943. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  131944. */
  131945. static CreateCylinder(name: string, options: {
  131946. height?: number;
  131947. diameterTop?: number;
  131948. diameterBottom?: number;
  131949. diameter?: number;
  131950. tessellation?: number;
  131951. subdivisions?: number;
  131952. arc?: number;
  131953. faceColors?: Color4[];
  131954. faceUV?: Vector4[];
  131955. updatable?: boolean;
  131956. hasRings?: boolean;
  131957. enclose?: boolean;
  131958. cap?: number;
  131959. sideOrientation?: number;
  131960. frontUVs?: Vector4;
  131961. backUVs?: Vector4;
  131962. }, scene: any): Mesh;
  131963. }
  131964. }
  131965. declare module BABYLON {
  131966. /**
  131967. * States of the webXR experience
  131968. */
  131969. export enum WebXRState {
  131970. /**
  131971. * Transitioning to being in XR mode
  131972. */
  131973. ENTERING_XR = 0,
  131974. /**
  131975. * Transitioning to non XR mode
  131976. */
  131977. EXITING_XR = 1,
  131978. /**
  131979. * In XR mode and presenting
  131980. */
  131981. IN_XR = 2,
  131982. /**
  131983. * Not entered XR mode
  131984. */
  131985. NOT_IN_XR = 3
  131986. }
  131987. /**
  131988. * The state of the XR camera's tracking
  131989. */
  131990. export enum WebXRTrackingState {
  131991. /**
  131992. * No transformation received, device is not being tracked
  131993. */
  131994. NOT_TRACKING = 0,
  131995. /**
  131996. * Tracking lost - using emulated position
  131997. */
  131998. TRACKING_LOST = 1,
  131999. /**
  132000. * Transformation tracking works normally
  132001. */
  132002. TRACKING = 2
  132003. }
  132004. /**
  132005. * Abstraction of the XR render target
  132006. */
  132007. export interface WebXRRenderTarget extends IDisposable {
  132008. /**
  132009. * xrpresent context of the canvas which can be used to display/mirror xr content
  132010. */
  132011. canvasContext: WebGLRenderingContext;
  132012. /**
  132013. * xr layer for the canvas
  132014. */
  132015. xrLayer: Nullable<XRWebGLLayer>;
  132016. /**
  132017. * Initializes the xr layer for the session
  132018. * @param xrSession xr session
  132019. * @returns a promise that will resolve once the XR Layer has been created
  132020. */
  132021. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  132022. }
  132023. }
  132024. declare module BABYLON {
  132025. /**
  132026. * COnfiguration object for WebXR output canvas
  132027. */
  132028. export class WebXRManagedOutputCanvasOptions {
  132029. /**
  132030. * An optional canvas in case you wish to create it yourself and provide it here.
  132031. * If not provided, a new canvas will be created
  132032. */
  132033. canvasElement?: HTMLCanvasElement;
  132034. /**
  132035. * Options for this XR Layer output
  132036. */
  132037. canvasOptions?: XRWebGLLayerInit;
  132038. /**
  132039. * CSS styling for a newly created canvas (if not provided)
  132040. */
  132041. newCanvasCssStyle?: string;
  132042. /**
  132043. * Get the default values of the configuration object
  132044. * @param engine defines the engine to use (can be null)
  132045. * @returns default values of this configuration object
  132046. */
  132047. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  132048. }
  132049. /**
  132050. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  132051. */
  132052. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  132053. private _options;
  132054. private _canvas;
  132055. private _engine;
  132056. private _originalCanvasSize;
  132057. /**
  132058. * Rendering context of the canvas which can be used to display/mirror xr content
  132059. */
  132060. canvasContext: WebGLRenderingContext;
  132061. /**
  132062. * xr layer for the canvas
  132063. */
  132064. xrLayer: Nullable<XRWebGLLayer>;
  132065. /**
  132066. * Obseervers registered here will be triggered when the xr layer was initialized
  132067. */
  132068. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  132069. /**
  132070. * Initializes the canvas to be added/removed upon entering/exiting xr
  132071. * @param _xrSessionManager The XR Session manager
  132072. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  132073. */
  132074. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  132075. /**
  132076. * Disposes of the object
  132077. */
  132078. dispose(): void;
  132079. /**
  132080. * Initializes the xr layer for the session
  132081. * @param xrSession xr session
  132082. * @returns a promise that will resolve once the XR Layer has been created
  132083. */
  132084. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  132085. private _addCanvas;
  132086. private _removeCanvas;
  132087. private _setCanvasSize;
  132088. private _setManagedOutputCanvas;
  132089. }
  132090. }
  132091. declare module BABYLON {
  132092. /**
  132093. * Manages an XRSession to work with Babylon's engine
  132094. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  132095. */
  132096. export class WebXRSessionManager implements IDisposable {
  132097. /** The scene which the session should be created for */
  132098. scene: Scene;
  132099. private _referenceSpace;
  132100. private _rttProvider;
  132101. private _sessionEnded;
  132102. private _xrNavigator;
  132103. private baseLayer;
  132104. /**
  132105. * The base reference space from which the session started. good if you want to reset your
  132106. * reference space
  132107. */
  132108. baseReferenceSpace: XRReferenceSpace;
  132109. /**
  132110. * Current XR frame
  132111. */
  132112. currentFrame: Nullable<XRFrame>;
  132113. /** WebXR timestamp updated every frame */
  132114. currentTimestamp: number;
  132115. /**
  132116. * Used just in case of a failure to initialize an immersive session.
  132117. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  132118. */
  132119. defaultHeightCompensation: number;
  132120. /**
  132121. * Fires every time a new xrFrame arrives which can be used to update the camera
  132122. */
  132123. onXRFrameObservable: Observable<XRFrame>;
  132124. /**
  132125. * Fires when the reference space changed
  132126. */
  132127. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  132128. /**
  132129. * Fires when the xr session is ended either by the device or manually done
  132130. */
  132131. onXRSessionEnded: Observable<any>;
  132132. /**
  132133. * Fires when the xr session is ended either by the device or manually done
  132134. */
  132135. onXRSessionInit: Observable<XRSession>;
  132136. /**
  132137. * Underlying xr session
  132138. */
  132139. session: XRSession;
  132140. /**
  132141. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  132142. * or get the offset the player is currently at.
  132143. */
  132144. viewerReferenceSpace: XRReferenceSpace;
  132145. /**
  132146. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  132147. * @param scene The scene which the session should be created for
  132148. */
  132149. constructor(
  132150. /** The scene which the session should be created for */
  132151. scene: Scene);
  132152. /**
  132153. * The current reference space used in this session. This reference space can constantly change!
  132154. * It is mainly used to offset the camera's position.
  132155. */
  132156. get referenceSpace(): XRReferenceSpace;
  132157. /**
  132158. * Set a new reference space and triggers the observable
  132159. */
  132160. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  132161. /**
  132162. * Disposes of the session manager
  132163. */
  132164. dispose(): void;
  132165. /**
  132166. * Stops the xrSession and restores the render loop
  132167. * @returns Promise which resolves after it exits XR
  132168. */
  132169. exitXRAsync(): Promise<void>;
  132170. /**
  132171. * Gets the correct render target texture to be rendered this frame for this eye
  132172. * @param eye the eye for which to get the render target
  132173. * @returns the render target for the specified eye
  132174. */
  132175. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  132176. /**
  132177. * Creates a WebXRRenderTarget object for the XR session
  132178. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  132179. * @param options optional options to provide when creating a new render target
  132180. * @returns a WebXR render target to which the session can render
  132181. */
  132182. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  132183. /**
  132184. * Initializes the manager
  132185. * After initialization enterXR can be called to start an XR session
  132186. * @returns Promise which resolves after it is initialized
  132187. */
  132188. initializeAsync(): Promise<void>;
  132189. /**
  132190. * Initializes an xr session
  132191. * @param xrSessionMode mode to initialize
  132192. * @param xrSessionInit defines optional and required values to pass to the session builder
  132193. * @returns a promise which will resolve once the session has been initialized
  132194. */
  132195. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  132196. /**
  132197. * Checks if a session would be supported for the creation options specified
  132198. * @param sessionMode session mode to check if supported eg. immersive-vr
  132199. * @returns A Promise that resolves to true if supported and false if not
  132200. */
  132201. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  132202. /**
  132203. * Resets the reference space to the one started the session
  132204. */
  132205. resetReferenceSpace(): void;
  132206. /**
  132207. * Starts rendering to the xr layer
  132208. */
  132209. runXRRenderLoop(): void;
  132210. /**
  132211. * Sets the reference space on the xr session
  132212. * @param referenceSpaceType space to set
  132213. * @returns a promise that will resolve once the reference space has been set
  132214. */
  132215. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  132216. /**
  132217. * Updates the render state of the session
  132218. * @param state state to set
  132219. * @returns a promise that resolves once the render state has been updated
  132220. */
  132221. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  132222. /**
  132223. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  132224. * @param sessionMode defines the session to test
  132225. * @returns a promise with boolean as final value
  132226. */
  132227. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  132228. private _createRenderTargetTexture;
  132229. }
  132230. }
  132231. declare module BABYLON {
  132232. /**
  132233. * WebXR Camera which holds the views for the xrSession
  132234. * @see https://doc.babylonjs.com/how_to/webxr_camera
  132235. */
  132236. export class WebXRCamera extends FreeCamera {
  132237. private _xrSessionManager;
  132238. private _firstFrame;
  132239. private _referenceQuaternion;
  132240. private _referencedPosition;
  132241. private _xrInvPositionCache;
  132242. private _xrInvQuaternionCache;
  132243. private _trackingState;
  132244. /**
  132245. * Observable raised before camera teleportation
  132246. */
  132247. onBeforeCameraTeleport: Observable<Vector3>;
  132248. /**
  132249. * Observable raised after camera teleportation
  132250. */
  132251. onAfterCameraTeleport: Observable<Vector3>;
  132252. /**
  132253. * Notifies when the camera's tracking state has changed.
  132254. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  132255. */
  132256. onTrackingStateChanged: Observable<WebXRTrackingState>;
  132257. /**
  132258. * Should position compensation execute on first frame.
  132259. * This is used when copying the position from a native (non XR) camera
  132260. */
  132261. compensateOnFirstFrame: boolean;
  132262. /**
  132263. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  132264. * @param name the name of the camera
  132265. * @param scene the scene to add the camera to
  132266. * @param _xrSessionManager a constructed xr session manager
  132267. */
  132268. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  132269. /**
  132270. * Get the current XR tracking state of the camera
  132271. */
  132272. get trackingState(): WebXRTrackingState;
  132273. private _setTrackingState;
  132274. /**
  132275. * Return the user's height, unrelated to the current ground.
  132276. * This will be the y position of this camera, when ground level is 0.
  132277. */
  132278. get realWorldHeight(): number;
  132279. /** @hidden */
  132280. _updateForDualEyeDebugging(): void;
  132281. /**
  132282. * Sets this camera's transformation based on a non-vr camera
  132283. * @param otherCamera the non-vr camera to copy the transformation from
  132284. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  132285. */
  132286. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  132287. /**
  132288. * Gets the current instance class name ("WebXRCamera").
  132289. * @returns the class name
  132290. */
  132291. getClassName(): string;
  132292. private _rotate180;
  132293. private _updateFromXRSession;
  132294. private _updateNumberOfRigCameras;
  132295. private _updateReferenceSpace;
  132296. private _updateReferenceSpaceOffset;
  132297. }
  132298. }
  132299. declare module BABYLON {
  132300. /**
  132301. * Defining the interface required for a (webxr) feature
  132302. */
  132303. export interface IWebXRFeature extends IDisposable {
  132304. /**
  132305. * Is this feature attached
  132306. */
  132307. attached: boolean;
  132308. /**
  132309. * Should auto-attach be disabled?
  132310. */
  132311. disableAutoAttach: boolean;
  132312. /**
  132313. * Attach the feature to the session
  132314. * Will usually be called by the features manager
  132315. *
  132316. * @param force should attachment be forced (even when already attached)
  132317. * @returns true if successful.
  132318. */
  132319. attach(force?: boolean): boolean;
  132320. /**
  132321. * Detach the feature from the session
  132322. * Will usually be called by the features manager
  132323. *
  132324. * @returns true if successful.
  132325. */
  132326. detach(): boolean;
  132327. /**
  132328. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  132329. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  132330. *
  132331. * @returns whether or not the feature is compatible in this environment
  132332. */
  132333. isCompatible(): boolean;
  132334. /**
  132335. * Was this feature disposed;
  132336. */
  132337. isDisposed: boolean;
  132338. /**
  132339. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  132340. */
  132341. xrNativeFeatureName?: string;
  132342. /**
  132343. * A list of (Babylon WebXR) features this feature depends on
  132344. */
  132345. dependsOn?: string[];
  132346. }
  132347. /**
  132348. * A list of the currently available features without referencing them
  132349. */
  132350. export class WebXRFeatureName {
  132351. /**
  132352. * The name of the anchor system feature
  132353. */
  132354. static readonly ANCHOR_SYSTEM: string;
  132355. /**
  132356. * The name of the background remover feature
  132357. */
  132358. static readonly BACKGROUND_REMOVER: string;
  132359. /**
  132360. * The name of the hit test feature
  132361. */
  132362. static readonly HIT_TEST: string;
  132363. /**
  132364. * physics impostors for xr controllers feature
  132365. */
  132366. static readonly PHYSICS_CONTROLLERS: string;
  132367. /**
  132368. * The name of the plane detection feature
  132369. */
  132370. static readonly PLANE_DETECTION: string;
  132371. /**
  132372. * The name of the pointer selection feature
  132373. */
  132374. static readonly POINTER_SELECTION: string;
  132375. /**
  132376. * The name of the teleportation feature
  132377. */
  132378. static readonly TELEPORTATION: string;
  132379. /**
  132380. * The name of the feature points feature.
  132381. */
  132382. static readonly FEATURE_POINTS: string;
  132383. /**
  132384. * The name of the hand tracking feature.
  132385. */
  132386. static readonly HAND_TRACKING: string;
  132387. }
  132388. /**
  132389. * Defining the constructor of a feature. Used to register the modules.
  132390. */
  132391. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  132392. /**
  132393. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  132394. * It is mainly used in AR sessions.
  132395. *
  132396. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  132397. */
  132398. export class WebXRFeaturesManager implements IDisposable {
  132399. private _xrSessionManager;
  132400. private static readonly _AvailableFeatures;
  132401. private _features;
  132402. /**
  132403. * constructs a new features manages.
  132404. *
  132405. * @param _xrSessionManager an instance of WebXRSessionManager
  132406. */
  132407. constructor(_xrSessionManager: WebXRSessionManager);
  132408. /**
  132409. * Used to register a module. After calling this function a developer can use this feature in the scene.
  132410. * Mainly used internally.
  132411. *
  132412. * @param featureName the name of the feature to register
  132413. * @param constructorFunction the function used to construct the module
  132414. * @param version the (babylon) version of the module
  132415. * @param stable is that a stable version of this module
  132416. */
  132417. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  132418. /**
  132419. * Returns a constructor of a specific feature.
  132420. *
  132421. * @param featureName the name of the feature to construct
  132422. * @param version the version of the feature to load
  132423. * @param xrSessionManager the xrSessionManager. Used to construct the module
  132424. * @param options optional options provided to the module.
  132425. * @returns a function that, when called, will return a new instance of this feature
  132426. */
  132427. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  132428. /**
  132429. * Can be used to return the list of features currently registered
  132430. *
  132431. * @returns an Array of available features
  132432. */
  132433. static GetAvailableFeatures(): string[];
  132434. /**
  132435. * Gets the versions available for a specific feature
  132436. * @param featureName the name of the feature
  132437. * @returns an array with the available versions
  132438. */
  132439. static GetAvailableVersions(featureName: string): string[];
  132440. /**
  132441. * Return the latest unstable version of this feature
  132442. * @param featureName the name of the feature to search
  132443. * @returns the version number. if not found will return -1
  132444. */
  132445. static GetLatestVersionOfFeature(featureName: string): number;
  132446. /**
  132447. * Return the latest stable version of this feature
  132448. * @param featureName the name of the feature to search
  132449. * @returns the version number. if not found will return -1
  132450. */
  132451. static GetStableVersionOfFeature(featureName: string): number;
  132452. /**
  132453. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  132454. * Can be used during a session to start a feature
  132455. * @param featureName the name of feature to attach
  132456. */
  132457. attachFeature(featureName: string): void;
  132458. /**
  132459. * Can be used inside a session or when the session ends to detach a specific feature
  132460. * @param featureName the name of the feature to detach
  132461. */
  132462. detachFeature(featureName: string): void;
  132463. /**
  132464. * Used to disable an already-enabled feature
  132465. * The feature will be disposed and will be recreated once enabled.
  132466. * @param featureName the feature to disable
  132467. * @returns true if disable was successful
  132468. */
  132469. disableFeature(featureName: string | {
  132470. Name: string;
  132471. }): boolean;
  132472. /**
  132473. * dispose this features manager
  132474. */
  132475. dispose(): void;
  132476. /**
  132477. * 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.
  132478. * 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.
  132479. *
  132480. * @param featureName the name of the feature to load or the class of the feature
  132481. * @param version optional version to load. if not provided the latest version will be enabled
  132482. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  132483. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  132484. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  132485. * @returns a new constructed feature or throws an error if feature not found.
  132486. */
  132487. enableFeature(featureName: string | {
  132488. Name: string;
  132489. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  132490. /**
  132491. * get the implementation of an enabled feature.
  132492. * @param featureName the name of the feature to load
  132493. * @returns the feature class, if found
  132494. */
  132495. getEnabledFeature(featureName: string): IWebXRFeature;
  132496. /**
  132497. * Get the list of enabled features
  132498. * @returns an array of enabled features
  132499. */
  132500. getEnabledFeatures(): string[];
  132501. /**
  132502. * This function will exten the session creation configuration object with enabled features.
  132503. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  132504. * according to the defined "required" variable, provided during enableFeature call
  132505. * @param xrSessionInit the xr Session init object to extend
  132506. *
  132507. * @returns an extended XRSessionInit object
  132508. */
  132509. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  132510. }
  132511. }
  132512. declare module BABYLON {
  132513. /**
  132514. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  132515. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  132516. */
  132517. export class WebXRExperienceHelper implements IDisposable {
  132518. private scene;
  132519. private _nonVRCamera;
  132520. private _originalSceneAutoClear;
  132521. private _supported;
  132522. /**
  132523. * Camera used to render xr content
  132524. */
  132525. camera: WebXRCamera;
  132526. /** A features manager for this xr session */
  132527. featuresManager: WebXRFeaturesManager;
  132528. /**
  132529. * Observers registered here will be triggered after the camera's initial transformation is set
  132530. * This can be used to set a different ground level or an extra rotation.
  132531. *
  132532. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  132533. * to the position set after this observable is done executing.
  132534. */
  132535. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  132536. /**
  132537. * Fires when the state of the experience helper has changed
  132538. */
  132539. onStateChangedObservable: Observable<WebXRState>;
  132540. /** Session manager used to keep track of xr session */
  132541. sessionManager: WebXRSessionManager;
  132542. /**
  132543. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  132544. */
  132545. state: WebXRState;
  132546. /**
  132547. * Creates a WebXRExperienceHelper
  132548. * @param scene The scene the helper should be created in
  132549. */
  132550. private constructor();
  132551. /**
  132552. * Creates the experience helper
  132553. * @param scene the scene to attach the experience helper to
  132554. * @returns a promise for the experience helper
  132555. */
  132556. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  132557. /**
  132558. * Disposes of the experience helper
  132559. */
  132560. dispose(): void;
  132561. /**
  132562. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  132563. * @param sessionMode options for the XR session
  132564. * @param referenceSpaceType frame of reference of the XR session
  132565. * @param renderTarget the output canvas that will be used to enter XR mode
  132566. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  132567. * @returns promise that resolves after xr mode has entered
  132568. */
  132569. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  132570. /**
  132571. * Exits XR mode and returns the scene to its original state
  132572. * @returns promise that resolves after xr mode has exited
  132573. */
  132574. exitXRAsync(): Promise<void>;
  132575. private _nonXRToXRCamera;
  132576. private _setState;
  132577. }
  132578. }
  132579. declare module BABYLON {
  132580. /**
  132581. * X-Y values for axes in WebXR
  132582. */
  132583. export interface IWebXRMotionControllerAxesValue {
  132584. /**
  132585. * The value of the x axis
  132586. */
  132587. x: number;
  132588. /**
  132589. * The value of the y-axis
  132590. */
  132591. y: number;
  132592. }
  132593. /**
  132594. * changed / previous values for the values of this component
  132595. */
  132596. export interface IWebXRMotionControllerComponentChangesValues<T> {
  132597. /**
  132598. * current (this frame) value
  132599. */
  132600. current: T;
  132601. /**
  132602. * previous (last change) value
  132603. */
  132604. previous: T;
  132605. }
  132606. /**
  132607. * Represents changes in the component between current frame and last values recorded
  132608. */
  132609. export interface IWebXRMotionControllerComponentChanges {
  132610. /**
  132611. * will be populated with previous and current values if axes changed
  132612. */
  132613. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  132614. /**
  132615. * will be populated with previous and current values if pressed changed
  132616. */
  132617. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132618. /**
  132619. * will be populated with previous and current values if touched changed
  132620. */
  132621. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132622. /**
  132623. * will be populated with previous and current values if value changed
  132624. */
  132625. value?: IWebXRMotionControllerComponentChangesValues<number>;
  132626. }
  132627. /**
  132628. * This class represents a single component (for example button or thumbstick) of a motion controller
  132629. */
  132630. export class WebXRControllerComponent implements IDisposable {
  132631. /**
  132632. * the id of this component
  132633. */
  132634. id: string;
  132635. /**
  132636. * the type of the component
  132637. */
  132638. type: MotionControllerComponentType;
  132639. private _buttonIndex;
  132640. private _axesIndices;
  132641. private _axes;
  132642. private _changes;
  132643. private _currentValue;
  132644. private _hasChanges;
  132645. private _pressed;
  132646. private _touched;
  132647. /**
  132648. * button component type
  132649. */
  132650. static BUTTON_TYPE: MotionControllerComponentType;
  132651. /**
  132652. * squeeze component type
  132653. */
  132654. static SQUEEZE_TYPE: MotionControllerComponentType;
  132655. /**
  132656. * Thumbstick component type
  132657. */
  132658. static THUMBSTICK_TYPE: MotionControllerComponentType;
  132659. /**
  132660. * Touchpad component type
  132661. */
  132662. static TOUCHPAD_TYPE: MotionControllerComponentType;
  132663. /**
  132664. * trigger component type
  132665. */
  132666. static TRIGGER_TYPE: MotionControllerComponentType;
  132667. /**
  132668. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  132669. * the axes data changes
  132670. */
  132671. onAxisValueChangedObservable: Observable<{
  132672. x: number;
  132673. y: number;
  132674. }>;
  132675. /**
  132676. * Observers registered here will be triggered when the state of a button changes
  132677. * State change is either pressed / touched / value
  132678. */
  132679. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  132680. /**
  132681. * Creates a new component for a motion controller.
  132682. * It is created by the motion controller itself
  132683. *
  132684. * @param id the id of this component
  132685. * @param type the type of the component
  132686. * @param _buttonIndex index in the buttons array of the gamepad
  132687. * @param _axesIndices indices of the values in the axes array of the gamepad
  132688. */
  132689. constructor(
  132690. /**
  132691. * the id of this component
  132692. */
  132693. id: string,
  132694. /**
  132695. * the type of the component
  132696. */
  132697. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  132698. /**
  132699. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  132700. */
  132701. get axes(): IWebXRMotionControllerAxesValue;
  132702. /**
  132703. * Get the changes. Elements will be populated only if they changed with their previous and current value
  132704. */
  132705. get changes(): IWebXRMotionControllerComponentChanges;
  132706. /**
  132707. * Return whether or not the component changed the last frame
  132708. */
  132709. get hasChanges(): boolean;
  132710. /**
  132711. * is the button currently pressed
  132712. */
  132713. get pressed(): boolean;
  132714. /**
  132715. * is the button currently touched
  132716. */
  132717. get touched(): boolean;
  132718. /**
  132719. * Get the current value of this component
  132720. */
  132721. get value(): number;
  132722. /**
  132723. * Dispose this component
  132724. */
  132725. dispose(): void;
  132726. /**
  132727. * Are there axes correlating to this component
  132728. * @return true is axes data is available
  132729. */
  132730. isAxes(): boolean;
  132731. /**
  132732. * Is this component a button (hence - pressable)
  132733. * @returns true if can be pressed
  132734. */
  132735. isButton(): boolean;
  132736. /**
  132737. * update this component using the gamepad object it is in. Called on every frame
  132738. * @param nativeController the native gamepad controller object
  132739. */
  132740. update(nativeController: IMinimalMotionControllerObject): void;
  132741. }
  132742. }
  132743. declare module BABYLON {
  132744. /**
  132745. * Type used for the success callback of ImportMesh
  132746. */
  132747. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  132748. /**
  132749. * Interface used for the result of ImportMeshAsync
  132750. */
  132751. export interface ISceneLoaderAsyncResult {
  132752. /**
  132753. * The array of loaded meshes
  132754. */
  132755. readonly meshes: AbstractMesh[];
  132756. /**
  132757. * The array of loaded particle systems
  132758. */
  132759. readonly particleSystems: IParticleSystem[];
  132760. /**
  132761. * The array of loaded skeletons
  132762. */
  132763. readonly skeletons: Skeleton[];
  132764. /**
  132765. * The array of loaded animation groups
  132766. */
  132767. readonly animationGroups: AnimationGroup[];
  132768. /**
  132769. * The array of loaded transform nodes
  132770. */
  132771. readonly transformNodes: TransformNode[];
  132772. /**
  132773. * The array of loaded geometries
  132774. */
  132775. readonly geometries: Geometry[];
  132776. /**
  132777. * The array of loaded lights
  132778. */
  132779. readonly lights: Light[];
  132780. }
  132781. /**
  132782. * Interface used to represent data loading progression
  132783. */
  132784. export interface ISceneLoaderProgressEvent {
  132785. /**
  132786. * Defines if data length to load can be evaluated
  132787. */
  132788. readonly lengthComputable: boolean;
  132789. /**
  132790. * Defines the loaded data length
  132791. */
  132792. readonly loaded: number;
  132793. /**
  132794. * Defines the data length to load
  132795. */
  132796. readonly total: number;
  132797. }
  132798. /**
  132799. * Interface used by SceneLoader plugins to define supported file extensions
  132800. */
  132801. export interface ISceneLoaderPluginExtensions {
  132802. /**
  132803. * Defines the list of supported extensions
  132804. */
  132805. [extension: string]: {
  132806. isBinary: boolean;
  132807. };
  132808. }
  132809. /**
  132810. * Interface used by SceneLoader plugin factory
  132811. */
  132812. export interface ISceneLoaderPluginFactory {
  132813. /**
  132814. * Defines the name of the factory
  132815. */
  132816. name: string;
  132817. /**
  132818. * Function called to create a new plugin
  132819. * @return the new plugin
  132820. */
  132821. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  132822. /**
  132823. * The callback that returns true if the data can be directly loaded.
  132824. * @param data string containing the file data
  132825. * @returns if the data can be loaded directly
  132826. */
  132827. canDirectLoad?(data: string): boolean;
  132828. }
  132829. /**
  132830. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  132831. */
  132832. export interface ISceneLoaderPluginBase {
  132833. /**
  132834. * The friendly name of this plugin.
  132835. */
  132836. name: string;
  132837. /**
  132838. * The file extensions supported by this plugin.
  132839. */
  132840. extensions: string | ISceneLoaderPluginExtensions;
  132841. /**
  132842. * The callback called when loading from a url.
  132843. * @param scene scene loading this url
  132844. * @param url url to load
  132845. * @param onSuccess callback called when the file successfully loads
  132846. * @param onProgress callback called while file is loading (if the server supports this mode)
  132847. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  132848. * @param onError callback called when the file fails to load
  132849. * @returns a file request object
  132850. */
  132851. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132852. /**
  132853. * The callback called when loading from a file object.
  132854. * @param scene scene loading this file
  132855. * @param file defines the file to load
  132856. * @param onSuccess defines the callback to call when data is loaded
  132857. * @param onProgress defines the callback to call during loading process
  132858. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  132859. * @param onError defines the callback to call when an error occurs
  132860. * @returns a file request object
  132861. */
  132862. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132863. /**
  132864. * The callback that returns true if the data can be directly loaded.
  132865. * @param data string containing the file data
  132866. * @returns if the data can be loaded directly
  132867. */
  132868. canDirectLoad?(data: string): boolean;
  132869. /**
  132870. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  132871. * @param scene scene loading this data
  132872. * @param data string containing the data
  132873. * @returns data to pass to the plugin
  132874. */
  132875. directLoad?(scene: Scene, data: string): any;
  132876. /**
  132877. * The callback that allows custom handling of the root url based on the response url.
  132878. * @param rootUrl the original root url
  132879. * @param responseURL the response url if available
  132880. * @returns the new root url
  132881. */
  132882. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  132883. }
  132884. /**
  132885. * Interface used to define a SceneLoader plugin
  132886. */
  132887. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  132888. /**
  132889. * Import meshes into a scene.
  132890. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132891. * @param scene The scene to import into
  132892. * @param data The data to import
  132893. * @param rootUrl The root url for scene and resources
  132894. * @param meshes The meshes array to import into
  132895. * @param particleSystems The particle systems array to import into
  132896. * @param skeletons The skeletons array to import into
  132897. * @param onError The callback when import fails
  132898. * @returns True if successful or false otherwise
  132899. */
  132900. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  132901. /**
  132902. * Load into a scene.
  132903. * @param scene The scene to load into
  132904. * @param data The data to import
  132905. * @param rootUrl The root url for scene and resources
  132906. * @param onError The callback when import fails
  132907. * @returns True if successful or false otherwise
  132908. */
  132909. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  132910. /**
  132911. * Load into an asset container.
  132912. * @param scene The scene to load into
  132913. * @param data The data to import
  132914. * @param rootUrl The root url for scene and resources
  132915. * @param onError The callback when import fails
  132916. * @returns The loaded asset container
  132917. */
  132918. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  132919. }
  132920. /**
  132921. * Interface used to define an async SceneLoader plugin
  132922. */
  132923. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  132924. /**
  132925. * Import meshes into a scene.
  132926. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132927. * @param scene The scene to import into
  132928. * @param data The data to import
  132929. * @param rootUrl The root url for scene and resources
  132930. * @param onProgress The callback when the load progresses
  132931. * @param fileName Defines the name of the file to load
  132932. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  132933. */
  132934. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  132935. /**
  132936. * Load into a scene.
  132937. * @param scene The scene to load into
  132938. * @param data The data to import
  132939. * @param rootUrl The root url for scene and resources
  132940. * @param onProgress The callback when the load progresses
  132941. * @param fileName Defines the name of the file to load
  132942. * @returns Nothing
  132943. */
  132944. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  132945. /**
  132946. * Load into an asset container.
  132947. * @param scene The scene to load into
  132948. * @param data The data to import
  132949. * @param rootUrl The root url for scene and resources
  132950. * @param onProgress The callback when the load progresses
  132951. * @param fileName Defines the name of the file to load
  132952. * @returns The loaded asset container
  132953. */
  132954. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  132955. }
  132956. /**
  132957. * Mode that determines how to handle old animation groups before loading new ones.
  132958. */
  132959. export enum SceneLoaderAnimationGroupLoadingMode {
  132960. /**
  132961. * Reset all old animations to initial state then dispose them.
  132962. */
  132963. Clean = 0,
  132964. /**
  132965. * Stop all old animations.
  132966. */
  132967. Stop = 1,
  132968. /**
  132969. * Restart old animations from first frame.
  132970. */
  132971. Sync = 2,
  132972. /**
  132973. * Old animations remains untouched.
  132974. */
  132975. NoSync = 3
  132976. }
  132977. /**
  132978. * Defines a plugin registered by the SceneLoader
  132979. */
  132980. interface IRegisteredPlugin {
  132981. /**
  132982. * Defines the plugin to use
  132983. */
  132984. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  132985. /**
  132986. * Defines if the plugin supports binary data
  132987. */
  132988. isBinary: boolean;
  132989. }
  132990. /**
  132991. * Class used to load scene from various file formats using registered plugins
  132992. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  132993. */
  132994. export class SceneLoader {
  132995. /**
  132996. * No logging while loading
  132997. */
  132998. static readonly NO_LOGGING: number;
  132999. /**
  133000. * Minimal logging while loading
  133001. */
  133002. static readonly MINIMAL_LOGGING: number;
  133003. /**
  133004. * Summary logging while loading
  133005. */
  133006. static readonly SUMMARY_LOGGING: number;
  133007. /**
  133008. * Detailled logging while loading
  133009. */
  133010. static readonly DETAILED_LOGGING: number;
  133011. /**
  133012. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  133013. */
  133014. static get ForceFullSceneLoadingForIncremental(): boolean;
  133015. static set ForceFullSceneLoadingForIncremental(value: boolean);
  133016. /**
  133017. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  133018. */
  133019. static get ShowLoadingScreen(): boolean;
  133020. static set ShowLoadingScreen(value: boolean);
  133021. /**
  133022. * Defines the current logging level (while loading the scene)
  133023. * @ignorenaming
  133024. */
  133025. static get loggingLevel(): number;
  133026. static set loggingLevel(value: number);
  133027. /**
  133028. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  133029. */
  133030. static get CleanBoneMatrixWeights(): boolean;
  133031. static set CleanBoneMatrixWeights(value: boolean);
  133032. /**
  133033. * Event raised when a plugin is used to load a scene
  133034. */
  133035. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  133036. private static _registeredPlugins;
  133037. private static _showingLoadingScreen;
  133038. /**
  133039. * Gets the default plugin (used to load Babylon files)
  133040. * @returns the .babylon plugin
  133041. */
  133042. static GetDefaultPlugin(): IRegisteredPlugin;
  133043. private static _GetPluginForExtension;
  133044. private static _GetPluginForDirectLoad;
  133045. private static _GetPluginForFilename;
  133046. private static _GetDirectLoad;
  133047. private static _LoadData;
  133048. private static _GetFileInfo;
  133049. /**
  133050. * Gets a plugin that can load the given extension
  133051. * @param extension defines the extension to load
  133052. * @returns a plugin or null if none works
  133053. */
  133054. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  133055. /**
  133056. * Gets a boolean indicating that the given extension can be loaded
  133057. * @param extension defines the extension to load
  133058. * @returns true if the extension is supported
  133059. */
  133060. static IsPluginForExtensionAvailable(extension: string): boolean;
  133061. /**
  133062. * Adds a new plugin to the list of registered plugins
  133063. * @param plugin defines the plugin to add
  133064. */
  133065. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  133066. /**
  133067. * Import meshes into a scene
  133068. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  133069. * @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)
  133070. * @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)
  133071. * @param scene the instance of BABYLON.Scene to append to
  133072. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  133073. * @param onProgress a callback with a progress event for each file being loaded
  133074. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133075. * @param pluginExtension the extension used to determine the plugin
  133076. * @returns The loaded plugin
  133077. */
  133078. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  133079. /**
  133080. * Import meshes into a scene
  133081. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  133082. * @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)
  133083. * @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)
  133084. * @param scene the instance of BABYLON.Scene to append to
  133085. * @param onProgress a callback with a progress event for each file being loaded
  133086. * @param pluginExtension the extension used to determine the plugin
  133087. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  133088. */
  133089. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  133090. /**
  133091. * Load a scene
  133092. * @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)
  133093. * @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)
  133094. * @param engine is the instance of BABYLON.Engine to use to create the scene
  133095. * @param onSuccess a callback with the scene when import succeeds
  133096. * @param onProgress a callback with a progress event for each file being loaded
  133097. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133098. * @param pluginExtension the extension used to determine the plugin
  133099. * @returns The loaded plugin
  133100. */
  133101. 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>;
  133102. /**
  133103. * Load a scene
  133104. * @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)
  133105. * @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)
  133106. * @param engine is the instance of BABYLON.Engine to use to create the scene
  133107. * @param onProgress a callback with a progress event for each file being loaded
  133108. * @param pluginExtension the extension used to determine the plugin
  133109. * @returns The loaded scene
  133110. */
  133111. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  133112. /**
  133113. * Append a scene
  133114. * @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)
  133115. * @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)
  133116. * @param scene is the instance of BABYLON.Scene to append to
  133117. * @param onSuccess a callback with the scene when import succeeds
  133118. * @param onProgress a callback with a progress event for each file being loaded
  133119. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133120. * @param pluginExtension the extension used to determine the plugin
  133121. * @returns The loaded plugin
  133122. */
  133123. 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>;
  133124. /**
  133125. * Append a scene
  133126. * @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)
  133127. * @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)
  133128. * @param scene is the instance of BABYLON.Scene to append to
  133129. * @param onProgress a callback with a progress event for each file being loaded
  133130. * @param pluginExtension the extension used to determine the plugin
  133131. * @returns The given scene
  133132. */
  133133. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  133134. /**
  133135. * Load a scene into an asset container
  133136. * @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)
  133137. * @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)
  133138. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133139. * @param onSuccess a callback with the scene when import succeeds
  133140. * @param onProgress a callback with a progress event for each file being loaded
  133141. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133142. * @param pluginExtension the extension used to determine the plugin
  133143. * @returns The loaded plugin
  133144. */
  133145. 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>;
  133146. /**
  133147. * Load a scene into an asset container
  133148. * @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)
  133149. * @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)
  133150. * @param scene is the instance of Scene to append to
  133151. * @param onProgress a callback with a progress event for each file being loaded
  133152. * @param pluginExtension the extension used to determine the plugin
  133153. * @returns The loaded asset container
  133154. */
  133155. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  133156. /**
  133157. * Import animations from a file into a scene
  133158. * @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)
  133159. * @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)
  133160. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133161. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  133162. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  133163. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  133164. * @param onSuccess a callback with the scene when import succeeds
  133165. * @param onProgress a callback with a progress event for each file being loaded
  133166. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133167. * @param pluginExtension the extension used to determine the plugin
  133168. */
  133169. 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;
  133170. /**
  133171. * Import animations from a file into a scene
  133172. * @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)
  133173. * @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)
  133174. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133175. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  133176. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  133177. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  133178. * @param onSuccess a callback with the scene when import succeeds
  133179. * @param onProgress a callback with a progress event for each file being loaded
  133180. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133181. * @param pluginExtension the extension used to determine the plugin
  133182. * @returns the updated scene with imported animations
  133183. */
  133184. 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>;
  133185. }
  133186. }
  133187. declare module BABYLON {
  133188. /**
  133189. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  133190. */
  133191. export type MotionControllerHandedness = "none" | "left" | "right";
  133192. /**
  133193. * The type of components available in motion controllers.
  133194. * This is not the name of the component.
  133195. */
  133196. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  133197. /**
  133198. * The state of a controller component
  133199. */
  133200. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  133201. /**
  133202. * The schema of motion controller layout.
  133203. * No object will be initialized using this interface
  133204. * This is used just to define the profile.
  133205. */
  133206. export interface IMotionControllerLayout {
  133207. /**
  133208. * Path to load the assets. Usually relative to the base path
  133209. */
  133210. assetPath: string;
  133211. /**
  133212. * Available components (unsorted)
  133213. */
  133214. components: {
  133215. /**
  133216. * A map of component Ids
  133217. */
  133218. [componentId: string]: {
  133219. /**
  133220. * The type of input the component outputs
  133221. */
  133222. type: MotionControllerComponentType;
  133223. /**
  133224. * The indices of this component in the gamepad object
  133225. */
  133226. gamepadIndices: {
  133227. /**
  133228. * Index of button
  133229. */
  133230. button?: number;
  133231. /**
  133232. * If available, index of x-axis
  133233. */
  133234. xAxis?: number;
  133235. /**
  133236. * If available, index of y-axis
  133237. */
  133238. yAxis?: number;
  133239. };
  133240. /**
  133241. * The mesh's root node name
  133242. */
  133243. rootNodeName: string;
  133244. /**
  133245. * Animation definitions for this model
  133246. */
  133247. visualResponses: {
  133248. [stateKey: string]: {
  133249. /**
  133250. * What property will be animated
  133251. */
  133252. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  133253. /**
  133254. * What states influence this visual response
  133255. */
  133256. states: MotionControllerComponentStateType[];
  133257. /**
  133258. * Type of animation - movement or visibility
  133259. */
  133260. valueNodeProperty: "transform" | "visibility";
  133261. /**
  133262. * Base node name to move. Its position will be calculated according to the min and max nodes
  133263. */
  133264. valueNodeName?: string;
  133265. /**
  133266. * Minimum movement node
  133267. */
  133268. minNodeName?: string;
  133269. /**
  133270. * Max movement node
  133271. */
  133272. maxNodeName?: string;
  133273. };
  133274. };
  133275. /**
  133276. * If touch enabled, what is the name of node to display user feedback
  133277. */
  133278. touchPointNodeName?: string;
  133279. };
  133280. };
  133281. /**
  133282. * Is it xr standard mapping or not
  133283. */
  133284. gamepadMapping: "" | "xr-standard";
  133285. /**
  133286. * Base root node of this entire model
  133287. */
  133288. rootNodeName: string;
  133289. /**
  133290. * Defines the main button component id
  133291. */
  133292. selectComponentId: string;
  133293. }
  133294. /**
  133295. * A definition for the layout map in the input profile
  133296. */
  133297. export interface IMotionControllerLayoutMap {
  133298. /**
  133299. * Layouts with handedness type as a key
  133300. */
  133301. [handedness: string]: IMotionControllerLayout;
  133302. }
  133303. /**
  133304. * The XR Input profile schema
  133305. * Profiles can be found here:
  133306. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  133307. */
  133308. export interface IMotionControllerProfile {
  133309. /**
  133310. * fallback profiles for this profileId
  133311. */
  133312. fallbackProfileIds: string[];
  133313. /**
  133314. * The layout map, with handedness as key
  133315. */
  133316. layouts: IMotionControllerLayoutMap;
  133317. /**
  133318. * The id of this profile
  133319. * correlates to the profile(s) in the xrInput.profiles array
  133320. */
  133321. profileId: string;
  133322. }
  133323. /**
  133324. * A helper-interface for the 3 meshes needed for controller button animation
  133325. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  133326. */
  133327. export interface IMotionControllerButtonMeshMap {
  133328. /**
  133329. * the mesh that defines the pressed value mesh position.
  133330. * This is used to find the max-position of this button
  133331. */
  133332. pressedMesh: AbstractMesh;
  133333. /**
  133334. * the mesh that defines the unpressed value mesh position.
  133335. * This is used to find the min (or initial) position of this button
  133336. */
  133337. unpressedMesh: AbstractMesh;
  133338. /**
  133339. * The mesh that will be changed when value changes
  133340. */
  133341. valueMesh: AbstractMesh;
  133342. }
  133343. /**
  133344. * A helper-interface for the 3 meshes needed for controller axis animation.
  133345. * This will be expanded when touchpad animations are fully supported
  133346. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  133347. */
  133348. export interface IMotionControllerMeshMap {
  133349. /**
  133350. * the mesh that defines the maximum value mesh position.
  133351. */
  133352. maxMesh?: AbstractMesh;
  133353. /**
  133354. * the mesh that defines the minimum value mesh position.
  133355. */
  133356. minMesh?: AbstractMesh;
  133357. /**
  133358. * The mesh that will be changed when axis value changes
  133359. */
  133360. valueMesh?: AbstractMesh;
  133361. }
  133362. /**
  133363. * The elements needed for change-detection of the gamepad objects in motion controllers
  133364. */
  133365. export interface IMinimalMotionControllerObject {
  133366. /**
  133367. * Available axes of this controller
  133368. */
  133369. axes: number[];
  133370. /**
  133371. * An array of available buttons
  133372. */
  133373. buttons: Array<{
  133374. /**
  133375. * Value of the button/trigger
  133376. */
  133377. value: number;
  133378. /**
  133379. * If the button/trigger is currently touched
  133380. */
  133381. touched: boolean;
  133382. /**
  133383. * If the button/trigger is currently pressed
  133384. */
  133385. pressed: boolean;
  133386. }>;
  133387. /**
  133388. * EXPERIMENTAL haptic support.
  133389. */
  133390. hapticActuators?: Array<{
  133391. pulse: (value: number, duration: number) => Promise<boolean>;
  133392. }>;
  133393. }
  133394. /**
  133395. * An Abstract Motion controller
  133396. * This class receives an xrInput and a profile layout and uses those to initialize the components
  133397. * Each component has an observable to check for changes in value and state
  133398. */
  133399. export abstract class WebXRAbstractMotionController implements IDisposable {
  133400. protected scene: Scene;
  133401. protected layout: IMotionControllerLayout;
  133402. /**
  133403. * The gamepad object correlating to this controller
  133404. */
  133405. gamepadObject: IMinimalMotionControllerObject;
  133406. /**
  133407. * handedness (left/right/none) of this controller
  133408. */
  133409. handedness: MotionControllerHandedness;
  133410. private _initComponent;
  133411. private _modelReady;
  133412. /**
  133413. * A map of components (WebXRControllerComponent) in this motion controller
  133414. * Components have a ComponentType and can also have both button and axis definitions
  133415. */
  133416. readonly components: {
  133417. [id: string]: WebXRControllerComponent;
  133418. };
  133419. /**
  133420. * Disable the model's animation. Can be set at any time.
  133421. */
  133422. disableAnimation: boolean;
  133423. /**
  133424. * Observers registered here will be triggered when the model of this controller is done loading
  133425. */
  133426. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  133427. /**
  133428. * The profile id of this motion controller
  133429. */
  133430. abstract profileId: string;
  133431. /**
  133432. * The root mesh of the model. It is null if the model was not yet initialized
  133433. */
  133434. rootMesh: Nullable<AbstractMesh>;
  133435. /**
  133436. * constructs a new abstract motion controller
  133437. * @param scene the scene to which the model of the controller will be added
  133438. * @param layout The profile layout to load
  133439. * @param gamepadObject The gamepad object correlating to this controller
  133440. * @param handedness handedness (left/right/none) of this controller
  133441. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  133442. */
  133443. constructor(scene: Scene, layout: IMotionControllerLayout,
  133444. /**
  133445. * The gamepad object correlating to this controller
  133446. */
  133447. gamepadObject: IMinimalMotionControllerObject,
  133448. /**
  133449. * handedness (left/right/none) of this controller
  133450. */
  133451. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  133452. /**
  133453. * Dispose this controller, the model mesh and all its components
  133454. */
  133455. dispose(): void;
  133456. /**
  133457. * Returns all components of specific type
  133458. * @param type the type to search for
  133459. * @return an array of components with this type
  133460. */
  133461. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  133462. /**
  133463. * get a component based an its component id as defined in layout.components
  133464. * @param id the id of the component
  133465. * @returns the component correlates to the id or undefined if not found
  133466. */
  133467. getComponent(id: string): WebXRControllerComponent;
  133468. /**
  133469. * Get the list of components available in this motion controller
  133470. * @returns an array of strings correlating to available components
  133471. */
  133472. getComponentIds(): string[];
  133473. /**
  133474. * Get the first component of specific type
  133475. * @param type type of component to find
  133476. * @return a controller component or null if not found
  133477. */
  133478. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  133479. /**
  133480. * Get the main (Select) component of this controller as defined in the layout
  133481. * @returns the main component of this controller
  133482. */
  133483. getMainComponent(): WebXRControllerComponent;
  133484. /**
  133485. * Loads the model correlating to this controller
  133486. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  133487. * @returns A promise fulfilled with the result of the model loading
  133488. */
  133489. loadModel(): Promise<boolean>;
  133490. /**
  133491. * Update this model using the current XRFrame
  133492. * @param xrFrame the current xr frame to use and update the model
  133493. */
  133494. updateFromXRFrame(xrFrame: XRFrame): void;
  133495. /**
  133496. * Backwards compatibility due to a deeply-integrated typo
  133497. */
  133498. get handness(): XREye;
  133499. /**
  133500. * Pulse (vibrate) this controller
  133501. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  133502. * Consecutive calls to this function will cancel the last pulse call
  133503. *
  133504. * @param value the strength of the pulse in 0.0...1.0 range
  133505. * @param duration Duration of the pulse in milliseconds
  133506. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  133507. * @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
  133508. */
  133509. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  133510. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  133511. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  133512. /**
  133513. * Moves the axis on the controller mesh based on its current state
  133514. * @param axis the index of the axis
  133515. * @param axisValue the value of the axis which determines the meshes new position
  133516. * @hidden
  133517. */
  133518. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  133519. /**
  133520. * Update the model itself with the current frame data
  133521. * @param xrFrame the frame to use for updating the model mesh
  133522. */
  133523. protected updateModel(xrFrame: XRFrame): void;
  133524. /**
  133525. * Get the filename and path for this controller's model
  133526. * @returns a map of filename and path
  133527. */
  133528. protected abstract _getFilenameAndPath(): {
  133529. filename: string;
  133530. path: string;
  133531. };
  133532. /**
  133533. * This function is called before the mesh is loaded. It checks for loading constraints.
  133534. * For example, this function can check if the GLB loader is available
  133535. * If this function returns false, the generic controller will be loaded instead
  133536. * @returns Is the client ready to load the mesh
  133537. */
  133538. protected abstract _getModelLoadingConstraints(): boolean;
  133539. /**
  133540. * This function will be called after the model was successfully loaded and can be used
  133541. * for mesh transformations before it is available for the user
  133542. * @param meshes the loaded meshes
  133543. */
  133544. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  133545. /**
  133546. * Set the root mesh for this controller. Important for the WebXR controller class
  133547. * @param meshes the loaded meshes
  133548. */
  133549. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  133550. /**
  133551. * A function executed each frame that updates the mesh (if needed)
  133552. * @param xrFrame the current xrFrame
  133553. */
  133554. protected abstract _updateModel(xrFrame: XRFrame): void;
  133555. private _getGenericFilenameAndPath;
  133556. private _getGenericParentMesh;
  133557. }
  133558. }
  133559. declare module BABYLON {
  133560. /**
  133561. * A generic trigger-only motion controller for WebXR
  133562. */
  133563. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  133564. /**
  133565. * Static version of the profile id of this controller
  133566. */
  133567. static ProfileId: string;
  133568. profileId: string;
  133569. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  133570. protected _getFilenameAndPath(): {
  133571. filename: string;
  133572. path: string;
  133573. };
  133574. protected _getModelLoadingConstraints(): boolean;
  133575. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  133576. protected _setRootMesh(meshes: AbstractMesh[]): void;
  133577. protected _updateModel(): void;
  133578. }
  133579. }
  133580. declare module BABYLON {
  133581. /**
  133582. * Class containing static functions to help procedurally build meshes
  133583. */
  133584. export class SphereBuilder {
  133585. /**
  133586. * Creates a sphere mesh
  133587. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  133588. * * 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`)
  133589. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  133590. * * 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
  133591. * * 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)
  133592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133595. * @param name defines the name of the mesh
  133596. * @param options defines the options used to create the mesh
  133597. * @param scene defines the hosting scene
  133598. * @returns the sphere mesh
  133599. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  133600. */
  133601. static CreateSphere(name: string, options: {
  133602. segments?: number;
  133603. diameter?: number;
  133604. diameterX?: number;
  133605. diameterY?: number;
  133606. diameterZ?: number;
  133607. arc?: number;
  133608. slice?: number;
  133609. sideOrientation?: number;
  133610. frontUVs?: Vector4;
  133611. backUVs?: Vector4;
  133612. updatable?: boolean;
  133613. }, scene?: Nullable<Scene>): Mesh;
  133614. }
  133615. }
  133616. declare module BABYLON {
  133617. /**
  133618. * A profiled motion controller has its profile loaded from an online repository.
  133619. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  133620. */
  133621. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  133622. private _repositoryUrl;
  133623. private _buttonMeshMapping;
  133624. private _touchDots;
  133625. /**
  133626. * The profile ID of this controller. Will be populated when the controller initializes.
  133627. */
  133628. profileId: string;
  133629. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  133630. dispose(): void;
  133631. protected _getFilenameAndPath(): {
  133632. filename: string;
  133633. path: string;
  133634. };
  133635. protected _getModelLoadingConstraints(): boolean;
  133636. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  133637. protected _setRootMesh(meshes: AbstractMesh[]): void;
  133638. protected _updateModel(_xrFrame: XRFrame): void;
  133639. }
  133640. }
  133641. declare module BABYLON {
  133642. /**
  133643. * A construction function type to create a new controller based on an xrInput object
  133644. */
  133645. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  133646. /**
  133647. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  133648. *
  133649. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  133650. * it should be replaced with auto-loaded controllers.
  133651. *
  133652. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  133653. */
  133654. export class WebXRMotionControllerManager {
  133655. private static _AvailableControllers;
  133656. private static _Fallbacks;
  133657. private static _ProfileLoadingPromises;
  133658. private static _ProfilesList;
  133659. /**
  133660. * The base URL of the online controller repository. Can be changed at any time.
  133661. */
  133662. static BaseRepositoryUrl: string;
  133663. /**
  133664. * Which repository gets priority - local or online
  133665. */
  133666. static PrioritizeOnlineRepository: boolean;
  133667. /**
  133668. * Use the online repository, or use only locally-defined controllers
  133669. */
  133670. static UseOnlineRepository: boolean;
  133671. /**
  133672. * Clear the cache used for profile loading and reload when requested again
  133673. */
  133674. static ClearProfilesCache(): void;
  133675. /**
  133676. * Register the default fallbacks.
  133677. * This function is called automatically when this file is imported.
  133678. */
  133679. static DefaultFallbacks(): void;
  133680. /**
  133681. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  133682. * @param profileId the profile to which a fallback needs to be found
  133683. * @return an array with corresponding fallback profiles
  133684. */
  133685. static FindFallbackWithProfileId(profileId: string): string[];
  133686. /**
  133687. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  133688. * The order of search:
  133689. *
  133690. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  133691. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  133692. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  133693. * 4) return the generic trigger controller if none were found
  133694. *
  133695. * @param xrInput the xrInput to which a new controller is initialized
  133696. * @param scene the scene to which the model will be added
  133697. * @param forceProfile force a certain profile for this controller
  133698. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  133699. */
  133700. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  133701. /**
  133702. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  133703. *
  133704. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  133705. *
  133706. * @param type the profile type to register
  133707. * @param constructFunction the function to be called when loading this profile
  133708. */
  133709. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  133710. /**
  133711. * Register a fallback to a specific profile.
  133712. * @param profileId the profileId that will receive the fallbacks
  133713. * @param fallbacks A list of fallback profiles
  133714. */
  133715. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  133716. /**
  133717. * Will update the list of profiles available in the repository
  133718. * @return a promise that resolves to a map of profiles available online
  133719. */
  133720. static UpdateProfilesList(): Promise<{
  133721. [profile: string]: string;
  133722. }>;
  133723. private static _LoadProfileFromRepository;
  133724. private static _LoadProfilesFromAvailableControllers;
  133725. }
  133726. }
  133727. declare module BABYLON {
  133728. /**
  133729. * Configuration options for the WebXR controller creation
  133730. */
  133731. export interface IWebXRControllerOptions {
  133732. /**
  133733. * Should the controller mesh be animated when a user interacts with it
  133734. * The pressed buttons / thumbstick and touchpad animations will be disabled
  133735. */
  133736. disableMotionControllerAnimation?: boolean;
  133737. /**
  133738. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  133739. */
  133740. doNotLoadControllerMesh?: boolean;
  133741. /**
  133742. * Force a specific controller type for this controller.
  133743. * This can be used when creating your own profile or when testing different controllers
  133744. */
  133745. forceControllerProfile?: string;
  133746. /**
  133747. * Defines a rendering group ID for meshes that will be loaded.
  133748. * This is for the default controllers only.
  133749. */
  133750. renderingGroupId?: number;
  133751. }
  133752. /**
  133753. * Represents an XR controller
  133754. */
  133755. export class WebXRInputSource {
  133756. private _scene;
  133757. /** The underlying input source for the controller */
  133758. inputSource: XRInputSource;
  133759. private _options;
  133760. private _tmpVector;
  133761. private _uniqueId;
  133762. private _disposed;
  133763. /**
  133764. * 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
  133765. */
  133766. grip?: AbstractMesh;
  133767. /**
  133768. * If available, this is the gamepad object related to this controller.
  133769. * Using this object it is possible to get click events and trackpad changes of the
  133770. * webxr controller that is currently being used.
  133771. */
  133772. motionController?: WebXRAbstractMotionController;
  133773. /**
  133774. * Event that fires when the controller is removed/disposed.
  133775. * The object provided as event data is this controller, after associated assets were disposed.
  133776. * uniqueId is still available.
  133777. */
  133778. onDisposeObservable: Observable<WebXRInputSource>;
  133779. /**
  133780. * Will be triggered when the mesh associated with the motion controller is done loading.
  133781. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  133782. * A shortened version of controller -> motion controller -> on mesh loaded.
  133783. */
  133784. onMeshLoadedObservable: Observable<AbstractMesh>;
  133785. /**
  133786. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  133787. */
  133788. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  133789. /**
  133790. * Pointer which can be used to select objects or attach a visible laser to
  133791. */
  133792. pointer: AbstractMesh;
  133793. /**
  133794. * Creates the input source object
  133795. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  133796. * @param _scene the scene which the controller should be associated to
  133797. * @param inputSource the underlying input source for the controller
  133798. * @param _options options for this controller creation
  133799. */
  133800. constructor(_scene: Scene,
  133801. /** The underlying input source for the controller */
  133802. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  133803. /**
  133804. * Get this controllers unique id
  133805. */
  133806. get uniqueId(): string;
  133807. /**
  133808. * Disposes of the object
  133809. */
  133810. dispose(): void;
  133811. /**
  133812. * Gets a world space ray coming from the pointer or grip
  133813. * @param result the resulting ray
  133814. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  133815. */
  133816. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  133817. /**
  133818. * Updates the controller pose based on the given XRFrame
  133819. * @param xrFrame xr frame to update the pose with
  133820. * @param referenceSpace reference space to use
  133821. */
  133822. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  133823. }
  133824. }
  133825. declare module BABYLON {
  133826. /**
  133827. * The schema for initialization options of the XR Input class
  133828. */
  133829. export interface IWebXRInputOptions {
  133830. /**
  133831. * If set to true no model will be automatically loaded
  133832. */
  133833. doNotLoadControllerMeshes?: boolean;
  133834. /**
  133835. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  133836. * If not found, the xr input profile data will be used.
  133837. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  133838. */
  133839. forceInputProfile?: string;
  133840. /**
  133841. * Do not send a request to the controller repository to load the profile.
  133842. *
  133843. * Instead, use the controllers available in babylon itself.
  133844. */
  133845. disableOnlineControllerRepository?: boolean;
  133846. /**
  133847. * A custom URL for the controllers repository
  133848. */
  133849. customControllersRepositoryURL?: string;
  133850. /**
  133851. * Should the controller model's components not move according to the user input
  133852. */
  133853. disableControllerAnimation?: boolean;
  133854. /**
  133855. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  133856. */
  133857. controllerOptions?: IWebXRControllerOptions;
  133858. }
  133859. /**
  133860. * XR input used to track XR inputs such as controllers/rays
  133861. */
  133862. export class WebXRInput implements IDisposable {
  133863. /**
  133864. * the xr session manager for this session
  133865. */
  133866. xrSessionManager: WebXRSessionManager;
  133867. /**
  133868. * the WebXR camera for this session. Mainly used for teleportation
  133869. */
  133870. xrCamera: WebXRCamera;
  133871. private readonly options;
  133872. /**
  133873. * XR controllers being tracked
  133874. */
  133875. controllers: Array<WebXRInputSource>;
  133876. private _frameObserver;
  133877. private _sessionEndedObserver;
  133878. private _sessionInitObserver;
  133879. /**
  133880. * Event when a controller has been connected/added
  133881. */
  133882. onControllerAddedObservable: Observable<WebXRInputSource>;
  133883. /**
  133884. * Event when a controller has been removed/disconnected
  133885. */
  133886. onControllerRemovedObservable: Observable<WebXRInputSource>;
  133887. /**
  133888. * Initializes the WebXRInput
  133889. * @param xrSessionManager the xr session manager for this session
  133890. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  133891. * @param options = initialization options for this xr input
  133892. */
  133893. constructor(
  133894. /**
  133895. * the xr session manager for this session
  133896. */
  133897. xrSessionManager: WebXRSessionManager,
  133898. /**
  133899. * the WebXR camera for this session. Mainly used for teleportation
  133900. */
  133901. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  133902. private _onInputSourcesChange;
  133903. private _addAndRemoveControllers;
  133904. /**
  133905. * Disposes of the object
  133906. */
  133907. dispose(): void;
  133908. }
  133909. }
  133910. declare module BABYLON {
  133911. /**
  133912. * This is the base class for all WebXR features.
  133913. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  133914. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  133915. */
  133916. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  133917. protected _xrSessionManager: WebXRSessionManager;
  133918. private _attached;
  133919. private _removeOnDetach;
  133920. /**
  133921. * Is this feature disposed?
  133922. */
  133923. isDisposed: boolean;
  133924. /**
  133925. * Should auto-attach be disabled?
  133926. */
  133927. disableAutoAttach: boolean;
  133928. /**
  133929. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  133930. */
  133931. xrNativeFeatureName: string;
  133932. /**
  133933. * Construct a new (abstract) WebXR feature
  133934. * @param _xrSessionManager the xr session manager for this feature
  133935. */
  133936. constructor(_xrSessionManager: WebXRSessionManager);
  133937. /**
  133938. * Is this feature attached
  133939. */
  133940. get attached(): boolean;
  133941. /**
  133942. * attach this feature
  133943. *
  133944. * @param force should attachment be forced (even when already attached)
  133945. * @returns true if successful, false is failed or already attached
  133946. */
  133947. attach(force?: boolean): boolean;
  133948. /**
  133949. * detach this feature.
  133950. *
  133951. * @returns true if successful, false if failed or already detached
  133952. */
  133953. detach(): boolean;
  133954. /**
  133955. * Dispose this feature and all of the resources attached
  133956. */
  133957. dispose(): void;
  133958. /**
  133959. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  133960. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  133961. *
  133962. * @returns whether or not the feature is compatible in this environment
  133963. */
  133964. isCompatible(): boolean;
  133965. /**
  133966. * This is used to register callbacks that will automatically be removed when detach is called.
  133967. * @param observable the observable to which the observer will be attached
  133968. * @param callback the callback to register
  133969. */
  133970. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  133971. /**
  133972. * Code in this function will be executed on each xrFrame received from the browser.
  133973. * This function will not execute after the feature is detached.
  133974. * @param _xrFrame the current frame
  133975. */
  133976. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  133977. }
  133978. }
  133979. declare module BABYLON {
  133980. /**
  133981. * Renders a layer on top of an existing scene
  133982. */
  133983. export class UtilityLayerRenderer implements IDisposable {
  133984. /** the original scene that will be rendered on top of */
  133985. originalScene: Scene;
  133986. private _pointerCaptures;
  133987. private _lastPointerEvents;
  133988. private static _DefaultUtilityLayer;
  133989. private static _DefaultKeepDepthUtilityLayer;
  133990. private _sharedGizmoLight;
  133991. private _renderCamera;
  133992. /**
  133993. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  133994. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  133995. * @returns the camera that is used when rendering the utility layer
  133996. */
  133997. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  133998. /**
  133999. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  134000. * @param cam the camera that should be used when rendering the utility layer
  134001. */
  134002. setRenderCamera(cam: Nullable<Camera>): void;
  134003. /**
  134004. * @hidden
  134005. * Light which used by gizmos to get light shading
  134006. */
  134007. _getSharedGizmoLight(): HemisphericLight;
  134008. /**
  134009. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  134010. */
  134011. pickUtilitySceneFirst: boolean;
  134012. /**
  134013. * 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)
  134014. */
  134015. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  134016. /**
  134017. * 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)
  134018. */
  134019. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  134020. /**
  134021. * The scene that is rendered on top of the original scene
  134022. */
  134023. utilityLayerScene: Scene;
  134024. /**
  134025. * If the utility layer should automatically be rendered on top of existing scene
  134026. */
  134027. shouldRender: boolean;
  134028. /**
  134029. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  134030. */
  134031. onlyCheckPointerDownEvents: boolean;
  134032. /**
  134033. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  134034. */
  134035. processAllEvents: boolean;
  134036. /**
  134037. * Observable raised when the pointer move from the utility layer scene to the main scene
  134038. */
  134039. onPointerOutObservable: Observable<number>;
  134040. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  134041. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  134042. private _afterRenderObserver;
  134043. private _sceneDisposeObserver;
  134044. private _originalPointerObserver;
  134045. /**
  134046. * Instantiates a UtilityLayerRenderer
  134047. * @param originalScene the original scene that will be rendered on top of
  134048. * @param handleEvents boolean indicating if the utility layer should handle events
  134049. */
  134050. constructor(
  134051. /** the original scene that will be rendered on top of */
  134052. originalScene: Scene, handleEvents?: boolean);
  134053. private _notifyObservers;
  134054. /**
  134055. * Renders the utility layers scene on top of the original scene
  134056. */
  134057. render(): void;
  134058. /**
  134059. * Disposes of the renderer
  134060. */
  134061. dispose(): void;
  134062. private _updateCamera;
  134063. }
  134064. }
  134065. declare module BABYLON {
  134066. /**
  134067. * Options interface for the pointer selection module
  134068. */
  134069. export interface IWebXRControllerPointerSelectionOptions {
  134070. /**
  134071. * if provided, this scene will be used to render meshes.
  134072. */
  134073. customUtilityLayerScene?: Scene;
  134074. /**
  134075. * 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)
  134076. * If not disabled, the last picked point will be used to execute a pointer up event
  134077. * If disabled, pointer up event will be triggered right after the pointer down event.
  134078. * Used in screen and gaze target ray mode only
  134079. */
  134080. disablePointerUpOnTouchOut: boolean;
  134081. /**
  134082. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  134083. */
  134084. forceGazeMode: boolean;
  134085. /**
  134086. * 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
  134087. * to start a new countdown to the pointer down event.
  134088. * Defaults to 1.
  134089. */
  134090. gazeModePointerMovedFactor?: number;
  134091. /**
  134092. * Different button type to use instead of the main component
  134093. */
  134094. overrideButtonId?: string;
  134095. /**
  134096. * use this rendering group id for the meshes (optional)
  134097. */
  134098. renderingGroupId?: number;
  134099. /**
  134100. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  134101. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  134102. * 3000 means 3 seconds between pointing at something and selecting it
  134103. */
  134104. timeToSelect?: number;
  134105. /**
  134106. * Should meshes created here be added to a utility layer or the main scene
  134107. */
  134108. useUtilityLayer?: boolean;
  134109. /**
  134110. * Optional WebXR camera to be used for gaze selection
  134111. */
  134112. gazeCamera?: WebXRCamera;
  134113. /**
  134114. * the xr input to use with this pointer selection
  134115. */
  134116. xrInput: WebXRInput;
  134117. /**
  134118. * Should the scene pointerX and pointerY update be disabled
  134119. * This is required for fullscreen AR GUI, but might slow down other experiences.
  134120. * Disable in VR, if not needed.
  134121. * The first rig camera (left eye) will be used to calculate the projection
  134122. */
  134123. disableScenePointerVectorUpdate: boolean;
  134124. /**
  134125. * Enable pointer selection on all controllers instead of switching between them
  134126. */
  134127. enablePointerSelectionOnAllControllers?: boolean;
  134128. /**
  134129. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  134130. * If switch is enabled, it will still allow the user to switch between the different controllers
  134131. */
  134132. preferredHandedness?: XRHandedness;
  134133. /**
  134134. * Disable switching the pointer selection from one controller to the other.
  134135. * 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
  134136. */
  134137. disableSwitchOnClick?: boolean;
  134138. /**
  134139. * The maximum distance of the pointer selection feature. Defaults to 100.
  134140. */
  134141. maxPointerDistance?: number;
  134142. }
  134143. /**
  134144. * A module that will enable pointer selection for motion controllers of XR Input Sources
  134145. */
  134146. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  134147. private readonly _options;
  134148. private static _idCounter;
  134149. private _attachController;
  134150. private _controllers;
  134151. private _scene;
  134152. private _tmpVectorForPickCompare;
  134153. private _attachedController;
  134154. /**
  134155. * The module's name
  134156. */
  134157. static readonly Name: string;
  134158. /**
  134159. * The (Babylon) version of this module.
  134160. * This is an integer representing the implementation version.
  134161. * This number does not correspond to the WebXR specs version
  134162. */
  134163. static readonly Version: number;
  134164. /**
  134165. * Disable lighting on the laser pointer (so it will always be visible)
  134166. */
  134167. disablePointerLighting: boolean;
  134168. /**
  134169. * Disable lighting on the selection mesh (so it will always be visible)
  134170. */
  134171. disableSelectionMeshLighting: boolean;
  134172. /**
  134173. * Should the laser pointer be displayed
  134174. */
  134175. displayLaserPointer: boolean;
  134176. /**
  134177. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  134178. */
  134179. displaySelectionMesh: boolean;
  134180. /**
  134181. * This color will be set to the laser pointer when selection is triggered
  134182. */
  134183. laserPointerPickedColor: Color3;
  134184. /**
  134185. * Default color of the laser pointer
  134186. */
  134187. laserPointerDefaultColor: Color3;
  134188. /**
  134189. * default color of the selection ring
  134190. */
  134191. selectionMeshDefaultColor: Color3;
  134192. /**
  134193. * This color will be applied to the selection ring when selection is triggered
  134194. */
  134195. selectionMeshPickedColor: Color3;
  134196. /**
  134197. * Optional filter to be used for ray selection. This predicate shares behavior with
  134198. * scene.pointerMovePredicate which takes priority if it is also assigned.
  134199. */
  134200. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  134201. /**
  134202. * constructs a new background remover module
  134203. * @param _xrSessionManager the session manager for this module
  134204. * @param _options read-only options to be used in this module
  134205. */
  134206. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  134207. /**
  134208. * attach this feature
  134209. * Will usually be called by the features manager
  134210. *
  134211. * @returns true if successful.
  134212. */
  134213. attach(): boolean;
  134214. /**
  134215. * detach this feature.
  134216. * Will usually be called by the features manager
  134217. *
  134218. * @returns true if successful.
  134219. */
  134220. detach(): boolean;
  134221. /**
  134222. * Will get the mesh under a specific pointer.
  134223. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  134224. * @param controllerId the controllerId to check
  134225. * @returns The mesh under pointer or null if no mesh is under the pointer
  134226. */
  134227. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  134228. /**
  134229. * Get the xr controller that correlates to the pointer id in the pointer event
  134230. *
  134231. * @param id the pointer id to search for
  134232. * @returns the controller that correlates to this id or null if not found
  134233. */
  134234. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  134235. private _identityMatrix;
  134236. private _screenCoordinatesRef;
  134237. private _viewportRef;
  134238. protected _onXRFrame(_xrFrame: XRFrame): void;
  134239. private _attachGazeMode;
  134240. private _attachScreenRayMode;
  134241. private _attachTrackedPointerRayMode;
  134242. private _convertNormalToDirectionOfRay;
  134243. private _detachController;
  134244. private _generateNewMeshPair;
  134245. private _pickingMoved;
  134246. private _updatePointerDistance;
  134247. /** @hidden */
  134248. get lasterPointerDefaultColor(): Color3;
  134249. }
  134250. }
  134251. declare module BABYLON {
  134252. /**
  134253. * Button which can be used to enter a different mode of XR
  134254. */
  134255. export class WebXREnterExitUIButton {
  134256. /** button element */
  134257. element: HTMLElement;
  134258. /** XR initialization options for the button */
  134259. sessionMode: XRSessionMode;
  134260. /** Reference space type */
  134261. referenceSpaceType: XRReferenceSpaceType;
  134262. /**
  134263. * Creates a WebXREnterExitUIButton
  134264. * @param element button element
  134265. * @param sessionMode XR initialization session mode
  134266. * @param referenceSpaceType the type of reference space to be used
  134267. */
  134268. constructor(
  134269. /** button element */
  134270. element: HTMLElement,
  134271. /** XR initialization options for the button */
  134272. sessionMode: XRSessionMode,
  134273. /** Reference space type */
  134274. referenceSpaceType: XRReferenceSpaceType);
  134275. /**
  134276. * Extendable function which can be used to update the button's visuals when the state changes
  134277. * @param activeButton the current active button in the UI
  134278. */
  134279. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  134280. }
  134281. /**
  134282. * Options to create the webXR UI
  134283. */
  134284. export class WebXREnterExitUIOptions {
  134285. /**
  134286. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  134287. */
  134288. customButtons?: Array<WebXREnterExitUIButton>;
  134289. /**
  134290. * A reference space type to use when creating the default button.
  134291. * Default is local-floor
  134292. */
  134293. referenceSpaceType?: XRReferenceSpaceType;
  134294. /**
  134295. * Context to enter xr with
  134296. */
  134297. renderTarget?: Nullable<WebXRRenderTarget>;
  134298. /**
  134299. * A session mode to use when creating the default button.
  134300. * Default is immersive-vr
  134301. */
  134302. sessionMode?: XRSessionMode;
  134303. /**
  134304. * A list of optional features to init the session with
  134305. */
  134306. optionalFeatures?: string[];
  134307. /**
  134308. * A list of optional features to init the session with
  134309. */
  134310. requiredFeatures?: string[];
  134311. /**
  134312. * If defined, this function will be executed if the UI encounters an error when entering XR
  134313. */
  134314. onError?: (error: any) => void;
  134315. }
  134316. /**
  134317. * UI to allow the user to enter/exit XR mode
  134318. */
  134319. export class WebXREnterExitUI implements IDisposable {
  134320. private scene;
  134321. /** version of the options passed to this UI */
  134322. options: WebXREnterExitUIOptions;
  134323. private _activeButton;
  134324. private _buttons;
  134325. /**
  134326. * The HTML Div Element to which buttons are added.
  134327. */
  134328. readonly overlay: HTMLDivElement;
  134329. /**
  134330. * Fired every time the active button is changed.
  134331. *
  134332. * When xr is entered via a button that launches xr that button will be the callback parameter
  134333. *
  134334. * When exiting xr the callback parameter will be null)
  134335. */
  134336. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  134337. /**
  134338. *
  134339. * @param scene babylon scene object to use
  134340. * @param options (read-only) version of the options passed to this UI
  134341. */
  134342. private constructor();
  134343. /**
  134344. * Creates UI to allow the user to enter/exit XR mode
  134345. * @param scene the scene to add the ui to
  134346. * @param helper the xr experience helper to enter/exit xr with
  134347. * @param options options to configure the UI
  134348. * @returns the created ui
  134349. */
  134350. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  134351. /**
  134352. * Disposes of the XR UI component
  134353. */
  134354. dispose(): void;
  134355. private _updateButtons;
  134356. }
  134357. }
  134358. declare module BABYLON {
  134359. /**
  134360. * Class containing static functions to help procedurally build meshes
  134361. */
  134362. export class LinesBuilder {
  134363. /**
  134364. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134365. * * 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
  134366. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134367. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134368. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134369. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134370. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134371. * * 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
  134372. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134375. * @param name defines the name of the new line system
  134376. * @param options defines the options used to create the line system
  134377. * @param scene defines the hosting scene
  134378. * @returns a new line system mesh
  134379. */
  134380. static CreateLineSystem(name: string, options: {
  134381. lines: Vector3[][];
  134382. updatable?: boolean;
  134383. instance?: Nullable<LinesMesh>;
  134384. colors?: Nullable<Color4[][]>;
  134385. useVertexAlpha?: boolean;
  134386. }, scene: Nullable<Scene>): LinesMesh;
  134387. /**
  134388. * Creates a line mesh
  134389. * 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
  134390. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134391. * * The parameter `points` is an array successive Vector3
  134392. * * 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
  134393. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134394. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134395. * * When updating an instance, remember that only point positions can change, not the number of points
  134396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134397. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134398. * @param name defines the name of the new line system
  134399. * @param options defines the options used to create the line system
  134400. * @param scene defines the hosting scene
  134401. * @returns a new line mesh
  134402. */
  134403. static CreateLines(name: string, options: {
  134404. points: Vector3[];
  134405. updatable?: boolean;
  134406. instance?: Nullable<LinesMesh>;
  134407. colors?: Color4[];
  134408. useVertexAlpha?: boolean;
  134409. }, scene?: Nullable<Scene>): LinesMesh;
  134410. /**
  134411. * Creates a dashed line mesh
  134412. * * 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
  134413. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134414. * * The parameter `points` is an array successive Vector3
  134415. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134416. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134417. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134418. * * 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
  134419. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134420. * * When updating an instance, remember that only point positions can change, not the number of points
  134421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134422. * @param name defines the name of the mesh
  134423. * @param options defines the options used to create the mesh
  134424. * @param scene defines the hosting scene
  134425. * @returns the dashed line mesh
  134426. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134427. */
  134428. static CreateDashedLines(name: string, options: {
  134429. points: Vector3[];
  134430. dashSize?: number;
  134431. gapSize?: number;
  134432. dashNb?: number;
  134433. updatable?: boolean;
  134434. instance?: LinesMesh;
  134435. useVertexAlpha?: boolean;
  134436. }, scene?: Nullable<Scene>): LinesMesh;
  134437. }
  134438. }
  134439. declare module BABYLON {
  134440. /**
  134441. * Construction options for a timer
  134442. */
  134443. export interface ITimerOptions<T> {
  134444. /**
  134445. * Time-to-end
  134446. */
  134447. timeout: number;
  134448. /**
  134449. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  134450. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  134451. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  134452. */
  134453. contextObservable: Observable<T>;
  134454. /**
  134455. * Optional parameters when adding an observer to the observable
  134456. */
  134457. observableParameters?: {
  134458. mask?: number;
  134459. insertFirst?: boolean;
  134460. scope?: any;
  134461. };
  134462. /**
  134463. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  134464. */
  134465. breakCondition?: (data?: ITimerData<T>) => boolean;
  134466. /**
  134467. * Will be triggered when the time condition has met
  134468. */
  134469. onEnded?: (data: ITimerData<any>) => void;
  134470. /**
  134471. * Will be triggered when the break condition has met (prematurely ended)
  134472. */
  134473. onAborted?: (data: ITimerData<any>) => void;
  134474. /**
  134475. * Optional function to execute on each tick (or count)
  134476. */
  134477. onTick?: (data: ITimerData<any>) => void;
  134478. }
  134479. /**
  134480. * An interface defining the data sent by the timer
  134481. */
  134482. export interface ITimerData<T> {
  134483. /**
  134484. * When did it start
  134485. */
  134486. startTime: number;
  134487. /**
  134488. * Time now
  134489. */
  134490. currentTime: number;
  134491. /**
  134492. * Time passed since started
  134493. */
  134494. deltaTime: number;
  134495. /**
  134496. * How much is completed, in [0.0...1.0].
  134497. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  134498. */
  134499. completeRate: number;
  134500. /**
  134501. * What the registered observable sent in the last count
  134502. */
  134503. payload: T;
  134504. }
  134505. /**
  134506. * The current state of the timer
  134507. */
  134508. export enum TimerState {
  134509. /**
  134510. * Timer initialized, not yet started
  134511. */
  134512. INIT = 0,
  134513. /**
  134514. * Timer started and counting
  134515. */
  134516. STARTED = 1,
  134517. /**
  134518. * Timer ended (whether aborted or time reached)
  134519. */
  134520. ENDED = 2
  134521. }
  134522. /**
  134523. * A simple version of the timer. Will take options and start the timer immediately after calling it
  134524. *
  134525. * @param options options with which to initialize this timer
  134526. */
  134527. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  134528. /**
  134529. * An advanced implementation of a timer class
  134530. */
  134531. export class AdvancedTimer<T = any> implements IDisposable {
  134532. /**
  134533. * Will notify each time the timer calculates the remaining time
  134534. */
  134535. onEachCountObservable: Observable<ITimerData<T>>;
  134536. /**
  134537. * Will trigger when the timer was aborted due to the break condition
  134538. */
  134539. onTimerAbortedObservable: Observable<ITimerData<T>>;
  134540. /**
  134541. * Will trigger when the timer ended successfully
  134542. */
  134543. onTimerEndedObservable: Observable<ITimerData<T>>;
  134544. /**
  134545. * Will trigger when the timer state has changed
  134546. */
  134547. onStateChangedObservable: Observable<TimerState>;
  134548. private _observer;
  134549. private _contextObservable;
  134550. private _observableParameters;
  134551. private _startTime;
  134552. private _timer;
  134553. private _state;
  134554. private _breakCondition;
  134555. private _timeToEnd;
  134556. private _breakOnNextTick;
  134557. /**
  134558. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  134559. * @param options construction options for this advanced timer
  134560. */
  134561. constructor(options: ITimerOptions<T>);
  134562. /**
  134563. * set a breaking condition for this timer. Default is to never break during count
  134564. * @param predicate the new break condition. Returns true to break, false otherwise
  134565. */
  134566. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  134567. /**
  134568. * Reset ALL associated observables in this advanced timer
  134569. */
  134570. clearObservables(): void;
  134571. /**
  134572. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  134573. *
  134574. * @param timeToEnd how much time to measure until timer ended
  134575. */
  134576. start(timeToEnd?: number): void;
  134577. /**
  134578. * Will force a stop on the next tick.
  134579. */
  134580. stop(): void;
  134581. /**
  134582. * Dispose this timer, clearing all resources
  134583. */
  134584. dispose(): void;
  134585. private _setState;
  134586. private _tick;
  134587. private _stop;
  134588. }
  134589. }
  134590. declare module BABYLON {
  134591. /**
  134592. * The options container for the teleportation module
  134593. */
  134594. export interface IWebXRTeleportationOptions {
  134595. /**
  134596. * if provided, this scene will be used to render meshes.
  134597. */
  134598. customUtilityLayerScene?: Scene;
  134599. /**
  134600. * Values to configure the default target mesh
  134601. */
  134602. defaultTargetMeshOptions?: {
  134603. /**
  134604. * Fill color of the teleportation area
  134605. */
  134606. teleportationFillColor?: string;
  134607. /**
  134608. * Border color for the teleportation area
  134609. */
  134610. teleportationBorderColor?: string;
  134611. /**
  134612. * Disable the mesh's animation sequence
  134613. */
  134614. disableAnimation?: boolean;
  134615. /**
  134616. * Disable lighting on the material or the ring and arrow
  134617. */
  134618. disableLighting?: boolean;
  134619. /**
  134620. * Override the default material of the torus and arrow
  134621. */
  134622. torusArrowMaterial?: Material;
  134623. };
  134624. /**
  134625. * A list of meshes to use as floor meshes.
  134626. * Meshes can be added and removed after initializing the feature using the
  134627. * addFloorMesh and removeFloorMesh functions
  134628. * If empty, rotation will still work
  134629. */
  134630. floorMeshes?: AbstractMesh[];
  134631. /**
  134632. * use this rendering group id for the meshes (optional)
  134633. */
  134634. renderingGroupId?: number;
  134635. /**
  134636. * Should teleportation move only to snap points
  134637. */
  134638. snapPointsOnly?: boolean;
  134639. /**
  134640. * An array of points to which the teleportation will snap to.
  134641. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  134642. */
  134643. snapPositions?: Vector3[];
  134644. /**
  134645. * How close should the teleportation ray be in order to snap to position.
  134646. * Default to 0.8 units (meters)
  134647. */
  134648. snapToPositionRadius?: number;
  134649. /**
  134650. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  134651. * If you want to support rotation, make sure your mesh has a direction indicator.
  134652. *
  134653. * When left untouched, the default mesh will be initialized.
  134654. */
  134655. teleportationTargetMesh?: AbstractMesh;
  134656. /**
  134657. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  134658. */
  134659. timeToTeleport?: number;
  134660. /**
  134661. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  134662. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  134663. */
  134664. useMainComponentOnly?: boolean;
  134665. /**
  134666. * Should meshes created here be added to a utility layer or the main scene
  134667. */
  134668. useUtilityLayer?: boolean;
  134669. /**
  134670. * Babylon XR Input class for controller
  134671. */
  134672. xrInput: WebXRInput;
  134673. /**
  134674. * Meshes that the teleportation ray cannot go through
  134675. */
  134676. pickBlockerMeshes?: AbstractMesh[];
  134677. /**
  134678. * Should teleport work only on a specific hand?
  134679. */
  134680. forceHandedness?: XRHandedness;
  134681. /**
  134682. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  134683. */
  134684. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  134685. }
  134686. /**
  134687. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  134688. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  134689. * the input of the attached controllers.
  134690. */
  134691. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  134692. private _options;
  134693. private _controllers;
  134694. private _currentTeleportationControllerId;
  134695. private _floorMeshes;
  134696. private _quadraticBezierCurve;
  134697. private _selectionFeature;
  134698. private _snapToPositions;
  134699. private _snappedToPoint;
  134700. private _teleportationRingMaterial?;
  134701. private _tmpRay;
  134702. private _tmpVector;
  134703. private _tmpQuaternion;
  134704. /**
  134705. * The module's name
  134706. */
  134707. static readonly Name: string;
  134708. /**
  134709. * The (Babylon) version of this module.
  134710. * This is an integer representing the implementation version.
  134711. * This number does not correspond to the webxr specs version
  134712. */
  134713. static readonly Version: number;
  134714. /**
  134715. * Is movement backwards enabled
  134716. */
  134717. backwardsMovementEnabled: boolean;
  134718. /**
  134719. * Distance to travel when moving backwards
  134720. */
  134721. backwardsTeleportationDistance: number;
  134722. /**
  134723. * The distance from the user to the inspection point in the direction of the controller
  134724. * A higher number will allow the user to move further
  134725. * defaults to 5 (meters, in xr units)
  134726. */
  134727. parabolicCheckRadius: number;
  134728. /**
  134729. * Should the module support parabolic ray on top of direct ray
  134730. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  134731. * Very helpful when moving between floors / different heights
  134732. */
  134733. parabolicRayEnabled: boolean;
  134734. /**
  134735. * The second type of ray - straight line.
  134736. * Should it be enabled or should the parabolic line be the only one.
  134737. */
  134738. straightRayEnabled: boolean;
  134739. /**
  134740. * How much rotation should be applied when rotating right and left
  134741. */
  134742. rotationAngle: number;
  134743. private _rotationEnabled;
  134744. /**
  134745. * Is rotation enabled when moving forward?
  134746. * Disabling this feature will prevent the user from deciding the direction when teleporting
  134747. */
  134748. get rotationEnabled(): boolean;
  134749. /**
  134750. * Sets wether rotation is enabled or not
  134751. * @param enabled is rotation enabled when teleportation is shown
  134752. */
  134753. set rotationEnabled(enabled: boolean);
  134754. /**
  134755. * Exposes the currently set teleportation target mesh.
  134756. */
  134757. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  134758. /**
  134759. * constructs a new anchor system
  134760. * @param _xrSessionManager an instance of WebXRSessionManager
  134761. * @param _options configuration object for this feature
  134762. */
  134763. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  134764. /**
  134765. * Get the snapPointsOnly flag
  134766. */
  134767. get snapPointsOnly(): boolean;
  134768. /**
  134769. * Sets the snapPointsOnly flag
  134770. * @param snapToPoints should teleportation be exclusively to snap points
  134771. */
  134772. set snapPointsOnly(snapToPoints: boolean);
  134773. /**
  134774. * Add a new mesh to the floor meshes array
  134775. * @param mesh the mesh to use as floor mesh
  134776. */
  134777. addFloorMesh(mesh: AbstractMesh): void;
  134778. /**
  134779. * Add a new snap-to point to fix teleportation to this position
  134780. * @param newSnapPoint The new Snap-To point
  134781. */
  134782. addSnapPoint(newSnapPoint: Vector3): void;
  134783. attach(): boolean;
  134784. detach(): boolean;
  134785. dispose(): void;
  134786. /**
  134787. * Remove a mesh from the floor meshes array
  134788. * @param mesh the mesh to remove
  134789. */
  134790. removeFloorMesh(mesh: AbstractMesh): void;
  134791. /**
  134792. * Remove a mesh from the floor meshes array using its name
  134793. * @param name the mesh name to remove
  134794. */
  134795. removeFloorMeshByName(name: string): void;
  134796. /**
  134797. * 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
  134798. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  134799. * @returns was the point found and removed or not
  134800. */
  134801. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  134802. /**
  134803. * This function sets a selection feature that will be disabled when
  134804. * the forward ray is shown and will be reattached when hidden.
  134805. * This is used to remove the selection rays when moving.
  134806. * @param selectionFeature the feature to disable when forward movement is enabled
  134807. */
  134808. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  134809. protected _onXRFrame(_xrFrame: XRFrame): void;
  134810. private _attachController;
  134811. private _createDefaultTargetMesh;
  134812. private _detachController;
  134813. private _findClosestSnapPointWithRadius;
  134814. private _setTargetMeshPosition;
  134815. private _setTargetMeshVisibility;
  134816. private _showParabolicPath;
  134817. private _teleportForward;
  134818. }
  134819. }
  134820. declare module BABYLON {
  134821. /**
  134822. * Options for the default xr helper
  134823. */
  134824. export class WebXRDefaultExperienceOptions {
  134825. /**
  134826. * Enable or disable default UI to enter XR
  134827. */
  134828. disableDefaultUI?: boolean;
  134829. /**
  134830. * Should teleportation not initialize. defaults to false.
  134831. */
  134832. disableTeleportation?: boolean;
  134833. /**
  134834. * Floor meshes that will be used for teleport
  134835. */
  134836. floorMeshes?: Array<AbstractMesh>;
  134837. /**
  134838. * If set to true, the first frame will not be used to reset position
  134839. * The first frame is mainly used when copying transformation from the old camera
  134840. * Mainly used in AR
  134841. */
  134842. ignoreNativeCameraTransformation?: boolean;
  134843. /**
  134844. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  134845. */
  134846. inputOptions?: IWebXRInputOptions;
  134847. /**
  134848. * optional configuration for the output canvas
  134849. */
  134850. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  134851. /**
  134852. * optional UI options. This can be used among other to change session mode and reference space type
  134853. */
  134854. uiOptions?: WebXREnterExitUIOptions;
  134855. /**
  134856. * When loading teleportation and pointer select, use stable versions instead of latest.
  134857. */
  134858. useStablePlugins?: boolean;
  134859. /**
  134860. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  134861. */
  134862. renderingGroupId?: number;
  134863. /**
  134864. * A list of optional features to init the session with
  134865. * If set to true, all features we support will be added
  134866. */
  134867. optionalFeatures?: boolean | string[];
  134868. }
  134869. /**
  134870. * Default experience which provides a similar setup to the previous webVRExperience
  134871. */
  134872. export class WebXRDefaultExperience {
  134873. /**
  134874. * Base experience
  134875. */
  134876. baseExperience: WebXRExperienceHelper;
  134877. /**
  134878. * Enables ui for entering/exiting xr
  134879. */
  134880. enterExitUI: WebXREnterExitUI;
  134881. /**
  134882. * Input experience extension
  134883. */
  134884. input: WebXRInput;
  134885. /**
  134886. * Enables laser pointer and selection
  134887. */
  134888. pointerSelection: WebXRControllerPointerSelection;
  134889. /**
  134890. * Default target xr should render to
  134891. */
  134892. renderTarget: WebXRRenderTarget;
  134893. /**
  134894. * Enables teleportation
  134895. */
  134896. teleportation: WebXRMotionControllerTeleportation;
  134897. private constructor();
  134898. /**
  134899. * Creates the default xr experience
  134900. * @param scene scene
  134901. * @param options options for basic configuration
  134902. * @returns resulting WebXRDefaultExperience
  134903. */
  134904. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134905. /**
  134906. * DIsposes of the experience helper
  134907. */
  134908. dispose(): void;
  134909. }
  134910. }
  134911. declare module BABYLON {
  134912. /**
  134913. * Options to modify the vr teleportation behavior.
  134914. */
  134915. export interface VRTeleportationOptions {
  134916. /**
  134917. * The name of the mesh which should be used as the teleportation floor. (default: null)
  134918. */
  134919. floorMeshName?: string;
  134920. /**
  134921. * A list of meshes to be used as the teleportation floor. (default: empty)
  134922. */
  134923. floorMeshes?: Mesh[];
  134924. /**
  134925. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  134926. */
  134927. teleportationMode?: number;
  134928. /**
  134929. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  134930. */
  134931. teleportationTime?: number;
  134932. /**
  134933. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  134934. */
  134935. teleportationSpeed?: number;
  134936. /**
  134937. * The easing function used in the animation or null for Linear. (default CircleEase)
  134938. */
  134939. easingFunction?: EasingFunction;
  134940. }
  134941. /**
  134942. * Options to modify the vr experience helper's behavior.
  134943. */
  134944. export interface VRExperienceHelperOptions extends WebVROptions {
  134945. /**
  134946. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  134947. */
  134948. createDeviceOrientationCamera?: boolean;
  134949. /**
  134950. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  134951. */
  134952. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  134953. /**
  134954. * Uses the main button on the controller to toggle the laser casted. (default: true)
  134955. */
  134956. laserToggle?: boolean;
  134957. /**
  134958. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  134959. */
  134960. floorMeshes?: Mesh[];
  134961. /**
  134962. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  134963. */
  134964. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  134965. /**
  134966. * Defines if WebXR should be used instead of WebVR (if available)
  134967. */
  134968. useXR?: boolean;
  134969. }
  134970. /**
  134971. * Event containing information after VR has been entered
  134972. */
  134973. export class OnAfterEnteringVRObservableEvent {
  134974. /**
  134975. * If entering vr was successful
  134976. */
  134977. success: boolean;
  134978. }
  134979. /**
  134980. * Helps to quickly add VR support to an existing scene.
  134981. * See https://doc.babylonjs.com/how_to/webvr_helper
  134982. */
  134983. export class VRExperienceHelper {
  134984. /** Options to modify the vr experience helper's behavior. */
  134985. webVROptions: VRExperienceHelperOptions;
  134986. private _scene;
  134987. private _position;
  134988. private _btnVR;
  134989. private _btnVRDisplayed;
  134990. private _webVRsupported;
  134991. private _webVRready;
  134992. private _webVRrequesting;
  134993. private _webVRpresenting;
  134994. private _hasEnteredVR;
  134995. private _fullscreenVRpresenting;
  134996. private _inputElement;
  134997. private _webVRCamera;
  134998. private _vrDeviceOrientationCamera;
  134999. private _deviceOrientationCamera;
  135000. private _existingCamera;
  135001. private _onKeyDown;
  135002. private _onVrDisplayPresentChange;
  135003. private _onVRDisplayChanged;
  135004. private _onVRRequestPresentStart;
  135005. private _onVRRequestPresentComplete;
  135006. /**
  135007. * 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)
  135008. */
  135009. enableGazeEvenWhenNoPointerLock: boolean;
  135010. /**
  135011. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  135012. */
  135013. exitVROnDoubleTap: boolean;
  135014. /**
  135015. * Observable raised right before entering VR.
  135016. */
  135017. onEnteringVRObservable: Observable<VRExperienceHelper>;
  135018. /**
  135019. * Observable raised when entering VR has completed.
  135020. */
  135021. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  135022. /**
  135023. * Observable raised when exiting VR.
  135024. */
  135025. onExitingVRObservable: Observable<VRExperienceHelper>;
  135026. /**
  135027. * Observable raised when controller mesh is loaded.
  135028. */
  135029. onControllerMeshLoadedObservable: Observable<WebVRController>;
  135030. /** Return this.onEnteringVRObservable
  135031. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  135032. */
  135033. get onEnteringVR(): Observable<VRExperienceHelper>;
  135034. /** Return this.onExitingVRObservable
  135035. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  135036. */
  135037. get onExitingVR(): Observable<VRExperienceHelper>;
  135038. /** Return this.onControllerMeshLoadedObservable
  135039. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  135040. */
  135041. get onControllerMeshLoaded(): Observable<WebVRController>;
  135042. private _rayLength;
  135043. private _useCustomVRButton;
  135044. private _teleportationRequested;
  135045. private _teleportActive;
  135046. private _floorMeshName;
  135047. private _floorMeshesCollection;
  135048. private _teleportationMode;
  135049. private _teleportationTime;
  135050. private _teleportationSpeed;
  135051. private _teleportationEasing;
  135052. private _rotationAllowed;
  135053. private _teleportBackwardsVector;
  135054. private _teleportationTarget;
  135055. private _isDefaultTeleportationTarget;
  135056. private _postProcessMove;
  135057. private _teleportationFillColor;
  135058. private _teleportationBorderColor;
  135059. private _rotationAngle;
  135060. private _haloCenter;
  135061. private _cameraGazer;
  135062. private _padSensibilityUp;
  135063. private _padSensibilityDown;
  135064. private _leftController;
  135065. private _rightController;
  135066. private _gazeColor;
  135067. private _laserColor;
  135068. private _pickedLaserColor;
  135069. private _pickedGazeColor;
  135070. /**
  135071. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  135072. */
  135073. onNewMeshSelected: Observable<AbstractMesh>;
  135074. /**
  135075. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  135076. * This observable will provide the mesh and the controller used to select the mesh
  135077. */
  135078. onMeshSelectedWithController: Observable<{
  135079. mesh: AbstractMesh;
  135080. controller: WebVRController;
  135081. }>;
  135082. /**
  135083. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  135084. */
  135085. onNewMeshPicked: Observable<PickingInfo>;
  135086. private _circleEase;
  135087. /**
  135088. * Observable raised before camera teleportation
  135089. */
  135090. onBeforeCameraTeleport: Observable<Vector3>;
  135091. /**
  135092. * Observable raised after camera teleportation
  135093. */
  135094. onAfterCameraTeleport: Observable<Vector3>;
  135095. /**
  135096. * Observable raised when current selected mesh gets unselected
  135097. */
  135098. onSelectedMeshUnselected: Observable<AbstractMesh>;
  135099. private _raySelectionPredicate;
  135100. /**
  135101. * To be optionaly changed by user to define custom ray selection
  135102. */
  135103. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  135104. /**
  135105. * To be optionaly changed by user to define custom selection logic (after ray selection)
  135106. */
  135107. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  135108. /**
  135109. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  135110. */
  135111. teleportationEnabled: boolean;
  135112. private _defaultHeight;
  135113. private _teleportationInitialized;
  135114. private _interactionsEnabled;
  135115. private _interactionsRequested;
  135116. private _displayGaze;
  135117. private _displayLaserPointer;
  135118. /**
  135119. * The mesh used to display where the user is going to teleport.
  135120. */
  135121. get teleportationTarget(): Mesh;
  135122. /**
  135123. * Sets the mesh to be used to display where the user is going to teleport.
  135124. */
  135125. set teleportationTarget(value: Mesh);
  135126. /**
  135127. * 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
  135128. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  135129. * See https://doc.babylonjs.com/resources/baking_transformations
  135130. */
  135131. get gazeTrackerMesh(): Mesh;
  135132. set gazeTrackerMesh(value: Mesh);
  135133. /**
  135134. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  135135. */
  135136. updateGazeTrackerScale: boolean;
  135137. /**
  135138. * If the gaze trackers color should be updated when selecting meshes
  135139. */
  135140. updateGazeTrackerColor: boolean;
  135141. /**
  135142. * If the controller laser color should be updated when selecting meshes
  135143. */
  135144. updateControllerLaserColor: boolean;
  135145. /**
  135146. * The gaze tracking mesh corresponding to the left controller
  135147. */
  135148. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  135149. /**
  135150. * The gaze tracking mesh corresponding to the right controller
  135151. */
  135152. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  135153. /**
  135154. * If the ray of the gaze should be displayed.
  135155. */
  135156. get displayGaze(): boolean;
  135157. /**
  135158. * Sets if the ray of the gaze should be displayed.
  135159. */
  135160. set displayGaze(value: boolean);
  135161. /**
  135162. * If the ray of the LaserPointer should be displayed.
  135163. */
  135164. get displayLaserPointer(): boolean;
  135165. /**
  135166. * Sets if the ray of the LaserPointer should be displayed.
  135167. */
  135168. set displayLaserPointer(value: boolean);
  135169. /**
  135170. * The deviceOrientationCamera used as the camera when not in VR.
  135171. */
  135172. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  135173. /**
  135174. * Based on the current WebVR support, returns the current VR camera used.
  135175. */
  135176. get currentVRCamera(): Nullable<Camera>;
  135177. /**
  135178. * The webVRCamera which is used when in VR.
  135179. */
  135180. get webVRCamera(): WebVRFreeCamera;
  135181. /**
  135182. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  135183. */
  135184. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  135185. /**
  135186. * The html button that is used to trigger entering into VR.
  135187. */
  135188. get vrButton(): Nullable<HTMLButtonElement>;
  135189. private get _teleportationRequestInitiated();
  135190. /**
  135191. * Defines whether or not Pointer lock should be requested when switching to
  135192. * full screen.
  135193. */
  135194. requestPointerLockOnFullScreen: boolean;
  135195. /**
  135196. * If asking to force XR, this will be populated with the default xr experience
  135197. */
  135198. xr: WebXRDefaultExperience;
  135199. /**
  135200. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  135201. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  135202. */
  135203. xrTestDone: boolean;
  135204. /**
  135205. * Instantiates a VRExperienceHelper.
  135206. * Helps to quickly add VR support to an existing scene.
  135207. * @param scene The scene the VRExperienceHelper belongs to.
  135208. * @param webVROptions Options to modify the vr experience helper's behavior.
  135209. */
  135210. constructor(scene: Scene,
  135211. /** Options to modify the vr experience helper's behavior. */
  135212. webVROptions?: VRExperienceHelperOptions);
  135213. private completeVRInit;
  135214. private _onDefaultMeshLoaded;
  135215. private _onResize;
  135216. private _onFullscreenChange;
  135217. /**
  135218. * Gets a value indicating if we are currently in VR mode.
  135219. */
  135220. get isInVRMode(): boolean;
  135221. private onVrDisplayPresentChange;
  135222. private onVRDisplayChanged;
  135223. private moveButtonToBottomRight;
  135224. private displayVRButton;
  135225. private updateButtonVisibility;
  135226. private _cachedAngularSensibility;
  135227. /**
  135228. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  135229. * Otherwise, will use the fullscreen API.
  135230. */
  135231. enterVR(): void;
  135232. /**
  135233. * Attempt to exit VR, or fullscreen.
  135234. */
  135235. exitVR(): void;
  135236. /**
  135237. * The position of the vr experience helper.
  135238. */
  135239. get position(): Vector3;
  135240. /**
  135241. * Sets the position of the vr experience helper.
  135242. */
  135243. set position(value: Vector3);
  135244. /**
  135245. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  135246. */
  135247. enableInteractions(): void;
  135248. private get _noControllerIsActive();
  135249. private beforeRender;
  135250. private _isTeleportationFloor;
  135251. /**
  135252. * Adds a floor mesh to be used for teleportation.
  135253. * @param floorMesh the mesh to be used for teleportation.
  135254. */
  135255. addFloorMesh(floorMesh: Mesh): void;
  135256. /**
  135257. * Removes a floor mesh from being used for teleportation.
  135258. * @param floorMesh the mesh to be removed.
  135259. */
  135260. removeFloorMesh(floorMesh: Mesh): void;
  135261. /**
  135262. * Enables interactions and teleportation using the VR controllers and gaze.
  135263. * @param vrTeleportationOptions options to modify teleportation behavior.
  135264. */
  135265. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  135266. private _onNewGamepadConnected;
  135267. private _tryEnableInteractionOnController;
  135268. private _onNewGamepadDisconnected;
  135269. private _enableInteractionOnController;
  135270. private _checkTeleportWithRay;
  135271. private _checkRotate;
  135272. private _checkTeleportBackwards;
  135273. private _enableTeleportationOnController;
  135274. private _createTeleportationCircles;
  135275. private _displayTeleportationTarget;
  135276. private _hideTeleportationTarget;
  135277. private _rotateCamera;
  135278. private _moveTeleportationSelectorTo;
  135279. private _workingVector;
  135280. private _workingQuaternion;
  135281. private _workingMatrix;
  135282. /**
  135283. * Time Constant Teleportation Mode
  135284. */
  135285. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  135286. /**
  135287. * Speed Constant Teleportation Mode
  135288. */
  135289. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  135290. /**
  135291. * Teleports the users feet to the desired location
  135292. * @param location The location where the user's feet should be placed
  135293. */
  135294. teleportCamera(location: Vector3): void;
  135295. private _convertNormalToDirectionOfRay;
  135296. private _castRayAndSelectObject;
  135297. private _notifySelectedMeshUnselected;
  135298. /**
  135299. * Permanently set new colors for the laser pointer
  135300. * @param color the new laser color
  135301. * @param pickedColor the new laser color when picked mesh detected
  135302. */
  135303. setLaserColor(color: Color3, pickedColor?: Color3): void;
  135304. /**
  135305. * Set lighting enabled / disabled on the laser pointer of both controllers
  135306. * @param enabled should the lighting be enabled on the laser pointer
  135307. */
  135308. setLaserLightingState(enabled?: boolean): void;
  135309. /**
  135310. * Permanently set new colors for the gaze pointer
  135311. * @param color the new gaze color
  135312. * @param pickedColor the new gaze color when picked mesh detected
  135313. */
  135314. setGazeColor(color: Color3, pickedColor?: Color3): void;
  135315. /**
  135316. * Sets the color of the laser ray from the vr controllers.
  135317. * @param color new color for the ray.
  135318. */
  135319. changeLaserColor(color: Color3): void;
  135320. /**
  135321. * Sets the color of the ray from the vr headsets gaze.
  135322. * @param color new color for the ray.
  135323. */
  135324. changeGazeColor(color: Color3): void;
  135325. /**
  135326. * Exits VR and disposes of the vr experience helper
  135327. */
  135328. dispose(): void;
  135329. /**
  135330. * Gets the name of the VRExperienceHelper class
  135331. * @returns "VRExperienceHelper"
  135332. */
  135333. getClassName(): string;
  135334. }
  135335. }
  135336. declare module BABYLON {
  135337. /**
  135338. * Contains an array of blocks representing the octree
  135339. */
  135340. export interface IOctreeContainer<T> {
  135341. /**
  135342. * Blocks within the octree
  135343. */
  135344. blocks: Array<OctreeBlock<T>>;
  135345. }
  135346. /**
  135347. * Class used to store a cell in an octree
  135348. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135349. */
  135350. export class OctreeBlock<T> {
  135351. /**
  135352. * Gets the content of the current block
  135353. */
  135354. entries: T[];
  135355. /**
  135356. * Gets the list of block children
  135357. */
  135358. blocks: Array<OctreeBlock<T>>;
  135359. private _depth;
  135360. private _maxDepth;
  135361. private _capacity;
  135362. private _minPoint;
  135363. private _maxPoint;
  135364. private _boundingVectors;
  135365. private _creationFunc;
  135366. /**
  135367. * Creates a new block
  135368. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  135369. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  135370. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  135371. * @param depth defines the current depth of this block in the octree
  135372. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  135373. * @param creationFunc defines a callback to call when an element is added to the block
  135374. */
  135375. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  135376. /**
  135377. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  135378. */
  135379. get capacity(): number;
  135380. /**
  135381. * Gets the minimum vector (in world space) of the block's bounding box
  135382. */
  135383. get minPoint(): Vector3;
  135384. /**
  135385. * Gets the maximum vector (in world space) of the block's bounding box
  135386. */
  135387. get maxPoint(): Vector3;
  135388. /**
  135389. * Add a new element to this block
  135390. * @param entry defines the element to add
  135391. */
  135392. addEntry(entry: T): void;
  135393. /**
  135394. * Remove an element from this block
  135395. * @param entry defines the element to remove
  135396. */
  135397. removeEntry(entry: T): void;
  135398. /**
  135399. * Add an array of elements to this block
  135400. * @param entries defines the array of elements to add
  135401. */
  135402. addEntries(entries: T[]): void;
  135403. /**
  135404. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  135405. * @param frustumPlanes defines the frustum planes to test
  135406. * @param selection defines the array to store current content if selection is positive
  135407. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135408. */
  135409. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  135410. /**
  135411. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  135412. * @param sphereCenter defines the bounding sphere center
  135413. * @param sphereRadius defines the bounding sphere radius
  135414. * @param selection defines the array to store current content if selection is positive
  135415. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135416. */
  135417. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  135418. /**
  135419. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  135420. * @param ray defines the ray to test with
  135421. * @param selection defines the array to store current content if selection is positive
  135422. */
  135423. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  135424. /**
  135425. * Subdivide the content into child blocks (this block will then be empty)
  135426. */
  135427. createInnerBlocks(): void;
  135428. /**
  135429. * @hidden
  135430. */
  135431. 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;
  135432. }
  135433. }
  135434. declare module BABYLON {
  135435. /**
  135436. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  135437. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135438. */
  135439. export class Octree<T> {
  135440. /** 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.) */
  135441. maxDepth: number;
  135442. /**
  135443. * Blocks within the octree containing objects
  135444. */
  135445. blocks: Array<OctreeBlock<T>>;
  135446. /**
  135447. * Content stored in the octree
  135448. */
  135449. dynamicContent: T[];
  135450. private _maxBlockCapacity;
  135451. private _selectionContent;
  135452. private _creationFunc;
  135453. /**
  135454. * Creates a octree
  135455. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135456. * @param creationFunc function to be used to instatiate the octree
  135457. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  135458. * @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.)
  135459. */
  135460. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  135461. /** 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.) */
  135462. maxDepth?: number);
  135463. /**
  135464. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  135465. * @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);
  135466. * @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);
  135467. * @param entries meshes to be added to the octree blocks
  135468. */
  135469. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  135470. /**
  135471. * Adds a mesh to the octree
  135472. * @param entry Mesh to add to the octree
  135473. */
  135474. addMesh(entry: T): void;
  135475. /**
  135476. * Remove an element from the octree
  135477. * @param entry defines the element to remove
  135478. */
  135479. removeMesh(entry: T): void;
  135480. /**
  135481. * Selects an array of meshes within the frustum
  135482. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  135483. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  135484. * @returns array of meshes within the frustum
  135485. */
  135486. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  135487. /**
  135488. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  135489. * @param sphereCenter defines the bounding sphere center
  135490. * @param sphereRadius defines the bounding sphere radius
  135491. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135492. * @returns an array of objects that intersect the sphere
  135493. */
  135494. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  135495. /**
  135496. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  135497. * @param ray defines the ray to test with
  135498. * @returns array of intersected objects
  135499. */
  135500. intersectsRay(ray: Ray): SmartArray<T>;
  135501. /**
  135502. * Adds a mesh into the octree block if it intersects the block
  135503. */
  135504. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  135505. /**
  135506. * Adds a submesh into the octree block if it intersects the block
  135507. */
  135508. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  135509. }
  135510. }
  135511. declare module BABYLON {
  135512. interface Scene {
  135513. /**
  135514. * @hidden
  135515. * Backing Filed
  135516. */
  135517. _selectionOctree: Octree<AbstractMesh>;
  135518. /**
  135519. * Gets the octree used to boost mesh selection (picking)
  135520. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135521. */
  135522. selectionOctree: Octree<AbstractMesh>;
  135523. /**
  135524. * Creates or updates the octree used to boost selection (picking)
  135525. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135526. * @param maxCapacity defines the maximum capacity per leaf
  135527. * @param maxDepth defines the maximum depth of the octree
  135528. * @returns an octree of AbstractMesh
  135529. */
  135530. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  135531. }
  135532. interface AbstractMesh {
  135533. /**
  135534. * @hidden
  135535. * Backing Field
  135536. */
  135537. _submeshesOctree: Octree<SubMesh>;
  135538. /**
  135539. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  135540. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  135541. * @param maxCapacity defines the maximum size of each block (64 by default)
  135542. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  135543. * @returns the new octree
  135544. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  135545. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135546. */
  135547. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  135548. }
  135549. /**
  135550. * Defines the octree scene component responsible to manage any octrees
  135551. * in a given scene.
  135552. */
  135553. export class OctreeSceneComponent {
  135554. /**
  135555. * The component name help to identify the component in the list of scene components.
  135556. */
  135557. readonly name: string;
  135558. /**
  135559. * The scene the component belongs to.
  135560. */
  135561. scene: Scene;
  135562. /**
  135563. * Indicates if the meshes have been checked to make sure they are isEnabled()
  135564. */
  135565. readonly checksIsEnabled: boolean;
  135566. /**
  135567. * Creates a new instance of the component for the given scene
  135568. * @param scene Defines the scene to register the component in
  135569. */
  135570. constructor(scene: Scene);
  135571. /**
  135572. * Registers the component in a given scene
  135573. */
  135574. register(): void;
  135575. /**
  135576. * Return the list of active meshes
  135577. * @returns the list of active meshes
  135578. */
  135579. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  135580. /**
  135581. * Return the list of active sub meshes
  135582. * @param mesh The mesh to get the candidates sub meshes from
  135583. * @returns the list of active sub meshes
  135584. */
  135585. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  135586. private _tempRay;
  135587. /**
  135588. * Return the list of sub meshes intersecting with a given local ray
  135589. * @param mesh defines the mesh to find the submesh for
  135590. * @param localRay defines the ray in local space
  135591. * @returns the list of intersecting sub meshes
  135592. */
  135593. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  135594. /**
  135595. * Return the list of sub meshes colliding with a collider
  135596. * @param mesh defines the mesh to find the submesh for
  135597. * @param collider defines the collider to evaluate the collision against
  135598. * @returns the list of colliding sub meshes
  135599. */
  135600. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  135601. /**
  135602. * Rebuilds the elements related to this component in case of
  135603. * context lost for instance.
  135604. */
  135605. rebuild(): void;
  135606. /**
  135607. * Disposes the component and the associated ressources.
  135608. */
  135609. dispose(): void;
  135610. }
  135611. }
  135612. declare module BABYLON {
  135613. /**
  135614. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  135615. */
  135616. export interface GizmoAxisCache {
  135617. /** Mesh used to runder the Gizmo */
  135618. gizmoMeshes: Mesh[];
  135619. /** Mesh used to detect user interaction with Gizmo */
  135620. colliderMeshes: Mesh[];
  135621. /** Material used to inicate color of gizmo mesh */
  135622. material: StandardMaterial;
  135623. /** Material used to inicate hover state of the Gizmo */
  135624. hoverMaterial: StandardMaterial;
  135625. /** Material used to inicate disabled state of the Gizmo */
  135626. disableMaterial: StandardMaterial;
  135627. /** Used to indicate Active state of the Gizmo */
  135628. active: boolean;
  135629. }
  135630. /**
  135631. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  135632. */
  135633. export class Gizmo implements IDisposable {
  135634. /** The utility layer the gizmo will be added to */
  135635. gizmoLayer: UtilityLayerRenderer;
  135636. /**
  135637. * The root mesh of the gizmo
  135638. */
  135639. _rootMesh: Mesh;
  135640. private _attachedMesh;
  135641. private _attachedNode;
  135642. /**
  135643. * Ratio for the scale of the gizmo (Default: 1)
  135644. */
  135645. protected _scaleRatio: number;
  135646. /**
  135647. * boolean updated by pointermove when a gizmo mesh is hovered
  135648. */
  135649. protected _isHovered: boolean;
  135650. /**
  135651. * Ratio for the scale of the gizmo (Default: 1)
  135652. */
  135653. set scaleRatio(value: number);
  135654. get scaleRatio(): number;
  135655. /**
  135656. * True when the mouse pointer is hovered a gizmo mesh
  135657. */
  135658. get isHovered(): boolean;
  135659. /**
  135660. * If a custom mesh has been set (Default: false)
  135661. */
  135662. protected _customMeshSet: boolean;
  135663. /**
  135664. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  135665. * * When set, interactions will be enabled
  135666. */
  135667. get attachedMesh(): Nullable<AbstractMesh>;
  135668. set attachedMesh(value: Nullable<AbstractMesh>);
  135669. /**
  135670. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  135671. * * When set, interactions will be enabled
  135672. */
  135673. get attachedNode(): Nullable<Node>;
  135674. set attachedNode(value: Nullable<Node>);
  135675. /**
  135676. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  135677. * @param mesh The mesh to replace the default mesh of the gizmo
  135678. */
  135679. setCustomMesh(mesh: Mesh): void;
  135680. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  135681. /**
  135682. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  135683. */
  135684. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135685. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135686. /**
  135687. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  135688. */
  135689. updateGizmoPositionToMatchAttachedMesh: boolean;
  135690. /**
  135691. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  135692. */
  135693. updateScale: boolean;
  135694. protected _interactionsEnabled: boolean;
  135695. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135696. private _beforeRenderObserver;
  135697. private _tempQuaternion;
  135698. private _tempVector;
  135699. private _tempVector2;
  135700. private _tempMatrix1;
  135701. private _tempMatrix2;
  135702. private _rightHandtoLeftHandMatrix;
  135703. /**
  135704. * Creates a gizmo
  135705. * @param gizmoLayer The utility layer the gizmo will be added to
  135706. */
  135707. constructor(
  135708. /** The utility layer the gizmo will be added to */
  135709. gizmoLayer?: UtilityLayerRenderer);
  135710. /**
  135711. * Updates the gizmo to match the attached mesh's position/rotation
  135712. */
  135713. protected _update(): void;
  135714. /**
  135715. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  135716. * @param value Node, TransformNode or mesh
  135717. */
  135718. protected _matrixChanged(): void;
  135719. /**
  135720. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  135721. * @param gizmoLayer The utility layer the gizmo will be added to
  135722. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  135723. * @returns {Observer<PointerInfo>} pointerObserver
  135724. */
  135725. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  135726. /**
  135727. * Disposes of the gizmo
  135728. */
  135729. dispose(): void;
  135730. }
  135731. }
  135732. declare module BABYLON {
  135733. /**
  135734. * Single plane drag gizmo
  135735. */
  135736. export class PlaneDragGizmo extends Gizmo {
  135737. /**
  135738. * Drag behavior responsible for the gizmos dragging interactions
  135739. */
  135740. dragBehavior: PointerDragBehavior;
  135741. private _pointerObserver;
  135742. /**
  135743. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135744. */
  135745. snapDistance: number;
  135746. /**
  135747. * Event that fires each time the gizmo snaps to a new location.
  135748. * * snapDistance is the the change in distance
  135749. */
  135750. onSnapObservable: Observable<{
  135751. snapDistance: number;
  135752. }>;
  135753. private _gizmoMesh;
  135754. private _coloredMaterial;
  135755. private _hoverMaterial;
  135756. private _disableMaterial;
  135757. private _isEnabled;
  135758. private _parent;
  135759. private _dragging;
  135760. /** @hidden */
  135761. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  135762. /**
  135763. * Creates a PlaneDragGizmo
  135764. * @param gizmoLayer The utility layer the gizmo will be added to
  135765. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  135766. * @param color The color of the gizmo
  135767. */
  135768. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  135769. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135770. /**
  135771. * If the gizmo is enabled
  135772. */
  135773. set isEnabled(value: boolean);
  135774. get isEnabled(): boolean;
  135775. /**
  135776. * Disposes of the gizmo
  135777. */
  135778. dispose(): void;
  135779. }
  135780. }
  135781. declare module BABYLON {
  135782. /**
  135783. * Single plane rotation gizmo
  135784. */
  135785. export class PlaneRotationGizmo extends Gizmo {
  135786. /**
  135787. * Drag behavior responsible for the gizmos dragging interactions
  135788. */
  135789. dragBehavior: PointerDragBehavior;
  135790. private _pointerObserver;
  135791. /**
  135792. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  135793. */
  135794. snapDistance: number;
  135795. /**
  135796. * Event that fires each time the gizmo snaps to a new location.
  135797. * * snapDistance is the the change in distance
  135798. */
  135799. onSnapObservable: Observable<{
  135800. snapDistance: number;
  135801. }>;
  135802. private _isEnabled;
  135803. private _parent;
  135804. private _coloredMaterial;
  135805. private _hoverMaterial;
  135806. private _disableMaterial;
  135807. private _gizmoMesh;
  135808. private _rotationCircle;
  135809. private _dragging;
  135810. private static _CircleConstants;
  135811. /**
  135812. * Creates a PlaneRotationGizmo
  135813. * @param gizmoLayer The utility layer the gizmo will be added to
  135814. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  135815. * @param color The color of the gizmo
  135816. * @param tessellation Amount of tessellation to be used when creating rotation circles
  135817. * @param useEulerRotation Use and update Euler angle instead of quaternion
  135818. * @param thickness display gizmo axis thickness
  135819. */
  135820. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  135821. /** Create Geometry for Gizmo */
  135822. private _createGizmoMesh;
  135823. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135824. private setupRotationCircle;
  135825. private updateRotationPath;
  135826. private updateRotationCircle;
  135827. /**
  135828. * If the gizmo is enabled
  135829. */
  135830. set isEnabled(value: boolean);
  135831. get isEnabled(): boolean;
  135832. /**
  135833. * Disposes of the gizmo
  135834. */
  135835. dispose(): void;
  135836. }
  135837. }
  135838. declare module BABYLON {
  135839. /**
  135840. * Gizmo that enables rotating a mesh along 3 axis
  135841. */
  135842. export class RotationGizmo extends Gizmo {
  135843. /**
  135844. * Internal gizmo used for interactions on the x axis
  135845. */
  135846. xGizmo: PlaneRotationGizmo;
  135847. /**
  135848. * Internal gizmo used for interactions on the y axis
  135849. */
  135850. yGizmo: PlaneRotationGizmo;
  135851. /**
  135852. * Internal gizmo used for interactions on the z axis
  135853. */
  135854. zGizmo: PlaneRotationGizmo;
  135855. /** Fires an event when any of it's sub gizmos are dragged */
  135856. onDragStartObservable: Observable<unknown>;
  135857. /** Fires an event when any of it's sub gizmos are released from dragging */
  135858. onDragEndObservable: Observable<unknown>;
  135859. private _meshAttached;
  135860. private _nodeAttached;
  135861. private _observables;
  135862. /** Node Caching for quick lookup */
  135863. private _gizmoAxisCache;
  135864. get attachedMesh(): Nullable<AbstractMesh>;
  135865. set attachedMesh(mesh: Nullable<AbstractMesh>);
  135866. get attachedNode(): Nullable<Node>;
  135867. set attachedNode(node: Nullable<Node>);
  135868. protected _checkBillboardTransform(): void;
  135869. /**
  135870. * True when the mouse pointer is hovering a gizmo mesh
  135871. */
  135872. get isHovered(): boolean;
  135873. /**
  135874. * Creates a RotationGizmo
  135875. * @param gizmoLayer The utility layer the gizmo will be added to
  135876. * @param tessellation Amount of tessellation to be used when creating rotation circles
  135877. * @param useEulerRotation Use and update Euler angle instead of quaternion
  135878. * @param thickness display gizmo axis thickness
  135879. */
  135880. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  135881. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135882. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135883. /**
  135884. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135885. */
  135886. set snapDistance(value: number);
  135887. get snapDistance(): number;
  135888. /**
  135889. * Ratio for the scale of the gizmo (Default: 1)
  135890. */
  135891. set scaleRatio(value: number);
  135892. get scaleRatio(): number;
  135893. /**
  135894. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  135895. * @param mesh Axis gizmo mesh
  135896. * @param cache Gizmo axis definition used for reactive gizmo UI
  135897. */
  135898. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  135899. /**
  135900. * Disposes of the gizmo
  135901. */
  135902. dispose(): void;
  135903. /**
  135904. * CustomMeshes are not supported by this gizmo
  135905. * @param mesh The mesh to replace the default mesh of the gizmo
  135906. */
  135907. setCustomMesh(mesh: Mesh): void;
  135908. }
  135909. }
  135910. declare module BABYLON {
  135911. /**
  135912. * Class containing static functions to help procedurally build meshes
  135913. */
  135914. export class PolyhedronBuilder {
  135915. /**
  135916. * Creates a polyhedron mesh
  135917. * * 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
  135918. * * The parameter `size` (positive float, default 1) sets the polygon size
  135919. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  135920. * * 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`
  135921. * * 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
  135922. * * 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)`)
  135923. * * 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
  135924. * * 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
  135925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135928. * @param name defines the name of the mesh
  135929. * @param options defines the options used to create the mesh
  135930. * @param scene defines the hosting scene
  135931. * @returns the polyhedron mesh
  135932. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  135933. */
  135934. static CreatePolyhedron(name: string, options: {
  135935. type?: number;
  135936. size?: number;
  135937. sizeX?: number;
  135938. sizeY?: number;
  135939. sizeZ?: number;
  135940. custom?: any;
  135941. faceUV?: Vector4[];
  135942. faceColors?: Color4[];
  135943. flat?: boolean;
  135944. updatable?: boolean;
  135945. sideOrientation?: number;
  135946. frontUVs?: Vector4;
  135947. backUVs?: Vector4;
  135948. }, scene?: Nullable<Scene>): Mesh;
  135949. }
  135950. }
  135951. declare module BABYLON {
  135952. /**
  135953. * Class containing static functions to help procedurally build meshes
  135954. */
  135955. export class BoxBuilder {
  135956. /**
  135957. * Creates a box mesh
  135958. * * The parameter `size` sets the size (float) of each box side (default 1)
  135959. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  135960. * * 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)
  135961. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135963. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135965. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135966. * @param name defines the name of the mesh
  135967. * @param options defines the options used to create the mesh
  135968. * @param scene defines the hosting scene
  135969. * @returns the box mesh
  135970. */
  135971. static CreateBox(name: string, options: {
  135972. size?: number;
  135973. width?: number;
  135974. height?: number;
  135975. depth?: number;
  135976. faceUV?: Vector4[];
  135977. faceColors?: Color4[];
  135978. sideOrientation?: number;
  135979. frontUVs?: Vector4;
  135980. backUVs?: Vector4;
  135981. wrap?: boolean;
  135982. topBaseAt?: number;
  135983. bottomBaseAt?: number;
  135984. updatable?: boolean;
  135985. }, scene?: Nullable<Scene>): Mesh;
  135986. }
  135987. }
  135988. declare module BABYLON {
  135989. /**
  135990. * Single axis scale gizmo
  135991. */
  135992. export class AxisScaleGizmo extends Gizmo {
  135993. /**
  135994. * Drag behavior responsible for the gizmos dragging interactions
  135995. */
  135996. dragBehavior: PointerDragBehavior;
  135997. private _pointerObserver;
  135998. /**
  135999. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136000. */
  136001. snapDistance: number;
  136002. /**
  136003. * Event that fires each time the gizmo snaps to a new location.
  136004. * * snapDistance is the the change in distance
  136005. */
  136006. onSnapObservable: Observable<{
  136007. snapDistance: number;
  136008. }>;
  136009. /**
  136010. * If the scaling operation should be done on all axis (default: false)
  136011. */
  136012. uniformScaling: boolean;
  136013. /**
  136014. * Custom sensitivity value for the drag strength
  136015. */
  136016. sensitivity: number;
  136017. private _isEnabled;
  136018. private _parent;
  136019. private _gizmoMesh;
  136020. private _coloredMaterial;
  136021. private _hoverMaterial;
  136022. private _disableMaterial;
  136023. private _dragging;
  136024. private _tmpVector;
  136025. private _tmpMatrix;
  136026. private _tmpMatrix2;
  136027. /**
  136028. * Creates an AxisScaleGizmo
  136029. * @param gizmoLayer The utility layer the gizmo will be added to
  136030. * @param dragAxis The axis which the gizmo will be able to scale on
  136031. * @param color The color of the gizmo
  136032. * @param thickness display gizmo axis thickness
  136033. */
  136034. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  136035. /** Create Geometry for Gizmo */
  136036. private _createGizmoMesh;
  136037. protected _attachedNodeChanged(value: Nullable<Node>): void;
  136038. /**
  136039. * If the gizmo is enabled
  136040. */
  136041. set isEnabled(value: boolean);
  136042. get isEnabled(): boolean;
  136043. /**
  136044. * Disposes of the gizmo
  136045. */
  136046. dispose(): void;
  136047. /**
  136048. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  136049. * @param mesh The mesh to replace the default mesh of the gizmo
  136050. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  136051. */
  136052. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  136053. }
  136054. }
  136055. declare module BABYLON {
  136056. /**
  136057. * Gizmo that enables scaling a mesh along 3 axis
  136058. */
  136059. export class ScaleGizmo extends Gizmo {
  136060. /**
  136061. * Internal gizmo used for interactions on the x axis
  136062. */
  136063. xGizmo: AxisScaleGizmo;
  136064. /**
  136065. * Internal gizmo used for interactions on the y axis
  136066. */
  136067. yGizmo: AxisScaleGizmo;
  136068. /**
  136069. * Internal gizmo used for interactions on the z axis
  136070. */
  136071. zGizmo: AxisScaleGizmo;
  136072. /**
  136073. * Internal gizmo used to scale all axis equally
  136074. */
  136075. uniformScaleGizmo: AxisScaleGizmo;
  136076. private _meshAttached;
  136077. private _nodeAttached;
  136078. private _snapDistance;
  136079. private _uniformScalingMesh;
  136080. private _octahedron;
  136081. private _sensitivity;
  136082. private _coloredMaterial;
  136083. private _hoverMaterial;
  136084. private _disableMaterial;
  136085. private _observables;
  136086. /** Node Caching for quick lookup */
  136087. private _gizmoAxisCache;
  136088. /** Fires an event when any of it's sub gizmos are dragged */
  136089. onDragStartObservable: Observable<unknown>;
  136090. /** Fires an event when any of it's sub gizmos are released from dragging */
  136091. onDragEndObservable: Observable<unknown>;
  136092. get attachedMesh(): Nullable<AbstractMesh>;
  136093. set attachedMesh(mesh: Nullable<AbstractMesh>);
  136094. get attachedNode(): Nullable<Node>;
  136095. set attachedNode(node: Nullable<Node>);
  136096. /**
  136097. * True when the mouse pointer is hovering a gizmo mesh
  136098. */
  136099. get isHovered(): boolean;
  136100. /**
  136101. * Creates a ScaleGizmo
  136102. * @param gizmoLayer The utility layer the gizmo will be added to
  136103. * @param thickness display gizmo axis thickness
  136104. */
  136105. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  136106. /** Create Geometry for Gizmo */
  136107. private _createUniformScaleMesh;
  136108. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  136109. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  136110. /**
  136111. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136112. */
  136113. set snapDistance(value: number);
  136114. get snapDistance(): number;
  136115. /**
  136116. * Ratio for the scale of the gizmo (Default: 1)
  136117. */
  136118. set scaleRatio(value: number);
  136119. get scaleRatio(): number;
  136120. /**
  136121. * Sensitivity factor for dragging (Default: 1)
  136122. */
  136123. set sensitivity(value: number);
  136124. get sensitivity(): number;
  136125. /**
  136126. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136127. * @param mesh Axis gizmo mesh
  136128. * @param cache Gizmo axis definition used for reactive gizmo UI
  136129. */
  136130. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  136131. /**
  136132. * Disposes of the gizmo
  136133. */
  136134. dispose(): void;
  136135. }
  136136. }
  136137. declare module BABYLON {
  136138. /**
  136139. * Bounding box gizmo
  136140. */
  136141. export class BoundingBoxGizmo extends Gizmo {
  136142. private _lineBoundingBox;
  136143. private _rotateSpheresParent;
  136144. private _scaleBoxesParent;
  136145. private _boundingDimensions;
  136146. private _renderObserver;
  136147. private _pointerObserver;
  136148. private _scaleDragSpeed;
  136149. private _tmpQuaternion;
  136150. private _tmpVector;
  136151. private _tmpRotationMatrix;
  136152. /**
  136153. * 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)
  136154. */
  136155. ignoreChildren: boolean;
  136156. /**
  136157. * 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)
  136158. */
  136159. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  136160. /**
  136161. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  136162. */
  136163. rotationSphereSize: number;
  136164. /**
  136165. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  136166. */
  136167. scaleBoxSize: number;
  136168. /**
  136169. * 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)
  136170. */
  136171. fixedDragMeshScreenSize: boolean;
  136172. /**
  136173. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  136174. */
  136175. fixedDragMeshScreenSizeDistanceFactor: number;
  136176. /**
  136177. * Fired when a rotation sphere or scale box is dragged
  136178. */
  136179. onDragStartObservable: Observable<{}>;
  136180. /**
  136181. * Fired when a scale box is dragged
  136182. */
  136183. onScaleBoxDragObservable: Observable<{}>;
  136184. /**
  136185. * Fired when a scale box drag is ended
  136186. */
  136187. onScaleBoxDragEndObservable: Observable<{}>;
  136188. /**
  136189. * Fired when a rotation sphere is dragged
  136190. */
  136191. onRotationSphereDragObservable: Observable<{}>;
  136192. /**
  136193. * Fired when a rotation sphere drag is ended
  136194. */
  136195. onRotationSphereDragEndObservable: Observable<{}>;
  136196. /**
  136197. * 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)
  136198. */
  136199. scalePivot: Nullable<Vector3>;
  136200. /**
  136201. * Mesh used as a pivot to rotate the attached node
  136202. */
  136203. private _anchorMesh;
  136204. private _existingMeshScale;
  136205. private _dragMesh;
  136206. private pointerDragBehavior;
  136207. private coloredMaterial;
  136208. private hoverColoredMaterial;
  136209. /**
  136210. * Sets the color of the bounding box gizmo
  136211. * @param color the color to set
  136212. */
  136213. setColor(color: Color3): void;
  136214. /**
  136215. * Creates an BoundingBoxGizmo
  136216. * @param gizmoLayer The utility layer the gizmo will be added to
  136217. * @param color The color of the gizmo
  136218. */
  136219. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  136220. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  136221. private _selectNode;
  136222. /**
  136223. * Updates the bounding box information for the Gizmo
  136224. */
  136225. updateBoundingBox(): void;
  136226. private _updateRotationSpheres;
  136227. private _updateScaleBoxes;
  136228. /**
  136229. * Enables rotation on the specified axis and disables rotation on the others
  136230. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  136231. */
  136232. setEnabledRotationAxis(axis: string): void;
  136233. /**
  136234. * Enables/disables scaling
  136235. * @param enable if scaling should be enabled
  136236. * @param homogeneousScaling defines if scaling should only be homogeneous
  136237. */
  136238. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  136239. private _updateDummy;
  136240. /**
  136241. * Enables a pointer drag behavior on the bounding box of the gizmo
  136242. */
  136243. enableDragBehavior(): void;
  136244. /**
  136245. * Disposes of the gizmo
  136246. */
  136247. dispose(): void;
  136248. /**
  136249. * 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)
  136250. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  136251. * @returns the bounding box mesh with the passed in mesh as a child
  136252. */
  136253. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  136254. /**
  136255. * CustomMeshes are not supported by this gizmo
  136256. * @param mesh The mesh to replace the default mesh of the gizmo
  136257. */
  136258. setCustomMesh(mesh: Mesh): void;
  136259. }
  136260. }
  136261. declare module BABYLON {
  136262. /**
  136263. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  136264. */
  136265. export class GizmoManager implements IDisposable {
  136266. private scene;
  136267. /**
  136268. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  136269. */
  136270. gizmos: {
  136271. positionGizmo: Nullable<PositionGizmo>;
  136272. rotationGizmo: Nullable<RotationGizmo>;
  136273. scaleGizmo: Nullable<ScaleGizmo>;
  136274. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  136275. };
  136276. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  136277. clearGizmoOnEmptyPointerEvent: boolean;
  136278. /** Fires an event when the manager is attached to a mesh */
  136279. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  136280. /** Fires an event when the manager is attached to a node */
  136281. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  136282. private _gizmosEnabled;
  136283. private _pointerObservers;
  136284. private _attachedMesh;
  136285. private _attachedNode;
  136286. private _boundingBoxColor;
  136287. private _defaultUtilityLayer;
  136288. private _defaultKeepDepthUtilityLayer;
  136289. private _thickness;
  136290. /** Node Caching for quick lookup */
  136291. private _gizmoAxisCache;
  136292. /**
  136293. * When bounding box gizmo is enabled, this can be used to track drag/end events
  136294. */
  136295. boundingBoxDragBehavior: SixDofDragBehavior;
  136296. /**
  136297. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  136298. */
  136299. attachableMeshes: Nullable<Array<AbstractMesh>>;
  136300. /**
  136301. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  136302. */
  136303. attachableNodes: Nullable<Array<Node>>;
  136304. /**
  136305. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  136306. */
  136307. usePointerToAttachGizmos: boolean;
  136308. /**
  136309. * Utility layer that the bounding box gizmo belongs to
  136310. */
  136311. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  136312. /**
  136313. * Utility layer that all gizmos besides bounding box belong to
  136314. */
  136315. get utilityLayer(): UtilityLayerRenderer;
  136316. /**
  136317. * True when the mouse pointer is hovering a gizmo mesh
  136318. */
  136319. get isHovered(): boolean;
  136320. /**
  136321. * Instatiates a gizmo manager
  136322. * @param scene the scene to overlay the gizmos on top of
  136323. * @param thickness display gizmo axis thickness
  136324. * @param utilityLayer the layer where gizmos are rendered
  136325. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  136326. */
  136327. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  136328. /**
  136329. * Subscribes to pointer down events, for attaching and detaching mesh
  136330. * @param scene The sceme layer the observer will be added to
  136331. */
  136332. private _attachToMeshPointerObserver;
  136333. /**
  136334. * Attaches a set of gizmos to the specified mesh
  136335. * @param mesh The mesh the gizmo's should be attached to
  136336. */
  136337. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  136338. /**
  136339. * Attaches a set of gizmos to the specified node
  136340. * @param node The node the gizmo's should be attached to
  136341. */
  136342. attachToNode(node: Nullable<Node>): void;
  136343. /**
  136344. * If the position gizmo is enabled
  136345. */
  136346. set positionGizmoEnabled(value: boolean);
  136347. get positionGizmoEnabled(): boolean;
  136348. /**
  136349. * If the rotation gizmo is enabled
  136350. */
  136351. set rotationGizmoEnabled(value: boolean);
  136352. get rotationGizmoEnabled(): boolean;
  136353. /**
  136354. * If the scale gizmo is enabled
  136355. */
  136356. set scaleGizmoEnabled(value: boolean);
  136357. get scaleGizmoEnabled(): boolean;
  136358. /**
  136359. * If the boundingBox gizmo is enabled
  136360. */
  136361. set boundingBoxGizmoEnabled(value: boolean);
  136362. get boundingBoxGizmoEnabled(): boolean;
  136363. /**
  136364. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136365. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  136366. */
  136367. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  136368. /**
  136369. * Disposes of the gizmo manager
  136370. */
  136371. dispose(): void;
  136372. }
  136373. }
  136374. declare module BABYLON {
  136375. /**
  136376. * Gizmo that enables dragging a mesh along 3 axis
  136377. */
  136378. export class PositionGizmo extends Gizmo {
  136379. /**
  136380. * Internal gizmo used for interactions on the x axis
  136381. */
  136382. xGizmo: AxisDragGizmo;
  136383. /**
  136384. * Internal gizmo used for interactions on the y axis
  136385. */
  136386. yGizmo: AxisDragGizmo;
  136387. /**
  136388. * Internal gizmo used for interactions on the z axis
  136389. */
  136390. zGizmo: AxisDragGizmo;
  136391. /**
  136392. * Internal gizmo used for interactions on the yz plane
  136393. */
  136394. xPlaneGizmo: PlaneDragGizmo;
  136395. /**
  136396. * Internal gizmo used for interactions on the xz plane
  136397. */
  136398. yPlaneGizmo: PlaneDragGizmo;
  136399. /**
  136400. * Internal gizmo used for interactions on the xy plane
  136401. */
  136402. zPlaneGizmo: PlaneDragGizmo;
  136403. /**
  136404. * private variables
  136405. */
  136406. private _meshAttached;
  136407. private _nodeAttached;
  136408. private _snapDistance;
  136409. private _observables;
  136410. /** Node Caching for quick lookup */
  136411. private _gizmoAxisCache;
  136412. /** Fires an event when any of it's sub gizmos are dragged */
  136413. onDragStartObservable: Observable<unknown>;
  136414. /** Fires an event when any of it's sub gizmos are released from dragging */
  136415. onDragEndObservable: Observable<unknown>;
  136416. /**
  136417. * If set to true, planar drag is enabled
  136418. */
  136419. private _planarGizmoEnabled;
  136420. get attachedMesh(): Nullable<AbstractMesh>;
  136421. set attachedMesh(mesh: Nullable<AbstractMesh>);
  136422. get attachedNode(): Nullable<Node>;
  136423. set attachedNode(node: Nullable<Node>);
  136424. /**
  136425. * True when the mouse pointer is hovering a gizmo mesh
  136426. */
  136427. get isHovered(): boolean;
  136428. /**
  136429. * Creates a PositionGizmo
  136430. * @param gizmoLayer The utility layer the gizmo will be added to
  136431. @param thickness display gizmo axis thickness
  136432. */
  136433. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  136434. /**
  136435. * If the planar drag gizmo is enabled
  136436. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  136437. */
  136438. set planarGizmoEnabled(value: boolean);
  136439. get planarGizmoEnabled(): boolean;
  136440. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  136441. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  136442. /**
  136443. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136444. */
  136445. set snapDistance(value: number);
  136446. get snapDistance(): number;
  136447. /**
  136448. * Ratio for the scale of the gizmo (Default: 1)
  136449. */
  136450. set scaleRatio(value: number);
  136451. get scaleRatio(): number;
  136452. /**
  136453. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136454. * @param mesh Axis gizmo mesh
  136455. * @param cache Gizmo axis definition used for reactive gizmo UI
  136456. */
  136457. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  136458. /**
  136459. * Disposes of the gizmo
  136460. */
  136461. dispose(): void;
  136462. /**
  136463. * CustomMeshes are not supported by this gizmo
  136464. * @param mesh The mesh to replace the default mesh of the gizmo
  136465. */
  136466. setCustomMesh(mesh: Mesh): void;
  136467. }
  136468. }
  136469. declare module BABYLON {
  136470. /**
  136471. * Single axis drag gizmo
  136472. */
  136473. export class AxisDragGizmo extends Gizmo {
  136474. /**
  136475. * Drag behavior responsible for the gizmos dragging interactions
  136476. */
  136477. dragBehavior: PointerDragBehavior;
  136478. private _pointerObserver;
  136479. /**
  136480. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136481. */
  136482. snapDistance: number;
  136483. /**
  136484. * Event that fires each time the gizmo snaps to a new location.
  136485. * * snapDistance is the the change in distance
  136486. */
  136487. onSnapObservable: Observable<{
  136488. snapDistance: number;
  136489. }>;
  136490. private _isEnabled;
  136491. private _parent;
  136492. private _gizmoMesh;
  136493. private _coloredMaterial;
  136494. private _hoverMaterial;
  136495. private _disableMaterial;
  136496. private _dragging;
  136497. /** @hidden */
  136498. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  136499. /** @hidden */
  136500. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  136501. /**
  136502. * Creates an AxisDragGizmo
  136503. * @param gizmoLayer The utility layer the gizmo will be added to
  136504. * @param dragAxis The axis which the gizmo will be able to drag on
  136505. * @param color The color of the gizmo
  136506. * @param thickness display gizmo axis thickness
  136507. */
  136508. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  136509. protected _attachedNodeChanged(value: Nullable<Node>): void;
  136510. /**
  136511. * If the gizmo is enabled
  136512. */
  136513. set isEnabled(value: boolean);
  136514. get isEnabled(): boolean;
  136515. /**
  136516. * Disposes of the gizmo
  136517. */
  136518. dispose(): void;
  136519. }
  136520. }
  136521. declare module BABYLON.Debug {
  136522. /**
  136523. * The Axes viewer will show 3 axes in a specific point in space
  136524. */
  136525. export class AxesViewer {
  136526. private _xAxis;
  136527. private _yAxis;
  136528. private _zAxis;
  136529. private _scaleLinesFactor;
  136530. private _instanced;
  136531. /**
  136532. * Gets the hosting scene
  136533. */
  136534. scene: Nullable<Scene>;
  136535. /**
  136536. * Gets or sets a number used to scale line length
  136537. */
  136538. scaleLines: number;
  136539. /** Gets the node hierarchy used to render x-axis */
  136540. get xAxis(): TransformNode;
  136541. /** Gets the node hierarchy used to render y-axis */
  136542. get yAxis(): TransformNode;
  136543. /** Gets the node hierarchy used to render z-axis */
  136544. get zAxis(): TransformNode;
  136545. /**
  136546. * Creates a new AxesViewer
  136547. * @param scene defines the hosting scene
  136548. * @param scaleLines defines a number used to scale line length (1 by default)
  136549. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  136550. * @param xAxis defines the node hierarchy used to render the x-axis
  136551. * @param yAxis defines the node hierarchy used to render the y-axis
  136552. * @param zAxis defines the node hierarchy used to render the z-axis
  136553. */
  136554. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  136555. /**
  136556. * Force the viewer to update
  136557. * @param position defines the position of the viewer
  136558. * @param xaxis defines the x axis of the viewer
  136559. * @param yaxis defines the y axis of the viewer
  136560. * @param zaxis defines the z axis of the viewer
  136561. */
  136562. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  136563. /**
  136564. * Creates an instance of this axes viewer.
  136565. * @returns a new axes viewer with instanced meshes
  136566. */
  136567. createInstance(): AxesViewer;
  136568. /** Releases resources */
  136569. dispose(): void;
  136570. private static _SetRenderingGroupId;
  136571. }
  136572. }
  136573. declare module BABYLON.Debug {
  136574. /**
  136575. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  136576. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  136577. */
  136578. export class BoneAxesViewer extends AxesViewer {
  136579. /**
  136580. * Gets or sets the target mesh where to display the axes viewer
  136581. */
  136582. mesh: Nullable<Mesh>;
  136583. /**
  136584. * Gets or sets the target bone where to display the axes viewer
  136585. */
  136586. bone: Nullable<Bone>;
  136587. /** Gets current position */
  136588. pos: Vector3;
  136589. /** Gets direction of X axis */
  136590. xaxis: Vector3;
  136591. /** Gets direction of Y axis */
  136592. yaxis: Vector3;
  136593. /** Gets direction of Z axis */
  136594. zaxis: Vector3;
  136595. /**
  136596. * Creates a new BoneAxesViewer
  136597. * @param scene defines the hosting scene
  136598. * @param bone defines the target bone
  136599. * @param mesh defines the target mesh
  136600. * @param scaleLines defines a scaling factor for line length (1 by default)
  136601. */
  136602. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  136603. /**
  136604. * Force the viewer to update
  136605. */
  136606. update(): void;
  136607. /** Releases resources */
  136608. dispose(): void;
  136609. }
  136610. }
  136611. declare module BABYLON {
  136612. /**
  136613. * Interface used to define scene explorer extensibility option
  136614. */
  136615. export interface IExplorerExtensibilityOption {
  136616. /**
  136617. * Define the option label
  136618. */
  136619. label: string;
  136620. /**
  136621. * Defines the action to execute on click
  136622. */
  136623. action: (entity: any) => void;
  136624. }
  136625. /**
  136626. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  136627. */
  136628. export interface IExplorerExtensibilityGroup {
  136629. /**
  136630. * Defines a predicate to test if a given type mut be extended
  136631. */
  136632. predicate: (entity: any) => boolean;
  136633. /**
  136634. * Gets the list of options added to a type
  136635. */
  136636. entries: IExplorerExtensibilityOption[];
  136637. }
  136638. /**
  136639. * Interface used to define the options to use to create the Inspector
  136640. */
  136641. export interface IInspectorOptions {
  136642. /**
  136643. * Display in overlay mode (default: false)
  136644. */
  136645. overlay?: boolean;
  136646. /**
  136647. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  136648. */
  136649. globalRoot?: HTMLElement;
  136650. /**
  136651. * Display the Scene explorer
  136652. */
  136653. showExplorer?: boolean;
  136654. /**
  136655. * Display the property inspector
  136656. */
  136657. showInspector?: boolean;
  136658. /**
  136659. * Display in embed mode (both panes on the right)
  136660. */
  136661. embedMode?: boolean;
  136662. /**
  136663. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  136664. */
  136665. handleResize?: boolean;
  136666. /**
  136667. * Allow the panes to popup (default: true)
  136668. */
  136669. enablePopup?: boolean;
  136670. /**
  136671. * Allow the panes to be closed by users (default: true)
  136672. */
  136673. enableClose?: boolean;
  136674. /**
  136675. * Optional list of extensibility entries
  136676. */
  136677. explorerExtensibility?: IExplorerExtensibilityGroup[];
  136678. /**
  136679. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  136680. */
  136681. inspectorURL?: string;
  136682. /**
  136683. * Optional initial tab (default to DebugLayerTab.Properties)
  136684. */
  136685. initialTab?: DebugLayerTab;
  136686. }
  136687. interface Scene {
  136688. /**
  136689. * @hidden
  136690. * Backing field
  136691. */
  136692. _debugLayer: DebugLayer;
  136693. /**
  136694. * Gets the debug layer (aka Inspector) associated with the scene
  136695. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136696. */
  136697. debugLayer: DebugLayer;
  136698. }
  136699. /**
  136700. * Enum of inspector action tab
  136701. */
  136702. export enum DebugLayerTab {
  136703. /**
  136704. * Properties tag (default)
  136705. */
  136706. Properties = 0,
  136707. /**
  136708. * Debug tab
  136709. */
  136710. Debug = 1,
  136711. /**
  136712. * Statistics tab
  136713. */
  136714. Statistics = 2,
  136715. /**
  136716. * Tools tab
  136717. */
  136718. Tools = 3,
  136719. /**
  136720. * Settings tab
  136721. */
  136722. Settings = 4
  136723. }
  136724. /**
  136725. * The debug layer (aka Inspector) is the go to tool in order to better understand
  136726. * what is happening in your scene
  136727. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136728. */
  136729. export class DebugLayer {
  136730. /**
  136731. * Define the url to get the inspector script from.
  136732. * By default it uses the babylonjs CDN.
  136733. * @ignoreNaming
  136734. */
  136735. static InspectorURL: string;
  136736. private _scene;
  136737. private BJSINSPECTOR;
  136738. private _onPropertyChangedObservable?;
  136739. /**
  136740. * Observable triggered when a property is changed through the inspector.
  136741. */
  136742. get onPropertyChangedObservable(): any;
  136743. /**
  136744. * Instantiates a new debug layer.
  136745. * The debug layer (aka Inspector) is the go to tool in order to better understand
  136746. * what is happening in your scene
  136747. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136748. * @param scene Defines the scene to inspect
  136749. */
  136750. constructor(scene: Scene);
  136751. /** Creates the inspector window. */
  136752. private _createInspector;
  136753. /**
  136754. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  136755. * @param entity defines the entity to select
  136756. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  136757. */
  136758. select(entity: any, lineContainerTitles?: string | string[]): void;
  136759. /** Get the inspector from bundle or global */
  136760. private _getGlobalInspector;
  136761. /**
  136762. * Get if the inspector is visible or not.
  136763. * @returns true if visible otherwise, false
  136764. */
  136765. isVisible(): boolean;
  136766. /**
  136767. * Hide the inspector and close its window.
  136768. */
  136769. hide(): void;
  136770. /**
  136771. * Update the scene in the inspector
  136772. */
  136773. setAsActiveScene(): void;
  136774. /**
  136775. * Launch the debugLayer.
  136776. * @param config Define the configuration of the inspector
  136777. * @return a promise fulfilled when the debug layer is visible
  136778. */
  136779. show(config?: IInspectorOptions): Promise<DebugLayer>;
  136780. }
  136781. }
  136782. declare module BABYLON.Debug {
  136783. /**
  136784. * Used to show the physics impostor around the specific mesh
  136785. */
  136786. export class PhysicsViewer {
  136787. /** @hidden */
  136788. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  136789. /** @hidden */
  136790. protected _meshes: Array<Nullable<AbstractMesh>>;
  136791. /** @hidden */
  136792. protected _scene: Nullable<Scene>;
  136793. /** @hidden */
  136794. protected _numMeshes: number;
  136795. /** @hidden */
  136796. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  136797. private _renderFunction;
  136798. private _utilityLayer;
  136799. private _debugBoxMesh;
  136800. private _debugSphereMesh;
  136801. private _debugCylinderMesh;
  136802. private _debugMaterial;
  136803. private _debugMeshMeshes;
  136804. /**
  136805. * Creates a new PhysicsViewer
  136806. * @param scene defines the hosting scene
  136807. */
  136808. constructor(scene: Scene);
  136809. /** @hidden */
  136810. protected _updateDebugMeshes(): void;
  136811. /**
  136812. * Renders a specified physic impostor
  136813. * @param impostor defines the impostor to render
  136814. * @param targetMesh defines the mesh represented by the impostor
  136815. * @returns the new debug mesh used to render the impostor
  136816. */
  136817. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  136818. /**
  136819. * Hides a specified physic impostor
  136820. * @param impostor defines the impostor to hide
  136821. */
  136822. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  136823. private _getDebugMaterial;
  136824. private _getDebugBoxMesh;
  136825. private _getDebugSphereMesh;
  136826. private _getDebugCylinderMesh;
  136827. private _getDebugMeshMesh;
  136828. private _getDebugMesh;
  136829. /** Releases all resources */
  136830. dispose(): void;
  136831. }
  136832. }
  136833. declare module BABYLON {
  136834. /**
  136835. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  136836. * in order to better appreciate the issue one might have.
  136837. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  136838. */
  136839. export class RayHelper {
  136840. /**
  136841. * Defines the ray we are currently tryin to visualize.
  136842. */
  136843. ray: Nullable<Ray>;
  136844. private _renderPoints;
  136845. private _renderLine;
  136846. private _renderFunction;
  136847. private _scene;
  136848. private _onAfterRenderObserver;
  136849. private _onAfterStepObserver;
  136850. private _attachedToMesh;
  136851. private _meshSpaceDirection;
  136852. private _meshSpaceOrigin;
  136853. /**
  136854. * Helper function to create a colored helper in a scene in one line.
  136855. * @param ray Defines the ray we are currently tryin to visualize
  136856. * @param scene Defines the scene the ray is used in
  136857. * @param color Defines the color we want to see the ray in
  136858. * @returns The newly created ray helper.
  136859. */
  136860. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  136861. /**
  136862. * Instantiate a new ray helper.
  136863. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  136864. * in order to better appreciate the issue one might have.
  136865. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  136866. * @param ray Defines the ray we are currently tryin to visualize
  136867. */
  136868. constructor(ray: Ray);
  136869. /**
  136870. * Shows the ray we are willing to debug.
  136871. * @param scene Defines the scene the ray needs to be rendered in
  136872. * @param color Defines the color the ray needs to be rendered in
  136873. */
  136874. show(scene: Scene, color?: Color3): void;
  136875. /**
  136876. * Hides the ray we are debugging.
  136877. */
  136878. hide(): void;
  136879. private _render;
  136880. /**
  136881. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  136882. * @param mesh Defines the mesh we want the helper attached to
  136883. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  136884. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  136885. * @param length Defines the length of the ray
  136886. */
  136887. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  136888. /**
  136889. * Detach the ray helper from the mesh it has previously been attached to.
  136890. */
  136891. detachFromMesh(): void;
  136892. private _updateToMesh;
  136893. /**
  136894. * Dispose the helper and release its associated resources.
  136895. */
  136896. dispose(): void;
  136897. }
  136898. }
  136899. declare module BABYLON {
  136900. /**
  136901. * Defines the options associated with the creation of a SkeletonViewer.
  136902. */
  136903. export interface ISkeletonViewerOptions {
  136904. /** Should the system pause animations before building the Viewer? */
  136905. pauseAnimations: boolean;
  136906. /** Should the system return the skeleton to rest before building? */
  136907. returnToRest: boolean;
  136908. /** public Display Mode of the Viewer */
  136909. displayMode: number;
  136910. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  136911. displayOptions: ISkeletonViewerDisplayOptions;
  136912. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  136913. computeBonesUsingShaders: boolean;
  136914. /** Flag ignore non weighted bones */
  136915. useAllBones: boolean;
  136916. }
  136917. /**
  136918. * Defines how to display the various bone meshes for the viewer.
  136919. */
  136920. export interface ISkeletonViewerDisplayOptions {
  136921. /** How far down to start tapering the bone spurs */
  136922. midStep?: number;
  136923. /** How big is the midStep? */
  136924. midStepFactor?: number;
  136925. /** Base for the Sphere Size */
  136926. sphereBaseSize?: number;
  136927. /** The ratio of the sphere to the longest bone in units */
  136928. sphereScaleUnit?: number;
  136929. /** Ratio for the Sphere Size */
  136930. sphereFactor?: number;
  136931. /** Whether a spur should attach its far end to the child bone position */
  136932. spurFollowsChild?: boolean;
  136933. /** Whether to show local axes or not */
  136934. showLocalAxes?: boolean;
  136935. /** Length of each local axis */
  136936. localAxesSize?: number;
  136937. }
  136938. /**
  136939. * Defines the constructor options for the BoneWeight Shader.
  136940. */
  136941. export interface IBoneWeightShaderOptions {
  136942. /** Skeleton to Map */
  136943. skeleton: Skeleton;
  136944. /** Colors for Uninfluenced bones */
  136945. colorBase?: Color3;
  136946. /** Colors for 0.0-0.25 Weight bones */
  136947. colorZero?: Color3;
  136948. /** Color for 0.25-0.5 Weight Influence */
  136949. colorQuarter?: Color3;
  136950. /** Color for 0.5-0.75 Weight Influence */
  136951. colorHalf?: Color3;
  136952. /** Color for 0.75-1 Weight Influence */
  136953. colorFull?: Color3;
  136954. /** Color for Zero Weight Influence */
  136955. targetBoneIndex?: number;
  136956. }
  136957. /**
  136958. * Simple structure of the gradient steps for the Color Map.
  136959. */
  136960. export interface ISkeletonMapShaderColorMapKnot {
  136961. /** Color of the Knot */
  136962. color: Color3;
  136963. /** Location of the Knot */
  136964. location: number;
  136965. }
  136966. /**
  136967. * Defines the constructor options for the SkeletonMap Shader.
  136968. */
  136969. export interface ISkeletonMapShaderOptions {
  136970. /** Skeleton to Map */
  136971. skeleton: Skeleton;
  136972. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  136973. colorMap?: ISkeletonMapShaderColorMapKnot[];
  136974. }
  136975. }
  136976. declare module BABYLON {
  136977. /**
  136978. * Class containing static functions to help procedurally build meshes
  136979. */
  136980. export class RibbonBuilder {
  136981. /**
  136982. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136983. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  136984. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  136985. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  136986. * * 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
  136987. * * 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
  136988. * * 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
  136989. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136990. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136991. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136992. * * 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
  136993. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  136994. * * 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
  136995. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  136996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136997. * @param name defines the name of the mesh
  136998. * @param options defines the options used to create the mesh
  136999. * @param scene defines the hosting scene
  137000. * @returns the ribbon mesh
  137001. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  137002. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137003. */
  137004. static CreateRibbon(name: string, options: {
  137005. pathArray: Vector3[][];
  137006. closeArray?: boolean;
  137007. closePath?: boolean;
  137008. offset?: number;
  137009. updatable?: boolean;
  137010. sideOrientation?: number;
  137011. frontUVs?: Vector4;
  137012. backUVs?: Vector4;
  137013. instance?: Mesh;
  137014. invertUV?: boolean;
  137015. uvs?: Vector2[];
  137016. colors?: Color4[];
  137017. }, scene?: Nullable<Scene>): Mesh;
  137018. }
  137019. }
  137020. declare module BABYLON {
  137021. /**
  137022. * Class containing static functions to help procedurally build meshes
  137023. */
  137024. export class ShapeBuilder {
  137025. /**
  137026. * 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.
  137027. * * 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.
  137028. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137029. * * 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.
  137030. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  137031. * * 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
  137032. * * 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
  137033. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  137034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137036. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  137037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137038. * @param name defines the name of the mesh
  137039. * @param options defines the options used to create the mesh
  137040. * @param scene defines the hosting scene
  137041. * @returns the extruded shape mesh
  137042. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137043. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137044. */
  137045. static ExtrudeShape(name: string, options: {
  137046. shape: Vector3[];
  137047. path: Vector3[];
  137048. scale?: number;
  137049. rotation?: number;
  137050. cap?: number;
  137051. updatable?: boolean;
  137052. sideOrientation?: number;
  137053. frontUVs?: Vector4;
  137054. backUVs?: Vector4;
  137055. instance?: Mesh;
  137056. invertUV?: boolean;
  137057. }, scene?: Nullable<Scene>): Mesh;
  137058. /**
  137059. * Creates an custom extruded shape mesh.
  137060. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  137061. * * 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.
  137062. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137063. * * 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
  137064. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  137065. * * 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
  137066. * * It must returns a float value that will be the scale value applied to the shape on each path point
  137067. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  137068. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  137069. * * 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
  137070. * * 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
  137071. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  137072. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137074. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137076. * @param name defines the name of the mesh
  137077. * @param options defines the options used to create the mesh
  137078. * @param scene defines the hosting scene
  137079. * @returns the custom extruded shape mesh
  137080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  137081. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137082. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137083. */
  137084. static ExtrudeShapeCustom(name: string, options: {
  137085. shape: Vector3[];
  137086. path: Vector3[];
  137087. scaleFunction?: any;
  137088. rotationFunction?: any;
  137089. ribbonCloseArray?: boolean;
  137090. ribbonClosePath?: boolean;
  137091. cap?: number;
  137092. updatable?: boolean;
  137093. sideOrientation?: number;
  137094. frontUVs?: Vector4;
  137095. backUVs?: Vector4;
  137096. instance?: Mesh;
  137097. invertUV?: boolean;
  137098. }, scene?: Nullable<Scene>): Mesh;
  137099. private static _ExtrudeShapeGeneric;
  137100. }
  137101. }
  137102. declare module BABYLON.Debug {
  137103. /**
  137104. * Class used to render a debug view of a given skeleton
  137105. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  137106. */
  137107. export class SkeletonViewer {
  137108. /** defines the skeleton to render */
  137109. skeleton: Skeleton;
  137110. /** defines the mesh attached to the skeleton */
  137111. mesh: AbstractMesh;
  137112. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  137113. autoUpdateBonesMatrices: boolean;
  137114. /** defines the rendering group id to use with the viewer */
  137115. renderingGroupId: number;
  137116. /** is the options for the viewer */
  137117. options: Partial<ISkeletonViewerOptions>;
  137118. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  137119. static readonly DISPLAY_LINES: number;
  137120. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  137121. static readonly DISPLAY_SPHERES: number;
  137122. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  137123. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  137124. /** public static method to create a BoneWeight Shader
  137125. * @param options The constructor options
  137126. * @param scene The scene that the shader is scoped to
  137127. * @returns The created ShaderMaterial
  137128. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  137129. */
  137130. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  137131. /** public static method to create a BoneWeight Shader
  137132. * @param options The constructor options
  137133. * @param scene The scene that the shader is scoped to
  137134. * @returns The created ShaderMaterial
  137135. */
  137136. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  137137. /** private static method to create a BoneWeight Shader
  137138. * @param size The size of the buffer to create (usually the bone count)
  137139. * @param colorMap The gradient data to generate
  137140. * @param scene The scene that the shader is scoped to
  137141. * @returns an Array of floats from the color gradient values
  137142. */
  137143. private static _CreateBoneMapColorBuffer;
  137144. /** If SkeletonViewer scene scope. */
  137145. private _scene;
  137146. /** Gets or sets the color used to render the skeleton */
  137147. color: Color3;
  137148. /** Array of the points of the skeleton fo the line view. */
  137149. private _debugLines;
  137150. /** The SkeletonViewers Mesh. */
  137151. private _debugMesh;
  137152. /** The local axes Meshes. */
  137153. private _localAxes;
  137154. /** If SkeletonViewer is enabled. */
  137155. private _isEnabled;
  137156. /** If SkeletonViewer is ready. */
  137157. private _ready;
  137158. /** SkeletonViewer render observable. */
  137159. private _obs;
  137160. /** The Utility Layer to render the gizmos in. */
  137161. private _utilityLayer;
  137162. private _boneIndices;
  137163. /** Gets the Scene. */
  137164. get scene(): Scene;
  137165. /** Gets the utilityLayer. */
  137166. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  137167. /** Checks Ready Status. */
  137168. get isReady(): Boolean;
  137169. /** Sets Ready Status. */
  137170. set ready(value: boolean);
  137171. /** Gets the debugMesh */
  137172. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  137173. /** Sets the debugMesh */
  137174. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  137175. /** Gets the displayMode */
  137176. get displayMode(): number;
  137177. /** Sets the displayMode */
  137178. set displayMode(value: number);
  137179. /**
  137180. * Creates a new SkeletonViewer
  137181. * @param skeleton defines the skeleton to render
  137182. * @param mesh defines the mesh attached to the skeleton
  137183. * @param scene defines the hosting scene
  137184. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  137185. * @param renderingGroupId defines the rendering group id to use with the viewer
  137186. * @param options All of the extra constructor options for the SkeletonViewer
  137187. */
  137188. constructor(
  137189. /** defines the skeleton to render */
  137190. skeleton: Skeleton,
  137191. /** defines the mesh attached to the skeleton */
  137192. mesh: AbstractMesh,
  137193. /** The Scene scope*/
  137194. scene: Scene,
  137195. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  137196. autoUpdateBonesMatrices?: boolean,
  137197. /** defines the rendering group id to use with the viewer */
  137198. renderingGroupId?: number,
  137199. /** is the options for the viewer */
  137200. options?: Partial<ISkeletonViewerOptions>);
  137201. /** The Dynamic bindings for the update functions */
  137202. private _bindObs;
  137203. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  137204. update(): void;
  137205. /** Gets or sets a boolean indicating if the viewer is enabled */
  137206. set isEnabled(value: boolean);
  137207. get isEnabled(): boolean;
  137208. private _getBonePosition;
  137209. private _getLinesForBonesWithLength;
  137210. private _getLinesForBonesNoLength;
  137211. /** function to revert the mesh and scene back to the initial state. */
  137212. private _revert;
  137213. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  137214. private _getAbsoluteBindPoseToRef;
  137215. /** function to build and bind sphere joint points and spur bone representations. */
  137216. private _buildSpheresAndSpurs;
  137217. private _buildLocalAxes;
  137218. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  137219. private _displayLinesUpdate;
  137220. /** Changes the displayMode of the skeleton viewer
  137221. * @param mode The displayMode numerical value
  137222. */
  137223. changeDisplayMode(mode: number): void;
  137224. /** Sets a display option of the skeleton viewer
  137225. *
  137226. * | Option | Type | Default | Description |
  137227. * | ---------------- | ------- | ------- | ----------- |
  137228. * | 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`. |
  137229. * | 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`. |
  137230. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  137231. * | 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`. |
  137232. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  137233. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  137234. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  137235. *
  137236. * @param option String of the option name
  137237. * @param value The numerical option value
  137238. */
  137239. changeDisplayOptions(option: string, value: number): void;
  137240. /** Release associated resources */
  137241. dispose(): void;
  137242. }
  137243. }
  137244. declare module BABYLON {
  137245. /**
  137246. * Enum for Device Types
  137247. */
  137248. export enum DeviceType {
  137249. /** Generic */
  137250. Generic = 0,
  137251. /** Keyboard */
  137252. Keyboard = 1,
  137253. /** Mouse */
  137254. Mouse = 2,
  137255. /** Touch Pointers */
  137256. Touch = 3,
  137257. /** PS4 Dual Shock */
  137258. DualShock = 4,
  137259. /** Xbox */
  137260. Xbox = 5,
  137261. /** Switch Controller */
  137262. Switch = 6
  137263. }
  137264. /**
  137265. * Enum for All Pointers (Touch/Mouse)
  137266. */
  137267. export enum PointerInput {
  137268. /** Horizontal Axis */
  137269. Horizontal = 0,
  137270. /** Vertical Axis */
  137271. Vertical = 1,
  137272. /** Left Click or Touch */
  137273. LeftClick = 2,
  137274. /** Middle Click */
  137275. MiddleClick = 3,
  137276. /** Right Click */
  137277. RightClick = 4,
  137278. /** Browser Back */
  137279. BrowserBack = 5,
  137280. /** Browser Forward */
  137281. BrowserForward = 6
  137282. }
  137283. /**
  137284. * Enum for Dual Shock Gamepad
  137285. */
  137286. export enum DualShockInput {
  137287. /** Cross */
  137288. Cross = 0,
  137289. /** Circle */
  137290. Circle = 1,
  137291. /** Square */
  137292. Square = 2,
  137293. /** Triangle */
  137294. Triangle = 3,
  137295. /** L1 */
  137296. L1 = 4,
  137297. /** R1 */
  137298. R1 = 5,
  137299. /** L2 */
  137300. L2 = 6,
  137301. /** R2 */
  137302. R2 = 7,
  137303. /** Share */
  137304. Share = 8,
  137305. /** Options */
  137306. Options = 9,
  137307. /** L3 */
  137308. L3 = 10,
  137309. /** R3 */
  137310. R3 = 11,
  137311. /** DPadUp */
  137312. DPadUp = 12,
  137313. /** DPadDown */
  137314. DPadDown = 13,
  137315. /** DPadLeft */
  137316. DPadLeft = 14,
  137317. /** DRight */
  137318. DPadRight = 15,
  137319. /** Home */
  137320. Home = 16,
  137321. /** TouchPad */
  137322. TouchPad = 17,
  137323. /** LStickXAxis */
  137324. LStickXAxis = 18,
  137325. /** LStickYAxis */
  137326. LStickYAxis = 19,
  137327. /** RStickXAxis */
  137328. RStickXAxis = 20,
  137329. /** RStickYAxis */
  137330. RStickYAxis = 21
  137331. }
  137332. /**
  137333. * Enum for Xbox Gamepad
  137334. */
  137335. export enum XboxInput {
  137336. /** A */
  137337. A = 0,
  137338. /** B */
  137339. B = 1,
  137340. /** X */
  137341. X = 2,
  137342. /** Y */
  137343. Y = 3,
  137344. /** LB */
  137345. LB = 4,
  137346. /** RB */
  137347. RB = 5,
  137348. /** LT */
  137349. LT = 6,
  137350. /** RT */
  137351. RT = 7,
  137352. /** Back */
  137353. Back = 8,
  137354. /** Start */
  137355. Start = 9,
  137356. /** LS */
  137357. LS = 10,
  137358. /** RS */
  137359. RS = 11,
  137360. /** DPadUp */
  137361. DPadUp = 12,
  137362. /** DPadDown */
  137363. DPadDown = 13,
  137364. /** DPadLeft */
  137365. DPadLeft = 14,
  137366. /** DRight */
  137367. DPadRight = 15,
  137368. /** Home */
  137369. Home = 16,
  137370. /** LStickXAxis */
  137371. LStickXAxis = 17,
  137372. /** LStickYAxis */
  137373. LStickYAxis = 18,
  137374. /** RStickXAxis */
  137375. RStickXAxis = 19,
  137376. /** RStickYAxis */
  137377. RStickYAxis = 20
  137378. }
  137379. /**
  137380. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  137381. */
  137382. export enum SwitchInput {
  137383. /** B */
  137384. B = 0,
  137385. /** A */
  137386. A = 1,
  137387. /** Y */
  137388. Y = 2,
  137389. /** X */
  137390. X = 3,
  137391. /** L */
  137392. L = 4,
  137393. /** R */
  137394. R = 5,
  137395. /** ZL */
  137396. ZL = 6,
  137397. /** ZR */
  137398. ZR = 7,
  137399. /** Minus */
  137400. Minus = 8,
  137401. /** Plus */
  137402. Plus = 9,
  137403. /** LS */
  137404. LS = 10,
  137405. /** RS */
  137406. RS = 11,
  137407. /** DPadUp */
  137408. DPadUp = 12,
  137409. /** DPadDown */
  137410. DPadDown = 13,
  137411. /** DPadLeft */
  137412. DPadLeft = 14,
  137413. /** DRight */
  137414. DPadRight = 15,
  137415. /** Home */
  137416. Home = 16,
  137417. /** Capture */
  137418. Capture = 17,
  137419. /** LStickXAxis */
  137420. LStickXAxis = 18,
  137421. /** LStickYAxis */
  137422. LStickYAxis = 19,
  137423. /** RStickXAxis */
  137424. RStickXAxis = 20,
  137425. /** RStickYAxis */
  137426. RStickYAxis = 21
  137427. }
  137428. }
  137429. declare module BABYLON {
  137430. /**
  137431. * This class will take all inputs from Keyboard, Pointer, and
  137432. * any Gamepads and provide a polling system that all devices
  137433. * will use. This class assumes that there will only be one
  137434. * pointer device and one keyboard.
  137435. */
  137436. export class DeviceInputSystem implements IDisposable {
  137437. /**
  137438. * Returns onDeviceConnected callback property
  137439. * @returns Callback with function to execute when a device is connected
  137440. */
  137441. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  137442. /**
  137443. * Sets callback function when a device is connected and executes against all connected devices
  137444. * @param callback Function to execute when a device is connected
  137445. */
  137446. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  137447. /**
  137448. * Callback to be triggered when a device is disconnected
  137449. */
  137450. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  137451. /**
  137452. * Callback to be triggered when event driven input is updated
  137453. */
  137454. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  137455. private _inputs;
  137456. private _gamepads;
  137457. private _keyboardActive;
  137458. private _pointerActive;
  137459. private _elementToAttachTo;
  137460. private _keyboardDownEvent;
  137461. private _keyboardUpEvent;
  137462. private _pointerMoveEvent;
  137463. private _pointerDownEvent;
  137464. private _pointerUpEvent;
  137465. private _gamepadConnectedEvent;
  137466. private _gamepadDisconnectedEvent;
  137467. private _onDeviceConnected;
  137468. private static _MAX_KEYCODES;
  137469. private static _MAX_POINTER_INPUTS;
  137470. private constructor();
  137471. /**
  137472. * Creates a new DeviceInputSystem instance
  137473. * @param engine Engine to pull input element from
  137474. * @returns The new instance
  137475. */
  137476. static Create(engine: Engine): DeviceInputSystem;
  137477. /**
  137478. * Checks for current device input value, given an id and input index
  137479. * @param deviceName Id of connected device
  137480. * @param inputIndex Index of device input
  137481. * @returns Current value of input
  137482. */
  137483. /**
  137484. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  137485. * @param deviceType Enum specifiying device type
  137486. * @param deviceSlot "Slot" or index that device is referenced in
  137487. * @param inputIndex Id of input to be checked
  137488. * @returns Current value of input
  137489. */
  137490. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  137491. /**
  137492. * Dispose of all the eventlisteners
  137493. */
  137494. dispose(): void;
  137495. /**
  137496. * Checks for existing connections to devices and register them, if necessary
  137497. * Currently handles gamepads and mouse
  137498. */
  137499. private _checkForConnectedDevices;
  137500. /**
  137501. * Add a gamepad to the DeviceInputSystem
  137502. * @param gamepad A single DOM Gamepad object
  137503. */
  137504. private _addGamePad;
  137505. /**
  137506. * Add pointer device to DeviceInputSystem
  137507. * @param deviceType Type of Pointer to add
  137508. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  137509. * @param currentX Current X at point of adding
  137510. * @param currentY Current Y at point of adding
  137511. */
  137512. private _addPointerDevice;
  137513. /**
  137514. * Add device and inputs to device array
  137515. * @param deviceType Enum specifiying device type
  137516. * @param deviceSlot "Slot" or index that device is referenced in
  137517. * @param numberOfInputs Number of input entries to create for given device
  137518. */
  137519. private _registerDevice;
  137520. /**
  137521. * Given a specific device name, remove that device from the device map
  137522. * @param deviceType Enum specifiying device type
  137523. * @param deviceSlot "Slot" or index that device is referenced in
  137524. */
  137525. private _unregisterDevice;
  137526. /**
  137527. * Handle all actions that come from keyboard interaction
  137528. */
  137529. private _handleKeyActions;
  137530. /**
  137531. * Handle all actions that come from pointer interaction
  137532. */
  137533. private _handlePointerActions;
  137534. /**
  137535. * Handle all actions that come from gamepad interaction
  137536. */
  137537. private _handleGamepadActions;
  137538. /**
  137539. * Update all non-event based devices with each frame
  137540. * @param deviceType Enum specifiying device type
  137541. * @param deviceSlot "Slot" or index that device is referenced in
  137542. * @param inputIndex Id of input to be checked
  137543. */
  137544. private _updateDevice;
  137545. /**
  137546. * Gets DeviceType from the device name
  137547. * @param deviceName Name of Device from DeviceInputSystem
  137548. * @returns DeviceType enum value
  137549. */
  137550. private _getGamepadDeviceType;
  137551. }
  137552. }
  137553. declare module BABYLON {
  137554. /**
  137555. * Type to handle enforcement of inputs
  137556. */
  137557. 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;
  137558. }
  137559. declare module BABYLON {
  137560. /**
  137561. * Class that handles all input for a specific device
  137562. */
  137563. export class DeviceSource<T extends DeviceType> {
  137564. /** Type of device */
  137565. readonly deviceType: DeviceType;
  137566. /** "Slot" or index that device is referenced in */
  137567. readonly deviceSlot: number;
  137568. /**
  137569. * Observable to handle device input changes per device
  137570. */
  137571. readonly onInputChangedObservable: Observable<{
  137572. inputIndex: DeviceInput<T>;
  137573. previousState: Nullable<number>;
  137574. currentState: Nullable<number>;
  137575. }>;
  137576. private readonly _deviceInputSystem;
  137577. /**
  137578. * Default Constructor
  137579. * @param deviceInputSystem Reference to DeviceInputSystem
  137580. * @param deviceType Type of device
  137581. * @param deviceSlot "Slot" or index that device is referenced in
  137582. */
  137583. constructor(deviceInputSystem: DeviceInputSystem,
  137584. /** Type of device */
  137585. deviceType: DeviceType,
  137586. /** "Slot" or index that device is referenced in */
  137587. deviceSlot?: number);
  137588. /**
  137589. * Get input for specific input
  137590. * @param inputIndex index of specific input on device
  137591. * @returns Input value from DeviceInputSystem
  137592. */
  137593. getInput(inputIndex: DeviceInput<T>): number;
  137594. }
  137595. /**
  137596. * Class to keep track of devices
  137597. */
  137598. export class DeviceSourceManager implements IDisposable {
  137599. /**
  137600. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  137601. */
  137602. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  137603. /**
  137604. * Observable to be triggered when after a device is disconnected
  137605. */
  137606. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  137607. private readonly _devices;
  137608. private readonly _firstDevice;
  137609. private readonly _deviceInputSystem;
  137610. /**
  137611. * Default Constructor
  137612. * @param engine engine to pull input element from
  137613. */
  137614. constructor(engine: Engine);
  137615. /**
  137616. * Gets a DeviceSource, given a type and slot
  137617. * @param deviceType Enum specifying device type
  137618. * @param deviceSlot "Slot" or index that device is referenced in
  137619. * @returns DeviceSource object
  137620. */
  137621. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  137622. /**
  137623. * Gets an array of DeviceSource objects for a given device type
  137624. * @param deviceType Enum specifying device type
  137625. * @returns Array of DeviceSource objects
  137626. */
  137627. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  137628. /**
  137629. * Returns a read-only list of all available devices
  137630. * @returns Read-only array with active devices
  137631. */
  137632. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  137633. /**
  137634. * Dispose of DeviceInputSystem and other parts
  137635. */
  137636. dispose(): void;
  137637. /**
  137638. * Function to add device name to device list
  137639. * @param deviceType Enum specifying device type
  137640. * @param deviceSlot "Slot" or index that device is referenced in
  137641. */
  137642. private _addDevice;
  137643. /**
  137644. * Function to remove device name to device list
  137645. * @param deviceType Enum specifying device type
  137646. * @param deviceSlot "Slot" or index that device is referenced in
  137647. */
  137648. private _removeDevice;
  137649. /**
  137650. * Updates array storing first connected device of each type
  137651. * @param type Type of Device
  137652. */
  137653. private _updateFirstDevices;
  137654. }
  137655. }
  137656. declare module BABYLON {
  137657. /**
  137658. * Options to create the null engine
  137659. */
  137660. export class NullEngineOptions {
  137661. /**
  137662. * Render width (Default: 512)
  137663. */
  137664. renderWidth: number;
  137665. /**
  137666. * Render height (Default: 256)
  137667. */
  137668. renderHeight: number;
  137669. /**
  137670. * Texture size (Default: 512)
  137671. */
  137672. textureSize: number;
  137673. /**
  137674. * If delta time between frames should be constant
  137675. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137676. */
  137677. deterministicLockstep: boolean;
  137678. /**
  137679. * Maximum about of steps between frames (Default: 4)
  137680. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137681. */
  137682. lockstepMaxSteps: number;
  137683. /**
  137684. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  137685. */
  137686. useHighPrecisionMatrix?: boolean;
  137687. }
  137688. /**
  137689. * The null engine class provides support for headless version of babylon.js.
  137690. * This can be used in server side scenario or for testing purposes
  137691. */
  137692. export class NullEngine extends Engine {
  137693. private _options;
  137694. /**
  137695. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  137696. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137697. * @returns true if engine is in deterministic lock step mode
  137698. */
  137699. isDeterministicLockStep(): boolean;
  137700. /**
  137701. * Gets the max steps when engine is running in deterministic lock step
  137702. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137703. * @returns the max steps
  137704. */
  137705. getLockstepMaxSteps(): number;
  137706. /**
  137707. * Gets the current hardware scaling level.
  137708. * By default the hardware scaling level is computed from the window device ratio.
  137709. * 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.
  137710. * @returns a number indicating the current hardware scaling level
  137711. */
  137712. getHardwareScalingLevel(): number;
  137713. constructor(options?: NullEngineOptions);
  137714. /**
  137715. * Creates a vertex buffer
  137716. * @param vertices the data for the vertex buffer
  137717. * @returns the new WebGL static buffer
  137718. */
  137719. createVertexBuffer(vertices: FloatArray): DataBuffer;
  137720. /**
  137721. * Creates a new index buffer
  137722. * @param indices defines the content of the index buffer
  137723. * @param updatable defines if the index buffer must be updatable
  137724. * @returns a new webGL buffer
  137725. */
  137726. createIndexBuffer(indices: IndicesArray): DataBuffer;
  137727. /**
  137728. * Clear the current render buffer or the current render target (if any is set up)
  137729. * @param color defines the color to use
  137730. * @param backBuffer defines if the back buffer must be cleared
  137731. * @param depth defines if the depth buffer must be cleared
  137732. * @param stencil defines if the stencil buffer must be cleared
  137733. */
  137734. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  137735. /**
  137736. * Gets the current render width
  137737. * @param useScreen defines if screen size must be used (or the current render target if any)
  137738. * @returns a number defining the current render width
  137739. */
  137740. getRenderWidth(useScreen?: boolean): number;
  137741. /**
  137742. * Gets the current render height
  137743. * @param useScreen defines if screen size must be used (or the current render target if any)
  137744. * @returns a number defining the current render height
  137745. */
  137746. getRenderHeight(useScreen?: boolean): number;
  137747. /**
  137748. * Set the WebGL's viewport
  137749. * @param viewport defines the viewport element to be used
  137750. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  137751. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  137752. */
  137753. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  137754. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  137755. /**
  137756. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  137757. * @param pipelineContext defines the pipeline context to use
  137758. * @param uniformsNames defines the list of uniform names
  137759. * @returns an array of webGL uniform locations
  137760. */
  137761. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  137762. /**
  137763. * Gets the lsit of active attributes for a given webGL program
  137764. * @param pipelineContext defines the pipeline context to use
  137765. * @param attributesNames defines the list of attribute names to get
  137766. * @returns an array of indices indicating the offset of each attribute
  137767. */
  137768. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  137769. /**
  137770. * Binds an effect to the webGL context
  137771. * @param effect defines the effect to bind
  137772. */
  137773. bindSamplers(effect: Effect): void;
  137774. /**
  137775. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  137776. * @param effect defines the effect to activate
  137777. */
  137778. enableEffect(effect: Effect): void;
  137779. /**
  137780. * Set various states to the webGL context
  137781. * @param culling defines backface culling state
  137782. * @param zOffset defines the value to apply to zOffset (0 by default)
  137783. * @param force defines if states must be applied even if cache is up to date
  137784. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  137785. */
  137786. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  137787. /**
  137788. * Set the value of an uniform to an array of int32
  137789. * @param uniform defines the webGL uniform location where to store the value
  137790. * @param array defines the array of int32 to store
  137791. * @returns true if value was set
  137792. */
  137793. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137794. /**
  137795. * Set the value of an uniform to an array of int32 (stored as vec2)
  137796. * @param uniform defines the webGL uniform location where to store the value
  137797. * @param array defines the array of int32 to store
  137798. * @returns true if value was set
  137799. */
  137800. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137801. /**
  137802. * Set the value of an uniform to an array of int32 (stored as vec3)
  137803. * @param uniform defines the webGL uniform location where to store the value
  137804. * @param array defines the array of int32 to store
  137805. * @returns true if value was set
  137806. */
  137807. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137808. /**
  137809. * Set the value of an uniform to an array of int32 (stored as vec4)
  137810. * @param uniform defines the webGL uniform location where to store the value
  137811. * @param array defines the array of int32 to store
  137812. * @returns true if value was set
  137813. */
  137814. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137815. /**
  137816. * Set the value of an uniform to an array of float32
  137817. * @param uniform defines the webGL uniform location where to store the value
  137818. * @param array defines the array of float32 to store
  137819. * @returns true if value was set
  137820. */
  137821. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137822. /**
  137823. * Set the value of an uniform to an array of float32 (stored as vec2)
  137824. * @param uniform defines the webGL uniform location where to store the value
  137825. * @param array defines the array of float32 to store
  137826. * @returns true if value was set
  137827. */
  137828. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137829. /**
  137830. * Set the value of an uniform to an array of float32 (stored as vec3)
  137831. * @param uniform defines the webGL uniform location where to store the value
  137832. * @param array defines the array of float32 to store
  137833. * @returns true if value was set
  137834. */
  137835. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137836. /**
  137837. * Set the value of an uniform to an array of float32 (stored as vec4)
  137838. * @param uniform defines the webGL uniform location where to store the value
  137839. * @param array defines the array of float32 to store
  137840. * @returns true if value was set
  137841. */
  137842. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137843. /**
  137844. * Set the value of an uniform to an array of number
  137845. * @param uniform defines the webGL uniform location where to store the value
  137846. * @param array defines the array of number to store
  137847. * @returns true if value was set
  137848. */
  137849. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  137850. /**
  137851. * Set the value of an uniform to an array of number (stored as vec2)
  137852. * @param uniform defines the webGL uniform location where to store the value
  137853. * @param array defines the array of number to store
  137854. * @returns true if value was set
  137855. */
  137856. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  137857. /**
  137858. * Set the value of an uniform to an array of number (stored as vec3)
  137859. * @param uniform defines the webGL uniform location where to store the value
  137860. * @param array defines the array of number to store
  137861. * @returns true if value was set
  137862. */
  137863. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  137864. /**
  137865. * Set the value of an uniform to an array of number (stored as vec4)
  137866. * @param uniform defines the webGL uniform location where to store the value
  137867. * @param array defines the array of number to store
  137868. * @returns true if value was set
  137869. */
  137870. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  137871. /**
  137872. * Set the value of an uniform to an array of float32 (stored as matrices)
  137873. * @param uniform defines the webGL uniform location where to store the value
  137874. * @param matrices defines the array of float32 to store
  137875. * @returns true if value was set
  137876. */
  137877. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  137878. /**
  137879. * Set the value of an uniform to a matrix (3x3)
  137880. * @param uniform defines the webGL uniform location where to store the value
  137881. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  137882. * @returns true if value was set
  137883. */
  137884. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  137885. /**
  137886. * Set the value of an uniform to a matrix (2x2)
  137887. * @param uniform defines the webGL uniform location where to store the value
  137888. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  137889. * @returns true if value was set
  137890. */
  137891. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  137892. /**
  137893. * Set the value of an uniform to a number (float)
  137894. * @param uniform defines the webGL uniform location where to store the value
  137895. * @param value defines the float number to store
  137896. * @returns true if value was set
  137897. */
  137898. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  137899. /**
  137900. * Set the value of an uniform to a vec2
  137901. * @param uniform defines the webGL uniform location where to store the value
  137902. * @param x defines the 1st component of the value
  137903. * @param y defines the 2nd component of the value
  137904. * @returns true if value was set
  137905. */
  137906. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  137907. /**
  137908. * Set the value of an uniform to a vec3
  137909. * @param uniform defines the webGL uniform location where to store the value
  137910. * @param x defines the 1st component of the value
  137911. * @param y defines the 2nd component of the value
  137912. * @param z defines the 3rd component of the value
  137913. * @returns true if value was set
  137914. */
  137915. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  137916. /**
  137917. * Set the value of an uniform to a boolean
  137918. * @param uniform defines the webGL uniform location where to store the value
  137919. * @param bool defines the boolean to store
  137920. * @returns true if value was set
  137921. */
  137922. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  137923. /**
  137924. * Set the value of an uniform to a vec4
  137925. * @param uniform defines the webGL uniform location where to store the value
  137926. * @param x defines the 1st component of the value
  137927. * @param y defines the 2nd component of the value
  137928. * @param z defines the 3rd component of the value
  137929. * @param w defines the 4th component of the value
  137930. * @returns true if value was set
  137931. */
  137932. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  137933. /**
  137934. * Sets the current alpha mode
  137935. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  137936. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  137937. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  137938. */
  137939. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  137940. /**
  137941. * Bind webGl buffers directly to the webGL context
  137942. * @param vertexBuffers defines the vertex buffer to bind
  137943. * @param indexBuffer defines the index buffer to bind
  137944. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  137945. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  137946. * @param effect defines the effect associated with the vertex buffer
  137947. */
  137948. bindBuffers(vertexBuffers: {
  137949. [key: string]: VertexBuffer;
  137950. }, indexBuffer: DataBuffer, effect: Effect): void;
  137951. /**
  137952. * Force the entire cache to be cleared
  137953. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  137954. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  137955. */
  137956. wipeCaches(bruteForce?: boolean): void;
  137957. /**
  137958. * Send a draw order
  137959. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  137960. * @param indexStart defines the starting index
  137961. * @param indexCount defines the number of index to draw
  137962. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137963. */
  137964. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  137965. /**
  137966. * Draw a list of indexed primitives
  137967. * @param fillMode defines the primitive to use
  137968. * @param indexStart defines the starting index
  137969. * @param indexCount defines the number of index to draw
  137970. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137971. */
  137972. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  137973. /**
  137974. * Draw a list of unindexed primitives
  137975. * @param fillMode defines the primitive to use
  137976. * @param verticesStart defines the index of first vertex to draw
  137977. * @param verticesCount defines the count of vertices to draw
  137978. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137979. */
  137980. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  137981. /** @hidden */
  137982. _createTexture(): WebGLTexture;
  137983. /** @hidden */
  137984. _releaseTexture(texture: InternalTexture): void;
  137985. /**
  137986. * Usually called from Texture.ts.
  137987. * Passed information to create a WebGLTexture
  137988. * @param urlArg defines a value which contains one of the following:
  137989. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  137990. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  137991. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  137992. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  137993. * @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)
  137994. * @param scene needed for loading to the correct scene
  137995. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  137996. * @param onLoad optional callback to be called upon successful completion
  137997. * @param onError optional callback to be called upon failure
  137998. * @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
  137999. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  138000. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  138001. * @param forcedExtension defines the extension to use to pick the right loader
  138002. * @param mimeType defines an optional mime type
  138003. * @returns a InternalTexture for assignment back into BABYLON.Texture
  138004. */
  138005. 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;
  138006. /**
  138007. * Creates a new render target texture
  138008. * @param size defines the size of the texture
  138009. * @param options defines the options used to create the texture
  138010. * @returns a new render target texture stored in an InternalTexture
  138011. */
  138012. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  138013. /**
  138014. * Update the sampling mode of a given texture
  138015. * @param samplingMode defines the required sampling mode
  138016. * @param texture defines the texture to update
  138017. */
  138018. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  138019. /**
  138020. * Binds the frame buffer to the specified texture.
  138021. * @param texture The texture to render to or null for the default canvas
  138022. * @param faceIndex The face of the texture to render to in case of cube texture
  138023. * @param requiredWidth The width of the target to render to
  138024. * @param requiredHeight The height of the target to render to
  138025. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  138026. * @param lodLevel defines le lod level to bind to the frame buffer
  138027. */
  138028. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  138029. /**
  138030. * Unbind the current render target texture from the webGL context
  138031. * @param texture defines the render target texture to unbind
  138032. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  138033. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  138034. */
  138035. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  138036. /**
  138037. * Creates a dynamic vertex buffer
  138038. * @param vertices the data for the dynamic vertex buffer
  138039. * @returns the new WebGL dynamic buffer
  138040. */
  138041. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  138042. /**
  138043. * Update the content of a dynamic texture
  138044. * @param texture defines the texture to update
  138045. * @param canvas defines the canvas containing the source
  138046. * @param invertY defines if data must be stored with Y axis inverted
  138047. * @param premulAlpha defines if alpha is stored as premultiplied
  138048. * @param format defines the format of the data
  138049. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  138050. */
  138051. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  138052. /**
  138053. * Gets a boolean indicating if all created effects are ready
  138054. * @returns true if all effects are ready
  138055. */
  138056. areAllEffectsReady(): boolean;
  138057. /**
  138058. * @hidden
  138059. * Get the current error code of the webGL context
  138060. * @returns the error code
  138061. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  138062. */
  138063. getError(): number;
  138064. /** @hidden */
  138065. _getUnpackAlignement(): number;
  138066. /** @hidden */
  138067. _unpackFlipY(value: boolean): void;
  138068. /**
  138069. * Update a dynamic index buffer
  138070. * @param indexBuffer defines the target index buffer
  138071. * @param indices defines the data to update
  138072. * @param offset defines the offset in the target index buffer where update should start
  138073. */
  138074. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  138075. /**
  138076. * Updates a dynamic vertex buffer.
  138077. * @param vertexBuffer the vertex buffer to update
  138078. * @param vertices the data used to update the vertex buffer
  138079. * @param byteOffset the byte offset of the data (optional)
  138080. * @param byteLength the byte length of the data (optional)
  138081. */
  138082. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  138083. /** @hidden */
  138084. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  138085. /** @hidden */
  138086. _bindTexture(channel: number, texture: InternalTexture): void;
  138087. protected _deleteBuffer(buffer: WebGLBuffer): void;
  138088. /**
  138089. * 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
  138090. */
  138091. releaseEffects(): void;
  138092. displayLoadingUI(): void;
  138093. hideLoadingUI(): void;
  138094. /** @hidden */
  138095. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138096. /** @hidden */
  138097. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138098. /** @hidden */
  138099. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138100. /** @hidden */
  138101. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  138102. }
  138103. }
  138104. declare module BABYLON {
  138105. /**
  138106. * @hidden
  138107. **/
  138108. export class _TimeToken {
  138109. _startTimeQuery: Nullable<WebGLQuery>;
  138110. _endTimeQuery: Nullable<WebGLQuery>;
  138111. _timeElapsedQuery: Nullable<WebGLQuery>;
  138112. _timeElapsedQueryEnded: boolean;
  138113. }
  138114. }
  138115. declare module BABYLON {
  138116. /** @hidden */
  138117. export class _OcclusionDataStorage {
  138118. /** @hidden */
  138119. occlusionInternalRetryCounter: number;
  138120. /** @hidden */
  138121. isOcclusionQueryInProgress: boolean;
  138122. /** @hidden */
  138123. isOccluded: boolean;
  138124. /** @hidden */
  138125. occlusionRetryCount: number;
  138126. /** @hidden */
  138127. occlusionType: number;
  138128. /** @hidden */
  138129. occlusionQueryAlgorithmType: number;
  138130. }
  138131. interface Engine {
  138132. /**
  138133. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  138134. * @return the new query
  138135. */
  138136. createQuery(): WebGLQuery;
  138137. /**
  138138. * Delete and release a webGL query
  138139. * @param query defines the query to delete
  138140. * @return the current engine
  138141. */
  138142. deleteQuery(query: WebGLQuery): Engine;
  138143. /**
  138144. * Check if a given query has resolved and got its value
  138145. * @param query defines the query to check
  138146. * @returns true if the query got its value
  138147. */
  138148. isQueryResultAvailable(query: WebGLQuery): boolean;
  138149. /**
  138150. * Gets the value of a given query
  138151. * @param query defines the query to check
  138152. * @returns the value of the query
  138153. */
  138154. getQueryResult(query: WebGLQuery): number;
  138155. /**
  138156. * Initiates an occlusion query
  138157. * @param algorithmType defines the algorithm to use
  138158. * @param query defines the query to use
  138159. * @returns the current engine
  138160. * @see https://doc.babylonjs.com/features/occlusionquery
  138161. */
  138162. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  138163. /**
  138164. * Ends an occlusion query
  138165. * @see https://doc.babylonjs.com/features/occlusionquery
  138166. * @param algorithmType defines the algorithm to use
  138167. * @returns the current engine
  138168. */
  138169. endOcclusionQuery(algorithmType: number): Engine;
  138170. /**
  138171. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  138172. * Please note that only one query can be issued at a time
  138173. * @returns a time token used to track the time span
  138174. */
  138175. startTimeQuery(): Nullable<_TimeToken>;
  138176. /**
  138177. * Ends a time query
  138178. * @param token defines the token used to measure the time span
  138179. * @returns the time spent (in ns)
  138180. */
  138181. endTimeQuery(token: _TimeToken): int;
  138182. /** @hidden */
  138183. _currentNonTimestampToken: Nullable<_TimeToken>;
  138184. /** @hidden */
  138185. _createTimeQuery(): WebGLQuery;
  138186. /** @hidden */
  138187. _deleteTimeQuery(query: WebGLQuery): void;
  138188. /** @hidden */
  138189. _getGlAlgorithmType(algorithmType: number): number;
  138190. /** @hidden */
  138191. _getTimeQueryResult(query: WebGLQuery): any;
  138192. /** @hidden */
  138193. _getTimeQueryAvailability(query: WebGLQuery): any;
  138194. }
  138195. interface AbstractMesh {
  138196. /**
  138197. * Backing filed
  138198. * @hidden
  138199. */
  138200. __occlusionDataStorage: _OcclusionDataStorage;
  138201. /**
  138202. * Access property
  138203. * @hidden
  138204. */
  138205. _occlusionDataStorage: _OcclusionDataStorage;
  138206. /**
  138207. * 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.
  138208. * The default value is -1 which means don't break the query and wait till the result
  138209. * @see https://doc.babylonjs.com/features/occlusionquery
  138210. */
  138211. occlusionRetryCount: number;
  138212. /**
  138213. * 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:
  138214. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  138215. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  138216. * * 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.
  138217. * @see https://doc.babylonjs.com/features/occlusionquery
  138218. */
  138219. occlusionType: number;
  138220. /**
  138221. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  138222. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  138223. * * 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.
  138224. * @see https://doc.babylonjs.com/features/occlusionquery
  138225. */
  138226. occlusionQueryAlgorithmType: number;
  138227. /**
  138228. * 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
  138229. * @see https://doc.babylonjs.com/features/occlusionquery
  138230. */
  138231. isOccluded: boolean;
  138232. /**
  138233. * Flag to check the progress status of the query
  138234. * @see https://doc.babylonjs.com/features/occlusionquery
  138235. */
  138236. isOcclusionQueryInProgress: boolean;
  138237. }
  138238. }
  138239. declare module BABYLON {
  138240. /** @hidden */
  138241. export var _forceTransformFeedbackToBundle: boolean;
  138242. interface Engine {
  138243. /**
  138244. * Creates a webGL transform feedback object
  138245. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  138246. * @returns the webGL transform feedback object
  138247. */
  138248. createTransformFeedback(): WebGLTransformFeedback;
  138249. /**
  138250. * Delete a webGL transform feedback object
  138251. * @param value defines the webGL transform feedback object to delete
  138252. */
  138253. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  138254. /**
  138255. * Bind a webGL transform feedback object to the webgl context
  138256. * @param value defines the webGL transform feedback object to bind
  138257. */
  138258. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  138259. /**
  138260. * Begins a transform feedback operation
  138261. * @param usePoints defines if points or triangles must be used
  138262. */
  138263. beginTransformFeedback(usePoints: boolean): void;
  138264. /**
  138265. * Ends a transform feedback operation
  138266. */
  138267. endTransformFeedback(): void;
  138268. /**
  138269. * Specify the varyings to use with transform feedback
  138270. * @param program defines the associated webGL program
  138271. * @param value defines the list of strings representing the varying names
  138272. */
  138273. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  138274. /**
  138275. * Bind a webGL buffer for a transform feedback operation
  138276. * @param value defines the webGL buffer to bind
  138277. */
  138278. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  138279. }
  138280. }
  138281. declare module BABYLON {
  138282. /**
  138283. * Class used to define an additional view for the engine
  138284. * @see https://doc.babylonjs.com/how_to/multi_canvases
  138285. */
  138286. export class EngineView {
  138287. /** Defines the canvas where to render the view */
  138288. target: HTMLCanvasElement;
  138289. /** Defines an optional camera used to render the view (will use active camera else) */
  138290. camera?: Camera;
  138291. }
  138292. interface Engine {
  138293. /**
  138294. * Gets or sets the HTML element to use for attaching events
  138295. */
  138296. inputElement: Nullable<HTMLElement>;
  138297. /**
  138298. * Gets the current engine view
  138299. * @see https://doc.babylonjs.com/how_to/multi_canvases
  138300. */
  138301. activeView: Nullable<EngineView>;
  138302. /** Gets or sets the list of views */
  138303. views: EngineView[];
  138304. /**
  138305. * Register a new child canvas
  138306. * @param canvas defines the canvas to register
  138307. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  138308. * @returns the associated view
  138309. */
  138310. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  138311. /**
  138312. * Remove a registered child canvas
  138313. * @param canvas defines the canvas to remove
  138314. * @returns the current engine
  138315. */
  138316. unRegisterView(canvas: HTMLCanvasElement): Engine;
  138317. }
  138318. }
  138319. declare module BABYLON {
  138320. interface Engine {
  138321. /** @hidden */
  138322. _excludedCompressedTextures: string[];
  138323. /** @hidden */
  138324. _textureFormatInUse: string;
  138325. /**
  138326. * Gets the list of texture formats supported
  138327. */
  138328. readonly texturesSupported: Array<string>;
  138329. /**
  138330. * Gets the texture format in use
  138331. */
  138332. readonly textureFormatInUse: Nullable<string>;
  138333. /**
  138334. * Set the compressed texture extensions or file names to skip.
  138335. *
  138336. * @param skippedFiles defines the list of those texture files you want to skip
  138337. * Example: [".dds", ".env", "myfile.png"]
  138338. */
  138339. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  138340. /**
  138341. * Set the compressed texture format to use, based on the formats you have, and the formats
  138342. * supported by the hardware / browser.
  138343. *
  138344. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  138345. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  138346. * to API arguments needed to compressed textures. This puts the burden on the container
  138347. * generator to house the arcane code for determining these for current & future formats.
  138348. *
  138349. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138350. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138351. *
  138352. * Note: The result of this call is not taken into account when a texture is base64.
  138353. *
  138354. * @param formatsAvailable defines the list of those format families you have created
  138355. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  138356. *
  138357. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  138358. * @returns The extension selected.
  138359. */
  138360. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  138361. }
  138362. }
  138363. declare module BABYLON {
  138364. /** @hidden */
  138365. export var rgbdEncodePixelShader: {
  138366. name: string;
  138367. shader: string;
  138368. };
  138369. }
  138370. declare module BABYLON {
  138371. /**
  138372. * Raw texture data and descriptor sufficient for WebGL texture upload
  138373. */
  138374. export interface EnvironmentTextureInfo {
  138375. /**
  138376. * Version of the environment map
  138377. */
  138378. version: number;
  138379. /**
  138380. * Width of image
  138381. */
  138382. width: number;
  138383. /**
  138384. * Irradiance information stored in the file.
  138385. */
  138386. irradiance: any;
  138387. /**
  138388. * Specular information stored in the file.
  138389. */
  138390. specular: any;
  138391. }
  138392. /**
  138393. * Defines One Image in the file. It requires only the position in the file
  138394. * as well as the length.
  138395. */
  138396. interface BufferImageData {
  138397. /**
  138398. * Length of the image data.
  138399. */
  138400. length: number;
  138401. /**
  138402. * Position of the data from the null terminator delimiting the end of the JSON.
  138403. */
  138404. position: number;
  138405. }
  138406. /**
  138407. * Defines the specular data enclosed in the file.
  138408. * This corresponds to the version 1 of the data.
  138409. */
  138410. export interface EnvironmentTextureSpecularInfoV1 {
  138411. /**
  138412. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  138413. */
  138414. specularDataPosition?: number;
  138415. /**
  138416. * This contains all the images data needed to reconstruct the cubemap.
  138417. */
  138418. mipmaps: Array<BufferImageData>;
  138419. /**
  138420. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  138421. */
  138422. lodGenerationScale: number;
  138423. }
  138424. /**
  138425. * Sets of helpers addressing the serialization and deserialization of environment texture
  138426. * stored in a BabylonJS env file.
  138427. * Those files are usually stored as .env files.
  138428. */
  138429. export class EnvironmentTextureTools {
  138430. /**
  138431. * Magic number identifying the env file.
  138432. */
  138433. private static _MagicBytes;
  138434. /**
  138435. * Gets the environment info from an env file.
  138436. * @param data The array buffer containing the .env bytes.
  138437. * @returns the environment file info (the json header) if successfully parsed.
  138438. */
  138439. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  138440. /**
  138441. * Creates an environment texture from a loaded cube texture.
  138442. * @param texture defines the cube texture to convert in env file
  138443. * @return a promise containing the environment data if succesfull.
  138444. */
  138445. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  138446. /**
  138447. * Creates a JSON representation of the spherical data.
  138448. * @param texture defines the texture containing the polynomials
  138449. * @return the JSON representation of the spherical info
  138450. */
  138451. private static _CreateEnvTextureIrradiance;
  138452. /**
  138453. * Creates the ArrayBufferViews used for initializing environment texture image data.
  138454. * @param data the image data
  138455. * @param info parameters that determine what views will be created for accessing the underlying buffer
  138456. * @return the views described by info providing access to the underlying buffer
  138457. */
  138458. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  138459. /**
  138460. * Uploads the texture info contained in the env file to the GPU.
  138461. * @param texture defines the internal texture to upload to
  138462. * @param data defines the data to load
  138463. * @param info defines the texture info retrieved through the GetEnvInfo method
  138464. * @returns a promise
  138465. */
  138466. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  138467. private static _OnImageReadyAsync;
  138468. /**
  138469. * Uploads the levels of image data to the GPU.
  138470. * @param texture defines the internal texture to upload to
  138471. * @param imageData defines the array buffer views of image data [mipmap][face]
  138472. * @returns a promise
  138473. */
  138474. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  138475. /**
  138476. * Uploads spherical polynomials information to the texture.
  138477. * @param texture defines the texture we are trying to upload the information to
  138478. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  138479. */
  138480. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  138481. /** @hidden */
  138482. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  138483. }
  138484. }
  138485. declare module BABYLON {
  138486. /**
  138487. * Class used to inline functions in shader code
  138488. */
  138489. export class ShaderCodeInliner {
  138490. private static readonly _RegexpFindFunctionNameAndType;
  138491. private _sourceCode;
  138492. private _functionDescr;
  138493. private _numMaxIterations;
  138494. /** Gets or sets the token used to mark the functions to inline */
  138495. inlineToken: string;
  138496. /** Gets or sets the debug mode */
  138497. debug: boolean;
  138498. /** Gets the code after the inlining process */
  138499. get code(): string;
  138500. /**
  138501. * Initializes the inliner
  138502. * @param sourceCode shader code source to inline
  138503. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  138504. */
  138505. constructor(sourceCode: string, numMaxIterations?: number);
  138506. /**
  138507. * Start the processing of the shader code
  138508. */
  138509. processCode(): void;
  138510. private _collectFunctions;
  138511. private _processInlining;
  138512. private _extractBetweenMarkers;
  138513. private _skipWhitespaces;
  138514. private _removeComments;
  138515. private _replaceFunctionCallsByCode;
  138516. private _findBackward;
  138517. private _escapeRegExp;
  138518. private _replaceNames;
  138519. }
  138520. }
  138521. declare module BABYLON {
  138522. /**
  138523. * Container for accessors for natively-stored mesh data buffers.
  138524. */
  138525. class NativeDataBuffer extends DataBuffer {
  138526. /**
  138527. * Accessor value used to identify/retrieve a natively-stored index buffer.
  138528. */
  138529. nativeIndexBuffer?: any;
  138530. /**
  138531. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  138532. */
  138533. nativeVertexBuffer?: any;
  138534. }
  138535. /** @hidden */
  138536. class NativeTexture extends InternalTexture {
  138537. getInternalTexture(): InternalTexture;
  138538. getViewCount(): number;
  138539. }
  138540. /** @hidden */
  138541. export class NativeEngine extends Engine {
  138542. private readonly _native;
  138543. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  138544. private readonly INVALID_HANDLE;
  138545. private _boundBuffersVertexArray;
  138546. private _currentDepthTest;
  138547. getHardwareScalingLevel(): number;
  138548. constructor();
  138549. dispose(): void;
  138550. /**
  138551. * Can be used to override the current requestAnimationFrame requester.
  138552. * @hidden
  138553. */
  138554. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  138555. /**
  138556. * Override default engine behavior.
  138557. * @param color
  138558. * @param backBuffer
  138559. * @param depth
  138560. * @param stencil
  138561. */
  138562. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  138563. /**
  138564. * Gets host document
  138565. * @returns the host document object
  138566. */
  138567. getHostDocument(): Nullable<Document>;
  138568. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  138569. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  138570. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  138571. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  138572. [key: string]: VertexBuffer;
  138573. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  138574. bindBuffers(vertexBuffers: {
  138575. [key: string]: VertexBuffer;
  138576. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  138577. recordVertexArrayObject(vertexBuffers: {
  138578. [key: string]: VertexBuffer;
  138579. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  138580. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  138581. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  138582. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  138583. /**
  138584. * Draw a list of indexed primitives
  138585. * @param fillMode defines the primitive to use
  138586. * @param indexStart defines the starting index
  138587. * @param indexCount defines the number of index to draw
  138588. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138589. */
  138590. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  138591. /**
  138592. * Draw a list of unindexed primitives
  138593. * @param fillMode defines the primitive to use
  138594. * @param verticesStart defines the index of first vertex to draw
  138595. * @param verticesCount defines the count of vertices to draw
  138596. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138597. */
  138598. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  138599. createPipelineContext(): IPipelineContext;
  138600. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  138601. /** @hidden */
  138602. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  138603. /** @hidden */
  138604. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  138605. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  138606. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  138607. protected _setProgram(program: WebGLProgram): void;
  138608. _releaseEffect(effect: Effect): void;
  138609. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  138610. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  138611. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  138612. bindSamplers(effect: Effect): void;
  138613. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  138614. getRenderWidth(useScreen?: boolean): number;
  138615. getRenderHeight(useScreen?: boolean): number;
  138616. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  138617. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  138618. /**
  138619. * Set the z offset to apply to current rendering
  138620. * @param value defines the offset to apply
  138621. */
  138622. setZOffset(value: number): void;
  138623. /**
  138624. * Gets the current value of the zOffset
  138625. * @returns the current zOffset state
  138626. */
  138627. getZOffset(): number;
  138628. /**
  138629. * Enable or disable depth buffering
  138630. * @param enable defines the state to set
  138631. */
  138632. setDepthBuffer(enable: boolean): void;
  138633. /**
  138634. * Gets a boolean indicating if depth writing is enabled
  138635. * @returns the current depth writing state
  138636. */
  138637. getDepthWrite(): boolean;
  138638. setDepthFunctionToGreater(): void;
  138639. setDepthFunctionToGreaterOrEqual(): void;
  138640. setDepthFunctionToLess(): void;
  138641. setDepthFunctionToLessOrEqual(): void;
  138642. /**
  138643. * Enable or disable depth writing
  138644. * @param enable defines the state to set
  138645. */
  138646. setDepthWrite(enable: boolean): void;
  138647. /**
  138648. * Enable or disable color writing
  138649. * @param enable defines the state to set
  138650. */
  138651. setColorWrite(enable: boolean): void;
  138652. /**
  138653. * Gets a boolean indicating if color writing is enabled
  138654. * @returns the current color writing state
  138655. */
  138656. getColorWrite(): boolean;
  138657. /**
  138658. * Sets alpha constants used by some alpha blending modes
  138659. * @param r defines the red component
  138660. * @param g defines the green component
  138661. * @param b defines the blue component
  138662. * @param a defines the alpha component
  138663. */
  138664. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  138665. /**
  138666. * Sets the current alpha mode
  138667. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  138668. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  138669. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  138670. */
  138671. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  138672. /**
  138673. * Gets the current alpha mode
  138674. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  138675. * @returns the current alpha mode
  138676. */
  138677. getAlphaMode(): number;
  138678. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  138679. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138680. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138681. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138682. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138683. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138684. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138685. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138686. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138687. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  138688. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  138689. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  138690. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  138691. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  138692. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138693. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138694. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  138695. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  138696. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  138697. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  138698. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  138699. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  138700. wipeCaches(bruteForce?: boolean): void;
  138701. _createTexture(): WebGLTexture;
  138702. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  138703. /**
  138704. * Update the content of a dynamic texture
  138705. * @param texture defines the texture to update
  138706. * @param canvas defines the canvas containing the source
  138707. * @param invertY defines if data must be stored with Y axis inverted
  138708. * @param premulAlpha defines if alpha is stored as premultiplied
  138709. * @param format defines the format of the data
  138710. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  138711. */
  138712. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  138713. /**
  138714. * Usually called from Texture.ts.
  138715. * Passed information to create a WebGLTexture
  138716. * @param url defines a value which contains one of the following:
  138717. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  138718. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  138719. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  138720. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  138721. * @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)
  138722. * @param scene needed for loading to the correct scene
  138723. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  138724. * @param onLoad optional callback to be called upon successful completion
  138725. * @param onError optional callback to be called upon failure
  138726. * @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
  138727. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  138728. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  138729. * @param forcedExtension defines the extension to use to pick the right loader
  138730. * @param mimeType defines an optional mime type
  138731. * @param loaderOptions options to be passed to the loader
  138732. * @returns a InternalTexture for assignment back into BABYLON.Texture
  138733. */
  138734. 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;
  138735. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  138736. _releaseFramebufferObjects(texture: InternalTexture): void;
  138737. /**
  138738. * Creates a cube texture
  138739. * @param rootUrl defines the url where the files to load is located
  138740. * @param scene defines the current scene
  138741. * @param files defines the list of files to load (1 per face)
  138742. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  138743. * @param onLoad defines an optional callback raised when the texture is loaded
  138744. * @param onError defines an optional callback raised if there is an issue to load the texture
  138745. * @param format defines the format of the data
  138746. * @param forcedExtension defines the extension to use to pick the right loader
  138747. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  138748. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  138749. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  138750. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  138751. * @returns the cube texture as an InternalTexture
  138752. */
  138753. 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;
  138754. createRenderTargetTexture(size: number | {
  138755. width: number;
  138756. height: number;
  138757. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  138758. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  138759. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  138760. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  138761. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  138762. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  138763. /**
  138764. * Updates a dynamic vertex buffer.
  138765. * @param vertexBuffer the vertex buffer to update
  138766. * @param data the data used to update the vertex buffer
  138767. * @param byteOffset the byte offset of the data (optional)
  138768. * @param byteLength the byte length of the data (optional)
  138769. */
  138770. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  138771. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  138772. private _updateAnisotropicLevel;
  138773. private _getAddressMode;
  138774. /** @hidden */
  138775. _bindTexture(channel: number, texture: InternalTexture): void;
  138776. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  138777. releaseEffects(): void;
  138778. /** @hidden */
  138779. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138780. /** @hidden */
  138781. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138782. /** @hidden */
  138783. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138784. /** @hidden */
  138785. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  138786. private _getNativeSamplingMode;
  138787. private _getNativeTextureFormat;
  138788. private _getNativeAlphaMode;
  138789. private _getNativeAttribType;
  138790. }
  138791. }
  138792. declare module BABYLON {
  138793. /**
  138794. * Gather the list of clipboard event types as constants.
  138795. */
  138796. export class ClipboardEventTypes {
  138797. /**
  138798. * The clipboard event is fired when a copy command is active (pressed).
  138799. */
  138800. static readonly COPY: number;
  138801. /**
  138802. * The clipboard event is fired when a cut command is active (pressed).
  138803. */
  138804. static readonly CUT: number;
  138805. /**
  138806. * The clipboard event is fired when a paste command is active (pressed).
  138807. */
  138808. static readonly PASTE: number;
  138809. }
  138810. /**
  138811. * This class is used to store clipboard related info for the onClipboardObservable event.
  138812. */
  138813. export class ClipboardInfo {
  138814. /**
  138815. * Defines the type of event (BABYLON.ClipboardEventTypes)
  138816. */
  138817. type: number;
  138818. /**
  138819. * Defines the related dom event
  138820. */
  138821. event: ClipboardEvent;
  138822. /**
  138823. *Creates an instance of ClipboardInfo.
  138824. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  138825. * @param event Defines the related dom event
  138826. */
  138827. constructor(
  138828. /**
  138829. * Defines the type of event (BABYLON.ClipboardEventTypes)
  138830. */
  138831. type: number,
  138832. /**
  138833. * Defines the related dom event
  138834. */
  138835. event: ClipboardEvent);
  138836. /**
  138837. * Get the clipboard event's type from the keycode.
  138838. * @param keyCode Defines the keyCode for the current keyboard event.
  138839. * @return {number}
  138840. */
  138841. static GetTypeFromCharacter(keyCode: number): number;
  138842. }
  138843. }
  138844. declare module BABYLON {
  138845. /**
  138846. * Google Daydream controller
  138847. */
  138848. export class DaydreamController extends WebVRController {
  138849. /**
  138850. * Base Url for the controller model.
  138851. */
  138852. static MODEL_BASE_URL: string;
  138853. /**
  138854. * File name for the controller model.
  138855. */
  138856. static MODEL_FILENAME: string;
  138857. /**
  138858. * Gamepad Id prefix used to identify Daydream Controller.
  138859. */
  138860. static readonly GAMEPAD_ID_PREFIX: string;
  138861. /**
  138862. * Creates a new DaydreamController from a gamepad
  138863. * @param vrGamepad the gamepad that the controller should be created from
  138864. */
  138865. constructor(vrGamepad: any);
  138866. /**
  138867. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138868. * @param scene scene in which to add meshes
  138869. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138870. */
  138871. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  138872. /**
  138873. * Called once for each button that changed state since the last frame
  138874. * @param buttonIdx Which button index changed
  138875. * @param state New state of the button
  138876. * @param changes Which properties on the state changed since last frame
  138877. */
  138878. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  138879. }
  138880. }
  138881. declare module BABYLON {
  138882. /**
  138883. * Gear VR Controller
  138884. */
  138885. export class GearVRController extends WebVRController {
  138886. /**
  138887. * Base Url for the controller model.
  138888. */
  138889. static MODEL_BASE_URL: string;
  138890. /**
  138891. * File name for the controller model.
  138892. */
  138893. static MODEL_FILENAME: string;
  138894. /**
  138895. * Gamepad Id prefix used to identify this controller.
  138896. */
  138897. static readonly GAMEPAD_ID_PREFIX: string;
  138898. private readonly _buttonIndexToObservableNameMap;
  138899. /**
  138900. * Creates a new GearVRController from a gamepad
  138901. * @param vrGamepad the gamepad that the controller should be created from
  138902. */
  138903. constructor(vrGamepad: any);
  138904. /**
  138905. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138906. * @param scene scene in which to add meshes
  138907. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138908. */
  138909. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  138910. /**
  138911. * Called once for each button that changed state since the last frame
  138912. * @param buttonIdx Which button index changed
  138913. * @param state New state of the button
  138914. * @param changes Which properties on the state changed since last frame
  138915. */
  138916. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  138917. }
  138918. }
  138919. declare module BABYLON {
  138920. /**
  138921. * Generic Controller
  138922. */
  138923. export class GenericController extends WebVRController {
  138924. /**
  138925. * Base Url for the controller model.
  138926. */
  138927. static readonly MODEL_BASE_URL: string;
  138928. /**
  138929. * File name for the controller model.
  138930. */
  138931. static readonly MODEL_FILENAME: string;
  138932. /**
  138933. * Creates a new GenericController from a gamepad
  138934. * @param vrGamepad the gamepad that the controller should be created from
  138935. */
  138936. constructor(vrGamepad: any);
  138937. /**
  138938. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138939. * @param scene scene in which to add meshes
  138940. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138941. */
  138942. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  138943. /**
  138944. * Called once for each button that changed state since the last frame
  138945. * @param buttonIdx Which button index changed
  138946. * @param state New state of the button
  138947. * @param changes Which properties on the state changed since last frame
  138948. */
  138949. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  138950. }
  138951. }
  138952. declare module BABYLON {
  138953. /**
  138954. * Oculus Touch Controller
  138955. */
  138956. export class OculusTouchController extends WebVRController {
  138957. /**
  138958. * Base Url for the controller model.
  138959. */
  138960. static MODEL_BASE_URL: string;
  138961. /**
  138962. * File name for the left controller model.
  138963. */
  138964. static MODEL_LEFT_FILENAME: string;
  138965. /**
  138966. * File name for the right controller model.
  138967. */
  138968. static MODEL_RIGHT_FILENAME: string;
  138969. /**
  138970. * Base Url for the Quest controller model.
  138971. */
  138972. static QUEST_MODEL_BASE_URL: string;
  138973. /**
  138974. * @hidden
  138975. * If the controllers are running on a device that needs the updated Quest controller models
  138976. */
  138977. static _IsQuest: boolean;
  138978. /**
  138979. * Fired when the secondary trigger on this controller is modified
  138980. */
  138981. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  138982. /**
  138983. * Fired when the thumb rest on this controller is modified
  138984. */
  138985. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  138986. /**
  138987. * Creates a new OculusTouchController from a gamepad
  138988. * @param vrGamepad the gamepad that the controller should be created from
  138989. */
  138990. constructor(vrGamepad: any);
  138991. /**
  138992. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138993. * @param scene scene in which to add meshes
  138994. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138995. */
  138996. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  138997. /**
  138998. * Fired when the A button on this controller is modified
  138999. */
  139000. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139001. /**
  139002. * Fired when the B button on this controller is modified
  139003. */
  139004. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139005. /**
  139006. * Fired when the X button on this controller is modified
  139007. */
  139008. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139009. /**
  139010. * Fired when the Y button on this controller is modified
  139011. */
  139012. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139013. /**
  139014. * Called once for each button that changed state since the last frame
  139015. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  139016. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  139017. * 2) secondary trigger (same)
  139018. * 3) A (right) X (left), touch, pressed = value
  139019. * 4) B / Y
  139020. * 5) thumb rest
  139021. * @param buttonIdx Which button index changed
  139022. * @param state New state of the button
  139023. * @param changes Which properties on the state changed since last frame
  139024. */
  139025. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139026. }
  139027. }
  139028. declare module BABYLON {
  139029. /**
  139030. * Vive Controller
  139031. */
  139032. export class ViveController extends WebVRController {
  139033. /**
  139034. * Base Url for the controller model.
  139035. */
  139036. static MODEL_BASE_URL: string;
  139037. /**
  139038. * File name for the controller model.
  139039. */
  139040. static MODEL_FILENAME: string;
  139041. /**
  139042. * Creates a new ViveController from a gamepad
  139043. * @param vrGamepad the gamepad that the controller should be created from
  139044. */
  139045. constructor(vrGamepad: any);
  139046. /**
  139047. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139048. * @param scene scene in which to add meshes
  139049. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139050. */
  139051. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  139052. /**
  139053. * Fired when the left button on this controller is modified
  139054. */
  139055. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139056. /**
  139057. * Fired when the right button on this controller is modified
  139058. */
  139059. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139060. /**
  139061. * Fired when the menu button on this controller is modified
  139062. */
  139063. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139064. /**
  139065. * Called once for each button that changed state since the last frame
  139066. * Vive mapping:
  139067. * 0: touchpad
  139068. * 1: trigger
  139069. * 2: left AND right buttons
  139070. * 3: menu button
  139071. * @param buttonIdx Which button index changed
  139072. * @param state New state of the button
  139073. * @param changes Which properties on the state changed since last frame
  139074. */
  139075. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139076. }
  139077. }
  139078. declare module BABYLON {
  139079. /**
  139080. * Defines the WindowsMotionController object that the state of the windows motion controller
  139081. */
  139082. export class WindowsMotionController extends WebVRController {
  139083. /**
  139084. * The base url used to load the left and right controller models
  139085. */
  139086. static MODEL_BASE_URL: string;
  139087. /**
  139088. * The name of the left controller model file
  139089. */
  139090. static MODEL_LEFT_FILENAME: string;
  139091. /**
  139092. * The name of the right controller model file
  139093. */
  139094. static MODEL_RIGHT_FILENAME: string;
  139095. /**
  139096. * The controller name prefix for this controller type
  139097. */
  139098. static readonly GAMEPAD_ID_PREFIX: string;
  139099. /**
  139100. * The controller id pattern for this controller type
  139101. */
  139102. private static readonly GAMEPAD_ID_PATTERN;
  139103. private _loadedMeshInfo;
  139104. protected readonly _mapping: {
  139105. buttons: string[];
  139106. buttonMeshNames: {
  139107. trigger: string;
  139108. menu: string;
  139109. grip: string;
  139110. thumbstick: string;
  139111. trackpad: string;
  139112. };
  139113. buttonObservableNames: {
  139114. trigger: string;
  139115. menu: string;
  139116. grip: string;
  139117. thumbstick: string;
  139118. trackpad: string;
  139119. };
  139120. axisMeshNames: string[];
  139121. pointingPoseMeshName: string;
  139122. };
  139123. /**
  139124. * Fired when the trackpad on this controller is clicked
  139125. */
  139126. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  139127. /**
  139128. * Fired when the trackpad on this controller is modified
  139129. */
  139130. onTrackpadValuesChangedObservable: Observable<StickValues>;
  139131. /**
  139132. * The current x and y values of this controller's trackpad
  139133. */
  139134. trackpad: StickValues;
  139135. /**
  139136. * Creates a new WindowsMotionController from a gamepad
  139137. * @param vrGamepad the gamepad that the controller should be created from
  139138. */
  139139. constructor(vrGamepad: any);
  139140. /**
  139141. * Fired when the trigger on this controller is modified
  139142. */
  139143. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139144. /**
  139145. * Fired when the menu button on this controller is modified
  139146. */
  139147. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139148. /**
  139149. * Fired when the grip button on this controller is modified
  139150. */
  139151. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139152. /**
  139153. * Fired when the thumbstick button on this controller is modified
  139154. */
  139155. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139156. /**
  139157. * Fired when the touchpad button on this controller is modified
  139158. */
  139159. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139160. /**
  139161. * Fired when the touchpad values on this controller are modified
  139162. */
  139163. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  139164. protected _updateTrackpad(): void;
  139165. /**
  139166. * Called once per frame by the engine.
  139167. */
  139168. update(): void;
  139169. /**
  139170. * Called once for each button that changed state since the last frame
  139171. * @param buttonIdx Which button index changed
  139172. * @param state New state of the button
  139173. * @param changes Which properties on the state changed since last frame
  139174. */
  139175. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139176. /**
  139177. * Moves the buttons on the controller mesh based on their current state
  139178. * @param buttonName the name of the button to move
  139179. * @param buttonValue the value of the button which determines the buttons new position
  139180. */
  139181. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  139182. /**
  139183. * Moves the axis on the controller mesh based on its current state
  139184. * @param axis the index of the axis
  139185. * @param axisValue the value of the axis which determines the meshes new position
  139186. * @hidden
  139187. */
  139188. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  139189. /**
  139190. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139191. * @param scene scene in which to add meshes
  139192. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139193. */
  139194. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  139195. /**
  139196. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  139197. * can be transformed by button presses and axes values, based on this._mapping.
  139198. *
  139199. * @param scene scene in which the meshes exist
  139200. * @param meshes list of meshes that make up the controller model to process
  139201. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  139202. */
  139203. private processModel;
  139204. private createMeshInfo;
  139205. /**
  139206. * Gets the ray of the controller in the direction the controller is pointing
  139207. * @param length the length the resulting ray should be
  139208. * @returns a ray in the direction the controller is pointing
  139209. */
  139210. getForwardRay(length?: number): Ray;
  139211. /**
  139212. * Disposes of the controller
  139213. */
  139214. dispose(): void;
  139215. }
  139216. /**
  139217. * This class represents a new windows motion controller in XR.
  139218. */
  139219. export class XRWindowsMotionController extends WindowsMotionController {
  139220. /**
  139221. * Changing the original WIndowsMotionController mapping to fir the new mapping
  139222. */
  139223. protected readonly _mapping: {
  139224. buttons: string[];
  139225. buttonMeshNames: {
  139226. trigger: string;
  139227. menu: string;
  139228. grip: string;
  139229. thumbstick: string;
  139230. trackpad: string;
  139231. };
  139232. buttonObservableNames: {
  139233. trigger: string;
  139234. menu: string;
  139235. grip: string;
  139236. thumbstick: string;
  139237. trackpad: string;
  139238. };
  139239. axisMeshNames: string[];
  139240. pointingPoseMeshName: string;
  139241. };
  139242. /**
  139243. * Construct a new XR-Based windows motion controller
  139244. *
  139245. * @param gamepadInfo the gamepad object from the browser
  139246. */
  139247. constructor(gamepadInfo: any);
  139248. /**
  139249. * holds the thumbstick values (X,Y)
  139250. */
  139251. thumbstickValues: StickValues;
  139252. /**
  139253. * Fired when the thumbstick on this controller is clicked
  139254. */
  139255. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  139256. /**
  139257. * Fired when the thumbstick on this controller is modified
  139258. */
  139259. onThumbstickValuesChangedObservable: Observable<StickValues>;
  139260. /**
  139261. * Fired when the touchpad button on this controller is modified
  139262. */
  139263. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  139264. /**
  139265. * Fired when the touchpad values on this controller are modified
  139266. */
  139267. onTrackpadValuesChangedObservable: Observable<StickValues>;
  139268. /**
  139269. * Fired when the thumbstick button on this controller is modified
  139270. * here to prevent breaking changes
  139271. */
  139272. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139273. /**
  139274. * updating the thumbstick(!) and not the trackpad.
  139275. * This is named this way due to the difference between WebVR and XR and to avoid
  139276. * changing the parent class.
  139277. */
  139278. protected _updateTrackpad(): void;
  139279. /**
  139280. * Disposes the class with joy
  139281. */
  139282. dispose(): void;
  139283. }
  139284. }
  139285. declare module BABYLON {
  139286. /**
  139287. * A directional light is defined by a direction (what a surprise!).
  139288. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  139289. * 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.
  139290. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139291. */
  139292. export class DirectionalLight extends ShadowLight {
  139293. private _shadowFrustumSize;
  139294. /**
  139295. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  139296. */
  139297. get shadowFrustumSize(): number;
  139298. /**
  139299. * Specifies a fix frustum size for the shadow generation.
  139300. */
  139301. set shadowFrustumSize(value: number);
  139302. private _shadowOrthoScale;
  139303. /**
  139304. * Gets the shadow projection scale against the optimal computed one.
  139305. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  139306. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  139307. */
  139308. get shadowOrthoScale(): number;
  139309. /**
  139310. * Sets the shadow projection scale against the optimal computed one.
  139311. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  139312. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  139313. */
  139314. set shadowOrthoScale(value: number);
  139315. /**
  139316. * Automatically compute the projection matrix to best fit (including all the casters)
  139317. * on each frame.
  139318. */
  139319. autoUpdateExtends: boolean;
  139320. /**
  139321. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  139322. * on each frame. autoUpdateExtends must be set to true for this to work
  139323. */
  139324. autoCalcShadowZBounds: boolean;
  139325. private _orthoLeft;
  139326. private _orthoRight;
  139327. private _orthoTop;
  139328. private _orthoBottom;
  139329. /**
  139330. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  139331. * The directional light is emitted from everywhere in the given direction.
  139332. * It can cast shadows.
  139333. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139334. * @param name The friendly name of the light
  139335. * @param direction The direction of the light
  139336. * @param scene The scene the light belongs to
  139337. */
  139338. constructor(name: string, direction: Vector3, scene: Scene);
  139339. /**
  139340. * Returns the string "DirectionalLight".
  139341. * @return The class name
  139342. */
  139343. getClassName(): string;
  139344. /**
  139345. * Returns the integer 1.
  139346. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139347. */
  139348. getTypeID(): number;
  139349. /**
  139350. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  139351. * Returns the DirectionalLight Shadow projection matrix.
  139352. */
  139353. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139354. /**
  139355. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  139356. * Returns the DirectionalLight Shadow projection matrix.
  139357. */
  139358. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  139359. /**
  139360. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  139361. * Returns the DirectionalLight Shadow projection matrix.
  139362. */
  139363. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139364. protected _buildUniformLayout(): void;
  139365. /**
  139366. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  139367. * @param effect The effect to update
  139368. * @param lightIndex The index of the light in the effect to update
  139369. * @returns The directional light
  139370. */
  139371. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  139372. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  139373. /**
  139374. * Gets the minZ used for shadow according to both the scene and the light.
  139375. *
  139376. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  139377. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  139378. * @param activeCamera The camera we are returning the min for
  139379. * @returns the depth min z
  139380. */
  139381. getDepthMinZ(activeCamera: Camera): number;
  139382. /**
  139383. * Gets the maxZ used for shadow according to both the scene and the light.
  139384. *
  139385. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  139386. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  139387. * @param activeCamera The camera we are returning the max for
  139388. * @returns the depth max z
  139389. */
  139390. getDepthMaxZ(activeCamera: Camera): number;
  139391. /**
  139392. * Prepares the list of defines specific to the light type.
  139393. * @param defines the list of defines
  139394. * @param lightIndex defines the index of the light for the effect
  139395. */
  139396. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139397. }
  139398. }
  139399. declare module BABYLON {
  139400. /**
  139401. * Class containing static functions to help procedurally build meshes
  139402. */
  139403. export class HemisphereBuilder {
  139404. /**
  139405. * Creates a hemisphere mesh
  139406. * @param name defines the name of the mesh
  139407. * @param options defines the options used to create the mesh
  139408. * @param scene defines the hosting scene
  139409. * @returns the hemisphere mesh
  139410. */
  139411. static CreateHemisphere(name: string, options: {
  139412. segments?: number;
  139413. diameter?: number;
  139414. sideOrientation?: number;
  139415. }, scene: any): Mesh;
  139416. }
  139417. }
  139418. declare module BABYLON {
  139419. /**
  139420. * A spot light is defined by a position, a direction, an angle, and an exponent.
  139421. * These values define a cone of light starting from the position, emitting toward the direction.
  139422. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  139423. * and the exponent defines the speed of the decay of the light with distance (reach).
  139424. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139425. */
  139426. export class SpotLight extends ShadowLight {
  139427. private _angle;
  139428. private _innerAngle;
  139429. private _cosHalfAngle;
  139430. private _lightAngleScale;
  139431. private _lightAngleOffset;
  139432. /**
  139433. * Gets the cone angle of the spot light in Radians.
  139434. */
  139435. get angle(): number;
  139436. /**
  139437. * Sets the cone angle of the spot light in Radians.
  139438. */
  139439. set angle(value: number);
  139440. /**
  139441. * Only used in gltf falloff mode, this defines the angle where
  139442. * the directional falloff will start before cutting at angle which could be seen
  139443. * as outer angle.
  139444. */
  139445. get innerAngle(): number;
  139446. /**
  139447. * Only used in gltf falloff mode, this defines the angle where
  139448. * the directional falloff will start before cutting at angle which could be seen
  139449. * as outer angle.
  139450. */
  139451. set innerAngle(value: number);
  139452. private _shadowAngleScale;
  139453. /**
  139454. * Allows scaling the angle of the light for shadow generation only.
  139455. */
  139456. get shadowAngleScale(): number;
  139457. /**
  139458. * Allows scaling the angle of the light for shadow generation only.
  139459. */
  139460. set shadowAngleScale(value: number);
  139461. /**
  139462. * The light decay speed with the distance from the emission spot.
  139463. */
  139464. exponent: number;
  139465. private _projectionTextureMatrix;
  139466. /**
  139467. * Allows reading the projecton texture
  139468. */
  139469. get projectionTextureMatrix(): Matrix;
  139470. protected _projectionTextureLightNear: number;
  139471. /**
  139472. * Gets the near clip of the Spotlight for texture projection.
  139473. */
  139474. get projectionTextureLightNear(): number;
  139475. /**
  139476. * Sets the near clip of the Spotlight for texture projection.
  139477. */
  139478. set projectionTextureLightNear(value: number);
  139479. protected _projectionTextureLightFar: number;
  139480. /**
  139481. * Gets the far clip of the Spotlight for texture projection.
  139482. */
  139483. get projectionTextureLightFar(): number;
  139484. /**
  139485. * Sets the far clip of the Spotlight for texture projection.
  139486. */
  139487. set projectionTextureLightFar(value: number);
  139488. protected _projectionTextureUpDirection: Vector3;
  139489. /**
  139490. * Gets the Up vector of the Spotlight for texture projection.
  139491. */
  139492. get projectionTextureUpDirection(): Vector3;
  139493. /**
  139494. * Sets the Up vector of the Spotlight for texture projection.
  139495. */
  139496. set projectionTextureUpDirection(value: Vector3);
  139497. private _projectionTexture;
  139498. /**
  139499. * Gets the projection texture of the light.
  139500. */
  139501. get projectionTexture(): Nullable<BaseTexture>;
  139502. /**
  139503. * Sets the projection texture of the light.
  139504. */
  139505. set projectionTexture(value: Nullable<BaseTexture>);
  139506. private static _IsProceduralTexture;
  139507. private static _IsTexture;
  139508. private _projectionTextureViewLightDirty;
  139509. private _projectionTextureProjectionLightDirty;
  139510. private _projectionTextureDirty;
  139511. private _projectionTextureViewTargetVector;
  139512. private _projectionTextureViewLightMatrix;
  139513. private _projectionTextureProjectionLightMatrix;
  139514. private _projectionTextureScalingMatrix;
  139515. /**
  139516. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  139517. * It can cast shadows.
  139518. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139519. * @param name The light friendly name
  139520. * @param position The position of the spot light in the scene
  139521. * @param direction The direction of the light in the scene
  139522. * @param angle The cone angle of the light in Radians
  139523. * @param exponent The light decay speed with the distance from the emission spot
  139524. * @param scene The scene the lights belongs to
  139525. */
  139526. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  139527. /**
  139528. * Returns the string "SpotLight".
  139529. * @returns the class name
  139530. */
  139531. getClassName(): string;
  139532. /**
  139533. * Returns the integer 2.
  139534. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139535. */
  139536. getTypeID(): number;
  139537. /**
  139538. * Overrides the direction setter to recompute the projection texture view light Matrix.
  139539. */
  139540. protected _setDirection(value: Vector3): void;
  139541. /**
  139542. * Overrides the position setter to recompute the projection texture view light Matrix.
  139543. */
  139544. protected _setPosition(value: Vector3): void;
  139545. /**
  139546. * 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.
  139547. * Returns the SpotLight.
  139548. */
  139549. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139550. protected _computeProjectionTextureViewLightMatrix(): void;
  139551. protected _computeProjectionTextureProjectionLightMatrix(): void;
  139552. /**
  139553. * Main function for light texture projection matrix computing.
  139554. */
  139555. protected _computeProjectionTextureMatrix(): void;
  139556. protected _buildUniformLayout(): void;
  139557. private _computeAngleValues;
  139558. /**
  139559. * Sets the passed Effect "effect" with the Light textures.
  139560. * @param effect The effect to update
  139561. * @param lightIndex The index of the light in the effect to update
  139562. * @returns The light
  139563. */
  139564. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  139565. /**
  139566. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  139567. * @param effect The effect to update
  139568. * @param lightIndex The index of the light in the effect to update
  139569. * @returns The spot light
  139570. */
  139571. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  139572. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  139573. /**
  139574. * Disposes the light and the associated resources.
  139575. */
  139576. dispose(): void;
  139577. /**
  139578. * Prepares the list of defines specific to the light type.
  139579. * @param defines the list of defines
  139580. * @param lightIndex defines the index of the light for the effect
  139581. */
  139582. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139583. }
  139584. }
  139585. declare module BABYLON {
  139586. /**
  139587. * Gizmo that enables viewing a light
  139588. */
  139589. export class LightGizmo extends Gizmo {
  139590. private _lightMesh;
  139591. private _material;
  139592. private _cachedPosition;
  139593. private _cachedForward;
  139594. private _attachedMeshParent;
  139595. private _pointerObserver;
  139596. /**
  139597. * Event that fires each time the gizmo is clicked
  139598. */
  139599. onClickedObservable: Observable<Light>;
  139600. /**
  139601. * Creates a LightGizmo
  139602. * @param gizmoLayer The utility layer the gizmo will be added to
  139603. */
  139604. constructor(gizmoLayer?: UtilityLayerRenderer);
  139605. private _light;
  139606. /**
  139607. * The light that the gizmo is attached to
  139608. */
  139609. set light(light: Nullable<Light>);
  139610. get light(): Nullable<Light>;
  139611. /**
  139612. * Gets the material used to render the light gizmo
  139613. */
  139614. get material(): StandardMaterial;
  139615. /**
  139616. * @hidden
  139617. * Updates the gizmo to match the attached mesh's position/rotation
  139618. */
  139619. protected _update(): void;
  139620. private static _Scale;
  139621. /**
  139622. * Creates the lines for a light mesh
  139623. */
  139624. private static _CreateLightLines;
  139625. /**
  139626. * Disposes of the light gizmo
  139627. */
  139628. dispose(): void;
  139629. private static _CreateHemisphericLightMesh;
  139630. private static _CreatePointLightMesh;
  139631. private static _CreateSpotLightMesh;
  139632. private static _CreateDirectionalLightMesh;
  139633. }
  139634. }
  139635. declare module BABYLON {
  139636. /**
  139637. * Gizmo that enables viewing a camera
  139638. */
  139639. export class CameraGizmo extends Gizmo {
  139640. private _cameraMesh;
  139641. private _cameraLinesMesh;
  139642. private _material;
  139643. private _pointerObserver;
  139644. /**
  139645. * Event that fires each time the gizmo is clicked
  139646. */
  139647. onClickedObservable: Observable<Camera>;
  139648. /**
  139649. * Creates a CameraGizmo
  139650. * @param gizmoLayer The utility layer the gizmo will be added to
  139651. */
  139652. constructor(gizmoLayer?: UtilityLayerRenderer);
  139653. private _camera;
  139654. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  139655. get displayFrustum(): boolean;
  139656. set displayFrustum(value: boolean);
  139657. /**
  139658. * The camera that the gizmo is attached to
  139659. */
  139660. set camera(camera: Nullable<Camera>);
  139661. get camera(): Nullable<Camera>;
  139662. /**
  139663. * Gets the material used to render the camera gizmo
  139664. */
  139665. get material(): StandardMaterial;
  139666. /**
  139667. * @hidden
  139668. * Updates the gizmo to match the attached mesh's position/rotation
  139669. */
  139670. protected _update(): void;
  139671. private static _Scale;
  139672. private _invProjection;
  139673. /**
  139674. * Disposes of the camera gizmo
  139675. */
  139676. dispose(): void;
  139677. private static _CreateCameraMesh;
  139678. private static _CreateCameraFrustum;
  139679. }
  139680. }
  139681. declare module BABYLON {
  139682. /** @hidden */
  139683. export var backgroundFragmentDeclaration: {
  139684. name: string;
  139685. shader: string;
  139686. };
  139687. }
  139688. declare module BABYLON {
  139689. /** @hidden */
  139690. export var backgroundUboDeclaration: {
  139691. name: string;
  139692. shader: string;
  139693. };
  139694. }
  139695. declare module BABYLON {
  139696. /** @hidden */
  139697. export var backgroundPixelShader: {
  139698. name: string;
  139699. shader: string;
  139700. };
  139701. }
  139702. declare module BABYLON {
  139703. /** @hidden */
  139704. export var backgroundVertexDeclaration: {
  139705. name: string;
  139706. shader: string;
  139707. };
  139708. }
  139709. declare module BABYLON {
  139710. /** @hidden */
  139711. export var backgroundVertexShader: {
  139712. name: string;
  139713. shader: string;
  139714. };
  139715. }
  139716. declare module BABYLON {
  139717. /**
  139718. * Background material used to create an efficient environement around your scene.
  139719. */
  139720. export class BackgroundMaterial extends PushMaterial {
  139721. /**
  139722. * Standard reflectance value at parallel view angle.
  139723. */
  139724. static StandardReflectance0: number;
  139725. /**
  139726. * Standard reflectance value at grazing angle.
  139727. */
  139728. static StandardReflectance90: number;
  139729. protected _primaryColor: Color3;
  139730. /**
  139731. * Key light Color (multiply against the environement texture)
  139732. */
  139733. primaryColor: Color3;
  139734. protected __perceptualColor: Nullable<Color3>;
  139735. /**
  139736. * Experimental Internal Use Only.
  139737. *
  139738. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  139739. * This acts as a helper to set the primary color to a more "human friendly" value.
  139740. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  139741. * output color as close as possible from the chosen value.
  139742. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  139743. * part of lighting setup.)
  139744. */
  139745. get _perceptualColor(): Nullable<Color3>;
  139746. set _perceptualColor(value: Nullable<Color3>);
  139747. protected _primaryColorShadowLevel: float;
  139748. /**
  139749. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  139750. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  139751. */
  139752. get primaryColorShadowLevel(): float;
  139753. set primaryColorShadowLevel(value: float);
  139754. protected _primaryColorHighlightLevel: float;
  139755. /**
  139756. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  139757. * The primary color is used at the level chosen to define what the white area would look.
  139758. */
  139759. get primaryColorHighlightLevel(): float;
  139760. set primaryColorHighlightLevel(value: float);
  139761. protected _reflectionTexture: Nullable<BaseTexture>;
  139762. /**
  139763. * Reflection Texture used in the material.
  139764. * Should be author in a specific way for the best result (refer to the documentation).
  139765. */
  139766. reflectionTexture: Nullable<BaseTexture>;
  139767. protected _reflectionBlur: float;
  139768. /**
  139769. * Reflection Texture level of blur.
  139770. *
  139771. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  139772. * texture twice.
  139773. */
  139774. reflectionBlur: float;
  139775. protected _diffuseTexture: Nullable<BaseTexture>;
  139776. /**
  139777. * Diffuse Texture used in the material.
  139778. * Should be author in a specific way for the best result (refer to the documentation).
  139779. */
  139780. diffuseTexture: Nullable<BaseTexture>;
  139781. protected _shadowLights: Nullable<IShadowLight[]>;
  139782. /**
  139783. * Specify the list of lights casting shadow on the material.
  139784. * All scene shadow lights will be included if null.
  139785. */
  139786. shadowLights: Nullable<IShadowLight[]>;
  139787. protected _shadowLevel: float;
  139788. /**
  139789. * Helps adjusting the shadow to a softer level if required.
  139790. * 0 means black shadows and 1 means no shadows.
  139791. */
  139792. shadowLevel: float;
  139793. protected _sceneCenter: Vector3;
  139794. /**
  139795. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  139796. * It is usually zero but might be interesting to modify according to your setup.
  139797. */
  139798. sceneCenter: Vector3;
  139799. protected _opacityFresnel: boolean;
  139800. /**
  139801. * This helps specifying that the material is falling off to the sky box at grazing angle.
  139802. * This helps ensuring a nice transition when the camera goes under the ground.
  139803. */
  139804. opacityFresnel: boolean;
  139805. protected _reflectionFresnel: boolean;
  139806. /**
  139807. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  139808. * This helps adding a mirror texture on the ground.
  139809. */
  139810. reflectionFresnel: boolean;
  139811. protected _reflectionFalloffDistance: number;
  139812. /**
  139813. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  139814. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  139815. */
  139816. reflectionFalloffDistance: number;
  139817. protected _reflectionAmount: number;
  139818. /**
  139819. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  139820. */
  139821. reflectionAmount: number;
  139822. protected _reflectionReflectance0: number;
  139823. /**
  139824. * This specifies the weight of the reflection at grazing angle.
  139825. */
  139826. reflectionReflectance0: number;
  139827. protected _reflectionReflectance90: number;
  139828. /**
  139829. * This specifies the weight of the reflection at a perpendicular point of view.
  139830. */
  139831. reflectionReflectance90: number;
  139832. /**
  139833. * Sets the reflection reflectance fresnel values according to the default standard
  139834. * empirically know to work well :-)
  139835. */
  139836. set reflectionStandardFresnelWeight(value: number);
  139837. protected _useRGBColor: boolean;
  139838. /**
  139839. * Helps to directly use the maps channels instead of their level.
  139840. */
  139841. useRGBColor: boolean;
  139842. protected _enableNoise: boolean;
  139843. /**
  139844. * This helps reducing the banding effect that could occur on the background.
  139845. */
  139846. enableNoise: boolean;
  139847. /**
  139848. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  139849. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  139850. * Recommended to be keep at 1.0 except for special cases.
  139851. */
  139852. get fovMultiplier(): number;
  139853. set fovMultiplier(value: number);
  139854. private _fovMultiplier;
  139855. /**
  139856. * Enable the FOV adjustment feature controlled by fovMultiplier.
  139857. */
  139858. useEquirectangularFOV: boolean;
  139859. private _maxSimultaneousLights;
  139860. /**
  139861. * Number of Simultaneous lights allowed on the material.
  139862. */
  139863. maxSimultaneousLights: int;
  139864. private _shadowOnly;
  139865. /**
  139866. * Make the material only render shadows
  139867. */
  139868. shadowOnly: boolean;
  139869. /**
  139870. * Default configuration related to image processing available in the Background Material.
  139871. */
  139872. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  139873. /**
  139874. * Keep track of the image processing observer to allow dispose and replace.
  139875. */
  139876. private _imageProcessingObserver;
  139877. /**
  139878. * Attaches a new image processing configuration to the PBR Material.
  139879. * @param configuration (if null the scene configuration will be use)
  139880. */
  139881. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  139882. /**
  139883. * Gets the image processing configuration used either in this material.
  139884. */
  139885. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  139886. /**
  139887. * Sets the Default image processing configuration used either in the this material.
  139888. *
  139889. * If sets to null, the scene one is in use.
  139890. */
  139891. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  139892. /**
  139893. * Gets wether the color curves effect is enabled.
  139894. */
  139895. get cameraColorCurvesEnabled(): boolean;
  139896. /**
  139897. * Sets wether the color curves effect is enabled.
  139898. */
  139899. set cameraColorCurvesEnabled(value: boolean);
  139900. /**
  139901. * Gets wether the color grading effect is enabled.
  139902. */
  139903. get cameraColorGradingEnabled(): boolean;
  139904. /**
  139905. * Gets wether the color grading effect is enabled.
  139906. */
  139907. set cameraColorGradingEnabled(value: boolean);
  139908. /**
  139909. * Gets wether tonemapping is enabled or not.
  139910. */
  139911. get cameraToneMappingEnabled(): boolean;
  139912. /**
  139913. * Sets wether tonemapping is enabled or not
  139914. */
  139915. set cameraToneMappingEnabled(value: boolean);
  139916. /**
  139917. * The camera exposure used on this material.
  139918. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  139919. * This corresponds to a photographic exposure.
  139920. */
  139921. get cameraExposure(): float;
  139922. /**
  139923. * The camera exposure used on this material.
  139924. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  139925. * This corresponds to a photographic exposure.
  139926. */
  139927. set cameraExposure(value: float);
  139928. /**
  139929. * Gets The camera contrast used on this material.
  139930. */
  139931. get cameraContrast(): float;
  139932. /**
  139933. * Sets The camera contrast used on this material.
  139934. */
  139935. set cameraContrast(value: float);
  139936. /**
  139937. * Gets the Color Grading 2D Lookup Texture.
  139938. */
  139939. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  139940. /**
  139941. * Sets the Color Grading 2D Lookup Texture.
  139942. */
  139943. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  139944. /**
  139945. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  139946. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  139947. * 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;
  139948. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  139949. */
  139950. get cameraColorCurves(): Nullable<ColorCurves>;
  139951. /**
  139952. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  139953. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  139954. * 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;
  139955. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  139956. */
  139957. set cameraColorCurves(value: Nullable<ColorCurves>);
  139958. /**
  139959. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  139960. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  139961. */
  139962. switchToBGR: boolean;
  139963. private _renderTargets;
  139964. private _reflectionControls;
  139965. private _white;
  139966. private _primaryShadowColor;
  139967. private _primaryHighlightColor;
  139968. /**
  139969. * Instantiates a Background Material in the given scene
  139970. * @param name The friendly name of the material
  139971. * @param scene The scene to add the material to
  139972. */
  139973. constructor(name: string, scene: Scene);
  139974. /**
  139975. * Gets a boolean indicating that current material needs to register RTT
  139976. */
  139977. get hasRenderTargetTextures(): boolean;
  139978. /**
  139979. * The entire material has been created in order to prevent overdraw.
  139980. * @returns false
  139981. */
  139982. needAlphaTesting(): boolean;
  139983. /**
  139984. * The entire material has been created in order to prevent overdraw.
  139985. * @returns true if blending is enable
  139986. */
  139987. needAlphaBlending(): boolean;
  139988. /**
  139989. * Checks wether the material is ready to be rendered for a given mesh.
  139990. * @param mesh The mesh to render
  139991. * @param subMesh The submesh to check against
  139992. * @param useInstances Specify wether or not the material is used with instances
  139993. * @returns true if all the dependencies are ready (Textures, Effects...)
  139994. */
  139995. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  139996. /**
  139997. * Compute the primary color according to the chosen perceptual color.
  139998. */
  139999. private _computePrimaryColorFromPerceptualColor;
  140000. /**
  140001. * Compute the highlights and shadow colors according to their chosen levels.
  140002. */
  140003. private _computePrimaryColors;
  140004. /**
  140005. * Build the uniform buffer used in the material.
  140006. */
  140007. buildUniformLayout(): void;
  140008. /**
  140009. * Unbind the material.
  140010. */
  140011. unbind(): void;
  140012. /**
  140013. * Bind only the world matrix to the material.
  140014. * @param world The world matrix to bind.
  140015. */
  140016. bindOnlyWorldMatrix(world: Matrix): void;
  140017. /**
  140018. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  140019. * @param world The world matrix to bind.
  140020. * @param subMesh The submesh to bind for.
  140021. */
  140022. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  140023. /**
  140024. * Checks to see if a texture is used in the material.
  140025. * @param texture - Base texture to use.
  140026. * @returns - Boolean specifying if a texture is used in the material.
  140027. */
  140028. hasTexture(texture: BaseTexture): boolean;
  140029. /**
  140030. * Dispose the material.
  140031. * @param forceDisposeEffect Force disposal of the associated effect.
  140032. * @param forceDisposeTextures Force disposal of the associated textures.
  140033. */
  140034. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  140035. /**
  140036. * Clones the material.
  140037. * @param name The cloned name.
  140038. * @returns The cloned material.
  140039. */
  140040. clone(name: string): BackgroundMaterial;
  140041. /**
  140042. * Serializes the current material to its JSON representation.
  140043. * @returns The JSON representation.
  140044. */
  140045. serialize(): any;
  140046. /**
  140047. * Gets the class name of the material
  140048. * @returns "BackgroundMaterial"
  140049. */
  140050. getClassName(): string;
  140051. /**
  140052. * Parse a JSON input to create back a background material.
  140053. * @param source The JSON data to parse
  140054. * @param scene The scene to create the parsed material in
  140055. * @param rootUrl The root url of the assets the material depends upon
  140056. * @returns the instantiated BackgroundMaterial.
  140057. */
  140058. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  140059. }
  140060. }
  140061. declare module BABYLON {
  140062. /**
  140063. * Represents the different options available during the creation of
  140064. * a Environment helper.
  140065. *
  140066. * This can control the default ground, skybox and image processing setup of your scene.
  140067. */
  140068. export interface IEnvironmentHelperOptions {
  140069. /**
  140070. * Specifies whether or not to create a ground.
  140071. * True by default.
  140072. */
  140073. createGround: boolean;
  140074. /**
  140075. * Specifies the ground size.
  140076. * 15 by default.
  140077. */
  140078. groundSize: number;
  140079. /**
  140080. * The texture used on the ground for the main color.
  140081. * Comes from the BabylonJS CDN by default.
  140082. *
  140083. * Remarks: Can be either a texture or a url.
  140084. */
  140085. groundTexture: string | BaseTexture;
  140086. /**
  140087. * The color mixed in the ground texture by default.
  140088. * BabylonJS clearColor by default.
  140089. */
  140090. groundColor: Color3;
  140091. /**
  140092. * Specifies the ground opacity.
  140093. * 1 by default.
  140094. */
  140095. groundOpacity: number;
  140096. /**
  140097. * Enables the ground to receive shadows.
  140098. * True by default.
  140099. */
  140100. enableGroundShadow: boolean;
  140101. /**
  140102. * Helps preventing the shadow to be fully black on the ground.
  140103. * 0.5 by default.
  140104. */
  140105. groundShadowLevel: number;
  140106. /**
  140107. * Creates a mirror texture attach to the ground.
  140108. * false by default.
  140109. */
  140110. enableGroundMirror: boolean;
  140111. /**
  140112. * Specifies the ground mirror size ratio.
  140113. * 0.3 by default as the default kernel is 64.
  140114. */
  140115. groundMirrorSizeRatio: number;
  140116. /**
  140117. * Specifies the ground mirror blur kernel size.
  140118. * 64 by default.
  140119. */
  140120. groundMirrorBlurKernel: number;
  140121. /**
  140122. * Specifies the ground mirror visibility amount.
  140123. * 1 by default
  140124. */
  140125. groundMirrorAmount: number;
  140126. /**
  140127. * Specifies the ground mirror reflectance weight.
  140128. * This uses the standard weight of the background material to setup the fresnel effect
  140129. * of the mirror.
  140130. * 1 by default.
  140131. */
  140132. groundMirrorFresnelWeight: number;
  140133. /**
  140134. * Specifies the ground mirror Falloff distance.
  140135. * This can helps reducing the size of the reflection.
  140136. * 0 by Default.
  140137. */
  140138. groundMirrorFallOffDistance: number;
  140139. /**
  140140. * Specifies the ground mirror texture type.
  140141. * Unsigned Int by Default.
  140142. */
  140143. groundMirrorTextureType: number;
  140144. /**
  140145. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  140146. * the shown objects.
  140147. */
  140148. groundYBias: number;
  140149. /**
  140150. * Specifies whether or not to create a skybox.
  140151. * True by default.
  140152. */
  140153. createSkybox: boolean;
  140154. /**
  140155. * Specifies the skybox size.
  140156. * 20 by default.
  140157. */
  140158. skyboxSize: number;
  140159. /**
  140160. * The texture used on the skybox for the main color.
  140161. * Comes from the BabylonJS CDN by default.
  140162. *
  140163. * Remarks: Can be either a texture or a url.
  140164. */
  140165. skyboxTexture: string | BaseTexture;
  140166. /**
  140167. * The color mixed in the skybox texture by default.
  140168. * BabylonJS clearColor by default.
  140169. */
  140170. skyboxColor: Color3;
  140171. /**
  140172. * The background rotation around the Y axis of the scene.
  140173. * This helps aligning the key lights of your scene with the background.
  140174. * 0 by default.
  140175. */
  140176. backgroundYRotation: number;
  140177. /**
  140178. * Compute automatically the size of the elements to best fit with the scene.
  140179. */
  140180. sizeAuto: boolean;
  140181. /**
  140182. * Default position of the rootMesh if autoSize is not true.
  140183. */
  140184. rootPosition: Vector3;
  140185. /**
  140186. * Sets up the image processing in the scene.
  140187. * true by default.
  140188. */
  140189. setupImageProcessing: boolean;
  140190. /**
  140191. * The texture used as your environment texture in the scene.
  140192. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  140193. *
  140194. * Remarks: Can be either a texture or a url.
  140195. */
  140196. environmentTexture: string | BaseTexture;
  140197. /**
  140198. * The value of the exposure to apply to the scene.
  140199. * 0.6 by default if setupImageProcessing is true.
  140200. */
  140201. cameraExposure: number;
  140202. /**
  140203. * The value of the contrast to apply to the scene.
  140204. * 1.6 by default if setupImageProcessing is true.
  140205. */
  140206. cameraContrast: number;
  140207. /**
  140208. * Specifies whether or not tonemapping should be enabled in the scene.
  140209. * true by default if setupImageProcessing is true.
  140210. */
  140211. toneMappingEnabled: boolean;
  140212. }
  140213. /**
  140214. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  140215. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  140216. * It also helps with the default setup of your imageProcessing configuration.
  140217. */
  140218. export class EnvironmentHelper {
  140219. /**
  140220. * Default ground texture URL.
  140221. */
  140222. private static _groundTextureCDNUrl;
  140223. /**
  140224. * Default skybox texture URL.
  140225. */
  140226. private static _skyboxTextureCDNUrl;
  140227. /**
  140228. * Default environment texture URL.
  140229. */
  140230. private static _environmentTextureCDNUrl;
  140231. /**
  140232. * Creates the default options for the helper.
  140233. */
  140234. private static _getDefaultOptions;
  140235. private _rootMesh;
  140236. /**
  140237. * Gets the root mesh created by the helper.
  140238. */
  140239. get rootMesh(): Mesh;
  140240. private _skybox;
  140241. /**
  140242. * Gets the skybox created by the helper.
  140243. */
  140244. get skybox(): Nullable<Mesh>;
  140245. private _skyboxTexture;
  140246. /**
  140247. * Gets the skybox texture created by the helper.
  140248. */
  140249. get skyboxTexture(): Nullable<BaseTexture>;
  140250. private _skyboxMaterial;
  140251. /**
  140252. * Gets the skybox material created by the helper.
  140253. */
  140254. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  140255. private _ground;
  140256. /**
  140257. * Gets the ground mesh created by the helper.
  140258. */
  140259. get ground(): Nullable<Mesh>;
  140260. private _groundTexture;
  140261. /**
  140262. * Gets the ground texture created by the helper.
  140263. */
  140264. get groundTexture(): Nullable<BaseTexture>;
  140265. private _groundMirror;
  140266. /**
  140267. * Gets the ground mirror created by the helper.
  140268. */
  140269. get groundMirror(): Nullable<MirrorTexture>;
  140270. /**
  140271. * Gets the ground mirror render list to helps pushing the meshes
  140272. * you wish in the ground reflection.
  140273. */
  140274. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  140275. private _groundMaterial;
  140276. /**
  140277. * Gets the ground material created by the helper.
  140278. */
  140279. get groundMaterial(): Nullable<BackgroundMaterial>;
  140280. /**
  140281. * Stores the creation options.
  140282. */
  140283. private readonly _scene;
  140284. private _options;
  140285. /**
  140286. * This observable will be notified with any error during the creation of the environment,
  140287. * mainly texture creation errors.
  140288. */
  140289. onErrorObservable: Observable<{
  140290. message?: string;
  140291. exception?: any;
  140292. }>;
  140293. /**
  140294. * constructor
  140295. * @param options Defines the options we want to customize the helper
  140296. * @param scene The scene to add the material to
  140297. */
  140298. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  140299. /**
  140300. * Updates the background according to the new options
  140301. * @param options
  140302. */
  140303. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  140304. /**
  140305. * Sets the primary color of all the available elements.
  140306. * @param color the main color to affect to the ground and the background
  140307. */
  140308. setMainColor(color: Color3): void;
  140309. /**
  140310. * Setup the image processing according to the specified options.
  140311. */
  140312. private _setupImageProcessing;
  140313. /**
  140314. * Setup the environment texture according to the specified options.
  140315. */
  140316. private _setupEnvironmentTexture;
  140317. /**
  140318. * Setup the background according to the specified options.
  140319. */
  140320. private _setupBackground;
  140321. /**
  140322. * Get the scene sizes according to the setup.
  140323. */
  140324. private _getSceneSize;
  140325. /**
  140326. * Setup the ground according to the specified options.
  140327. */
  140328. private _setupGround;
  140329. /**
  140330. * Setup the ground material according to the specified options.
  140331. */
  140332. private _setupGroundMaterial;
  140333. /**
  140334. * Setup the ground diffuse texture according to the specified options.
  140335. */
  140336. private _setupGroundDiffuseTexture;
  140337. /**
  140338. * Setup the ground mirror texture according to the specified options.
  140339. */
  140340. private _setupGroundMirrorTexture;
  140341. /**
  140342. * Setup the ground to receive the mirror texture.
  140343. */
  140344. private _setupMirrorInGroundMaterial;
  140345. /**
  140346. * Setup the skybox according to the specified options.
  140347. */
  140348. private _setupSkybox;
  140349. /**
  140350. * Setup the skybox material according to the specified options.
  140351. */
  140352. private _setupSkyboxMaterial;
  140353. /**
  140354. * Setup the skybox reflection texture according to the specified options.
  140355. */
  140356. private _setupSkyboxReflectionTexture;
  140357. private _errorHandler;
  140358. /**
  140359. * Dispose all the elements created by the Helper.
  140360. */
  140361. dispose(): void;
  140362. }
  140363. }
  140364. declare module BABYLON {
  140365. /**
  140366. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  140367. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  140368. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  140369. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140370. */
  140371. export abstract class TextureDome<T extends Texture> extends TransformNode {
  140372. protected onError: Nullable<(message?: string, exception?: any) => void>;
  140373. /**
  140374. * Define the source as a Monoscopic panoramic 360/180.
  140375. */
  140376. static readonly MODE_MONOSCOPIC: number;
  140377. /**
  140378. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  140379. */
  140380. static readonly MODE_TOPBOTTOM: number;
  140381. /**
  140382. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  140383. */
  140384. static readonly MODE_SIDEBYSIDE: number;
  140385. private _halfDome;
  140386. private _crossEye;
  140387. protected _useDirectMapping: boolean;
  140388. /**
  140389. * The texture being displayed on the sphere
  140390. */
  140391. protected _texture: T;
  140392. /**
  140393. * Gets the texture being displayed on the sphere
  140394. */
  140395. get texture(): T;
  140396. /**
  140397. * Sets the texture being displayed on the sphere
  140398. */
  140399. set texture(newTexture: T);
  140400. /**
  140401. * The skybox material
  140402. */
  140403. protected _material: BackgroundMaterial;
  140404. /**
  140405. * The surface used for the dome
  140406. */
  140407. protected _mesh: Mesh;
  140408. /**
  140409. * Gets the mesh used for the dome.
  140410. */
  140411. get mesh(): Mesh;
  140412. /**
  140413. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  140414. */
  140415. private _halfDomeMask;
  140416. /**
  140417. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  140418. * Also see the options.resolution property.
  140419. */
  140420. get fovMultiplier(): number;
  140421. set fovMultiplier(value: number);
  140422. protected _textureMode: number;
  140423. /**
  140424. * Gets or set the current texture mode for the texture. It can be:
  140425. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140426. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140427. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140428. */
  140429. get textureMode(): number;
  140430. /**
  140431. * Sets the current texture mode for the texture. It can be:
  140432. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140433. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140434. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140435. */
  140436. set textureMode(value: number);
  140437. /**
  140438. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  140439. */
  140440. get halfDome(): boolean;
  140441. /**
  140442. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  140443. */
  140444. set halfDome(enabled: boolean);
  140445. /**
  140446. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  140447. */
  140448. set crossEye(enabled: boolean);
  140449. /**
  140450. * Is it a cross-eye texture?
  140451. */
  140452. get crossEye(): boolean;
  140453. /**
  140454. * The background material of this dome.
  140455. */
  140456. get material(): BackgroundMaterial;
  140457. /**
  140458. * Oberserver used in Stereoscopic VR Mode.
  140459. */
  140460. private _onBeforeCameraRenderObserver;
  140461. /**
  140462. * Observable raised when an error occured while loading the 360 image
  140463. */
  140464. onLoadErrorObservable: Observable<string>;
  140465. /**
  140466. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  140467. * @param name Element's name, child elements will append suffixes for their own names.
  140468. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  140469. * @param options An object containing optional or exposed sub element properties
  140470. */
  140471. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  140472. resolution?: number;
  140473. clickToPlay?: boolean;
  140474. autoPlay?: boolean;
  140475. loop?: boolean;
  140476. size?: number;
  140477. poster?: string;
  140478. faceForward?: boolean;
  140479. useDirectMapping?: boolean;
  140480. halfDomeMode?: boolean;
  140481. crossEyeMode?: boolean;
  140482. generateMipMaps?: boolean;
  140483. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  140484. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  140485. protected _changeTextureMode(value: number): void;
  140486. /**
  140487. * Releases resources associated with this node.
  140488. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  140489. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  140490. */
  140491. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  140492. }
  140493. }
  140494. declare module BABYLON {
  140495. /**
  140496. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  140497. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  140498. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  140499. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140500. */
  140501. export class PhotoDome extends TextureDome<Texture> {
  140502. /**
  140503. * Define the image as a Monoscopic panoramic 360 image.
  140504. */
  140505. static readonly MODE_MONOSCOPIC: number;
  140506. /**
  140507. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  140508. */
  140509. static readonly MODE_TOPBOTTOM: number;
  140510. /**
  140511. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  140512. */
  140513. static readonly MODE_SIDEBYSIDE: number;
  140514. /**
  140515. * Gets or sets the texture being displayed on the sphere
  140516. */
  140517. get photoTexture(): Texture;
  140518. /**
  140519. * sets the texture being displayed on the sphere
  140520. */
  140521. set photoTexture(value: Texture);
  140522. /**
  140523. * Gets the current video mode for the video. It can be:
  140524. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140525. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140526. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140527. */
  140528. get imageMode(): number;
  140529. /**
  140530. * Sets the current video mode for the video. It can be:
  140531. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140532. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140533. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140534. */
  140535. set imageMode(value: number);
  140536. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  140537. }
  140538. }
  140539. declare module BABYLON {
  140540. /**
  140541. * Direct draw surface info
  140542. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  140543. */
  140544. export interface DDSInfo {
  140545. /**
  140546. * Width of the texture
  140547. */
  140548. width: number;
  140549. /**
  140550. * Width of the texture
  140551. */
  140552. height: number;
  140553. /**
  140554. * Number of Mipmaps for the texture
  140555. * @see https://en.wikipedia.org/wiki/Mipmap
  140556. */
  140557. mipmapCount: number;
  140558. /**
  140559. * If the textures format is a known fourCC format
  140560. * @see https://www.fourcc.org/
  140561. */
  140562. isFourCC: boolean;
  140563. /**
  140564. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  140565. */
  140566. isRGB: boolean;
  140567. /**
  140568. * If the texture is a lumincance format
  140569. */
  140570. isLuminance: boolean;
  140571. /**
  140572. * If this is a cube texture
  140573. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  140574. */
  140575. isCube: boolean;
  140576. /**
  140577. * If the texture is a compressed format eg. FOURCC_DXT1
  140578. */
  140579. isCompressed: boolean;
  140580. /**
  140581. * The dxgiFormat of the texture
  140582. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  140583. */
  140584. dxgiFormat: number;
  140585. /**
  140586. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  140587. */
  140588. textureType: number;
  140589. /**
  140590. * Sphericle polynomial created for the dds texture
  140591. */
  140592. sphericalPolynomial?: SphericalPolynomial;
  140593. }
  140594. /**
  140595. * Class used to provide DDS decompression tools
  140596. */
  140597. export class DDSTools {
  140598. /**
  140599. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  140600. */
  140601. static StoreLODInAlphaChannel: boolean;
  140602. /**
  140603. * Gets DDS information from an array buffer
  140604. * @param data defines the array buffer view to read data from
  140605. * @returns the DDS information
  140606. */
  140607. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  140608. private static _FloatView;
  140609. private static _Int32View;
  140610. private static _ToHalfFloat;
  140611. private static _FromHalfFloat;
  140612. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  140613. private static _GetHalfFloatRGBAArrayBuffer;
  140614. private static _GetFloatRGBAArrayBuffer;
  140615. private static _GetFloatAsUIntRGBAArrayBuffer;
  140616. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  140617. private static _GetRGBAArrayBuffer;
  140618. private static _ExtractLongWordOrder;
  140619. private static _GetRGBArrayBuffer;
  140620. private static _GetLuminanceArrayBuffer;
  140621. /**
  140622. * Uploads DDS Levels to a Babylon Texture
  140623. * @hidden
  140624. */
  140625. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  140626. }
  140627. interface ThinEngine {
  140628. /**
  140629. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  140630. * @param rootUrl defines the url where the file to load is located
  140631. * @param scene defines the current scene
  140632. * @param lodScale defines scale to apply to the mip map selection
  140633. * @param lodOffset defines offset to apply to the mip map selection
  140634. * @param onLoad defines an optional callback raised when the texture is loaded
  140635. * @param onError defines an optional callback raised if there is an issue to load the texture
  140636. * @param format defines the format of the data
  140637. * @param forcedExtension defines the extension to use to pick the right loader
  140638. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  140639. * @returns the cube texture as an InternalTexture
  140640. */
  140641. 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;
  140642. }
  140643. }
  140644. declare module BABYLON {
  140645. /**
  140646. * Implementation of the DDS Texture Loader.
  140647. * @hidden
  140648. */
  140649. export class _DDSTextureLoader implements IInternalTextureLoader {
  140650. /**
  140651. * Defines wether the loader supports cascade loading the different faces.
  140652. */
  140653. readonly supportCascades: boolean;
  140654. /**
  140655. * This returns if the loader support the current file information.
  140656. * @param extension defines the file extension of the file being loaded
  140657. * @returns true if the loader can load the specified file
  140658. */
  140659. canLoad(extension: string): boolean;
  140660. /**
  140661. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140662. * @param data contains the texture data
  140663. * @param texture defines the BabylonJS internal texture
  140664. * @param createPolynomials will be true if polynomials have been requested
  140665. * @param onLoad defines the callback to trigger once the texture is ready
  140666. * @param onError defines the callback to trigger in case of error
  140667. */
  140668. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140669. /**
  140670. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140671. * @param data contains the texture data
  140672. * @param texture defines the BabylonJS internal texture
  140673. * @param callback defines the method to call once ready to upload
  140674. */
  140675. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140676. }
  140677. }
  140678. declare module BABYLON {
  140679. /**
  140680. * Implementation of the ENV Texture Loader.
  140681. * @hidden
  140682. */
  140683. export class _ENVTextureLoader implements IInternalTextureLoader {
  140684. /**
  140685. * Defines wether the loader supports cascade loading the different faces.
  140686. */
  140687. readonly supportCascades: boolean;
  140688. /**
  140689. * This returns if the loader support the current file information.
  140690. * @param extension defines the file extension of the file being loaded
  140691. * @returns true if the loader can load the specified file
  140692. */
  140693. canLoad(extension: string): boolean;
  140694. /**
  140695. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140696. * @param data contains the texture data
  140697. * @param texture defines the BabylonJS internal texture
  140698. * @param createPolynomials will be true if polynomials have been requested
  140699. * @param onLoad defines the callback to trigger once the texture is ready
  140700. * @param onError defines the callback to trigger in case of error
  140701. */
  140702. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140703. /**
  140704. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140705. * @param data contains the texture data
  140706. * @param texture defines the BabylonJS internal texture
  140707. * @param callback defines the method to call once ready to upload
  140708. */
  140709. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140710. }
  140711. }
  140712. declare module BABYLON {
  140713. /**
  140714. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  140715. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  140716. */
  140717. export class KhronosTextureContainer {
  140718. /** contents of the KTX container file */
  140719. data: ArrayBufferView;
  140720. private static HEADER_LEN;
  140721. private static COMPRESSED_2D;
  140722. private static COMPRESSED_3D;
  140723. private static TEX_2D;
  140724. private static TEX_3D;
  140725. /**
  140726. * Gets the openGL type
  140727. */
  140728. glType: number;
  140729. /**
  140730. * Gets the openGL type size
  140731. */
  140732. glTypeSize: number;
  140733. /**
  140734. * Gets the openGL format
  140735. */
  140736. glFormat: number;
  140737. /**
  140738. * Gets the openGL internal format
  140739. */
  140740. glInternalFormat: number;
  140741. /**
  140742. * Gets the base internal format
  140743. */
  140744. glBaseInternalFormat: number;
  140745. /**
  140746. * Gets image width in pixel
  140747. */
  140748. pixelWidth: number;
  140749. /**
  140750. * Gets image height in pixel
  140751. */
  140752. pixelHeight: number;
  140753. /**
  140754. * Gets image depth in pixels
  140755. */
  140756. pixelDepth: number;
  140757. /**
  140758. * Gets the number of array elements
  140759. */
  140760. numberOfArrayElements: number;
  140761. /**
  140762. * Gets the number of faces
  140763. */
  140764. numberOfFaces: number;
  140765. /**
  140766. * Gets the number of mipmap levels
  140767. */
  140768. numberOfMipmapLevels: number;
  140769. /**
  140770. * Gets the bytes of key value data
  140771. */
  140772. bytesOfKeyValueData: number;
  140773. /**
  140774. * Gets the load type
  140775. */
  140776. loadType: number;
  140777. /**
  140778. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  140779. */
  140780. isInvalid: boolean;
  140781. /**
  140782. * Creates a new KhronosTextureContainer
  140783. * @param data contents of the KTX container file
  140784. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  140785. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  140786. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  140787. */
  140788. constructor(
  140789. /** contents of the KTX container file */
  140790. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  140791. /**
  140792. * Uploads KTX content to a Babylon Texture.
  140793. * It is assumed that the texture has already been created & is currently bound
  140794. * @hidden
  140795. */
  140796. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  140797. private _upload2DCompressedLevels;
  140798. /**
  140799. * Checks if the given data starts with a KTX file identifier.
  140800. * @param data the data to check
  140801. * @returns true if the data is a KTX file or false otherwise
  140802. */
  140803. static IsValid(data: ArrayBufferView): boolean;
  140804. }
  140805. }
  140806. declare module BABYLON {
  140807. /**
  140808. * Helper class to push actions to a pool of workers.
  140809. */
  140810. export class WorkerPool implements IDisposable {
  140811. private _workerInfos;
  140812. private _pendingActions;
  140813. /**
  140814. * Constructor
  140815. * @param workers Array of workers to use for actions
  140816. */
  140817. constructor(workers: Array<Worker>);
  140818. /**
  140819. * Terminates all workers and clears any pending actions.
  140820. */
  140821. dispose(): void;
  140822. /**
  140823. * Pushes an action to the worker pool. If all the workers are active, the action will be
  140824. * pended until a worker has completed its action.
  140825. * @param action The action to perform. Call onComplete when the action is complete.
  140826. */
  140827. push(action: (worker: Worker, onComplete: () => void) => void): void;
  140828. private _execute;
  140829. }
  140830. }
  140831. declare module BABYLON {
  140832. /**
  140833. * Class for loading KTX2 files
  140834. */
  140835. export class KhronosTextureContainer2 {
  140836. private static _WorkerPoolPromise?;
  140837. private static _Initialized;
  140838. private static _Ktx2Decoder;
  140839. /**
  140840. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  140841. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  140842. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  140843. * Urls you can change:
  140844. * URLConfig.jsDecoderModule
  140845. * URLConfig.wasmUASTCToASTC
  140846. * URLConfig.wasmUASTCToBC7
  140847. * URLConfig.wasmUASTCToRGBA_UNORM
  140848. * URLConfig.wasmUASTCToRGBA_SRGB
  140849. * URLConfig.jsMSCTranscoder
  140850. * URLConfig.wasmMSCTranscoder
  140851. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  140852. */
  140853. static URLConfig: {
  140854. jsDecoderModule: string;
  140855. wasmUASTCToASTC: null;
  140856. wasmUASTCToBC7: null;
  140857. wasmUASTCToRGBA_UNORM: null;
  140858. wasmUASTCToRGBA_SRGB: null;
  140859. jsMSCTranscoder: null;
  140860. wasmMSCTranscoder: null;
  140861. };
  140862. /**
  140863. * Default number of workers used to handle data decoding
  140864. */
  140865. static DefaultNumWorkers: number;
  140866. private static GetDefaultNumWorkers;
  140867. private _engine;
  140868. private static _CreateWorkerPool;
  140869. /**
  140870. * Constructor
  140871. * @param engine The engine to use
  140872. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  140873. */
  140874. constructor(engine: ThinEngine, numWorkers?: number);
  140875. /** @hidden */
  140876. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  140877. /**
  140878. * Stop all async operations and release resources.
  140879. */
  140880. dispose(): void;
  140881. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  140882. /**
  140883. * Checks if the given data starts with a KTX2 file identifier.
  140884. * @param data the data to check
  140885. * @returns true if the data is a KTX2 file or false otherwise
  140886. */
  140887. static IsValid(data: ArrayBufferView): boolean;
  140888. }
  140889. }
  140890. declare module BABYLON {
  140891. /**
  140892. * Implementation of the KTX Texture Loader.
  140893. * @hidden
  140894. */
  140895. export class _KTXTextureLoader implements IInternalTextureLoader {
  140896. /**
  140897. * Defines wether the loader supports cascade loading the different faces.
  140898. */
  140899. readonly supportCascades: boolean;
  140900. /**
  140901. * This returns if the loader support the current file information.
  140902. * @param extension defines the file extension of the file being loaded
  140903. * @param mimeType defines the optional mime type of the file being loaded
  140904. * @returns true if the loader can load the specified file
  140905. */
  140906. canLoad(extension: string, mimeType?: string): boolean;
  140907. /**
  140908. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140909. * @param data contains the texture data
  140910. * @param texture defines the BabylonJS internal texture
  140911. * @param createPolynomials will be true if polynomials have been requested
  140912. * @param onLoad defines the callback to trigger once the texture is ready
  140913. * @param onError defines the callback to trigger in case of error
  140914. */
  140915. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140916. /**
  140917. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140918. * @param data contains the texture data
  140919. * @param texture defines the BabylonJS internal texture
  140920. * @param callback defines the method to call once ready to upload
  140921. */
  140922. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  140923. }
  140924. }
  140925. declare module BABYLON {
  140926. /** @hidden */
  140927. export var _forceSceneHelpersToBundle: boolean;
  140928. interface Scene {
  140929. /**
  140930. * Creates a default light for the scene.
  140931. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  140932. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  140933. */
  140934. createDefaultLight(replace?: boolean): void;
  140935. /**
  140936. * Creates a default camera for the scene.
  140937. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  140938. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  140939. * @param replace has default false, when true replaces the active camera in the scene
  140940. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  140941. */
  140942. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  140943. /**
  140944. * Creates a default camera and a default light.
  140945. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  140946. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  140947. * @param replace has the default false, when true replaces the active camera/light in the scene
  140948. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  140949. */
  140950. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  140951. /**
  140952. * Creates a new sky box
  140953. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  140954. * @param environmentTexture defines the texture to use as environment texture
  140955. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  140956. * @param scale defines the overall scale of the skybox
  140957. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  140958. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  140959. * @returns a new mesh holding the sky box
  140960. */
  140961. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  140962. /**
  140963. * Creates a new environment
  140964. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  140965. * @param options defines the options you can use to configure the environment
  140966. * @returns the new EnvironmentHelper
  140967. */
  140968. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  140969. /**
  140970. * Creates a new VREXperienceHelper
  140971. * @see https://doc.babylonjs.com/how_to/webvr_helper
  140972. * @param webVROptions defines the options used to create the new VREXperienceHelper
  140973. * @returns a new VREXperienceHelper
  140974. */
  140975. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  140976. /**
  140977. * Creates a new WebXRDefaultExperience
  140978. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  140979. * @param options experience options
  140980. * @returns a promise for a new WebXRDefaultExperience
  140981. */
  140982. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  140983. }
  140984. }
  140985. declare module BABYLON {
  140986. /**
  140987. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  140988. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  140989. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  140990. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140991. */
  140992. export class VideoDome extends TextureDome<VideoTexture> {
  140993. /**
  140994. * Define the video source as a Monoscopic panoramic 360 video.
  140995. */
  140996. static readonly MODE_MONOSCOPIC: number;
  140997. /**
  140998. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  140999. */
  141000. static readonly MODE_TOPBOTTOM: number;
  141001. /**
  141002. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  141003. */
  141004. static readonly MODE_SIDEBYSIDE: number;
  141005. /**
  141006. * Get the video texture associated with this video dome
  141007. */
  141008. get videoTexture(): VideoTexture;
  141009. /**
  141010. * Get the video mode of this dome
  141011. */
  141012. get videoMode(): number;
  141013. /**
  141014. * Set the video mode of this dome.
  141015. * @see textureMode
  141016. */
  141017. set videoMode(value: number);
  141018. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  141019. }
  141020. }
  141021. declare module BABYLON {
  141022. /**
  141023. * This class can be used to get instrumentation data from a Babylon engine
  141024. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  141025. */
  141026. export class EngineInstrumentation implements IDisposable {
  141027. /**
  141028. * Define the instrumented engine.
  141029. */
  141030. engine: Engine;
  141031. private _captureGPUFrameTime;
  141032. private _gpuFrameTimeToken;
  141033. private _gpuFrameTime;
  141034. private _captureShaderCompilationTime;
  141035. private _shaderCompilationTime;
  141036. private _onBeginFrameObserver;
  141037. private _onEndFrameObserver;
  141038. private _onBeforeShaderCompilationObserver;
  141039. private _onAfterShaderCompilationObserver;
  141040. /**
  141041. * Gets the perf counter used for GPU frame time
  141042. */
  141043. get gpuFrameTimeCounter(): PerfCounter;
  141044. /**
  141045. * Gets the GPU frame time capture status
  141046. */
  141047. get captureGPUFrameTime(): boolean;
  141048. /**
  141049. * Enable or disable the GPU frame time capture
  141050. */
  141051. set captureGPUFrameTime(value: boolean);
  141052. /**
  141053. * Gets the perf counter used for shader compilation time
  141054. */
  141055. get shaderCompilationTimeCounter(): PerfCounter;
  141056. /**
  141057. * Gets the shader compilation time capture status
  141058. */
  141059. get captureShaderCompilationTime(): boolean;
  141060. /**
  141061. * Enable or disable the shader compilation time capture
  141062. */
  141063. set captureShaderCompilationTime(value: boolean);
  141064. /**
  141065. * Instantiates a new engine instrumentation.
  141066. * This class can be used to get instrumentation data from a Babylon engine
  141067. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  141068. * @param engine Defines the engine to instrument
  141069. */
  141070. constructor(
  141071. /**
  141072. * Define the instrumented engine.
  141073. */
  141074. engine: Engine);
  141075. /**
  141076. * Dispose and release associated resources.
  141077. */
  141078. dispose(): void;
  141079. }
  141080. }
  141081. declare module BABYLON {
  141082. /**
  141083. * This class can be used to get instrumentation data from a Babylon engine
  141084. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  141085. */
  141086. export class SceneInstrumentation implements IDisposable {
  141087. /**
  141088. * Defines the scene to instrument
  141089. */
  141090. scene: Scene;
  141091. private _captureActiveMeshesEvaluationTime;
  141092. private _activeMeshesEvaluationTime;
  141093. private _captureRenderTargetsRenderTime;
  141094. private _renderTargetsRenderTime;
  141095. private _captureFrameTime;
  141096. private _frameTime;
  141097. private _captureRenderTime;
  141098. private _renderTime;
  141099. private _captureInterFrameTime;
  141100. private _interFrameTime;
  141101. private _captureParticlesRenderTime;
  141102. private _particlesRenderTime;
  141103. private _captureSpritesRenderTime;
  141104. private _spritesRenderTime;
  141105. private _capturePhysicsTime;
  141106. private _physicsTime;
  141107. private _captureAnimationsTime;
  141108. private _animationsTime;
  141109. private _captureCameraRenderTime;
  141110. private _cameraRenderTime;
  141111. private _onBeforeActiveMeshesEvaluationObserver;
  141112. private _onAfterActiveMeshesEvaluationObserver;
  141113. private _onBeforeRenderTargetsRenderObserver;
  141114. private _onAfterRenderTargetsRenderObserver;
  141115. private _onAfterRenderObserver;
  141116. private _onBeforeDrawPhaseObserver;
  141117. private _onAfterDrawPhaseObserver;
  141118. private _onBeforeAnimationsObserver;
  141119. private _onBeforeParticlesRenderingObserver;
  141120. private _onAfterParticlesRenderingObserver;
  141121. private _onBeforeSpritesRenderingObserver;
  141122. private _onAfterSpritesRenderingObserver;
  141123. private _onBeforePhysicsObserver;
  141124. private _onAfterPhysicsObserver;
  141125. private _onAfterAnimationsObserver;
  141126. private _onBeforeCameraRenderObserver;
  141127. private _onAfterCameraRenderObserver;
  141128. /**
  141129. * Gets the perf counter used for active meshes evaluation time
  141130. */
  141131. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  141132. /**
  141133. * Gets the active meshes evaluation time capture status
  141134. */
  141135. get captureActiveMeshesEvaluationTime(): boolean;
  141136. /**
  141137. * Enable or disable the active meshes evaluation time capture
  141138. */
  141139. set captureActiveMeshesEvaluationTime(value: boolean);
  141140. /**
  141141. * Gets the perf counter used for render targets render time
  141142. */
  141143. get renderTargetsRenderTimeCounter(): PerfCounter;
  141144. /**
  141145. * Gets the render targets render time capture status
  141146. */
  141147. get captureRenderTargetsRenderTime(): boolean;
  141148. /**
  141149. * Enable or disable the render targets render time capture
  141150. */
  141151. set captureRenderTargetsRenderTime(value: boolean);
  141152. /**
  141153. * Gets the perf counter used for particles render time
  141154. */
  141155. get particlesRenderTimeCounter(): PerfCounter;
  141156. /**
  141157. * Gets the particles render time capture status
  141158. */
  141159. get captureParticlesRenderTime(): boolean;
  141160. /**
  141161. * Enable or disable the particles render time capture
  141162. */
  141163. set captureParticlesRenderTime(value: boolean);
  141164. /**
  141165. * Gets the perf counter used for sprites render time
  141166. */
  141167. get spritesRenderTimeCounter(): PerfCounter;
  141168. /**
  141169. * Gets the sprites render time capture status
  141170. */
  141171. get captureSpritesRenderTime(): boolean;
  141172. /**
  141173. * Enable or disable the sprites render time capture
  141174. */
  141175. set captureSpritesRenderTime(value: boolean);
  141176. /**
  141177. * Gets the perf counter used for physics time
  141178. */
  141179. get physicsTimeCounter(): PerfCounter;
  141180. /**
  141181. * Gets the physics time capture status
  141182. */
  141183. get capturePhysicsTime(): boolean;
  141184. /**
  141185. * Enable or disable the physics time capture
  141186. */
  141187. set capturePhysicsTime(value: boolean);
  141188. /**
  141189. * Gets the perf counter used for animations time
  141190. */
  141191. get animationsTimeCounter(): PerfCounter;
  141192. /**
  141193. * Gets the animations time capture status
  141194. */
  141195. get captureAnimationsTime(): boolean;
  141196. /**
  141197. * Enable or disable the animations time capture
  141198. */
  141199. set captureAnimationsTime(value: boolean);
  141200. /**
  141201. * Gets the perf counter used for frame time capture
  141202. */
  141203. get frameTimeCounter(): PerfCounter;
  141204. /**
  141205. * Gets the frame time capture status
  141206. */
  141207. get captureFrameTime(): boolean;
  141208. /**
  141209. * Enable or disable the frame time capture
  141210. */
  141211. set captureFrameTime(value: boolean);
  141212. /**
  141213. * Gets the perf counter used for inter-frames time capture
  141214. */
  141215. get interFrameTimeCounter(): PerfCounter;
  141216. /**
  141217. * Gets the inter-frames time capture status
  141218. */
  141219. get captureInterFrameTime(): boolean;
  141220. /**
  141221. * Enable or disable the inter-frames time capture
  141222. */
  141223. set captureInterFrameTime(value: boolean);
  141224. /**
  141225. * Gets the perf counter used for render time capture
  141226. */
  141227. get renderTimeCounter(): PerfCounter;
  141228. /**
  141229. * Gets the render time capture status
  141230. */
  141231. get captureRenderTime(): boolean;
  141232. /**
  141233. * Enable or disable the render time capture
  141234. */
  141235. set captureRenderTime(value: boolean);
  141236. /**
  141237. * Gets the perf counter used for camera render time capture
  141238. */
  141239. get cameraRenderTimeCounter(): PerfCounter;
  141240. /**
  141241. * Gets the camera render time capture status
  141242. */
  141243. get captureCameraRenderTime(): boolean;
  141244. /**
  141245. * Enable or disable the camera render time capture
  141246. */
  141247. set captureCameraRenderTime(value: boolean);
  141248. /**
  141249. * Gets the perf counter used for draw calls
  141250. */
  141251. get drawCallsCounter(): PerfCounter;
  141252. /**
  141253. * Instantiates a new scene instrumentation.
  141254. * This class can be used to get instrumentation data from a Babylon engine
  141255. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  141256. * @param scene Defines the scene to instrument
  141257. */
  141258. constructor(
  141259. /**
  141260. * Defines the scene to instrument
  141261. */
  141262. scene: Scene);
  141263. /**
  141264. * Dispose and release associated resources.
  141265. */
  141266. dispose(): void;
  141267. }
  141268. }
  141269. declare module BABYLON {
  141270. /** @hidden */
  141271. export var glowMapGenerationPixelShader: {
  141272. name: string;
  141273. shader: string;
  141274. };
  141275. }
  141276. declare module BABYLON {
  141277. /** @hidden */
  141278. export var glowMapGenerationVertexShader: {
  141279. name: string;
  141280. shader: string;
  141281. };
  141282. }
  141283. declare module BABYLON {
  141284. /**
  141285. * Effect layer options. This helps customizing the behaviour
  141286. * of the effect layer.
  141287. */
  141288. export interface IEffectLayerOptions {
  141289. /**
  141290. * Multiplication factor apply to the canvas size to compute the render target size
  141291. * used to generated the objects (the smaller the faster).
  141292. */
  141293. mainTextureRatio: number;
  141294. /**
  141295. * Enforces a fixed size texture to ensure effect stability across devices.
  141296. */
  141297. mainTextureFixedSize?: number;
  141298. /**
  141299. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  141300. */
  141301. alphaBlendingMode: number;
  141302. /**
  141303. * The camera attached to the layer.
  141304. */
  141305. camera: Nullable<Camera>;
  141306. /**
  141307. * The rendering group to draw the layer in.
  141308. */
  141309. renderingGroupId: number;
  141310. }
  141311. /**
  141312. * The effect layer Helps adding post process effect blended with the main pass.
  141313. *
  141314. * This can be for instance use to generate glow or higlight effects on the scene.
  141315. *
  141316. * The effect layer class can not be used directly and is intented to inherited from to be
  141317. * customized per effects.
  141318. */
  141319. export abstract class EffectLayer {
  141320. private _vertexBuffers;
  141321. private _indexBuffer;
  141322. private _cachedDefines;
  141323. private _effectLayerMapGenerationEffect;
  141324. private _effectLayerOptions;
  141325. private _mergeEffect;
  141326. protected _scene: Scene;
  141327. protected _engine: Engine;
  141328. protected _maxSize: number;
  141329. protected _mainTextureDesiredSize: ISize;
  141330. protected _mainTexture: RenderTargetTexture;
  141331. protected _shouldRender: boolean;
  141332. protected _postProcesses: PostProcess[];
  141333. protected _textures: BaseTexture[];
  141334. protected _emissiveTextureAndColor: {
  141335. texture: Nullable<BaseTexture>;
  141336. color: Color4;
  141337. };
  141338. /**
  141339. * The name of the layer
  141340. */
  141341. name: string;
  141342. /**
  141343. * The clear color of the texture used to generate the glow map.
  141344. */
  141345. neutralColor: Color4;
  141346. /**
  141347. * Specifies whether the highlight layer is enabled or not.
  141348. */
  141349. isEnabled: boolean;
  141350. /**
  141351. * Gets the camera attached to the layer.
  141352. */
  141353. get camera(): Nullable<Camera>;
  141354. /**
  141355. * Gets the rendering group id the layer should render in.
  141356. */
  141357. get renderingGroupId(): number;
  141358. set renderingGroupId(renderingGroupId: number);
  141359. /**
  141360. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  141361. */
  141362. disableBoundingBoxesFromEffectLayer: boolean;
  141363. /**
  141364. * An event triggered when the effect layer has been disposed.
  141365. */
  141366. onDisposeObservable: Observable<EffectLayer>;
  141367. /**
  141368. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  141369. */
  141370. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  141371. /**
  141372. * An event triggered when the generated texture is being merged in the scene.
  141373. */
  141374. onBeforeComposeObservable: Observable<EffectLayer>;
  141375. /**
  141376. * An event triggered when the mesh is rendered into the effect render target.
  141377. */
  141378. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  141379. /**
  141380. * An event triggered after the mesh has been rendered into the effect render target.
  141381. */
  141382. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  141383. /**
  141384. * An event triggered when the generated texture has been merged in the scene.
  141385. */
  141386. onAfterComposeObservable: Observable<EffectLayer>;
  141387. /**
  141388. * An event triggered when the efffect layer changes its size.
  141389. */
  141390. onSizeChangedObservable: Observable<EffectLayer>;
  141391. /** @hidden */
  141392. static _SceneComponentInitialization: (scene: Scene) => void;
  141393. /**
  141394. * Instantiates a new effect Layer and references it in the scene.
  141395. * @param name The name of the layer
  141396. * @param scene The scene to use the layer in
  141397. */
  141398. constructor(
  141399. /** The Friendly of the effect in the scene */
  141400. name: string, scene: Scene);
  141401. /**
  141402. * Get the effect name of the layer.
  141403. * @return The effect name
  141404. */
  141405. abstract getEffectName(): string;
  141406. /**
  141407. * Checks for the readiness of the element composing the layer.
  141408. * @param subMesh the mesh to check for
  141409. * @param useInstances specify whether or not to use instances to render the mesh
  141410. * @return true if ready otherwise, false
  141411. */
  141412. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141413. /**
  141414. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  141415. * @returns true if the effect requires stencil during the main canvas render pass.
  141416. */
  141417. abstract needStencil(): boolean;
  141418. /**
  141419. * Create the merge effect. This is the shader use to blit the information back
  141420. * to the main canvas at the end of the scene rendering.
  141421. * @returns The effect containing the shader used to merge the effect on the main canvas
  141422. */
  141423. protected abstract _createMergeEffect(): Effect;
  141424. /**
  141425. * Creates the render target textures and post processes used in the effect layer.
  141426. */
  141427. protected abstract _createTextureAndPostProcesses(): void;
  141428. /**
  141429. * Implementation specific of rendering the generating effect on the main canvas.
  141430. * @param effect The effect used to render through
  141431. */
  141432. protected abstract _internalRender(effect: Effect): void;
  141433. /**
  141434. * Sets the required values for both the emissive texture and and the main color.
  141435. */
  141436. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141437. /**
  141438. * Free any resources and references associated to a mesh.
  141439. * Internal use
  141440. * @param mesh The mesh to free.
  141441. */
  141442. abstract _disposeMesh(mesh: Mesh): void;
  141443. /**
  141444. * Serializes this layer (Glow or Highlight for example)
  141445. * @returns a serialized layer object
  141446. */
  141447. abstract serialize?(): any;
  141448. /**
  141449. * Initializes the effect layer with the required options.
  141450. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  141451. */
  141452. protected _init(options: Partial<IEffectLayerOptions>): void;
  141453. /**
  141454. * Generates the index buffer of the full screen quad blending to the main canvas.
  141455. */
  141456. private _generateIndexBuffer;
  141457. /**
  141458. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  141459. */
  141460. private _generateVertexBuffer;
  141461. /**
  141462. * Sets the main texture desired size which is the closest power of two
  141463. * of the engine canvas size.
  141464. */
  141465. private _setMainTextureSize;
  141466. /**
  141467. * Creates the main texture for the effect layer.
  141468. */
  141469. protected _createMainTexture(): void;
  141470. /**
  141471. * Adds specific effects defines.
  141472. * @param defines The defines to add specifics to.
  141473. */
  141474. protected _addCustomEffectDefines(defines: string[]): void;
  141475. /**
  141476. * Checks for the readiness of the element composing the layer.
  141477. * @param subMesh the mesh to check for
  141478. * @param useInstances specify whether or not to use instances to render the mesh
  141479. * @param emissiveTexture the associated emissive texture used to generate the glow
  141480. * @return true if ready otherwise, false
  141481. */
  141482. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  141483. /**
  141484. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  141485. */
  141486. render(): void;
  141487. /**
  141488. * Determine if a given mesh will be used in the current effect.
  141489. * @param mesh mesh to test
  141490. * @returns true if the mesh will be used
  141491. */
  141492. hasMesh(mesh: AbstractMesh): boolean;
  141493. /**
  141494. * Returns true if the layer contains information to display, otherwise false.
  141495. * @returns true if the glow layer should be rendered
  141496. */
  141497. shouldRender(): boolean;
  141498. /**
  141499. * Returns true if the mesh should render, otherwise false.
  141500. * @param mesh The mesh to render
  141501. * @returns true if it should render otherwise false
  141502. */
  141503. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  141504. /**
  141505. * Returns true if the mesh can be rendered, otherwise false.
  141506. * @param mesh The mesh to render
  141507. * @param material The material used on the mesh
  141508. * @returns true if it can be rendered otherwise false
  141509. */
  141510. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141511. /**
  141512. * Returns true if the mesh should render, otherwise false.
  141513. * @param mesh The mesh to render
  141514. * @returns true if it should render otherwise false
  141515. */
  141516. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  141517. /**
  141518. * Renders the submesh passed in parameter to the generation map.
  141519. */
  141520. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  141521. /**
  141522. * Defines whether the current material of the mesh should be use to render the effect.
  141523. * @param mesh defines the current mesh to render
  141524. */
  141525. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  141526. /**
  141527. * Rebuild the required buffers.
  141528. * @hidden Internal use only.
  141529. */
  141530. _rebuild(): void;
  141531. /**
  141532. * Dispose only the render target textures and post process.
  141533. */
  141534. private _disposeTextureAndPostProcesses;
  141535. /**
  141536. * Dispose the highlight layer and free resources.
  141537. */
  141538. dispose(): void;
  141539. /**
  141540. * Gets the class name of the effect layer
  141541. * @returns the string with the class name of the effect layer
  141542. */
  141543. getClassName(): string;
  141544. /**
  141545. * Creates an effect layer from parsed effect layer data
  141546. * @param parsedEffectLayer defines effect layer data
  141547. * @param scene defines the current scene
  141548. * @param rootUrl defines the root URL containing the effect layer information
  141549. * @returns a parsed effect Layer
  141550. */
  141551. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  141552. }
  141553. }
  141554. declare module BABYLON {
  141555. interface AbstractScene {
  141556. /**
  141557. * The list of effect layers (highlights/glow) added to the scene
  141558. * @see https://doc.babylonjs.com/how_to/highlight_layer
  141559. * @see https://doc.babylonjs.com/how_to/glow_layer
  141560. */
  141561. effectLayers: Array<EffectLayer>;
  141562. /**
  141563. * Removes the given effect layer from this scene.
  141564. * @param toRemove defines the effect layer to remove
  141565. * @returns the index of the removed effect layer
  141566. */
  141567. removeEffectLayer(toRemove: EffectLayer): number;
  141568. /**
  141569. * Adds the given effect layer to this scene
  141570. * @param newEffectLayer defines the effect layer to add
  141571. */
  141572. addEffectLayer(newEffectLayer: EffectLayer): void;
  141573. }
  141574. /**
  141575. * Defines the layer scene component responsible to manage any effect layers
  141576. * in a given scene.
  141577. */
  141578. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  141579. /**
  141580. * The component name helpfull to identify the component in the list of scene components.
  141581. */
  141582. readonly name: string;
  141583. /**
  141584. * The scene the component belongs to.
  141585. */
  141586. scene: Scene;
  141587. private _engine;
  141588. private _renderEffects;
  141589. private _needStencil;
  141590. private _previousStencilState;
  141591. /**
  141592. * Creates a new instance of the component for the given scene
  141593. * @param scene Defines the scene to register the component in
  141594. */
  141595. constructor(scene: Scene);
  141596. /**
  141597. * Registers the component in a given scene
  141598. */
  141599. register(): void;
  141600. /**
  141601. * Rebuilds the elements related to this component in case of
  141602. * context lost for instance.
  141603. */
  141604. rebuild(): void;
  141605. /**
  141606. * Serializes the component data to the specified json object
  141607. * @param serializationObject The object to serialize to
  141608. */
  141609. serialize(serializationObject: any): void;
  141610. /**
  141611. * Adds all the elements from the container to the scene
  141612. * @param container the container holding the elements
  141613. */
  141614. addFromContainer(container: AbstractScene): void;
  141615. /**
  141616. * Removes all the elements in the container from the scene
  141617. * @param container contains the elements to remove
  141618. * @param dispose if the removed element should be disposed (default: false)
  141619. */
  141620. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141621. /**
  141622. * Disposes the component and the associated ressources.
  141623. */
  141624. dispose(): void;
  141625. private _isReadyForMesh;
  141626. private _renderMainTexture;
  141627. private _setStencil;
  141628. private _setStencilBack;
  141629. private _draw;
  141630. private _drawCamera;
  141631. private _drawRenderingGroup;
  141632. }
  141633. }
  141634. declare module BABYLON {
  141635. /** @hidden */
  141636. export var glowMapMergePixelShader: {
  141637. name: string;
  141638. shader: string;
  141639. };
  141640. }
  141641. declare module BABYLON {
  141642. /** @hidden */
  141643. export var glowMapMergeVertexShader: {
  141644. name: string;
  141645. shader: string;
  141646. };
  141647. }
  141648. declare module BABYLON {
  141649. interface AbstractScene {
  141650. /**
  141651. * Return a the first highlight layer of the scene with a given name.
  141652. * @param name The name of the highlight layer to look for.
  141653. * @return The highlight layer if found otherwise null.
  141654. */
  141655. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  141656. }
  141657. /**
  141658. * Glow layer options. This helps customizing the behaviour
  141659. * of the glow layer.
  141660. */
  141661. export interface IGlowLayerOptions {
  141662. /**
  141663. * Multiplication factor apply to the canvas size to compute the render target size
  141664. * used to generated the glowing objects (the smaller the faster).
  141665. */
  141666. mainTextureRatio: number;
  141667. /**
  141668. * Enforces a fixed size texture to ensure resize independant blur.
  141669. */
  141670. mainTextureFixedSize?: number;
  141671. /**
  141672. * How big is the kernel of the blur texture.
  141673. */
  141674. blurKernelSize: number;
  141675. /**
  141676. * The camera attached to the layer.
  141677. */
  141678. camera: Nullable<Camera>;
  141679. /**
  141680. * Enable MSAA by chosing the number of samples.
  141681. */
  141682. mainTextureSamples?: number;
  141683. /**
  141684. * The rendering group to draw the layer in.
  141685. */
  141686. renderingGroupId: number;
  141687. }
  141688. /**
  141689. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  141690. *
  141691. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  141692. *
  141693. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  141694. */
  141695. export class GlowLayer extends EffectLayer {
  141696. /**
  141697. * Effect Name of the layer.
  141698. */
  141699. static readonly EffectName: string;
  141700. /**
  141701. * The default blur kernel size used for the glow.
  141702. */
  141703. static DefaultBlurKernelSize: number;
  141704. /**
  141705. * The default texture size ratio used for the glow.
  141706. */
  141707. static DefaultTextureRatio: number;
  141708. /**
  141709. * Sets the kernel size of the blur.
  141710. */
  141711. set blurKernelSize(value: number);
  141712. /**
  141713. * Gets the kernel size of the blur.
  141714. */
  141715. get blurKernelSize(): number;
  141716. /**
  141717. * Sets the glow intensity.
  141718. */
  141719. set intensity(value: number);
  141720. /**
  141721. * Gets the glow intensity.
  141722. */
  141723. get intensity(): number;
  141724. private _options;
  141725. private _intensity;
  141726. private _horizontalBlurPostprocess1;
  141727. private _verticalBlurPostprocess1;
  141728. private _horizontalBlurPostprocess2;
  141729. private _verticalBlurPostprocess2;
  141730. private _blurTexture1;
  141731. private _blurTexture2;
  141732. private _postProcesses1;
  141733. private _postProcesses2;
  141734. private _includedOnlyMeshes;
  141735. private _excludedMeshes;
  141736. private _meshesUsingTheirOwnMaterials;
  141737. /**
  141738. * Callback used to let the user override the color selection on a per mesh basis
  141739. */
  141740. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  141741. /**
  141742. * Callback used to let the user override the texture selection on a per mesh basis
  141743. */
  141744. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  141745. /**
  141746. * Instantiates a new glow Layer and references it to the scene.
  141747. * @param name The name of the layer
  141748. * @param scene The scene to use the layer in
  141749. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  141750. */
  141751. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  141752. /**
  141753. * Get the effect name of the layer.
  141754. * @return The effect name
  141755. */
  141756. getEffectName(): string;
  141757. /**
  141758. * Create the merge effect. This is the shader use to blit the information back
  141759. * to the main canvas at the end of the scene rendering.
  141760. */
  141761. protected _createMergeEffect(): Effect;
  141762. /**
  141763. * Creates the render target textures and post processes used in the glow layer.
  141764. */
  141765. protected _createTextureAndPostProcesses(): void;
  141766. /**
  141767. * Checks for the readiness of the element composing the layer.
  141768. * @param subMesh the mesh to check for
  141769. * @param useInstances specify wether or not to use instances to render the mesh
  141770. * @param emissiveTexture the associated emissive texture used to generate the glow
  141771. * @return true if ready otherwise, false
  141772. */
  141773. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141774. /**
  141775. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  141776. */
  141777. needStencil(): boolean;
  141778. /**
  141779. * Returns true if the mesh can be rendered, otherwise false.
  141780. * @param mesh The mesh to render
  141781. * @param material The material used on the mesh
  141782. * @returns true if it can be rendered otherwise false
  141783. */
  141784. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141785. /**
  141786. * Implementation specific of rendering the generating effect on the main canvas.
  141787. * @param effect The effect used to render through
  141788. */
  141789. protected _internalRender(effect: Effect): void;
  141790. /**
  141791. * Sets the required values for both the emissive texture and and the main color.
  141792. */
  141793. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141794. /**
  141795. * Returns true if the mesh should render, otherwise false.
  141796. * @param mesh The mesh to render
  141797. * @returns true if it should render otherwise false
  141798. */
  141799. protected _shouldRenderMesh(mesh: Mesh): boolean;
  141800. /**
  141801. * Adds specific effects defines.
  141802. * @param defines The defines to add specifics to.
  141803. */
  141804. protected _addCustomEffectDefines(defines: string[]): void;
  141805. /**
  141806. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  141807. * @param mesh The mesh to exclude from the glow layer
  141808. */
  141809. addExcludedMesh(mesh: Mesh): void;
  141810. /**
  141811. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  141812. * @param mesh The mesh to remove
  141813. */
  141814. removeExcludedMesh(mesh: Mesh): void;
  141815. /**
  141816. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  141817. * @param mesh The mesh to include in the glow layer
  141818. */
  141819. addIncludedOnlyMesh(mesh: Mesh): void;
  141820. /**
  141821. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  141822. * @param mesh The mesh to remove
  141823. */
  141824. removeIncludedOnlyMesh(mesh: Mesh): void;
  141825. /**
  141826. * Determine if a given mesh will be used in the glow layer
  141827. * @param mesh The mesh to test
  141828. * @returns true if the mesh will be highlighted by the current glow layer
  141829. */
  141830. hasMesh(mesh: AbstractMesh): boolean;
  141831. /**
  141832. * Defines whether the current material of the mesh should be use to render the effect.
  141833. * @param mesh defines the current mesh to render
  141834. */
  141835. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  141836. /**
  141837. * Add a mesh to be rendered through its own material and not with emissive only.
  141838. * @param mesh The mesh for which we need to use its material
  141839. */
  141840. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  141841. /**
  141842. * Remove a mesh from being rendered through its own material and not with emissive only.
  141843. * @param mesh The mesh for which we need to not use its material
  141844. */
  141845. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  141846. /**
  141847. * Free any resources and references associated to a mesh.
  141848. * Internal use
  141849. * @param mesh The mesh to free.
  141850. * @hidden
  141851. */
  141852. _disposeMesh(mesh: Mesh): void;
  141853. /**
  141854. * Gets the class name of the effect layer
  141855. * @returns the string with the class name of the effect layer
  141856. */
  141857. getClassName(): string;
  141858. /**
  141859. * Serializes this glow layer
  141860. * @returns a serialized glow layer object
  141861. */
  141862. serialize(): any;
  141863. /**
  141864. * Creates a Glow Layer from parsed glow layer data
  141865. * @param parsedGlowLayer defines glow layer data
  141866. * @param scene defines the current scene
  141867. * @param rootUrl defines the root URL containing the glow layer information
  141868. * @returns a parsed Glow Layer
  141869. */
  141870. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  141871. }
  141872. }
  141873. declare module BABYLON {
  141874. /** @hidden */
  141875. export var glowBlurPostProcessPixelShader: {
  141876. name: string;
  141877. shader: string;
  141878. };
  141879. }
  141880. declare module BABYLON {
  141881. interface AbstractScene {
  141882. /**
  141883. * Return a the first highlight layer of the scene with a given name.
  141884. * @param name The name of the highlight layer to look for.
  141885. * @return The highlight layer if found otherwise null.
  141886. */
  141887. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  141888. }
  141889. /**
  141890. * Highlight layer options. This helps customizing the behaviour
  141891. * of the highlight layer.
  141892. */
  141893. export interface IHighlightLayerOptions {
  141894. /**
  141895. * Multiplication factor apply to the canvas size to compute the render target size
  141896. * used to generated the glowing objects (the smaller the faster).
  141897. */
  141898. mainTextureRatio: number;
  141899. /**
  141900. * Enforces a fixed size texture to ensure resize independant blur.
  141901. */
  141902. mainTextureFixedSize?: number;
  141903. /**
  141904. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  141905. * of the picture to blur (the smaller the faster).
  141906. */
  141907. blurTextureSizeRatio: number;
  141908. /**
  141909. * How big in texel of the blur texture is the vertical blur.
  141910. */
  141911. blurVerticalSize: number;
  141912. /**
  141913. * How big in texel of the blur texture is the horizontal blur.
  141914. */
  141915. blurHorizontalSize: number;
  141916. /**
  141917. * Alpha blending mode used to apply the blur. Default is combine.
  141918. */
  141919. alphaBlendingMode: number;
  141920. /**
  141921. * The camera attached to the layer.
  141922. */
  141923. camera: Nullable<Camera>;
  141924. /**
  141925. * Should we display highlight as a solid stroke?
  141926. */
  141927. isStroke?: boolean;
  141928. /**
  141929. * The rendering group to draw the layer in.
  141930. */
  141931. renderingGroupId: number;
  141932. }
  141933. /**
  141934. * The highlight layer Helps adding a glow effect around a mesh.
  141935. *
  141936. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  141937. * glowy meshes to your scene.
  141938. *
  141939. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  141940. */
  141941. export class HighlightLayer extends EffectLayer {
  141942. name: string;
  141943. /**
  141944. * Effect Name of the highlight layer.
  141945. */
  141946. static readonly EffectName: string;
  141947. /**
  141948. * The neutral color used during the preparation of the glow effect.
  141949. * This is black by default as the blend operation is a blend operation.
  141950. */
  141951. static NeutralColor: Color4;
  141952. /**
  141953. * Stencil value used for glowing meshes.
  141954. */
  141955. static GlowingMeshStencilReference: number;
  141956. /**
  141957. * Stencil value used for the other meshes in the scene.
  141958. */
  141959. static NormalMeshStencilReference: number;
  141960. /**
  141961. * Specifies whether or not the inner glow is ACTIVE in the layer.
  141962. */
  141963. innerGlow: boolean;
  141964. /**
  141965. * Specifies whether or not the outer glow is ACTIVE in the layer.
  141966. */
  141967. outerGlow: boolean;
  141968. /**
  141969. * Specifies the horizontal size of the blur.
  141970. */
  141971. set blurHorizontalSize(value: number);
  141972. /**
  141973. * Specifies the vertical size of the blur.
  141974. */
  141975. set blurVerticalSize(value: number);
  141976. /**
  141977. * Gets the horizontal size of the blur.
  141978. */
  141979. get blurHorizontalSize(): number;
  141980. /**
  141981. * Gets the vertical size of the blur.
  141982. */
  141983. get blurVerticalSize(): number;
  141984. /**
  141985. * An event triggered when the highlight layer is being blurred.
  141986. */
  141987. onBeforeBlurObservable: Observable<HighlightLayer>;
  141988. /**
  141989. * An event triggered when the highlight layer has been blurred.
  141990. */
  141991. onAfterBlurObservable: Observable<HighlightLayer>;
  141992. private _instanceGlowingMeshStencilReference;
  141993. private _options;
  141994. private _downSamplePostprocess;
  141995. private _horizontalBlurPostprocess;
  141996. private _verticalBlurPostprocess;
  141997. private _blurTexture;
  141998. private _meshes;
  141999. private _excludedMeshes;
  142000. /**
  142001. * Instantiates a new highlight Layer and references it to the scene..
  142002. * @param name The name of the layer
  142003. * @param scene The scene to use the layer in
  142004. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  142005. */
  142006. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  142007. /**
  142008. * Get the effect name of the layer.
  142009. * @return The effect name
  142010. */
  142011. getEffectName(): string;
  142012. /**
  142013. * Create the merge effect. This is the shader use to blit the information back
  142014. * to the main canvas at the end of the scene rendering.
  142015. */
  142016. protected _createMergeEffect(): Effect;
  142017. /**
  142018. * Creates the render target textures and post processes used in the highlight layer.
  142019. */
  142020. protected _createTextureAndPostProcesses(): void;
  142021. /**
  142022. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  142023. */
  142024. needStencil(): boolean;
  142025. /**
  142026. * Checks for the readiness of the element composing the layer.
  142027. * @param subMesh the mesh to check for
  142028. * @param useInstances specify wether or not to use instances to render the mesh
  142029. * @param emissiveTexture the associated emissive texture used to generate the glow
  142030. * @return true if ready otherwise, false
  142031. */
  142032. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142033. /**
  142034. * Implementation specific of rendering the generating effect on the main canvas.
  142035. * @param effect The effect used to render through
  142036. */
  142037. protected _internalRender(effect: Effect): void;
  142038. /**
  142039. * Returns true if the layer contains information to display, otherwise false.
  142040. */
  142041. shouldRender(): boolean;
  142042. /**
  142043. * Returns true if the mesh should render, otherwise false.
  142044. * @param mesh The mesh to render
  142045. * @returns true if it should render otherwise false
  142046. */
  142047. protected _shouldRenderMesh(mesh: Mesh): boolean;
  142048. /**
  142049. * Returns true if the mesh can be rendered, otherwise false.
  142050. * @param mesh The mesh to render
  142051. * @param material The material used on the mesh
  142052. * @returns true if it can be rendered otherwise false
  142053. */
  142054. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  142055. /**
  142056. * Adds specific effects defines.
  142057. * @param defines The defines to add specifics to.
  142058. */
  142059. protected _addCustomEffectDefines(defines: string[]): void;
  142060. /**
  142061. * Sets the required values for both the emissive texture and and the main color.
  142062. */
  142063. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  142064. /**
  142065. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  142066. * @param mesh The mesh to exclude from the highlight layer
  142067. */
  142068. addExcludedMesh(mesh: Mesh): void;
  142069. /**
  142070. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  142071. * @param mesh The mesh to highlight
  142072. */
  142073. removeExcludedMesh(mesh: Mesh): void;
  142074. /**
  142075. * Determine if a given mesh will be highlighted by the current HighlightLayer
  142076. * @param mesh mesh to test
  142077. * @returns true if the mesh will be highlighted by the current HighlightLayer
  142078. */
  142079. hasMesh(mesh: AbstractMesh): boolean;
  142080. /**
  142081. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  142082. * @param mesh The mesh to highlight
  142083. * @param color The color of the highlight
  142084. * @param glowEmissiveOnly Extract the glow from the emissive texture
  142085. */
  142086. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  142087. /**
  142088. * Remove a mesh from the highlight layer in order to make it stop glowing.
  142089. * @param mesh The mesh to highlight
  142090. */
  142091. removeMesh(mesh: Mesh): void;
  142092. /**
  142093. * Remove all the meshes currently referenced in the highlight layer
  142094. */
  142095. removeAllMeshes(): void;
  142096. /**
  142097. * Force the stencil to the normal expected value for none glowing parts
  142098. */
  142099. private _defaultStencilReference;
  142100. /**
  142101. * Free any resources and references associated to a mesh.
  142102. * Internal use
  142103. * @param mesh The mesh to free.
  142104. * @hidden
  142105. */
  142106. _disposeMesh(mesh: Mesh): void;
  142107. /**
  142108. * Dispose the highlight layer and free resources.
  142109. */
  142110. dispose(): void;
  142111. /**
  142112. * Gets the class name of the effect layer
  142113. * @returns the string with the class name of the effect layer
  142114. */
  142115. getClassName(): string;
  142116. /**
  142117. * Serializes this Highlight layer
  142118. * @returns a serialized Highlight layer object
  142119. */
  142120. serialize(): any;
  142121. /**
  142122. * Creates a Highlight layer from parsed Highlight layer data
  142123. * @param parsedHightlightLayer defines the Highlight layer data
  142124. * @param scene defines the current scene
  142125. * @param rootUrl defines the root URL containing the Highlight layer information
  142126. * @returns a parsed Highlight layer
  142127. */
  142128. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  142129. }
  142130. }
  142131. declare module BABYLON {
  142132. interface AbstractScene {
  142133. /**
  142134. * The list of layers (background and foreground) of the scene
  142135. */
  142136. layers: Array<Layer>;
  142137. }
  142138. /**
  142139. * Defines the layer scene component responsible to manage any layers
  142140. * in a given scene.
  142141. */
  142142. export class LayerSceneComponent implements ISceneComponent {
  142143. /**
  142144. * The component name helpfull to identify the component in the list of scene components.
  142145. */
  142146. readonly name: string;
  142147. /**
  142148. * The scene the component belongs to.
  142149. */
  142150. scene: Scene;
  142151. private _engine;
  142152. /**
  142153. * Creates a new instance of the component for the given scene
  142154. * @param scene Defines the scene to register the component in
  142155. */
  142156. constructor(scene: Scene);
  142157. /**
  142158. * Registers the component in a given scene
  142159. */
  142160. register(): void;
  142161. /**
  142162. * Rebuilds the elements related to this component in case of
  142163. * context lost for instance.
  142164. */
  142165. rebuild(): void;
  142166. /**
  142167. * Disposes the component and the associated ressources.
  142168. */
  142169. dispose(): void;
  142170. private _draw;
  142171. private _drawCameraPredicate;
  142172. private _drawCameraBackground;
  142173. private _drawCameraForeground;
  142174. private _drawRenderTargetPredicate;
  142175. private _drawRenderTargetBackground;
  142176. private _drawRenderTargetForeground;
  142177. /**
  142178. * Adds all the elements from the container to the scene
  142179. * @param container the container holding the elements
  142180. */
  142181. addFromContainer(container: AbstractScene): void;
  142182. /**
  142183. * Removes all the elements in the container from the scene
  142184. * @param container contains the elements to remove
  142185. * @param dispose if the removed element should be disposed (default: false)
  142186. */
  142187. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142188. }
  142189. }
  142190. declare module BABYLON {
  142191. /** @hidden */
  142192. export var layerPixelShader: {
  142193. name: string;
  142194. shader: string;
  142195. };
  142196. }
  142197. declare module BABYLON {
  142198. /** @hidden */
  142199. export var layerVertexShader: {
  142200. name: string;
  142201. shader: string;
  142202. };
  142203. }
  142204. declare module BABYLON {
  142205. /**
  142206. * This represents a full screen 2d layer.
  142207. * This can be useful to display a picture in the background of your scene for instance.
  142208. * @see https://www.babylonjs-playground.com/#08A2BS#1
  142209. */
  142210. export class Layer {
  142211. /**
  142212. * Define the name of the layer.
  142213. */
  142214. name: string;
  142215. /**
  142216. * Define the texture the layer should display.
  142217. */
  142218. texture: Nullable<Texture>;
  142219. /**
  142220. * Is the layer in background or foreground.
  142221. */
  142222. isBackground: boolean;
  142223. /**
  142224. * Define the color of the layer (instead of texture).
  142225. */
  142226. color: Color4;
  142227. /**
  142228. * Define the scale of the layer in order to zoom in out of the texture.
  142229. */
  142230. scale: Vector2;
  142231. /**
  142232. * Define an offset for the layer in order to shift the texture.
  142233. */
  142234. offset: Vector2;
  142235. /**
  142236. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  142237. */
  142238. alphaBlendingMode: number;
  142239. /**
  142240. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  142241. * Alpha test will not mix with the background color in case of transparency.
  142242. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  142243. */
  142244. alphaTest: boolean;
  142245. /**
  142246. * Define a mask to restrict the layer to only some of the scene cameras.
  142247. */
  142248. layerMask: number;
  142249. /**
  142250. * Define the list of render target the layer is visible into.
  142251. */
  142252. renderTargetTextures: RenderTargetTexture[];
  142253. /**
  142254. * Define if the layer is only used in renderTarget or if it also
  142255. * renders in the main frame buffer of the canvas.
  142256. */
  142257. renderOnlyInRenderTargetTextures: boolean;
  142258. private _scene;
  142259. private _vertexBuffers;
  142260. private _indexBuffer;
  142261. private _effect;
  142262. private _previousDefines;
  142263. /**
  142264. * An event triggered when the layer is disposed.
  142265. */
  142266. onDisposeObservable: Observable<Layer>;
  142267. private _onDisposeObserver;
  142268. /**
  142269. * Back compatibility with callback before the onDisposeObservable existed.
  142270. * The set callback will be triggered when the layer has been disposed.
  142271. */
  142272. set onDispose(callback: () => void);
  142273. /**
  142274. * An event triggered before rendering the scene
  142275. */
  142276. onBeforeRenderObservable: Observable<Layer>;
  142277. private _onBeforeRenderObserver;
  142278. /**
  142279. * Back compatibility with callback before the onBeforeRenderObservable existed.
  142280. * The set callback will be triggered just before rendering the layer.
  142281. */
  142282. set onBeforeRender(callback: () => void);
  142283. /**
  142284. * An event triggered after rendering the scene
  142285. */
  142286. onAfterRenderObservable: Observable<Layer>;
  142287. private _onAfterRenderObserver;
  142288. /**
  142289. * Back compatibility with callback before the onAfterRenderObservable existed.
  142290. * The set callback will be triggered just after rendering the layer.
  142291. */
  142292. set onAfterRender(callback: () => void);
  142293. /**
  142294. * Instantiates a new layer.
  142295. * This represents a full screen 2d layer.
  142296. * This can be useful to display a picture in the background of your scene for instance.
  142297. * @see https://www.babylonjs-playground.com/#08A2BS#1
  142298. * @param name Define the name of the layer in the scene
  142299. * @param imgUrl Define the url of the texture to display in the layer
  142300. * @param scene Define the scene the layer belongs to
  142301. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  142302. * @param color Defines a color for the layer
  142303. */
  142304. constructor(
  142305. /**
  142306. * Define the name of the layer.
  142307. */
  142308. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  142309. private _createIndexBuffer;
  142310. /** @hidden */
  142311. _rebuild(): void;
  142312. /**
  142313. * Renders the layer in the scene.
  142314. */
  142315. render(): void;
  142316. /**
  142317. * Disposes and releases the associated ressources.
  142318. */
  142319. dispose(): void;
  142320. }
  142321. }
  142322. declare module BABYLON {
  142323. /** @hidden */
  142324. export var lensFlarePixelShader: {
  142325. name: string;
  142326. shader: string;
  142327. };
  142328. }
  142329. declare module BABYLON {
  142330. /** @hidden */
  142331. export var lensFlareVertexShader: {
  142332. name: string;
  142333. shader: string;
  142334. };
  142335. }
  142336. declare module BABYLON {
  142337. /**
  142338. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  142339. * It is usually composed of several `lensFlare`.
  142340. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142341. */
  142342. export class LensFlareSystem {
  142343. /**
  142344. * Define the name of the lens flare system
  142345. */
  142346. name: string;
  142347. /**
  142348. * List of lens flares used in this system.
  142349. */
  142350. lensFlares: LensFlare[];
  142351. /**
  142352. * Define a limit from the border the lens flare can be visible.
  142353. */
  142354. borderLimit: number;
  142355. /**
  142356. * Define a viewport border we do not want to see the lens flare in.
  142357. */
  142358. viewportBorder: number;
  142359. /**
  142360. * Define a predicate which could limit the list of meshes able to occlude the effect.
  142361. */
  142362. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  142363. /**
  142364. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  142365. */
  142366. layerMask: number;
  142367. /**
  142368. * Define the id of the lens flare system in the scene.
  142369. * (equal to name by default)
  142370. */
  142371. id: string;
  142372. private _scene;
  142373. private _emitter;
  142374. private _vertexBuffers;
  142375. private _indexBuffer;
  142376. private _effect;
  142377. private _positionX;
  142378. private _positionY;
  142379. private _isEnabled;
  142380. /** @hidden */
  142381. static _SceneComponentInitialization: (scene: Scene) => void;
  142382. /**
  142383. * Instantiates a lens flare system.
  142384. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  142385. * It is usually composed of several `lensFlare`.
  142386. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142387. * @param name Define the name of the lens flare system in the scene
  142388. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  142389. * @param scene Define the scene the lens flare system belongs to
  142390. */
  142391. constructor(
  142392. /**
  142393. * Define the name of the lens flare system
  142394. */
  142395. name: string, emitter: any, scene: Scene);
  142396. /**
  142397. * Define if the lens flare system is enabled.
  142398. */
  142399. get isEnabled(): boolean;
  142400. set isEnabled(value: boolean);
  142401. /**
  142402. * Get the scene the effects belongs to.
  142403. * @returns the scene holding the lens flare system
  142404. */
  142405. getScene(): Scene;
  142406. /**
  142407. * Get the emitter of the lens flare system.
  142408. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  142409. * @returns the emitter of the lens flare system
  142410. */
  142411. getEmitter(): any;
  142412. /**
  142413. * Set the emitter of the lens flare system.
  142414. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  142415. * @param newEmitter Define the new emitter of the system
  142416. */
  142417. setEmitter(newEmitter: any): void;
  142418. /**
  142419. * Get the lens flare system emitter position.
  142420. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  142421. * @returns the position
  142422. */
  142423. getEmitterPosition(): Vector3;
  142424. /**
  142425. * @hidden
  142426. */
  142427. computeEffectivePosition(globalViewport: Viewport): boolean;
  142428. /** @hidden */
  142429. _isVisible(): boolean;
  142430. /**
  142431. * @hidden
  142432. */
  142433. render(): boolean;
  142434. /**
  142435. * Dispose and release the lens flare with its associated resources.
  142436. */
  142437. dispose(): void;
  142438. /**
  142439. * Parse a lens flare system from a JSON repressentation
  142440. * @param parsedLensFlareSystem Define the JSON to parse
  142441. * @param scene Define the scene the parsed system should be instantiated in
  142442. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  142443. * @returns the parsed system
  142444. */
  142445. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  142446. /**
  142447. * Serialize the current Lens Flare System into a JSON representation.
  142448. * @returns the serialized JSON
  142449. */
  142450. serialize(): any;
  142451. }
  142452. }
  142453. declare module BABYLON {
  142454. /**
  142455. * This represents one of the lens effect in a `lensFlareSystem`.
  142456. * It controls one of the indiviual texture used in the effect.
  142457. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142458. */
  142459. export class LensFlare {
  142460. /**
  142461. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  142462. */
  142463. size: number;
  142464. /**
  142465. * 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.
  142466. */
  142467. position: number;
  142468. /**
  142469. * Define the lens color.
  142470. */
  142471. color: Color3;
  142472. /**
  142473. * Define the lens texture.
  142474. */
  142475. texture: Nullable<Texture>;
  142476. /**
  142477. * Define the alpha mode to render this particular lens.
  142478. */
  142479. alphaMode: number;
  142480. private _system;
  142481. /**
  142482. * Creates a new Lens Flare.
  142483. * This represents one of the lens effect in a `lensFlareSystem`.
  142484. * It controls one of the indiviual texture used in the effect.
  142485. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142486. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  142487. * @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.
  142488. * @param color Define the lens color
  142489. * @param imgUrl Define the lens texture url
  142490. * @param system Define the `lensFlareSystem` this flare is part of
  142491. * @returns The newly created Lens Flare
  142492. */
  142493. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  142494. /**
  142495. * Instantiates a new Lens Flare.
  142496. * This represents one of the lens effect in a `lensFlareSystem`.
  142497. * It controls one of the indiviual texture used in the effect.
  142498. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142499. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  142500. * @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.
  142501. * @param color Define the lens color
  142502. * @param imgUrl Define the lens texture url
  142503. * @param system Define the `lensFlareSystem` this flare is part of
  142504. */
  142505. constructor(
  142506. /**
  142507. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  142508. */
  142509. size: number,
  142510. /**
  142511. * 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.
  142512. */
  142513. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  142514. /**
  142515. * Dispose and release the lens flare with its associated resources.
  142516. */
  142517. dispose(): void;
  142518. }
  142519. }
  142520. declare module BABYLON {
  142521. interface AbstractScene {
  142522. /**
  142523. * The list of lens flare system added to the scene
  142524. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142525. */
  142526. lensFlareSystems: Array<LensFlareSystem>;
  142527. /**
  142528. * Removes the given lens flare system from this scene.
  142529. * @param toRemove The lens flare system to remove
  142530. * @returns The index of the removed lens flare system
  142531. */
  142532. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  142533. /**
  142534. * Adds the given lens flare system to this scene
  142535. * @param newLensFlareSystem The lens flare system to add
  142536. */
  142537. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  142538. /**
  142539. * Gets a lens flare system using its name
  142540. * @param name defines the name to look for
  142541. * @returns the lens flare system or null if not found
  142542. */
  142543. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  142544. /**
  142545. * Gets a lens flare system using its id
  142546. * @param id defines the id to look for
  142547. * @returns the lens flare system or null if not found
  142548. */
  142549. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  142550. }
  142551. /**
  142552. * Defines the lens flare scene component responsible to manage any lens flares
  142553. * in a given scene.
  142554. */
  142555. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  142556. /**
  142557. * The component name helpfull to identify the component in the list of scene components.
  142558. */
  142559. readonly name: string;
  142560. /**
  142561. * The scene the component belongs to.
  142562. */
  142563. scene: Scene;
  142564. /**
  142565. * Creates a new instance of the component for the given scene
  142566. * @param scene Defines the scene to register the component in
  142567. */
  142568. constructor(scene: Scene);
  142569. /**
  142570. * Registers the component in a given scene
  142571. */
  142572. register(): void;
  142573. /**
  142574. * Rebuilds the elements related to this component in case of
  142575. * context lost for instance.
  142576. */
  142577. rebuild(): void;
  142578. /**
  142579. * Adds all the elements from the container to the scene
  142580. * @param container the container holding the elements
  142581. */
  142582. addFromContainer(container: AbstractScene): void;
  142583. /**
  142584. * Removes all the elements in the container from the scene
  142585. * @param container contains the elements to remove
  142586. * @param dispose if the removed element should be disposed (default: false)
  142587. */
  142588. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142589. /**
  142590. * Serializes the component data to the specified json object
  142591. * @param serializationObject The object to serialize to
  142592. */
  142593. serialize(serializationObject: any): void;
  142594. /**
  142595. * Disposes the component and the associated ressources.
  142596. */
  142597. dispose(): void;
  142598. private _draw;
  142599. }
  142600. }
  142601. declare module BABYLON {
  142602. /** @hidden */
  142603. export var depthPixelShader: {
  142604. name: string;
  142605. shader: string;
  142606. };
  142607. }
  142608. declare module BABYLON {
  142609. /** @hidden */
  142610. export var depthVertexShader: {
  142611. name: string;
  142612. shader: string;
  142613. };
  142614. }
  142615. declare module BABYLON {
  142616. /**
  142617. * This represents a depth renderer in Babylon.
  142618. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  142619. */
  142620. export class DepthRenderer {
  142621. private _scene;
  142622. private _depthMap;
  142623. private _effect;
  142624. private readonly _storeNonLinearDepth;
  142625. private readonly _clearColor;
  142626. /** Get if the depth renderer is using packed depth or not */
  142627. readonly isPacked: boolean;
  142628. private _cachedDefines;
  142629. private _camera;
  142630. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  142631. enabled: boolean;
  142632. /**
  142633. * Specifiess that the depth renderer will only be used within
  142634. * the camera it is created for.
  142635. * This can help forcing its rendering during the camera processing.
  142636. */
  142637. useOnlyInActiveCamera: boolean;
  142638. /** @hidden */
  142639. static _SceneComponentInitialization: (scene: Scene) => void;
  142640. /**
  142641. * Instantiates a depth renderer
  142642. * @param scene The scene the renderer belongs to
  142643. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  142644. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  142645. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  142646. */
  142647. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  142648. /**
  142649. * Creates the depth rendering effect and checks if the effect is ready.
  142650. * @param subMesh The submesh to be used to render the depth map of
  142651. * @param useInstances If multiple world instances should be used
  142652. * @returns if the depth renderer is ready to render the depth map
  142653. */
  142654. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142655. /**
  142656. * Gets the texture which the depth map will be written to.
  142657. * @returns The depth map texture
  142658. */
  142659. getDepthMap(): RenderTargetTexture;
  142660. /**
  142661. * Disposes of the depth renderer.
  142662. */
  142663. dispose(): void;
  142664. }
  142665. }
  142666. declare module BABYLON {
  142667. /** @hidden */
  142668. export var minmaxReduxPixelShader: {
  142669. name: string;
  142670. shader: string;
  142671. };
  142672. }
  142673. declare module BABYLON {
  142674. /**
  142675. * This class computes a min/max reduction from a texture: it means it computes the minimum
  142676. * and maximum values from all values of the texture.
  142677. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  142678. * The source values are read from the red channel of the texture.
  142679. */
  142680. export class MinMaxReducer {
  142681. /**
  142682. * Observable triggered when the computation has been performed
  142683. */
  142684. onAfterReductionPerformed: Observable<{
  142685. min: number;
  142686. max: number;
  142687. }>;
  142688. protected _camera: Camera;
  142689. protected _sourceTexture: Nullable<RenderTargetTexture>;
  142690. protected _reductionSteps: Nullable<Array<PostProcess>>;
  142691. protected _postProcessManager: PostProcessManager;
  142692. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  142693. protected _forceFullscreenViewport: boolean;
  142694. /**
  142695. * Creates a min/max reducer
  142696. * @param camera The camera to use for the post processes
  142697. */
  142698. constructor(camera: Camera);
  142699. /**
  142700. * Gets the texture used to read the values from.
  142701. */
  142702. get sourceTexture(): Nullable<RenderTargetTexture>;
  142703. /**
  142704. * Sets the source texture to read the values from.
  142705. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  142706. * because in such textures '1' value must not be taken into account to compute the maximum
  142707. * as this value is used to clear the texture.
  142708. * Note that the computation is not activated by calling this function, you must call activate() for that!
  142709. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  142710. * @param depthRedux Indicates if the texture is a depth texture or not
  142711. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  142712. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  142713. */
  142714. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  142715. /**
  142716. * Defines the refresh rate of the computation.
  142717. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  142718. */
  142719. get refreshRate(): number;
  142720. set refreshRate(value: number);
  142721. protected _activated: boolean;
  142722. /**
  142723. * Gets the activation status of the reducer
  142724. */
  142725. get activated(): boolean;
  142726. /**
  142727. * Activates the reduction computation.
  142728. * When activated, the observers registered in onAfterReductionPerformed are
  142729. * called after the compuation is performed
  142730. */
  142731. activate(): void;
  142732. /**
  142733. * Deactivates the reduction computation.
  142734. */
  142735. deactivate(): void;
  142736. /**
  142737. * Disposes the min/max reducer
  142738. * @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.
  142739. */
  142740. dispose(disposeAll?: boolean): void;
  142741. }
  142742. }
  142743. declare module BABYLON {
  142744. /**
  142745. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  142746. */
  142747. export class DepthReducer extends MinMaxReducer {
  142748. private _depthRenderer;
  142749. private _depthRendererId;
  142750. /**
  142751. * Gets the depth renderer used for the computation.
  142752. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  142753. */
  142754. get depthRenderer(): Nullable<DepthRenderer>;
  142755. /**
  142756. * Creates a depth reducer
  142757. * @param camera The camera used to render the depth texture
  142758. */
  142759. constructor(camera: Camera);
  142760. /**
  142761. * Sets the depth renderer to use to generate the depth map
  142762. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  142763. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  142764. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  142765. */
  142766. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  142767. /** @hidden */
  142768. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  142769. /**
  142770. * Activates the reduction computation.
  142771. * When activated, the observers registered in onAfterReductionPerformed are
  142772. * called after the compuation is performed
  142773. */
  142774. activate(): void;
  142775. /**
  142776. * Deactivates the reduction computation.
  142777. */
  142778. deactivate(): void;
  142779. /**
  142780. * Disposes the depth reducer
  142781. * @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.
  142782. */
  142783. dispose(disposeAll?: boolean): void;
  142784. }
  142785. }
  142786. declare module BABYLON {
  142787. /**
  142788. * A CSM implementation allowing casting shadows on large scenes.
  142789. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  142790. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  142791. */
  142792. export class CascadedShadowGenerator extends ShadowGenerator {
  142793. private static readonly frustumCornersNDCSpace;
  142794. /**
  142795. * Name of the CSM class
  142796. */
  142797. static CLASSNAME: string;
  142798. /**
  142799. * Defines the default number of cascades used by the CSM.
  142800. */
  142801. static readonly DEFAULT_CASCADES_COUNT: number;
  142802. /**
  142803. * Defines the minimum number of cascades used by the CSM.
  142804. */
  142805. static readonly MIN_CASCADES_COUNT: number;
  142806. /**
  142807. * Defines the maximum number of cascades used by the CSM.
  142808. */
  142809. static readonly MAX_CASCADES_COUNT: number;
  142810. protected _validateFilter(filter: number): number;
  142811. /**
  142812. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  142813. */
  142814. penumbraDarkness: number;
  142815. private _numCascades;
  142816. /**
  142817. * Gets or set the number of cascades used by the CSM.
  142818. */
  142819. get numCascades(): number;
  142820. set numCascades(value: number);
  142821. /**
  142822. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  142823. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  142824. */
  142825. stabilizeCascades: boolean;
  142826. private _freezeShadowCastersBoundingInfo;
  142827. private _freezeShadowCastersBoundingInfoObservable;
  142828. /**
  142829. * Enables or disables the shadow casters bounding info computation.
  142830. * If your shadow casters don't move, you can disable this feature.
  142831. * If it is enabled, the bounding box computation is done every frame.
  142832. */
  142833. get freezeShadowCastersBoundingInfo(): boolean;
  142834. set freezeShadowCastersBoundingInfo(freeze: boolean);
  142835. private _scbiMin;
  142836. private _scbiMax;
  142837. protected _computeShadowCastersBoundingInfo(): void;
  142838. protected _shadowCastersBoundingInfo: BoundingInfo;
  142839. /**
  142840. * Gets or sets the shadow casters bounding info.
  142841. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  142842. * so that the system won't overwrite the bounds you provide
  142843. */
  142844. get shadowCastersBoundingInfo(): BoundingInfo;
  142845. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  142846. protected _breaksAreDirty: boolean;
  142847. protected _minDistance: number;
  142848. protected _maxDistance: number;
  142849. /**
  142850. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  142851. *
  142852. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  142853. * If you don't know these values, simply leave them to their defaults and don't call this function.
  142854. * @param min minimal distance for the breaks (default to 0.)
  142855. * @param max maximal distance for the breaks (default to 1.)
  142856. */
  142857. setMinMaxDistance(min: number, max: number): void;
  142858. /** Gets the minimal distance used in the cascade break computation */
  142859. get minDistance(): number;
  142860. /** Gets the maximal distance used in the cascade break computation */
  142861. get maxDistance(): number;
  142862. /**
  142863. * Gets the class name of that object
  142864. * @returns "CascadedShadowGenerator"
  142865. */
  142866. getClassName(): string;
  142867. private _cascadeMinExtents;
  142868. private _cascadeMaxExtents;
  142869. /**
  142870. * Gets a cascade minimum extents
  142871. * @param cascadeIndex index of the cascade
  142872. * @returns the minimum cascade extents
  142873. */
  142874. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  142875. /**
  142876. * Gets a cascade maximum extents
  142877. * @param cascadeIndex index of the cascade
  142878. * @returns the maximum cascade extents
  142879. */
  142880. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  142881. private _cascades;
  142882. private _currentLayer;
  142883. private _viewSpaceFrustumsZ;
  142884. private _viewMatrices;
  142885. private _projectionMatrices;
  142886. private _transformMatrices;
  142887. private _transformMatricesAsArray;
  142888. private _frustumLengths;
  142889. private _lightSizeUVCorrection;
  142890. private _depthCorrection;
  142891. private _frustumCornersWorldSpace;
  142892. private _frustumCenter;
  142893. private _shadowCameraPos;
  142894. private _shadowMaxZ;
  142895. /**
  142896. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  142897. * It defaults to camera.maxZ
  142898. */
  142899. get shadowMaxZ(): number;
  142900. /**
  142901. * Sets the shadow max z distance.
  142902. */
  142903. set shadowMaxZ(value: number);
  142904. protected _debug: boolean;
  142905. /**
  142906. * Gets or sets the debug flag.
  142907. * When enabled, the cascades are materialized by different colors on the screen.
  142908. */
  142909. get debug(): boolean;
  142910. set debug(dbg: boolean);
  142911. private _depthClamp;
  142912. /**
  142913. * Gets or sets the depth clamping value.
  142914. *
  142915. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  142916. * to account for the shadow casters far away.
  142917. *
  142918. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  142919. */
  142920. get depthClamp(): boolean;
  142921. set depthClamp(value: boolean);
  142922. private _cascadeBlendPercentage;
  142923. /**
  142924. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  142925. * It defaults to 0.1 (10% blending).
  142926. */
  142927. get cascadeBlendPercentage(): number;
  142928. set cascadeBlendPercentage(value: number);
  142929. private _lambda;
  142930. /**
  142931. * Gets or set the lambda parameter.
  142932. * This parameter is used to split the camera frustum and create the cascades.
  142933. * 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.
  142934. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  142935. */
  142936. get lambda(): number;
  142937. set lambda(value: number);
  142938. /**
  142939. * Gets the view matrix corresponding to a given cascade
  142940. * @param cascadeNum cascade to retrieve the view matrix from
  142941. * @returns the cascade view matrix
  142942. */
  142943. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  142944. /**
  142945. * Gets the projection matrix corresponding to a given cascade
  142946. * @param cascadeNum cascade to retrieve the projection matrix from
  142947. * @returns the cascade projection matrix
  142948. */
  142949. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  142950. /**
  142951. * Gets the transformation matrix corresponding to a given cascade
  142952. * @param cascadeNum cascade to retrieve the transformation matrix from
  142953. * @returns the cascade transformation matrix
  142954. */
  142955. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  142956. private _depthRenderer;
  142957. /**
  142958. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  142959. *
  142960. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  142961. *
  142962. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  142963. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  142964. * @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
  142965. */
  142966. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  142967. private _depthReducer;
  142968. private _autoCalcDepthBounds;
  142969. /**
  142970. * Gets or sets the autoCalcDepthBounds property.
  142971. *
  142972. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  142973. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  142974. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  142975. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  142976. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  142977. */
  142978. get autoCalcDepthBounds(): boolean;
  142979. set autoCalcDepthBounds(value: boolean);
  142980. /**
  142981. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  142982. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  142983. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  142984. * for setting the refresh rate on the renderer yourself!
  142985. */
  142986. get autoCalcDepthBoundsRefreshRate(): number;
  142987. set autoCalcDepthBoundsRefreshRate(value: number);
  142988. /**
  142989. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  142990. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  142991. * you change the camera near/far planes!
  142992. */
  142993. splitFrustum(): void;
  142994. private _splitFrustum;
  142995. private _computeMatrices;
  142996. private _computeFrustumInWorldSpace;
  142997. private _computeCascadeFrustum;
  142998. /**
  142999. * Support test.
  143000. */
  143001. static get IsSupported(): boolean;
  143002. /** @hidden */
  143003. static _SceneComponentInitialization: (scene: Scene) => void;
  143004. /**
  143005. * Creates a Cascaded Shadow Generator object.
  143006. * A ShadowGenerator is the required tool to use the shadows.
  143007. * Each directional light casting shadows needs to use its own ShadowGenerator.
  143008. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  143009. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  143010. * @param light The directional light object generating the shadows.
  143011. * @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.
  143012. */
  143013. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  143014. protected _initializeGenerator(): void;
  143015. protected _createTargetRenderTexture(): void;
  143016. protected _initializeShadowMap(): void;
  143017. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  143018. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  143019. /**
  143020. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  143021. * @param defines Defines of the material we want to update
  143022. * @param lightIndex Index of the light in the enabled light list of the material
  143023. */
  143024. prepareDefines(defines: any, lightIndex: number): void;
  143025. /**
  143026. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  143027. * defined in the generator but impacting the effect).
  143028. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  143029. * @param effect The effect we are binfing the information for
  143030. */
  143031. bindShadowLight(lightIndex: string, effect: Effect): void;
  143032. /**
  143033. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  143034. * (eq to view projection * shadow projection matrices)
  143035. * @returns The transform matrix used to create the shadow map
  143036. */
  143037. getTransformMatrix(): Matrix;
  143038. /**
  143039. * Disposes the ShadowGenerator.
  143040. * Returns nothing.
  143041. */
  143042. dispose(): void;
  143043. /**
  143044. * Serializes the shadow generator setup to a json object.
  143045. * @returns The serialized JSON object
  143046. */
  143047. serialize(): any;
  143048. /**
  143049. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  143050. * @param parsedShadowGenerator The JSON object to parse
  143051. * @param scene The scene to create the shadow map for
  143052. * @returns The parsed shadow generator
  143053. */
  143054. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  143055. }
  143056. }
  143057. declare module BABYLON {
  143058. /**
  143059. * Defines the shadow generator component responsible to manage any shadow generators
  143060. * in a given scene.
  143061. */
  143062. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  143063. /**
  143064. * The component name helpfull to identify the component in the list of scene components.
  143065. */
  143066. readonly name: string;
  143067. /**
  143068. * The scene the component belongs to.
  143069. */
  143070. scene: Scene;
  143071. /**
  143072. * Creates a new instance of the component for the given scene
  143073. * @param scene Defines the scene to register the component in
  143074. */
  143075. constructor(scene: Scene);
  143076. /**
  143077. * Registers the component in a given scene
  143078. */
  143079. register(): void;
  143080. /**
  143081. * Rebuilds the elements related to this component in case of
  143082. * context lost for instance.
  143083. */
  143084. rebuild(): void;
  143085. /**
  143086. * Serializes the component data to the specified json object
  143087. * @param serializationObject The object to serialize to
  143088. */
  143089. serialize(serializationObject: any): void;
  143090. /**
  143091. * Adds all the elements from the container to the scene
  143092. * @param container the container holding the elements
  143093. */
  143094. addFromContainer(container: AbstractScene): void;
  143095. /**
  143096. * Removes all the elements in the container from the scene
  143097. * @param container contains the elements to remove
  143098. * @param dispose if the removed element should be disposed (default: false)
  143099. */
  143100. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  143101. /**
  143102. * Rebuilds the elements related to this component in case of
  143103. * context lost for instance.
  143104. */
  143105. dispose(): void;
  143106. private _gatherRenderTargets;
  143107. }
  143108. }
  143109. declare module BABYLON {
  143110. /**
  143111. * A point light is a light defined by an unique point in world space.
  143112. * The light is emitted in every direction from this point.
  143113. * A good example of a point light is a standard light bulb.
  143114. * Documentation: https://doc.babylonjs.com/babylon101/lights
  143115. */
  143116. export class PointLight extends ShadowLight {
  143117. private _shadowAngle;
  143118. /**
  143119. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143120. * This specifies what angle the shadow will use to be created.
  143121. *
  143122. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  143123. */
  143124. get shadowAngle(): number;
  143125. /**
  143126. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143127. * This specifies what angle the shadow will use to be created.
  143128. *
  143129. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  143130. */
  143131. set shadowAngle(value: number);
  143132. /**
  143133. * Gets the direction if it has been set.
  143134. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143135. */
  143136. get direction(): Vector3;
  143137. /**
  143138. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143139. */
  143140. set direction(value: Vector3);
  143141. /**
  143142. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  143143. * A PointLight emits the light in every direction.
  143144. * It can cast shadows.
  143145. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  143146. * ```javascript
  143147. * var pointLight = new PointLight("pl", camera.position, scene);
  143148. * ```
  143149. * Documentation : https://doc.babylonjs.com/babylon101/lights
  143150. * @param name The light friendly name
  143151. * @param position The position of the point light in the scene
  143152. * @param scene The scene the lights belongs to
  143153. */
  143154. constructor(name: string, position: Vector3, scene: Scene);
  143155. /**
  143156. * Returns the string "PointLight"
  143157. * @returns the class name
  143158. */
  143159. getClassName(): string;
  143160. /**
  143161. * Returns the integer 0.
  143162. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  143163. */
  143164. getTypeID(): number;
  143165. /**
  143166. * Specifies wether or not the shadowmap should be a cube texture.
  143167. * @returns true if the shadowmap needs to be a cube texture.
  143168. */
  143169. needCube(): boolean;
  143170. /**
  143171. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  143172. * @param faceIndex The index of the face we are computed the direction to generate shadow
  143173. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  143174. */
  143175. getShadowDirection(faceIndex?: number): Vector3;
  143176. /**
  143177. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  143178. * - fov = PI / 2
  143179. * - aspect ratio : 1.0
  143180. * - z-near and far equal to the active camera minZ and maxZ.
  143181. * Returns the PointLight.
  143182. */
  143183. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  143184. protected _buildUniformLayout(): void;
  143185. /**
  143186. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  143187. * @param effect The effect to update
  143188. * @param lightIndex The index of the light in the effect to update
  143189. * @returns The point light
  143190. */
  143191. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  143192. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  143193. /**
  143194. * Prepares the list of defines specific to the light type.
  143195. * @param defines the list of defines
  143196. * @param lightIndex defines the index of the light for the effect
  143197. */
  143198. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  143199. }
  143200. }
  143201. declare module BABYLON {
  143202. /**
  143203. * Header information of HDR texture files.
  143204. */
  143205. export interface HDRInfo {
  143206. /**
  143207. * The height of the texture in pixels.
  143208. */
  143209. height: number;
  143210. /**
  143211. * The width of the texture in pixels.
  143212. */
  143213. width: number;
  143214. /**
  143215. * The index of the beginning of the data in the binary file.
  143216. */
  143217. dataPosition: number;
  143218. }
  143219. /**
  143220. * This groups tools to convert HDR texture to native colors array.
  143221. */
  143222. export class HDRTools {
  143223. private static Ldexp;
  143224. private static Rgbe2float;
  143225. private static readStringLine;
  143226. /**
  143227. * Reads header information from an RGBE texture stored in a native array.
  143228. * More information on this format are available here:
  143229. * https://en.wikipedia.org/wiki/RGBE_image_format
  143230. *
  143231. * @param uint8array The binary file stored in native array.
  143232. * @return The header information.
  143233. */
  143234. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  143235. /**
  143236. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  143237. * This RGBE texture needs to store the information as a panorama.
  143238. *
  143239. * More information on this format are available here:
  143240. * https://en.wikipedia.org/wiki/RGBE_image_format
  143241. *
  143242. * @param buffer The binary file stored in an array buffer.
  143243. * @param size The expected size of the extracted cubemap.
  143244. * @return The Cube Map information.
  143245. */
  143246. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  143247. /**
  143248. * Returns the pixels data extracted from an RGBE texture.
  143249. * This pixels will be stored left to right up to down in the R G B order in one array.
  143250. *
  143251. * More information on this format are available here:
  143252. * https://en.wikipedia.org/wiki/RGBE_image_format
  143253. *
  143254. * @param uint8array The binary file stored in an array buffer.
  143255. * @param hdrInfo The header information of the file.
  143256. * @return The pixels data in RGB right to left up to down order.
  143257. */
  143258. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  143259. private static RGBE_ReadPixels_RLE;
  143260. private static RGBE_ReadPixels_NOT_RLE;
  143261. }
  143262. }
  143263. declare module BABYLON {
  143264. /**
  143265. * Effect Render Options
  143266. */
  143267. export interface IEffectRendererOptions {
  143268. /**
  143269. * Defines the vertices positions.
  143270. */
  143271. positions?: number[];
  143272. /**
  143273. * Defines the indices.
  143274. */
  143275. indices?: number[];
  143276. }
  143277. /**
  143278. * Helper class to render one or more effects.
  143279. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  143280. */
  143281. export class EffectRenderer {
  143282. private engine;
  143283. private static _DefaultOptions;
  143284. private _vertexBuffers;
  143285. private _indexBuffer;
  143286. private _fullscreenViewport;
  143287. /**
  143288. * Creates an effect renderer
  143289. * @param engine the engine to use for rendering
  143290. * @param options defines the options of the effect renderer
  143291. */
  143292. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  143293. /**
  143294. * Sets the current viewport in normalized coordinates 0-1
  143295. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  143296. */
  143297. setViewport(viewport?: Viewport): void;
  143298. /**
  143299. * Binds the embedded attributes buffer to the effect.
  143300. * @param effect Defines the effect to bind the attributes for
  143301. */
  143302. bindBuffers(effect: Effect): void;
  143303. /**
  143304. * Sets the current effect wrapper to use during draw.
  143305. * The effect needs to be ready before calling this api.
  143306. * This also sets the default full screen position attribute.
  143307. * @param effectWrapper Defines the effect to draw with
  143308. */
  143309. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  143310. /**
  143311. * Restores engine states
  143312. */
  143313. restoreStates(): void;
  143314. /**
  143315. * Draws a full screen quad.
  143316. */
  143317. draw(): void;
  143318. private isRenderTargetTexture;
  143319. /**
  143320. * renders one or more effects to a specified texture
  143321. * @param effectWrapper the effect to renderer
  143322. * @param outputTexture texture to draw to, if null it will render to the screen.
  143323. */
  143324. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  143325. /**
  143326. * Disposes of the effect renderer
  143327. */
  143328. dispose(): void;
  143329. }
  143330. /**
  143331. * Options to create an EffectWrapper
  143332. */
  143333. interface EffectWrapperCreationOptions {
  143334. /**
  143335. * Engine to use to create the effect
  143336. */
  143337. engine: ThinEngine;
  143338. /**
  143339. * Fragment shader for the effect
  143340. */
  143341. fragmentShader: string;
  143342. /**
  143343. * Use the shader store instead of direct source code
  143344. */
  143345. useShaderStore?: boolean;
  143346. /**
  143347. * Vertex shader for the effect
  143348. */
  143349. vertexShader?: string;
  143350. /**
  143351. * Attributes to use in the shader
  143352. */
  143353. attributeNames?: Array<string>;
  143354. /**
  143355. * Uniforms to use in the shader
  143356. */
  143357. uniformNames?: Array<string>;
  143358. /**
  143359. * Texture sampler names to use in the shader
  143360. */
  143361. samplerNames?: Array<string>;
  143362. /**
  143363. * Defines to use in the shader
  143364. */
  143365. defines?: Array<string>;
  143366. /**
  143367. * Callback when effect is compiled
  143368. */
  143369. onCompiled?: Nullable<(effect: Effect) => void>;
  143370. /**
  143371. * The friendly name of the effect displayed in Spector.
  143372. */
  143373. name?: string;
  143374. }
  143375. /**
  143376. * Wraps an effect to be used for rendering
  143377. */
  143378. export class EffectWrapper {
  143379. /**
  143380. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  143381. */
  143382. onApplyObservable: Observable<{}>;
  143383. /**
  143384. * The underlying effect
  143385. */
  143386. effect: Effect;
  143387. /**
  143388. * Creates an effect to be renderer
  143389. * @param creationOptions options to create the effect
  143390. */
  143391. constructor(creationOptions: EffectWrapperCreationOptions);
  143392. /**
  143393. * Disposes of the effect wrapper
  143394. */
  143395. dispose(): void;
  143396. }
  143397. }
  143398. declare module BABYLON {
  143399. /** @hidden */
  143400. export var hdrFilteringVertexShader: {
  143401. name: string;
  143402. shader: string;
  143403. };
  143404. }
  143405. declare module BABYLON {
  143406. /** @hidden */
  143407. export var hdrFilteringPixelShader: {
  143408. name: string;
  143409. shader: string;
  143410. };
  143411. }
  143412. declare module BABYLON {
  143413. /**
  143414. * Options for texture filtering
  143415. */
  143416. interface IHDRFilteringOptions {
  143417. /**
  143418. * Scales pixel intensity for the input HDR map.
  143419. */
  143420. hdrScale?: number;
  143421. /**
  143422. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  143423. */
  143424. quality?: number;
  143425. }
  143426. /**
  143427. * Filters HDR maps to get correct renderings of PBR reflections
  143428. */
  143429. export class HDRFiltering {
  143430. private _engine;
  143431. private _effectRenderer;
  143432. private _effectWrapper;
  143433. private _lodGenerationOffset;
  143434. private _lodGenerationScale;
  143435. /**
  143436. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  143437. * you care about baking speed.
  143438. */
  143439. quality: number;
  143440. /**
  143441. * Scales pixel intensity for the input HDR map.
  143442. */
  143443. hdrScale: number;
  143444. /**
  143445. * Instantiates HDR filter for reflection maps
  143446. *
  143447. * @param engine Thin engine
  143448. * @param options Options
  143449. */
  143450. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  143451. private _createRenderTarget;
  143452. private _prefilterInternal;
  143453. private _createEffect;
  143454. /**
  143455. * Get a value indicating if the filter is ready to be used
  143456. * @param texture Texture to filter
  143457. * @returns true if the filter is ready
  143458. */
  143459. isReady(texture: BaseTexture): boolean;
  143460. /**
  143461. * Prefilters a cube texture to have mipmap levels representing roughness values.
  143462. * Prefiltering will be invoked at the end of next rendering pass.
  143463. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  143464. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  143465. * @param texture Texture to filter
  143466. * @param onFinished Callback when filtering is done
  143467. * @return Promise called when prefiltering is done
  143468. */
  143469. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  143470. }
  143471. }
  143472. declare module BABYLON {
  143473. /**
  143474. * This represents a texture coming from an HDR input.
  143475. *
  143476. * The only supported format is currently panorama picture stored in RGBE format.
  143477. * Example of such files can be found on HDRLib: http://hdrlib.com/
  143478. */
  143479. export class HDRCubeTexture extends BaseTexture {
  143480. private static _facesMapping;
  143481. private _generateHarmonics;
  143482. private _noMipmap;
  143483. private _prefilterOnLoad;
  143484. private _textureMatrix;
  143485. private _size;
  143486. private _onLoad;
  143487. private _onError;
  143488. /**
  143489. * The texture URL.
  143490. */
  143491. url: string;
  143492. protected _isBlocking: boolean;
  143493. /**
  143494. * Sets wether or not the texture is blocking during loading.
  143495. */
  143496. set isBlocking(value: boolean);
  143497. /**
  143498. * Gets wether or not the texture is blocking during loading.
  143499. */
  143500. get isBlocking(): boolean;
  143501. protected _rotationY: number;
  143502. /**
  143503. * Sets texture matrix rotation angle around Y axis in radians.
  143504. */
  143505. set rotationY(value: number);
  143506. /**
  143507. * Gets texture matrix rotation angle around Y axis radians.
  143508. */
  143509. get rotationY(): number;
  143510. /**
  143511. * Gets or sets the center of the bounding box associated with the cube texture
  143512. * It must define where the camera used to render the texture was set
  143513. */
  143514. boundingBoxPosition: Vector3;
  143515. private _boundingBoxSize;
  143516. /**
  143517. * Gets or sets the size of the bounding box associated with the cube texture
  143518. * When defined, the cubemap will switch to local mode
  143519. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  143520. * @example https://www.babylonjs-playground.com/#RNASML
  143521. */
  143522. set boundingBoxSize(value: Vector3);
  143523. get boundingBoxSize(): Vector3;
  143524. /**
  143525. * Instantiates an HDRTexture from the following parameters.
  143526. *
  143527. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  143528. * @param sceneOrEngine The scene or engine the texture will be used in
  143529. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  143530. * @param noMipmap Forces to not generate the mipmap if true
  143531. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  143532. * @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)
  143533. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  143534. */
  143535. 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>);
  143536. /**
  143537. * Get the current class name of the texture useful for serialization or dynamic coding.
  143538. * @returns "HDRCubeTexture"
  143539. */
  143540. getClassName(): string;
  143541. /**
  143542. * Occurs when the file is raw .hdr file.
  143543. */
  143544. private loadTexture;
  143545. clone(): HDRCubeTexture;
  143546. delayLoad(): void;
  143547. /**
  143548. * Get the texture reflection matrix used to rotate/transform the reflection.
  143549. * @returns the reflection matrix
  143550. */
  143551. getReflectionTextureMatrix(): Matrix;
  143552. /**
  143553. * Set the texture reflection matrix used to rotate/transform the reflection.
  143554. * @param value Define the reflection matrix to set
  143555. */
  143556. setReflectionTextureMatrix(value: Matrix): void;
  143557. /**
  143558. * Parses a JSON representation of an HDR Texture in order to create the texture
  143559. * @param parsedTexture Define the JSON representation
  143560. * @param scene Define the scene the texture should be created in
  143561. * @param rootUrl Define the root url in case we need to load relative dependencies
  143562. * @returns the newly created texture after parsing
  143563. */
  143564. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  143565. serialize(): any;
  143566. }
  143567. }
  143568. declare module BABYLON {
  143569. /**
  143570. * Class used to control physics engine
  143571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  143572. */
  143573. export class PhysicsEngine implements IPhysicsEngine {
  143574. private _physicsPlugin;
  143575. /**
  143576. * Global value used to control the smallest number supported by the simulation
  143577. */
  143578. static Epsilon: number;
  143579. private _impostors;
  143580. private _joints;
  143581. private _subTimeStep;
  143582. /**
  143583. * Gets the gravity vector used by the simulation
  143584. */
  143585. gravity: Vector3;
  143586. /**
  143587. * Factory used to create the default physics plugin.
  143588. * @returns The default physics plugin
  143589. */
  143590. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  143591. /**
  143592. * Creates a new Physics Engine
  143593. * @param gravity defines the gravity vector used by the simulation
  143594. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  143595. */
  143596. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  143597. /**
  143598. * Sets the gravity vector used by the simulation
  143599. * @param gravity defines the gravity vector to use
  143600. */
  143601. setGravity(gravity: Vector3): void;
  143602. /**
  143603. * Set the time step of the physics engine.
  143604. * Default is 1/60.
  143605. * To slow it down, enter 1/600 for example.
  143606. * To speed it up, 1/30
  143607. * @param newTimeStep defines the new timestep to apply to this world.
  143608. */
  143609. setTimeStep(newTimeStep?: number): void;
  143610. /**
  143611. * Get the time step of the physics engine.
  143612. * @returns the current time step
  143613. */
  143614. getTimeStep(): number;
  143615. /**
  143616. * Set the sub time step of the physics engine.
  143617. * Default is 0 meaning there is no sub steps
  143618. * To increase physics resolution precision, set a small value (like 1 ms)
  143619. * @param subTimeStep defines the new sub timestep used for physics resolution.
  143620. */
  143621. setSubTimeStep(subTimeStep?: number): void;
  143622. /**
  143623. * Get the sub time step of the physics engine.
  143624. * @returns the current sub time step
  143625. */
  143626. getSubTimeStep(): number;
  143627. /**
  143628. * Release all resources
  143629. */
  143630. dispose(): void;
  143631. /**
  143632. * Gets the name of the current physics plugin
  143633. * @returns the name of the plugin
  143634. */
  143635. getPhysicsPluginName(): string;
  143636. /**
  143637. * Adding a new impostor for the impostor tracking.
  143638. * This will be done by the impostor itself.
  143639. * @param impostor the impostor to add
  143640. */
  143641. addImpostor(impostor: PhysicsImpostor): void;
  143642. /**
  143643. * Remove an impostor from the engine.
  143644. * This impostor and its mesh will not longer be updated by the physics engine.
  143645. * @param impostor the impostor to remove
  143646. */
  143647. removeImpostor(impostor: PhysicsImpostor): void;
  143648. /**
  143649. * Add a joint to the physics engine
  143650. * @param mainImpostor defines the main impostor to which the joint is added.
  143651. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  143652. * @param joint defines the joint that will connect both impostors.
  143653. */
  143654. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  143655. /**
  143656. * Removes a joint from the simulation
  143657. * @param mainImpostor defines the impostor used with the joint
  143658. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  143659. * @param joint defines the joint to remove
  143660. */
  143661. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  143662. /**
  143663. * Called by the scene. No need to call it.
  143664. * @param delta defines the timespam between frames
  143665. */
  143666. _step(delta: number): void;
  143667. /**
  143668. * Gets the current plugin used to run the simulation
  143669. * @returns current plugin
  143670. */
  143671. getPhysicsPlugin(): IPhysicsEnginePlugin;
  143672. /**
  143673. * Gets the list of physic impostors
  143674. * @returns an array of PhysicsImpostor
  143675. */
  143676. getImpostors(): Array<PhysicsImpostor>;
  143677. /**
  143678. * Gets the impostor for a physics enabled object
  143679. * @param object defines the object impersonated by the impostor
  143680. * @returns the PhysicsImpostor or null if not found
  143681. */
  143682. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  143683. /**
  143684. * Gets the impostor for a physics body object
  143685. * @param body defines physics body used by the impostor
  143686. * @returns the PhysicsImpostor or null if not found
  143687. */
  143688. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  143689. /**
  143690. * Does a raycast in the physics world
  143691. * @param from when should the ray start?
  143692. * @param to when should the ray end?
  143693. * @returns PhysicsRaycastResult
  143694. */
  143695. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143696. }
  143697. }
  143698. declare module BABYLON {
  143699. /** @hidden */
  143700. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  143701. private _useDeltaForWorldStep;
  143702. world: any;
  143703. name: string;
  143704. private _physicsMaterials;
  143705. private _fixedTimeStep;
  143706. private _cannonRaycastResult;
  143707. private _raycastResult;
  143708. private _physicsBodysToRemoveAfterStep;
  143709. private _firstFrame;
  143710. BJSCANNON: any;
  143711. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  143712. setGravity(gravity: Vector3): void;
  143713. setTimeStep(timeStep: number): void;
  143714. getTimeStep(): number;
  143715. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143716. private _removeMarkedPhysicsBodiesFromWorld;
  143717. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143718. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143719. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143720. private _processChildMeshes;
  143721. removePhysicsBody(impostor: PhysicsImpostor): void;
  143722. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143723. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143724. private _addMaterial;
  143725. private _checkWithEpsilon;
  143726. private _createShape;
  143727. private _createHeightmap;
  143728. private _minus90X;
  143729. private _plus90X;
  143730. private _tmpPosition;
  143731. private _tmpDeltaPosition;
  143732. private _tmpUnityRotation;
  143733. private _updatePhysicsBodyTransformation;
  143734. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143735. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143736. isSupported(): boolean;
  143737. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143738. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143739. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143740. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143741. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143742. getBodyMass(impostor: PhysicsImpostor): number;
  143743. getBodyFriction(impostor: PhysicsImpostor): number;
  143744. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143745. getBodyRestitution(impostor: PhysicsImpostor): number;
  143746. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143747. sleepBody(impostor: PhysicsImpostor): void;
  143748. wakeUpBody(impostor: PhysicsImpostor): void;
  143749. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  143750. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  143751. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  143752. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143753. getRadius(impostor: PhysicsImpostor): number;
  143754. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143755. dispose(): void;
  143756. private _extendNamespace;
  143757. /**
  143758. * Does a raycast in the physics world
  143759. * @param from when should the ray start?
  143760. * @param to when should the ray end?
  143761. * @returns PhysicsRaycastResult
  143762. */
  143763. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143764. }
  143765. }
  143766. declare module BABYLON {
  143767. /** @hidden */
  143768. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  143769. private _useDeltaForWorldStep;
  143770. world: any;
  143771. name: string;
  143772. BJSOIMO: any;
  143773. private _raycastResult;
  143774. private _fixedTimeStep;
  143775. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  143776. setGravity(gravity: Vector3): void;
  143777. setTimeStep(timeStep: number): void;
  143778. getTimeStep(): number;
  143779. private _tmpImpostorsArray;
  143780. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143781. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143782. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143783. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143784. private _tmpPositionVector;
  143785. removePhysicsBody(impostor: PhysicsImpostor): void;
  143786. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143787. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143788. isSupported(): boolean;
  143789. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143790. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143791. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143792. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143793. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143794. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143795. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143796. getBodyMass(impostor: PhysicsImpostor): number;
  143797. getBodyFriction(impostor: PhysicsImpostor): number;
  143798. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143799. getBodyRestitution(impostor: PhysicsImpostor): number;
  143800. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143801. sleepBody(impostor: PhysicsImpostor): void;
  143802. wakeUpBody(impostor: PhysicsImpostor): void;
  143803. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  143804. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  143805. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  143806. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143807. getRadius(impostor: PhysicsImpostor): number;
  143808. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143809. dispose(): void;
  143810. /**
  143811. * Does a raycast in the physics world
  143812. * @param from when should the ray start?
  143813. * @param to when should the ray end?
  143814. * @returns PhysicsRaycastResult
  143815. */
  143816. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143817. }
  143818. }
  143819. declare module BABYLON {
  143820. /**
  143821. * AmmoJS Physics plugin
  143822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  143823. * @see https://github.com/kripken/ammo.js/
  143824. */
  143825. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  143826. private _useDeltaForWorldStep;
  143827. /**
  143828. * Reference to the Ammo library
  143829. */
  143830. bjsAMMO: any;
  143831. /**
  143832. * Created ammoJS world which physics bodies are added to
  143833. */
  143834. world: any;
  143835. /**
  143836. * Name of the plugin
  143837. */
  143838. name: string;
  143839. private _timeStep;
  143840. private _fixedTimeStep;
  143841. private _maxSteps;
  143842. private _tmpQuaternion;
  143843. private _tmpAmmoTransform;
  143844. private _tmpAmmoQuaternion;
  143845. private _tmpAmmoConcreteContactResultCallback;
  143846. private _collisionConfiguration;
  143847. private _dispatcher;
  143848. private _overlappingPairCache;
  143849. private _solver;
  143850. private _softBodySolver;
  143851. private _tmpAmmoVectorA;
  143852. private _tmpAmmoVectorB;
  143853. private _tmpAmmoVectorC;
  143854. private _tmpAmmoVectorD;
  143855. private _tmpContactCallbackResult;
  143856. private _tmpAmmoVectorRCA;
  143857. private _tmpAmmoVectorRCB;
  143858. private _raycastResult;
  143859. private _tmpContactPoint;
  143860. private static readonly DISABLE_COLLISION_FLAG;
  143861. private static readonly KINEMATIC_FLAG;
  143862. private static readonly DISABLE_DEACTIVATION_FLAG;
  143863. /**
  143864. * Initializes the ammoJS plugin
  143865. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  143866. * @param ammoInjection can be used to inject your own ammo reference
  143867. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  143868. */
  143869. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  143870. /**
  143871. * Sets the gravity of the physics world (m/(s^2))
  143872. * @param gravity Gravity to set
  143873. */
  143874. setGravity(gravity: Vector3): void;
  143875. /**
  143876. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  143877. * @param timeStep timestep to use in seconds
  143878. */
  143879. setTimeStep(timeStep: number): void;
  143880. /**
  143881. * 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)
  143882. * @param fixedTimeStep fixedTimeStep to use in seconds
  143883. */
  143884. setFixedTimeStep(fixedTimeStep: number): void;
  143885. /**
  143886. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  143887. * @param maxSteps the maximum number of steps by the physics engine per frame
  143888. */
  143889. setMaxSteps(maxSteps: number): void;
  143890. /**
  143891. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  143892. * @returns the current timestep in seconds
  143893. */
  143894. getTimeStep(): number;
  143895. /**
  143896. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  143897. */
  143898. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  143899. private _isImpostorInContact;
  143900. private _isImpostorPairInContact;
  143901. private _stepSimulation;
  143902. /**
  143903. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  143904. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  143905. * After the step the babylon meshes are set to the position of the physics imposters
  143906. * @param delta amount of time to step forward
  143907. * @param impostors array of imposters to update before/after the step
  143908. */
  143909. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143910. /**
  143911. * Update babylon mesh to match physics world object
  143912. * @param impostor imposter to match
  143913. */
  143914. private _afterSoftStep;
  143915. /**
  143916. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  143917. * @param impostor imposter to match
  143918. */
  143919. private _ropeStep;
  143920. /**
  143921. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  143922. * @param impostor imposter to match
  143923. */
  143924. private _softbodyOrClothStep;
  143925. private _tmpMatrix;
  143926. /**
  143927. * Applies an impulse on the imposter
  143928. * @param impostor imposter to apply impulse to
  143929. * @param force amount of force to be applied to the imposter
  143930. * @param contactPoint the location to apply the impulse on the imposter
  143931. */
  143932. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143933. /**
  143934. * Applies a force on the imposter
  143935. * @param impostor imposter to apply force
  143936. * @param force amount of force to be applied to the imposter
  143937. * @param contactPoint the location to apply the force on the imposter
  143938. */
  143939. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143940. /**
  143941. * Creates a physics body using the plugin
  143942. * @param impostor the imposter to create the physics body on
  143943. */
  143944. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143945. /**
  143946. * Removes the physics body from the imposter and disposes of the body's memory
  143947. * @param impostor imposter to remove the physics body from
  143948. */
  143949. removePhysicsBody(impostor: PhysicsImpostor): void;
  143950. /**
  143951. * Generates a joint
  143952. * @param impostorJoint the imposter joint to create the joint with
  143953. */
  143954. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143955. /**
  143956. * Removes a joint
  143957. * @param impostorJoint the imposter joint to remove the joint from
  143958. */
  143959. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143960. private _addMeshVerts;
  143961. /**
  143962. * Initialise the soft body vertices to match its object's (mesh) vertices
  143963. * Softbody vertices (nodes) are in world space and to match this
  143964. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  143965. * @param impostor to create the softbody for
  143966. */
  143967. private _softVertexData;
  143968. /**
  143969. * Create an impostor's soft body
  143970. * @param impostor to create the softbody for
  143971. */
  143972. private _createSoftbody;
  143973. /**
  143974. * Create cloth for an impostor
  143975. * @param impostor to create the softbody for
  143976. */
  143977. private _createCloth;
  143978. /**
  143979. * Create rope for an impostor
  143980. * @param impostor to create the softbody for
  143981. */
  143982. private _createRope;
  143983. /**
  143984. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  143985. * @param impostor to create the custom physics shape for
  143986. */
  143987. private _createCustom;
  143988. private _addHullVerts;
  143989. private _createShape;
  143990. /**
  143991. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  143992. * @param impostor imposter containing the physics body and babylon object
  143993. */
  143994. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143995. /**
  143996. * Sets the babylon object's position/rotation from the physics body's position/rotation
  143997. * @param impostor imposter containing the physics body and babylon object
  143998. * @param newPosition new position
  143999. * @param newRotation new rotation
  144000. */
  144001. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  144002. /**
  144003. * If this plugin is supported
  144004. * @returns true if its supported
  144005. */
  144006. isSupported(): boolean;
  144007. /**
  144008. * Sets the linear velocity of the physics body
  144009. * @param impostor imposter to set the velocity on
  144010. * @param velocity velocity to set
  144011. */
  144012. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  144013. /**
  144014. * Sets the angular velocity of the physics body
  144015. * @param impostor imposter to set the velocity on
  144016. * @param velocity velocity to set
  144017. */
  144018. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  144019. /**
  144020. * gets the linear velocity
  144021. * @param impostor imposter to get linear velocity from
  144022. * @returns linear velocity
  144023. */
  144024. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  144025. /**
  144026. * gets the angular velocity
  144027. * @param impostor imposter to get angular velocity from
  144028. * @returns angular velocity
  144029. */
  144030. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  144031. /**
  144032. * Sets the mass of physics body
  144033. * @param impostor imposter to set the mass on
  144034. * @param mass mass to set
  144035. */
  144036. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  144037. /**
  144038. * Gets the mass of the physics body
  144039. * @param impostor imposter to get the mass from
  144040. * @returns mass
  144041. */
  144042. getBodyMass(impostor: PhysicsImpostor): number;
  144043. /**
  144044. * Gets friction of the impostor
  144045. * @param impostor impostor to get friction from
  144046. * @returns friction value
  144047. */
  144048. getBodyFriction(impostor: PhysicsImpostor): number;
  144049. /**
  144050. * Sets friction of the impostor
  144051. * @param impostor impostor to set friction on
  144052. * @param friction friction value
  144053. */
  144054. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  144055. /**
  144056. * Gets restitution of the impostor
  144057. * @param impostor impostor to get restitution from
  144058. * @returns restitution value
  144059. */
  144060. getBodyRestitution(impostor: PhysicsImpostor): number;
  144061. /**
  144062. * Sets resitution of the impostor
  144063. * @param impostor impostor to set resitution on
  144064. * @param restitution resitution value
  144065. */
  144066. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  144067. /**
  144068. * Gets pressure inside the impostor
  144069. * @param impostor impostor to get pressure from
  144070. * @returns pressure value
  144071. */
  144072. getBodyPressure(impostor: PhysicsImpostor): number;
  144073. /**
  144074. * Sets pressure inside a soft body impostor
  144075. * Cloth and rope must remain 0 pressure
  144076. * @param impostor impostor to set pressure on
  144077. * @param pressure pressure value
  144078. */
  144079. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  144080. /**
  144081. * Gets stiffness of the impostor
  144082. * @param impostor impostor to get stiffness from
  144083. * @returns pressure value
  144084. */
  144085. getBodyStiffness(impostor: PhysicsImpostor): number;
  144086. /**
  144087. * Sets stiffness of the impostor
  144088. * @param impostor impostor to set stiffness on
  144089. * @param stiffness stiffness value from 0 to 1
  144090. */
  144091. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  144092. /**
  144093. * Gets velocityIterations of the impostor
  144094. * @param impostor impostor to get velocity iterations from
  144095. * @returns velocityIterations value
  144096. */
  144097. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  144098. /**
  144099. * Sets velocityIterations of the impostor
  144100. * @param impostor impostor to set velocity iterations on
  144101. * @param velocityIterations velocityIterations value
  144102. */
  144103. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  144104. /**
  144105. * Gets positionIterations of the impostor
  144106. * @param impostor impostor to get position iterations from
  144107. * @returns positionIterations value
  144108. */
  144109. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  144110. /**
  144111. * Sets positionIterations of the impostor
  144112. * @param impostor impostor to set position on
  144113. * @param positionIterations positionIterations value
  144114. */
  144115. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  144116. /**
  144117. * Append an anchor to a cloth object
  144118. * @param impostor is the cloth impostor to add anchor to
  144119. * @param otherImpostor is the rigid impostor to anchor to
  144120. * @param width ratio across width from 0 to 1
  144121. * @param height ratio up height from 0 to 1
  144122. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  144123. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  144124. */
  144125. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  144126. /**
  144127. * Append an hook to a rope object
  144128. * @param impostor is the rope impostor to add hook to
  144129. * @param otherImpostor is the rigid impostor to hook to
  144130. * @param length ratio along the rope from 0 to 1
  144131. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  144132. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  144133. */
  144134. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  144135. /**
  144136. * Sleeps the physics body and stops it from being active
  144137. * @param impostor impostor to sleep
  144138. */
  144139. sleepBody(impostor: PhysicsImpostor): void;
  144140. /**
  144141. * Activates the physics body
  144142. * @param impostor impostor to activate
  144143. */
  144144. wakeUpBody(impostor: PhysicsImpostor): void;
  144145. /**
  144146. * Updates the distance parameters of the joint
  144147. * @param joint joint to update
  144148. * @param maxDistance maximum distance of the joint
  144149. * @param minDistance minimum distance of the joint
  144150. */
  144151. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  144152. /**
  144153. * Sets a motor on the joint
  144154. * @param joint joint to set motor on
  144155. * @param speed speed of the motor
  144156. * @param maxForce maximum force of the motor
  144157. * @param motorIndex index of the motor
  144158. */
  144159. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  144160. /**
  144161. * Sets the motors limit
  144162. * @param joint joint to set limit on
  144163. * @param upperLimit upper limit
  144164. * @param lowerLimit lower limit
  144165. */
  144166. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  144167. /**
  144168. * Syncs the position and rotation of a mesh with the impostor
  144169. * @param mesh mesh to sync
  144170. * @param impostor impostor to update the mesh with
  144171. */
  144172. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  144173. /**
  144174. * Gets the radius of the impostor
  144175. * @param impostor impostor to get radius from
  144176. * @returns the radius
  144177. */
  144178. getRadius(impostor: PhysicsImpostor): number;
  144179. /**
  144180. * Gets the box size of the impostor
  144181. * @param impostor impostor to get box size from
  144182. * @param result the resulting box size
  144183. */
  144184. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  144185. /**
  144186. * Disposes of the impostor
  144187. */
  144188. dispose(): void;
  144189. /**
  144190. * Does a raycast in the physics world
  144191. * @param from when should the ray start?
  144192. * @param to when should the ray end?
  144193. * @returns PhysicsRaycastResult
  144194. */
  144195. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  144196. }
  144197. }
  144198. declare module BABYLON {
  144199. interface AbstractScene {
  144200. /**
  144201. * The list of reflection probes added to the scene
  144202. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  144203. */
  144204. reflectionProbes: Array<ReflectionProbe>;
  144205. /**
  144206. * Removes the given reflection probe from this scene.
  144207. * @param toRemove The reflection probe to remove
  144208. * @returns The index of the removed reflection probe
  144209. */
  144210. removeReflectionProbe(toRemove: ReflectionProbe): number;
  144211. /**
  144212. * Adds the given reflection probe to this scene.
  144213. * @param newReflectionProbe The reflection probe to add
  144214. */
  144215. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  144216. }
  144217. /**
  144218. * Class used to generate realtime reflection / refraction cube textures
  144219. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  144220. */
  144221. export class ReflectionProbe {
  144222. /** defines the name of the probe */
  144223. name: string;
  144224. private _scene;
  144225. private _renderTargetTexture;
  144226. private _projectionMatrix;
  144227. private _viewMatrix;
  144228. private _target;
  144229. private _add;
  144230. private _attachedMesh;
  144231. private _invertYAxis;
  144232. /** Gets or sets probe position (center of the cube map) */
  144233. position: Vector3;
  144234. /**
  144235. * Creates a new reflection probe
  144236. * @param name defines the name of the probe
  144237. * @param size defines the texture resolution (for each face)
  144238. * @param scene defines the hosting scene
  144239. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  144240. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  144241. */
  144242. constructor(
  144243. /** defines the name of the probe */
  144244. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  144245. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  144246. get samples(): number;
  144247. set samples(value: number);
  144248. /** Gets or sets the refresh rate to use (on every frame by default) */
  144249. get refreshRate(): number;
  144250. set refreshRate(value: number);
  144251. /**
  144252. * Gets the hosting scene
  144253. * @returns a Scene
  144254. */
  144255. getScene(): Scene;
  144256. /** Gets the internal CubeTexture used to render to */
  144257. get cubeTexture(): RenderTargetTexture;
  144258. /** Gets the list of meshes to render */
  144259. get renderList(): Nullable<AbstractMesh[]>;
  144260. /**
  144261. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  144262. * @param mesh defines the mesh to attach to
  144263. */
  144264. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  144265. /**
  144266. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  144267. * @param renderingGroupId The rendering group id corresponding to its index
  144268. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  144269. */
  144270. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  144271. /**
  144272. * Clean all associated resources
  144273. */
  144274. dispose(): void;
  144275. /**
  144276. * Converts the reflection probe information to a readable string for debug purpose.
  144277. * @param fullDetails Supports for multiple levels of logging within scene loading
  144278. * @returns the human readable reflection probe info
  144279. */
  144280. toString(fullDetails?: boolean): string;
  144281. /**
  144282. * Get the class name of the relfection probe.
  144283. * @returns "ReflectionProbe"
  144284. */
  144285. getClassName(): string;
  144286. /**
  144287. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  144288. * @returns The JSON representation of the texture
  144289. */
  144290. serialize(): any;
  144291. /**
  144292. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  144293. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  144294. * @param scene Define the scene the parsed reflection probe should be instantiated in
  144295. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  144296. * @returns The parsed reflection probe if successful
  144297. */
  144298. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  144299. }
  144300. }
  144301. declare module BABYLON {
  144302. /** @hidden */
  144303. export var _BabylonLoaderRegistered: boolean;
  144304. /**
  144305. * Helps setting up some configuration for the babylon file loader.
  144306. */
  144307. export class BabylonFileLoaderConfiguration {
  144308. /**
  144309. * The loader does not allow injecting custom physix engine into the plugins.
  144310. * Unfortunately in ES6, we need to manually inject them into the plugin.
  144311. * So you could set this variable to your engine import to make it work.
  144312. */
  144313. static LoaderInjectedPhysicsEngine: any;
  144314. }
  144315. }
  144316. declare module BABYLON {
  144317. /**
  144318. * The Physically based simple base material of BJS.
  144319. *
  144320. * This enables better naming and convention enforcements on top of the pbrMaterial.
  144321. * It is used as the base class for both the specGloss and metalRough conventions.
  144322. */
  144323. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  144324. /**
  144325. * Number of Simultaneous lights allowed on the material.
  144326. */
  144327. maxSimultaneousLights: number;
  144328. /**
  144329. * If sets to true, disables all the lights affecting the material.
  144330. */
  144331. disableLighting: boolean;
  144332. /**
  144333. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  144334. */
  144335. environmentTexture: BaseTexture;
  144336. /**
  144337. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  144338. */
  144339. invertNormalMapX: boolean;
  144340. /**
  144341. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  144342. */
  144343. invertNormalMapY: boolean;
  144344. /**
  144345. * Normal map used in the model.
  144346. */
  144347. normalTexture: BaseTexture;
  144348. /**
  144349. * Emissivie color used to self-illuminate the model.
  144350. */
  144351. emissiveColor: Color3;
  144352. /**
  144353. * Emissivie texture used to self-illuminate the model.
  144354. */
  144355. emissiveTexture: BaseTexture;
  144356. /**
  144357. * Occlusion Channel Strenght.
  144358. */
  144359. occlusionStrength: number;
  144360. /**
  144361. * Occlusion Texture of the material (adding extra occlusion effects).
  144362. */
  144363. occlusionTexture: BaseTexture;
  144364. /**
  144365. * Defines the alpha limits in alpha test mode.
  144366. */
  144367. alphaCutOff: number;
  144368. /**
  144369. * Gets the current double sided mode.
  144370. */
  144371. get doubleSided(): boolean;
  144372. /**
  144373. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  144374. */
  144375. set doubleSided(value: boolean);
  144376. /**
  144377. * Stores the pre-calculated light information of a mesh in a texture.
  144378. */
  144379. lightmapTexture: BaseTexture;
  144380. /**
  144381. * If true, the light map contains occlusion information instead of lighting info.
  144382. */
  144383. useLightmapAsShadowmap: boolean;
  144384. /**
  144385. * Instantiates a new PBRMaterial instance.
  144386. *
  144387. * @param name The material name
  144388. * @param scene The scene the material will be use in.
  144389. */
  144390. constructor(name: string, scene: Scene);
  144391. getClassName(): string;
  144392. }
  144393. }
  144394. declare module BABYLON {
  144395. /**
  144396. * The PBR material of BJS following the metal roughness convention.
  144397. *
  144398. * This fits to the PBR convention in the GLTF definition:
  144399. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  144400. */
  144401. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  144402. /**
  144403. * The base color has two different interpretations depending on the value of metalness.
  144404. * When the material is a metal, the base color is the specific measured reflectance value
  144405. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  144406. * of the material.
  144407. */
  144408. baseColor: Color3;
  144409. /**
  144410. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  144411. * well as opacity information in the alpha channel.
  144412. */
  144413. baseTexture: BaseTexture;
  144414. /**
  144415. * Specifies the metallic scalar value of the material.
  144416. * Can also be used to scale the metalness values of the metallic texture.
  144417. */
  144418. metallic: number;
  144419. /**
  144420. * Specifies the roughness scalar value of the material.
  144421. * Can also be used to scale the roughness values of the metallic texture.
  144422. */
  144423. roughness: number;
  144424. /**
  144425. * Texture containing both the metallic value in the B channel and the
  144426. * roughness value in the G channel to keep better precision.
  144427. */
  144428. metallicRoughnessTexture: BaseTexture;
  144429. /**
  144430. * Instantiates a new PBRMetalRoughnessMaterial instance.
  144431. *
  144432. * @param name The material name
  144433. * @param scene The scene the material will be use in.
  144434. */
  144435. constructor(name: string, scene: Scene);
  144436. /**
  144437. * Return the currrent class name of the material.
  144438. */
  144439. getClassName(): string;
  144440. /**
  144441. * Makes a duplicate of the current material.
  144442. * @param name - name to use for the new material.
  144443. */
  144444. clone(name: string): PBRMetallicRoughnessMaterial;
  144445. /**
  144446. * Serialize the material to a parsable JSON object.
  144447. */
  144448. serialize(): any;
  144449. /**
  144450. * Parses a JSON object correponding to the serialize function.
  144451. */
  144452. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  144453. }
  144454. }
  144455. declare module BABYLON {
  144456. /**
  144457. * The PBR material of BJS following the specular glossiness convention.
  144458. *
  144459. * This fits to the PBR convention in the GLTF definition:
  144460. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  144461. */
  144462. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  144463. /**
  144464. * Specifies the diffuse color of the material.
  144465. */
  144466. diffuseColor: Color3;
  144467. /**
  144468. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  144469. * channel.
  144470. */
  144471. diffuseTexture: BaseTexture;
  144472. /**
  144473. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  144474. */
  144475. specularColor: Color3;
  144476. /**
  144477. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  144478. */
  144479. glossiness: number;
  144480. /**
  144481. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  144482. */
  144483. specularGlossinessTexture: BaseTexture;
  144484. /**
  144485. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  144486. *
  144487. * @param name The material name
  144488. * @param scene The scene the material will be use in.
  144489. */
  144490. constructor(name: string, scene: Scene);
  144491. /**
  144492. * Return the currrent class name of the material.
  144493. */
  144494. getClassName(): string;
  144495. /**
  144496. * Makes a duplicate of the current material.
  144497. * @param name - name to use for the new material.
  144498. */
  144499. clone(name: string): PBRSpecularGlossinessMaterial;
  144500. /**
  144501. * Serialize the material to a parsable JSON object.
  144502. */
  144503. serialize(): any;
  144504. /**
  144505. * Parses a JSON object correponding to the serialize function.
  144506. */
  144507. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  144508. }
  144509. }
  144510. declare module BABYLON {
  144511. /**
  144512. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  144513. * It can help converting any input color in a desired output one. This can then be used to create effects
  144514. * from sepia, black and white to sixties or futuristic rendering...
  144515. *
  144516. * The only supported format is currently 3dl.
  144517. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  144518. */
  144519. export class ColorGradingTexture extends BaseTexture {
  144520. /**
  144521. * The texture URL.
  144522. */
  144523. url: string;
  144524. /**
  144525. * Empty line regex stored for GC.
  144526. */
  144527. private static _noneEmptyLineRegex;
  144528. private _textureMatrix;
  144529. private _onLoad;
  144530. /**
  144531. * Instantiates a ColorGradingTexture from the following parameters.
  144532. *
  144533. * @param url The location of the color gradind data (currently only supporting 3dl)
  144534. * @param sceneOrEngine The scene or engine the texture will be used in
  144535. * @param onLoad defines a callback triggered when the texture has been loaded
  144536. */
  144537. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  144538. /**
  144539. * Fires the onload event from the constructor if requested.
  144540. */
  144541. private _triggerOnLoad;
  144542. /**
  144543. * Returns the texture matrix used in most of the material.
  144544. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  144545. */
  144546. getTextureMatrix(): Matrix;
  144547. /**
  144548. * Occurs when the file being loaded is a .3dl LUT file.
  144549. */
  144550. private load3dlTexture;
  144551. /**
  144552. * Starts the loading process of the texture.
  144553. */
  144554. private loadTexture;
  144555. /**
  144556. * Clones the color gradind texture.
  144557. */
  144558. clone(): ColorGradingTexture;
  144559. /**
  144560. * Called during delayed load for textures.
  144561. */
  144562. delayLoad(): void;
  144563. /**
  144564. * Parses a color grading texture serialized by Babylon.
  144565. * @param parsedTexture The texture information being parsedTexture
  144566. * @param scene The scene to load the texture in
  144567. * @param rootUrl The root url of the data assets to load
  144568. * @return A color gradind texture
  144569. */
  144570. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  144571. /**
  144572. * Serializes the LUT texture to json format.
  144573. */
  144574. serialize(): any;
  144575. }
  144576. }
  144577. declare module BABYLON {
  144578. /**
  144579. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  144580. */
  144581. export class EquiRectangularCubeTexture extends BaseTexture {
  144582. /** The six faces of the cube. */
  144583. private static _FacesMapping;
  144584. private _noMipmap;
  144585. private _onLoad;
  144586. private _onError;
  144587. /** The size of the cubemap. */
  144588. private _size;
  144589. /** The buffer of the image. */
  144590. private _buffer;
  144591. /** The width of the input image. */
  144592. private _width;
  144593. /** The height of the input image. */
  144594. private _height;
  144595. /** The URL to the image. */
  144596. url: string;
  144597. /**
  144598. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  144599. * @param url The location of the image
  144600. * @param scene The scene the texture will be used in
  144601. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  144602. * @param noMipmap Forces to not generate the mipmap if true
  144603. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  144604. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  144605. * @param onLoad — defines a callback called when texture is loaded
  144606. * @param onError — defines a callback called if there is an error
  144607. */
  144608. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  144609. /**
  144610. * Load the image data, by putting the image on a canvas and extracting its buffer.
  144611. */
  144612. private loadImage;
  144613. /**
  144614. * Convert the image buffer into a cubemap and create a CubeTexture.
  144615. */
  144616. private loadTexture;
  144617. /**
  144618. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  144619. * @param buffer The ArrayBuffer that should be converted.
  144620. * @returns The buffer as Float32Array.
  144621. */
  144622. private getFloat32ArrayFromArrayBuffer;
  144623. /**
  144624. * Get the current class name of the texture useful for serialization or dynamic coding.
  144625. * @returns "EquiRectangularCubeTexture"
  144626. */
  144627. getClassName(): string;
  144628. /**
  144629. * Create a clone of the current EquiRectangularCubeTexture and return it.
  144630. * @returns A clone of the current EquiRectangularCubeTexture.
  144631. */
  144632. clone(): EquiRectangularCubeTexture;
  144633. }
  144634. }
  144635. declare module BABYLON {
  144636. /**
  144637. * Defines the options related to the creation of an HtmlElementTexture
  144638. */
  144639. export interface IHtmlElementTextureOptions {
  144640. /**
  144641. * Defines wether mip maps should be created or not.
  144642. */
  144643. generateMipMaps?: boolean;
  144644. /**
  144645. * Defines the sampling mode of the texture.
  144646. */
  144647. samplingMode?: number;
  144648. /**
  144649. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  144650. */
  144651. engine: Nullable<ThinEngine>;
  144652. /**
  144653. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  144654. */
  144655. scene: Nullable<Scene>;
  144656. }
  144657. /**
  144658. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  144659. * To be as efficient as possible depending on your constraints nothing aside the first upload
  144660. * is automatically managed.
  144661. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  144662. * in your application.
  144663. *
  144664. * As the update is not automatic, you need to call them manually.
  144665. */
  144666. export class HtmlElementTexture extends BaseTexture {
  144667. /**
  144668. * The texture URL.
  144669. */
  144670. element: HTMLVideoElement | HTMLCanvasElement;
  144671. private static readonly DefaultOptions;
  144672. private _textureMatrix;
  144673. private _isVideo;
  144674. private _generateMipMaps;
  144675. private _samplingMode;
  144676. /**
  144677. * Instantiates a HtmlElementTexture from the following parameters.
  144678. *
  144679. * @param name Defines the name of the texture
  144680. * @param element Defines the video or canvas the texture is filled with
  144681. * @param options Defines the other none mandatory texture creation options
  144682. */
  144683. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  144684. private _createInternalTexture;
  144685. /**
  144686. * Returns the texture matrix used in most of the material.
  144687. */
  144688. getTextureMatrix(): Matrix;
  144689. /**
  144690. * Updates the content of the texture.
  144691. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  144692. */
  144693. update(invertY?: Nullable<boolean>): void;
  144694. }
  144695. }
  144696. declare module BABYLON {
  144697. /**
  144698. * Based on jsTGALoader - Javascript loader for TGA file
  144699. * By Vincent Thibault
  144700. * @see http://blog.robrowser.com/javascript-tga-loader.html
  144701. */
  144702. export class TGATools {
  144703. private static _TYPE_INDEXED;
  144704. private static _TYPE_RGB;
  144705. private static _TYPE_GREY;
  144706. private static _TYPE_RLE_INDEXED;
  144707. private static _TYPE_RLE_RGB;
  144708. private static _TYPE_RLE_GREY;
  144709. private static _ORIGIN_MASK;
  144710. private static _ORIGIN_SHIFT;
  144711. private static _ORIGIN_BL;
  144712. private static _ORIGIN_BR;
  144713. private static _ORIGIN_UL;
  144714. private static _ORIGIN_UR;
  144715. /**
  144716. * Gets the header of a TGA file
  144717. * @param data defines the TGA data
  144718. * @returns the header
  144719. */
  144720. static GetTGAHeader(data: Uint8Array): any;
  144721. /**
  144722. * Uploads TGA content to a Babylon Texture
  144723. * @hidden
  144724. */
  144725. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  144726. /** @hidden */
  144727. 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;
  144728. /** @hidden */
  144729. 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;
  144730. /** @hidden */
  144731. 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;
  144732. /** @hidden */
  144733. 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;
  144734. /** @hidden */
  144735. 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;
  144736. /** @hidden */
  144737. 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;
  144738. }
  144739. }
  144740. declare module BABYLON {
  144741. /**
  144742. * Implementation of the TGA Texture Loader.
  144743. * @hidden
  144744. */
  144745. export class _TGATextureLoader implements IInternalTextureLoader {
  144746. /**
  144747. * Defines wether the loader supports cascade loading the different faces.
  144748. */
  144749. readonly supportCascades: boolean;
  144750. /**
  144751. * This returns if the loader support the current file information.
  144752. * @param extension defines the file extension of the file being loaded
  144753. * @returns true if the loader can load the specified file
  144754. */
  144755. canLoad(extension: string): boolean;
  144756. /**
  144757. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  144758. * @param data contains the texture data
  144759. * @param texture defines the BabylonJS internal texture
  144760. * @param createPolynomials will be true if polynomials have been requested
  144761. * @param onLoad defines the callback to trigger once the texture is ready
  144762. * @param onError defines the callback to trigger in case of error
  144763. */
  144764. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  144765. /**
  144766. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  144767. * @param data contains the texture data
  144768. * @param texture defines the BabylonJS internal texture
  144769. * @param callback defines the method to call once ready to upload
  144770. */
  144771. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  144772. }
  144773. }
  144774. declare module BABYLON {
  144775. /**
  144776. * Info about the .basis files
  144777. */
  144778. class BasisFileInfo {
  144779. /**
  144780. * If the file has alpha
  144781. */
  144782. hasAlpha: boolean;
  144783. /**
  144784. * Info about each image of the basis file
  144785. */
  144786. images: Array<{
  144787. levels: Array<{
  144788. width: number;
  144789. height: number;
  144790. transcodedPixels: ArrayBufferView;
  144791. }>;
  144792. }>;
  144793. }
  144794. /**
  144795. * Result of transcoding a basis file
  144796. */
  144797. class TranscodeResult {
  144798. /**
  144799. * Info about the .basis file
  144800. */
  144801. fileInfo: BasisFileInfo;
  144802. /**
  144803. * Format to use when loading the file
  144804. */
  144805. format: number;
  144806. }
  144807. /**
  144808. * Configuration options for the Basis transcoder
  144809. */
  144810. export class BasisTranscodeConfiguration {
  144811. /**
  144812. * Supported compression formats used to determine the supported output format of the transcoder
  144813. */
  144814. supportedCompressionFormats?: {
  144815. /**
  144816. * etc1 compression format
  144817. */
  144818. etc1?: boolean;
  144819. /**
  144820. * s3tc compression format
  144821. */
  144822. s3tc?: boolean;
  144823. /**
  144824. * pvrtc compression format
  144825. */
  144826. pvrtc?: boolean;
  144827. /**
  144828. * etc2 compression format
  144829. */
  144830. etc2?: boolean;
  144831. };
  144832. /**
  144833. * If mipmap levels should be loaded for transcoded images (Default: true)
  144834. */
  144835. loadMipmapLevels?: boolean;
  144836. /**
  144837. * Index of a single image to load (Default: all images)
  144838. */
  144839. loadSingleImage?: number;
  144840. }
  144841. /**
  144842. * Used to load .Basis files
  144843. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  144844. */
  144845. export class BasisTools {
  144846. private static _IgnoreSupportedFormats;
  144847. /**
  144848. * URL to use when loading the basis transcoder
  144849. */
  144850. static JSModuleURL: string;
  144851. /**
  144852. * URL to use when loading the wasm module for the transcoder
  144853. */
  144854. static WasmModuleURL: string;
  144855. /**
  144856. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  144857. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  144858. * @returns internal format corresponding to the Basis format
  144859. */
  144860. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  144861. private static _WorkerPromise;
  144862. private static _Worker;
  144863. private static _actionId;
  144864. private static _CreateWorkerAsync;
  144865. /**
  144866. * Transcodes a loaded image file to compressed pixel data
  144867. * @param data image data to transcode
  144868. * @param config configuration options for the transcoding
  144869. * @returns a promise resulting in the transcoded image
  144870. */
  144871. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  144872. /**
  144873. * Loads a texture from the transcode result
  144874. * @param texture texture load to
  144875. * @param transcodeResult the result of transcoding the basis file to load from
  144876. */
  144877. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  144878. }
  144879. }
  144880. declare module BABYLON {
  144881. /**
  144882. * Loader for .basis file format
  144883. */
  144884. export class _BasisTextureLoader implements IInternalTextureLoader {
  144885. /**
  144886. * Defines whether the loader supports cascade loading the different faces.
  144887. */
  144888. readonly supportCascades: boolean;
  144889. /**
  144890. * This returns if the loader support the current file information.
  144891. * @param extension defines the file extension of the file being loaded
  144892. * @returns true if the loader can load the specified file
  144893. */
  144894. canLoad(extension: string): boolean;
  144895. /**
  144896. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  144897. * @param data contains the texture data
  144898. * @param texture defines the BabylonJS internal texture
  144899. * @param createPolynomials will be true if polynomials have been requested
  144900. * @param onLoad defines the callback to trigger once the texture is ready
  144901. * @param onError defines the callback to trigger in case of error
  144902. */
  144903. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  144904. /**
  144905. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  144906. * @param data contains the texture data
  144907. * @param texture defines the BabylonJS internal texture
  144908. * @param callback defines the method to call once ready to upload
  144909. */
  144910. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  144911. }
  144912. }
  144913. declare module BABYLON {
  144914. /**
  144915. * Defines the basic options interface of a TexturePacker Frame
  144916. */
  144917. export interface ITexturePackerFrame {
  144918. /**
  144919. * The frame ID
  144920. */
  144921. id: number;
  144922. /**
  144923. * The frames Scale
  144924. */
  144925. scale: Vector2;
  144926. /**
  144927. * The Frames offset
  144928. */
  144929. offset: Vector2;
  144930. }
  144931. /**
  144932. * This is a support class for frame Data on texture packer sets.
  144933. */
  144934. export class TexturePackerFrame implements ITexturePackerFrame {
  144935. /**
  144936. * The frame ID
  144937. */
  144938. id: number;
  144939. /**
  144940. * The frames Scale
  144941. */
  144942. scale: Vector2;
  144943. /**
  144944. * The Frames offset
  144945. */
  144946. offset: Vector2;
  144947. /**
  144948. * Initializes a texture package frame.
  144949. * @param id The numerical frame identifier
  144950. * @param scale Scalar Vector2 for UV frame
  144951. * @param offset Vector2 for the frame position in UV units.
  144952. * @returns TexturePackerFrame
  144953. */
  144954. constructor(id: number, scale: Vector2, offset: Vector2);
  144955. }
  144956. }
  144957. declare module BABYLON {
  144958. /**
  144959. * Defines the basic options interface of a TexturePacker
  144960. */
  144961. export interface ITexturePackerOptions {
  144962. /**
  144963. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  144964. */
  144965. map?: string[];
  144966. /**
  144967. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  144968. */
  144969. uvsIn?: string;
  144970. /**
  144971. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  144972. */
  144973. uvsOut?: string;
  144974. /**
  144975. * number representing the layout style. Defaults to LAYOUT_STRIP
  144976. */
  144977. layout?: number;
  144978. /**
  144979. * number of columns if using custom column count layout(2). This defaults to 4.
  144980. */
  144981. colnum?: number;
  144982. /**
  144983. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  144984. */
  144985. updateInputMeshes?: boolean;
  144986. /**
  144987. * boolean flag to dispose all the source textures. Defaults to true.
  144988. */
  144989. disposeSources?: boolean;
  144990. /**
  144991. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  144992. */
  144993. fillBlanks?: boolean;
  144994. /**
  144995. * string value representing the context fill style color. Defaults to 'black'.
  144996. */
  144997. customFillColor?: string;
  144998. /**
  144999. * Width and Height Value of each Frame in the TexturePacker Sets
  145000. */
  145001. frameSize?: number;
  145002. /**
  145003. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  145004. */
  145005. paddingRatio?: number;
  145006. /**
  145007. * Number that declares the fill method for the padding gutter.
  145008. */
  145009. paddingMode?: number;
  145010. /**
  145011. * If in SUBUV_COLOR padding mode what color to use.
  145012. */
  145013. paddingColor?: Color3 | Color4;
  145014. }
  145015. /**
  145016. * Defines the basic interface of a TexturePacker JSON File
  145017. */
  145018. export interface ITexturePackerJSON {
  145019. /**
  145020. * The frame ID
  145021. */
  145022. name: string;
  145023. /**
  145024. * The base64 channel data
  145025. */
  145026. sets: any;
  145027. /**
  145028. * The options of the Packer
  145029. */
  145030. options: ITexturePackerOptions;
  145031. /**
  145032. * The frame data of the Packer
  145033. */
  145034. frames: Array<number>;
  145035. }
  145036. /**
  145037. * This is a support class that generates a series of packed texture sets.
  145038. * @see https://doc.babylonjs.com/babylon101/materials
  145039. */
  145040. export class TexturePacker {
  145041. /** Packer Layout Constant 0 */
  145042. static readonly LAYOUT_STRIP: number;
  145043. /** Packer Layout Constant 1 */
  145044. static readonly LAYOUT_POWER2: number;
  145045. /** Packer Layout Constant 2 */
  145046. static readonly LAYOUT_COLNUM: number;
  145047. /** Packer Layout Constant 0 */
  145048. static readonly SUBUV_WRAP: number;
  145049. /** Packer Layout Constant 1 */
  145050. static readonly SUBUV_EXTEND: number;
  145051. /** Packer Layout Constant 2 */
  145052. static readonly SUBUV_COLOR: number;
  145053. /** The Name of the Texture Package */
  145054. name: string;
  145055. /** The scene scope of the TexturePacker */
  145056. scene: Scene;
  145057. /** The Meshes to target */
  145058. meshes: AbstractMesh[];
  145059. /** Arguments passed with the Constructor */
  145060. options: ITexturePackerOptions;
  145061. /** The promise that is started upon initialization */
  145062. promise: Nullable<Promise<TexturePacker | string>>;
  145063. /** The Container object for the channel sets that are generated */
  145064. sets: object;
  145065. /** The Container array for the frames that are generated */
  145066. frames: TexturePackerFrame[];
  145067. /** The expected number of textures the system is parsing. */
  145068. private _expecting;
  145069. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  145070. private _paddingValue;
  145071. /**
  145072. * Initializes a texture package series from an array of meshes or a single mesh.
  145073. * @param name The name of the package
  145074. * @param meshes The target meshes to compose the package from
  145075. * @param options The arguments that texture packer should follow while building.
  145076. * @param scene The scene which the textures are scoped to.
  145077. * @returns TexturePacker
  145078. */
  145079. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  145080. /**
  145081. * Starts the package process
  145082. * @param resolve The promises resolution function
  145083. * @returns TexturePacker
  145084. */
  145085. private _createFrames;
  145086. /**
  145087. * Calculates the Size of the Channel Sets
  145088. * @returns Vector2
  145089. */
  145090. private _calculateSize;
  145091. /**
  145092. * Calculates the UV data for the frames.
  145093. * @param baseSize the base frameSize
  145094. * @param padding the base frame padding
  145095. * @param dtSize size of the Dynamic Texture for that channel
  145096. * @param dtUnits is 1/dtSize
  145097. * @param update flag to update the input meshes
  145098. */
  145099. private _calculateMeshUVFrames;
  145100. /**
  145101. * Calculates the frames Offset.
  145102. * @param index of the frame
  145103. * @returns Vector2
  145104. */
  145105. private _getFrameOffset;
  145106. /**
  145107. * Updates a Mesh to the frame data
  145108. * @param mesh that is the target
  145109. * @param frameID or the frame index
  145110. */
  145111. private _updateMeshUV;
  145112. /**
  145113. * Updates a Meshes materials to use the texture packer channels
  145114. * @param m is the mesh to target
  145115. * @param force all channels on the packer to be set.
  145116. */
  145117. private _updateTextureReferences;
  145118. /**
  145119. * Public method to set a Mesh to a frame
  145120. * @param m that is the target
  145121. * @param frameID or the frame index
  145122. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  145123. */
  145124. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  145125. /**
  145126. * Starts the async promise to compile the texture packer.
  145127. * @returns Promise<void>
  145128. */
  145129. processAsync(): Promise<void>;
  145130. /**
  145131. * Disposes all textures associated with this packer
  145132. */
  145133. dispose(): void;
  145134. /**
  145135. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  145136. * @param imageType is the image type to use.
  145137. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  145138. */
  145139. download(imageType?: string, quality?: number): void;
  145140. /**
  145141. * Public method to load a texturePacker JSON file.
  145142. * @param data of the JSON file in string format.
  145143. */
  145144. updateFromJSON(data: string): void;
  145145. }
  145146. }
  145147. declare module BABYLON {
  145148. /**
  145149. * 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.
  145150. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  145151. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  145152. */
  145153. export class CustomProceduralTexture extends ProceduralTexture {
  145154. private _animate;
  145155. private _time;
  145156. private _config;
  145157. private _texturePath;
  145158. /**
  145159. * Instantiates a new Custom Procedural Texture.
  145160. * 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.
  145161. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  145162. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  145163. * @param name Define the name of the texture
  145164. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  145165. * @param size Define the size of the texture to create
  145166. * @param scene Define the scene the texture belongs to
  145167. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  145168. * @param generateMipMaps Define if the texture should creates mip maps or not
  145169. */
  145170. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  145171. private _loadJson;
  145172. /**
  145173. * Is the texture ready to be used ? (rendered at least once)
  145174. * @returns true if ready, otherwise, false.
  145175. */
  145176. isReady(): boolean;
  145177. /**
  145178. * Render the texture to its associated render target.
  145179. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  145180. */
  145181. render(useCameraPostProcess?: boolean): void;
  145182. /**
  145183. * Update the list of dependant textures samplers in the shader.
  145184. */
  145185. updateTextures(): void;
  145186. /**
  145187. * Update the uniform values of the procedural texture in the shader.
  145188. */
  145189. updateShaderUniforms(): void;
  145190. /**
  145191. * Define if the texture animates or not.
  145192. */
  145193. get animate(): boolean;
  145194. set animate(value: boolean);
  145195. }
  145196. }
  145197. declare module BABYLON {
  145198. /** @hidden */
  145199. export var noisePixelShader: {
  145200. name: string;
  145201. shader: string;
  145202. };
  145203. }
  145204. declare module BABYLON {
  145205. /**
  145206. * Class used to generate noise procedural textures
  145207. */
  145208. export class NoiseProceduralTexture extends ProceduralTexture {
  145209. /** Gets or sets the start time (default is 0) */
  145210. time: number;
  145211. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  145212. brightness: number;
  145213. /** Defines the number of octaves to process */
  145214. octaves: number;
  145215. /** Defines the level of persistence (0.8 by default) */
  145216. persistence: number;
  145217. /** Gets or sets animation speed factor (default is 1) */
  145218. animationSpeedFactor: number;
  145219. /**
  145220. * Creates a new NoiseProceduralTexture
  145221. * @param name defines the name fo the texture
  145222. * @param size defines the size of the texture (default is 256)
  145223. * @param scene defines the hosting scene
  145224. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  145225. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  145226. */
  145227. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  145228. private _updateShaderUniforms;
  145229. protected _getDefines(): string;
  145230. /** Generate the current state of the procedural texture */
  145231. render(useCameraPostProcess?: boolean): void;
  145232. /**
  145233. * Serializes this noise procedural texture
  145234. * @returns a serialized noise procedural texture object
  145235. */
  145236. serialize(): any;
  145237. /**
  145238. * Clone the texture.
  145239. * @returns the cloned texture
  145240. */
  145241. clone(): NoiseProceduralTexture;
  145242. /**
  145243. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  145244. * @param parsedTexture defines parsed texture data
  145245. * @param scene defines the current scene
  145246. * @param rootUrl defines the root URL containing noise procedural texture information
  145247. * @returns a parsed NoiseProceduralTexture
  145248. */
  145249. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  145250. }
  145251. }
  145252. declare module BABYLON {
  145253. /**
  145254. * Raw cube texture where the raw buffers are passed in
  145255. */
  145256. export class RawCubeTexture extends CubeTexture {
  145257. /**
  145258. * Creates a cube texture where the raw buffers are passed in.
  145259. * @param scene defines the scene the texture is attached to
  145260. * @param data defines the array of data to use to create each face
  145261. * @param size defines the size of the textures
  145262. * @param format defines the format of the data
  145263. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  145264. * @param generateMipMaps defines if the engine should generate the mip levels
  145265. * @param invertY defines if data must be stored with Y axis inverted
  145266. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  145267. * @param compression defines the compression used (null by default)
  145268. */
  145269. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  145270. /**
  145271. * Updates the raw cube texture.
  145272. * @param data defines the data to store
  145273. * @param format defines the data format
  145274. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  145275. * @param invertY defines if data must be stored with Y axis inverted
  145276. * @param compression defines the compression used (null by default)
  145277. * @param level defines which level of the texture to update
  145278. */
  145279. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  145280. /**
  145281. * Updates a raw cube texture with RGBD encoded data.
  145282. * @param data defines the array of data [mipmap][face] to use to create each face
  145283. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  145284. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  145285. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  145286. * @returns a promsie that resolves when the operation is complete
  145287. */
  145288. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  145289. /**
  145290. * Clones the raw cube texture.
  145291. * @return a new cube texture
  145292. */
  145293. clone(): CubeTexture;
  145294. /** @hidden */
  145295. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  145296. }
  145297. }
  145298. declare module BABYLON {
  145299. /**
  145300. * Class used to store 2D array textures containing user data
  145301. */
  145302. export class RawTexture2DArray extends Texture {
  145303. /** Gets or sets the texture format to use */
  145304. format: number;
  145305. /**
  145306. * Create a new RawTexture2DArray
  145307. * @param data defines the data of the texture
  145308. * @param width defines the width of the texture
  145309. * @param height defines the height of the texture
  145310. * @param depth defines the number of layers of the texture
  145311. * @param format defines the texture format to use
  145312. * @param scene defines the hosting scene
  145313. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  145314. * @param invertY defines if texture must be stored with Y axis inverted
  145315. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  145316. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  145317. */
  145318. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  145319. /** Gets or sets the texture format to use */
  145320. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  145321. /**
  145322. * Update the texture with new data
  145323. * @param data defines the data to store in the texture
  145324. */
  145325. update(data: ArrayBufferView): void;
  145326. }
  145327. }
  145328. declare module BABYLON {
  145329. /**
  145330. * Class used to store 3D textures containing user data
  145331. */
  145332. export class RawTexture3D extends Texture {
  145333. /** Gets or sets the texture format to use */
  145334. format: number;
  145335. /**
  145336. * Create a new RawTexture3D
  145337. * @param data defines the data of the texture
  145338. * @param width defines the width of the texture
  145339. * @param height defines the height of the texture
  145340. * @param depth defines the depth of the texture
  145341. * @param format defines the texture format to use
  145342. * @param scene defines the hosting scene
  145343. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  145344. * @param invertY defines if texture must be stored with Y axis inverted
  145345. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  145346. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  145347. */
  145348. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  145349. /** Gets or sets the texture format to use */
  145350. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  145351. /**
  145352. * Update the texture with new data
  145353. * @param data defines the data to store in the texture
  145354. */
  145355. update(data: ArrayBufferView): void;
  145356. }
  145357. }
  145358. declare module BABYLON {
  145359. /**
  145360. * Creates a refraction texture used by refraction channel of the standard material.
  145361. * It is like a mirror but to see through a material.
  145362. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145363. */
  145364. export class RefractionTexture extends RenderTargetTexture {
  145365. /**
  145366. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  145367. * 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.
  145368. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145369. */
  145370. refractionPlane: Plane;
  145371. /**
  145372. * Define how deep under the surface we should see.
  145373. */
  145374. depth: number;
  145375. /**
  145376. * Creates a refraction texture used by refraction channel of the standard material.
  145377. * It is like a mirror but to see through a material.
  145378. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145379. * @param name Define the texture name
  145380. * @param size Define the size of the underlying texture
  145381. * @param scene Define the scene the refraction belongs to
  145382. * @param generateMipMaps Define if we need to generate mips level for the refraction
  145383. */
  145384. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  145385. /**
  145386. * Clone the refraction texture.
  145387. * @returns the cloned texture
  145388. */
  145389. clone(): RefractionTexture;
  145390. /**
  145391. * Serialize the texture to a JSON representation you could use in Parse later on
  145392. * @returns the serialized JSON representation
  145393. */
  145394. serialize(): any;
  145395. }
  145396. }
  145397. declare module BABYLON {
  145398. /**
  145399. * Block used to add support for vertex skinning (bones)
  145400. */
  145401. export class BonesBlock extends NodeMaterialBlock {
  145402. /**
  145403. * Creates a new BonesBlock
  145404. * @param name defines the block name
  145405. */
  145406. constructor(name: string);
  145407. /**
  145408. * Initialize the block and prepare the context for build
  145409. * @param state defines the state that will be used for the build
  145410. */
  145411. initialize(state: NodeMaterialBuildState): void;
  145412. /**
  145413. * Gets the current class name
  145414. * @returns the class name
  145415. */
  145416. getClassName(): string;
  145417. /**
  145418. * Gets the matrix indices input component
  145419. */
  145420. get matricesIndices(): NodeMaterialConnectionPoint;
  145421. /**
  145422. * Gets the matrix weights input component
  145423. */
  145424. get matricesWeights(): NodeMaterialConnectionPoint;
  145425. /**
  145426. * Gets the extra matrix indices input component
  145427. */
  145428. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  145429. /**
  145430. * Gets the extra matrix weights input component
  145431. */
  145432. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  145433. /**
  145434. * Gets the world input component
  145435. */
  145436. get world(): NodeMaterialConnectionPoint;
  145437. /**
  145438. * Gets the output component
  145439. */
  145440. get output(): NodeMaterialConnectionPoint;
  145441. autoConfigure(material: NodeMaterial): void;
  145442. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  145443. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145444. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145445. protected _buildBlock(state: NodeMaterialBuildState): this;
  145446. }
  145447. }
  145448. declare module BABYLON {
  145449. /**
  145450. * Block used to add support for instances
  145451. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  145452. */
  145453. export class InstancesBlock extends NodeMaterialBlock {
  145454. /**
  145455. * Creates a new InstancesBlock
  145456. * @param name defines the block name
  145457. */
  145458. constructor(name: string);
  145459. /**
  145460. * Gets the current class name
  145461. * @returns the class name
  145462. */
  145463. getClassName(): string;
  145464. /**
  145465. * Gets the first world row input component
  145466. */
  145467. get world0(): NodeMaterialConnectionPoint;
  145468. /**
  145469. * Gets the second world row input component
  145470. */
  145471. get world1(): NodeMaterialConnectionPoint;
  145472. /**
  145473. * Gets the third world row input component
  145474. */
  145475. get world2(): NodeMaterialConnectionPoint;
  145476. /**
  145477. * Gets the forth world row input component
  145478. */
  145479. get world3(): NodeMaterialConnectionPoint;
  145480. /**
  145481. * Gets the world input component
  145482. */
  145483. get world(): NodeMaterialConnectionPoint;
  145484. /**
  145485. * Gets the output component
  145486. */
  145487. get output(): NodeMaterialConnectionPoint;
  145488. /**
  145489. * Gets the isntanceID component
  145490. */
  145491. get instanceID(): NodeMaterialConnectionPoint;
  145492. autoConfigure(material: NodeMaterial): void;
  145493. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  145494. protected _buildBlock(state: NodeMaterialBuildState): this;
  145495. }
  145496. }
  145497. declare module BABYLON {
  145498. /**
  145499. * Block used to add morph targets support to vertex shader
  145500. */
  145501. export class MorphTargetsBlock extends NodeMaterialBlock {
  145502. private _repeatableContentAnchor;
  145503. /**
  145504. * Create a new MorphTargetsBlock
  145505. * @param name defines the block name
  145506. */
  145507. constructor(name: string);
  145508. /**
  145509. * Gets the current class name
  145510. * @returns the class name
  145511. */
  145512. getClassName(): string;
  145513. /**
  145514. * Gets the position input component
  145515. */
  145516. get position(): NodeMaterialConnectionPoint;
  145517. /**
  145518. * Gets the normal input component
  145519. */
  145520. get normal(): NodeMaterialConnectionPoint;
  145521. /**
  145522. * Gets the tangent input component
  145523. */
  145524. get tangent(): NodeMaterialConnectionPoint;
  145525. /**
  145526. * Gets the tangent input component
  145527. */
  145528. get uv(): NodeMaterialConnectionPoint;
  145529. /**
  145530. * Gets the position output component
  145531. */
  145532. get positionOutput(): NodeMaterialConnectionPoint;
  145533. /**
  145534. * Gets the normal output component
  145535. */
  145536. get normalOutput(): NodeMaterialConnectionPoint;
  145537. /**
  145538. * Gets the tangent output component
  145539. */
  145540. get tangentOutput(): NodeMaterialConnectionPoint;
  145541. /**
  145542. * Gets the tangent output component
  145543. */
  145544. get uvOutput(): NodeMaterialConnectionPoint;
  145545. initialize(state: NodeMaterialBuildState): void;
  145546. autoConfigure(material: NodeMaterial): void;
  145547. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145548. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145549. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  145550. protected _buildBlock(state: NodeMaterialBuildState): this;
  145551. }
  145552. }
  145553. declare module BABYLON {
  145554. /**
  145555. * Block used to get data information from a light
  145556. */
  145557. export class LightInformationBlock extends NodeMaterialBlock {
  145558. private _lightDataUniformName;
  145559. private _lightColorUniformName;
  145560. private _lightTypeDefineName;
  145561. /**
  145562. * Gets or sets the light associated with this block
  145563. */
  145564. light: Nullable<Light>;
  145565. /**
  145566. * Creates a new LightInformationBlock
  145567. * @param name defines the block name
  145568. */
  145569. constructor(name: string);
  145570. /**
  145571. * Gets the current class name
  145572. * @returns the class name
  145573. */
  145574. getClassName(): string;
  145575. /**
  145576. * Gets the world position input component
  145577. */
  145578. get worldPosition(): NodeMaterialConnectionPoint;
  145579. /**
  145580. * Gets the direction output component
  145581. */
  145582. get direction(): NodeMaterialConnectionPoint;
  145583. /**
  145584. * Gets the direction output component
  145585. */
  145586. get color(): NodeMaterialConnectionPoint;
  145587. /**
  145588. * Gets the direction output component
  145589. */
  145590. get intensity(): NodeMaterialConnectionPoint;
  145591. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145592. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145593. protected _buildBlock(state: NodeMaterialBuildState): this;
  145594. serialize(): any;
  145595. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145596. }
  145597. }
  145598. declare module BABYLON {
  145599. /**
  145600. * Block used to add image processing support to fragment shader
  145601. */
  145602. export class ImageProcessingBlock extends NodeMaterialBlock {
  145603. /**
  145604. * Create a new ImageProcessingBlock
  145605. * @param name defines the block name
  145606. */
  145607. constructor(name: string);
  145608. /**
  145609. * Gets the current class name
  145610. * @returns the class name
  145611. */
  145612. getClassName(): string;
  145613. /**
  145614. * Gets the color input component
  145615. */
  145616. get color(): NodeMaterialConnectionPoint;
  145617. /**
  145618. * Gets the output component
  145619. */
  145620. get output(): NodeMaterialConnectionPoint;
  145621. /**
  145622. * Initialize the block and prepare the context for build
  145623. * @param state defines the state that will be used for the build
  145624. */
  145625. initialize(state: NodeMaterialBuildState): void;
  145626. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  145627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145628. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145629. protected _buildBlock(state: NodeMaterialBuildState): this;
  145630. }
  145631. }
  145632. declare module BABYLON {
  145633. /**
  145634. * Block used to pertub normals based on a normal map
  145635. */
  145636. export class PerturbNormalBlock extends NodeMaterialBlock {
  145637. private _tangentSpaceParameterName;
  145638. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  145639. invertX: boolean;
  145640. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  145641. invertY: boolean;
  145642. /**
  145643. * Create a new PerturbNormalBlock
  145644. * @param name defines the block name
  145645. */
  145646. constructor(name: string);
  145647. /**
  145648. * Gets the current class name
  145649. * @returns the class name
  145650. */
  145651. getClassName(): string;
  145652. /**
  145653. * Gets the world position input component
  145654. */
  145655. get worldPosition(): NodeMaterialConnectionPoint;
  145656. /**
  145657. * Gets the world normal input component
  145658. */
  145659. get worldNormal(): NodeMaterialConnectionPoint;
  145660. /**
  145661. * Gets the world tangent input component
  145662. */
  145663. get worldTangent(): NodeMaterialConnectionPoint;
  145664. /**
  145665. * Gets the uv input component
  145666. */
  145667. get uv(): NodeMaterialConnectionPoint;
  145668. /**
  145669. * Gets the normal map color input component
  145670. */
  145671. get normalMapColor(): NodeMaterialConnectionPoint;
  145672. /**
  145673. * Gets the strength input component
  145674. */
  145675. get strength(): NodeMaterialConnectionPoint;
  145676. /**
  145677. * Gets the output component
  145678. */
  145679. get output(): NodeMaterialConnectionPoint;
  145680. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145681. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145682. autoConfigure(material: NodeMaterial): void;
  145683. protected _buildBlock(state: NodeMaterialBuildState): this;
  145684. protected _dumpPropertiesCode(): string;
  145685. serialize(): any;
  145686. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145687. }
  145688. }
  145689. declare module BABYLON {
  145690. /**
  145691. * Block used to discard a pixel if a value is smaller than a cutoff
  145692. */
  145693. export class DiscardBlock extends NodeMaterialBlock {
  145694. /**
  145695. * Create a new DiscardBlock
  145696. * @param name defines the block name
  145697. */
  145698. constructor(name: string);
  145699. /**
  145700. * Gets the current class name
  145701. * @returns the class name
  145702. */
  145703. getClassName(): string;
  145704. /**
  145705. * Gets the color input component
  145706. */
  145707. get value(): NodeMaterialConnectionPoint;
  145708. /**
  145709. * Gets the cutoff input component
  145710. */
  145711. get cutoff(): NodeMaterialConnectionPoint;
  145712. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145713. }
  145714. }
  145715. declare module BABYLON {
  145716. /**
  145717. * Block used to test if the fragment shader is front facing
  145718. */
  145719. export class FrontFacingBlock extends NodeMaterialBlock {
  145720. /**
  145721. * Creates a new FrontFacingBlock
  145722. * @param name defines the block name
  145723. */
  145724. constructor(name: string);
  145725. /**
  145726. * Gets the current class name
  145727. * @returns the class name
  145728. */
  145729. getClassName(): string;
  145730. /**
  145731. * Gets the output component
  145732. */
  145733. get output(): NodeMaterialConnectionPoint;
  145734. protected _buildBlock(state: NodeMaterialBuildState): this;
  145735. }
  145736. }
  145737. declare module BABYLON {
  145738. /**
  145739. * Block used to get the derivative value on x and y of a given input
  145740. */
  145741. export class DerivativeBlock extends NodeMaterialBlock {
  145742. /**
  145743. * Create a new DerivativeBlock
  145744. * @param name defines the block name
  145745. */
  145746. constructor(name: string);
  145747. /**
  145748. * Gets the current class name
  145749. * @returns the class name
  145750. */
  145751. getClassName(): string;
  145752. /**
  145753. * Gets the input component
  145754. */
  145755. get input(): NodeMaterialConnectionPoint;
  145756. /**
  145757. * Gets the derivative output on x
  145758. */
  145759. get dx(): NodeMaterialConnectionPoint;
  145760. /**
  145761. * Gets the derivative output on y
  145762. */
  145763. get dy(): NodeMaterialConnectionPoint;
  145764. protected _buildBlock(state: NodeMaterialBuildState): this;
  145765. }
  145766. }
  145767. declare module BABYLON {
  145768. /**
  145769. * Block used to make gl_FragCoord available
  145770. */
  145771. export class FragCoordBlock extends NodeMaterialBlock {
  145772. /**
  145773. * Creates a new FragCoordBlock
  145774. * @param name defines the block name
  145775. */
  145776. constructor(name: string);
  145777. /**
  145778. * Gets the current class name
  145779. * @returns the class name
  145780. */
  145781. getClassName(): string;
  145782. /**
  145783. * Gets the xy component
  145784. */
  145785. get xy(): NodeMaterialConnectionPoint;
  145786. /**
  145787. * Gets the xyz component
  145788. */
  145789. get xyz(): NodeMaterialConnectionPoint;
  145790. /**
  145791. * Gets the xyzw component
  145792. */
  145793. get xyzw(): NodeMaterialConnectionPoint;
  145794. /**
  145795. * Gets the x component
  145796. */
  145797. get x(): NodeMaterialConnectionPoint;
  145798. /**
  145799. * Gets the y component
  145800. */
  145801. get y(): NodeMaterialConnectionPoint;
  145802. /**
  145803. * Gets the z component
  145804. */
  145805. get z(): NodeMaterialConnectionPoint;
  145806. /**
  145807. * Gets the w component
  145808. */
  145809. get output(): NodeMaterialConnectionPoint;
  145810. protected writeOutputs(state: NodeMaterialBuildState): string;
  145811. protected _buildBlock(state: NodeMaterialBuildState): this;
  145812. }
  145813. }
  145814. declare module BABYLON {
  145815. /**
  145816. * Block used to get the screen sizes
  145817. */
  145818. export class ScreenSizeBlock extends NodeMaterialBlock {
  145819. private _varName;
  145820. private _scene;
  145821. /**
  145822. * Creates a new ScreenSizeBlock
  145823. * @param name defines the block name
  145824. */
  145825. constructor(name: string);
  145826. /**
  145827. * Gets the current class name
  145828. * @returns the class name
  145829. */
  145830. getClassName(): string;
  145831. /**
  145832. * Gets the xy component
  145833. */
  145834. get xy(): NodeMaterialConnectionPoint;
  145835. /**
  145836. * Gets the x component
  145837. */
  145838. get x(): NodeMaterialConnectionPoint;
  145839. /**
  145840. * Gets the y component
  145841. */
  145842. get y(): NodeMaterialConnectionPoint;
  145843. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145844. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  145845. protected _buildBlock(state: NodeMaterialBuildState): this;
  145846. }
  145847. }
  145848. declare module BABYLON {
  145849. /**
  145850. * Block used to add support for scene fog
  145851. */
  145852. export class FogBlock extends NodeMaterialBlock {
  145853. private _fogDistanceName;
  145854. private _fogParameters;
  145855. /**
  145856. * Create a new FogBlock
  145857. * @param name defines the block name
  145858. */
  145859. constructor(name: string);
  145860. /**
  145861. * Gets the current class name
  145862. * @returns the class name
  145863. */
  145864. getClassName(): string;
  145865. /**
  145866. * Gets the world position input component
  145867. */
  145868. get worldPosition(): NodeMaterialConnectionPoint;
  145869. /**
  145870. * Gets the view input component
  145871. */
  145872. get view(): NodeMaterialConnectionPoint;
  145873. /**
  145874. * Gets the color input component
  145875. */
  145876. get input(): NodeMaterialConnectionPoint;
  145877. /**
  145878. * Gets the fog color input component
  145879. */
  145880. get fogColor(): NodeMaterialConnectionPoint;
  145881. /**
  145882. * Gets the output component
  145883. */
  145884. get output(): NodeMaterialConnectionPoint;
  145885. autoConfigure(material: NodeMaterial): void;
  145886. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145887. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145888. protected _buildBlock(state: NodeMaterialBuildState): this;
  145889. }
  145890. }
  145891. declare module BABYLON {
  145892. /**
  145893. * Block used to add light in the fragment shader
  145894. */
  145895. export class LightBlock extends NodeMaterialBlock {
  145896. private _lightId;
  145897. /**
  145898. * Gets or sets the light associated with this block
  145899. */
  145900. light: Nullable<Light>;
  145901. /**
  145902. * Create a new LightBlock
  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 world position input component
  145913. */
  145914. get worldPosition(): NodeMaterialConnectionPoint;
  145915. /**
  145916. * Gets the world normal input component
  145917. */
  145918. get worldNormal(): NodeMaterialConnectionPoint;
  145919. /**
  145920. * Gets the camera (or eye) position component
  145921. */
  145922. get cameraPosition(): NodeMaterialConnectionPoint;
  145923. /**
  145924. * Gets the glossiness component
  145925. */
  145926. get glossiness(): NodeMaterialConnectionPoint;
  145927. /**
  145928. * Gets the glossinness power component
  145929. */
  145930. get glossPower(): NodeMaterialConnectionPoint;
  145931. /**
  145932. * Gets the diffuse color component
  145933. */
  145934. get diffuseColor(): NodeMaterialConnectionPoint;
  145935. /**
  145936. * Gets the specular color component
  145937. */
  145938. get specularColor(): NodeMaterialConnectionPoint;
  145939. /**
  145940. * Gets the view matrix component
  145941. */
  145942. get view(): NodeMaterialConnectionPoint;
  145943. /**
  145944. * Gets the diffuse output component
  145945. */
  145946. get diffuseOutput(): NodeMaterialConnectionPoint;
  145947. /**
  145948. * Gets the specular output component
  145949. */
  145950. get specularOutput(): NodeMaterialConnectionPoint;
  145951. /**
  145952. * Gets the shadow output component
  145953. */
  145954. get shadow(): NodeMaterialConnectionPoint;
  145955. autoConfigure(material: NodeMaterial): void;
  145956. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145957. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145958. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145959. private _injectVertexCode;
  145960. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145961. serialize(): any;
  145962. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145963. }
  145964. }
  145965. declare module BABYLON {
  145966. /**
  145967. * Block used to read a reflection texture from a sampler
  145968. */
  145969. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  145970. /**
  145971. * Create a new ReflectionTextureBlock
  145972. * @param name defines the block name
  145973. */
  145974. constructor(name: string);
  145975. /**
  145976. * Gets the current class name
  145977. * @returns the class name
  145978. */
  145979. getClassName(): string;
  145980. /**
  145981. * Gets the world position input component
  145982. */
  145983. get position(): NodeMaterialConnectionPoint;
  145984. /**
  145985. * Gets the world position input component
  145986. */
  145987. get worldPosition(): NodeMaterialConnectionPoint;
  145988. /**
  145989. * Gets the world normal input component
  145990. */
  145991. get worldNormal(): NodeMaterialConnectionPoint;
  145992. /**
  145993. * Gets the world input component
  145994. */
  145995. get world(): NodeMaterialConnectionPoint;
  145996. /**
  145997. * Gets the camera (or eye) position component
  145998. */
  145999. get cameraPosition(): NodeMaterialConnectionPoint;
  146000. /**
  146001. * Gets the view input component
  146002. */
  146003. get view(): NodeMaterialConnectionPoint;
  146004. /**
  146005. * Gets the rgb output component
  146006. */
  146007. get rgb(): NodeMaterialConnectionPoint;
  146008. /**
  146009. * Gets the rgba output component
  146010. */
  146011. get rgba(): NodeMaterialConnectionPoint;
  146012. /**
  146013. * Gets the r output component
  146014. */
  146015. get r(): NodeMaterialConnectionPoint;
  146016. /**
  146017. * Gets the g output component
  146018. */
  146019. get g(): NodeMaterialConnectionPoint;
  146020. /**
  146021. * Gets the b output component
  146022. */
  146023. get b(): NodeMaterialConnectionPoint;
  146024. /**
  146025. * Gets the a output component
  146026. */
  146027. get a(): NodeMaterialConnectionPoint;
  146028. autoConfigure(material: NodeMaterial): void;
  146029. protected _buildBlock(state: NodeMaterialBuildState): this;
  146030. }
  146031. }
  146032. declare module BABYLON {
  146033. /**
  146034. * Block used to add 2 vectors
  146035. */
  146036. export class AddBlock extends NodeMaterialBlock {
  146037. /**
  146038. * Creates a new AddBlock
  146039. * @param name defines the block name
  146040. */
  146041. constructor(name: string);
  146042. /**
  146043. * Gets the current class name
  146044. * @returns the class name
  146045. */
  146046. getClassName(): string;
  146047. /**
  146048. * Gets the left operand input component
  146049. */
  146050. get left(): NodeMaterialConnectionPoint;
  146051. /**
  146052. * Gets the right operand input component
  146053. */
  146054. get right(): NodeMaterialConnectionPoint;
  146055. /**
  146056. * Gets the output component
  146057. */
  146058. get output(): NodeMaterialConnectionPoint;
  146059. protected _buildBlock(state: NodeMaterialBuildState): this;
  146060. }
  146061. }
  146062. declare module BABYLON {
  146063. /**
  146064. * Block used to scale a vector by a float
  146065. */
  146066. export class ScaleBlock extends NodeMaterialBlock {
  146067. /**
  146068. * Creates a new ScaleBlock
  146069. * @param name defines the block name
  146070. */
  146071. constructor(name: string);
  146072. /**
  146073. * Gets the current class name
  146074. * @returns the class name
  146075. */
  146076. getClassName(): string;
  146077. /**
  146078. * Gets the input component
  146079. */
  146080. get input(): NodeMaterialConnectionPoint;
  146081. /**
  146082. * Gets the factor input component
  146083. */
  146084. get factor(): NodeMaterialConnectionPoint;
  146085. /**
  146086. * Gets the output component
  146087. */
  146088. get output(): NodeMaterialConnectionPoint;
  146089. protected _buildBlock(state: NodeMaterialBuildState): this;
  146090. }
  146091. }
  146092. declare module BABYLON {
  146093. /**
  146094. * Block used to clamp a float
  146095. */
  146096. export class ClampBlock extends NodeMaterialBlock {
  146097. /** Gets or sets the minimum range */
  146098. minimum: number;
  146099. /** Gets or sets the maximum range */
  146100. maximum: number;
  146101. /**
  146102. * Creates a new ClampBlock
  146103. * @param name defines the block name
  146104. */
  146105. constructor(name: string);
  146106. /**
  146107. * Gets the current class name
  146108. * @returns the class name
  146109. */
  146110. getClassName(): string;
  146111. /**
  146112. * Gets the value input component
  146113. */
  146114. get value(): NodeMaterialConnectionPoint;
  146115. /**
  146116. * Gets the output component
  146117. */
  146118. get output(): NodeMaterialConnectionPoint;
  146119. protected _buildBlock(state: NodeMaterialBuildState): this;
  146120. protected _dumpPropertiesCode(): string;
  146121. serialize(): any;
  146122. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146123. }
  146124. }
  146125. declare module BABYLON {
  146126. /**
  146127. * Block used to apply a cross product between 2 vectors
  146128. */
  146129. export class CrossBlock extends NodeMaterialBlock {
  146130. /**
  146131. * Creates a new CrossBlock
  146132. * @param name defines the block name
  146133. */
  146134. constructor(name: string);
  146135. /**
  146136. * Gets the current class name
  146137. * @returns the class name
  146138. */
  146139. getClassName(): string;
  146140. /**
  146141. * Gets the left operand input component
  146142. */
  146143. get left(): NodeMaterialConnectionPoint;
  146144. /**
  146145. * Gets the right operand input component
  146146. */
  146147. get right(): NodeMaterialConnectionPoint;
  146148. /**
  146149. * Gets the output component
  146150. */
  146151. get output(): NodeMaterialConnectionPoint;
  146152. protected _buildBlock(state: NodeMaterialBuildState): this;
  146153. }
  146154. }
  146155. declare module BABYLON {
  146156. /**
  146157. * Block used to apply a dot product between 2 vectors
  146158. */
  146159. export class DotBlock extends NodeMaterialBlock {
  146160. /**
  146161. * Creates a new DotBlock
  146162. * @param name defines the block name
  146163. */
  146164. constructor(name: string);
  146165. /**
  146166. * Gets the current class name
  146167. * @returns the class name
  146168. */
  146169. getClassName(): string;
  146170. /**
  146171. * Gets the left operand input component
  146172. */
  146173. get left(): NodeMaterialConnectionPoint;
  146174. /**
  146175. * Gets the right operand input component
  146176. */
  146177. get right(): NodeMaterialConnectionPoint;
  146178. /**
  146179. * Gets the output component
  146180. */
  146181. get output(): NodeMaterialConnectionPoint;
  146182. protected _buildBlock(state: NodeMaterialBuildState): this;
  146183. }
  146184. }
  146185. declare module BABYLON {
  146186. /**
  146187. * Block used to normalize a vector
  146188. */
  146189. export class NormalizeBlock extends NodeMaterialBlock {
  146190. /**
  146191. * Creates a new NormalizeBlock
  146192. * @param name defines the block name
  146193. */
  146194. constructor(name: string);
  146195. /**
  146196. * Gets the current class name
  146197. * @returns the class name
  146198. */
  146199. getClassName(): string;
  146200. /**
  146201. * Gets the input component
  146202. */
  146203. get input(): NodeMaterialConnectionPoint;
  146204. /**
  146205. * Gets the output component
  146206. */
  146207. get output(): NodeMaterialConnectionPoint;
  146208. protected _buildBlock(state: NodeMaterialBuildState): this;
  146209. }
  146210. }
  146211. declare module BABYLON {
  146212. /**
  146213. * Block used to create a Color3/4 out of individual inputs (one for each component)
  146214. */
  146215. export class ColorMergerBlock extends NodeMaterialBlock {
  146216. /**
  146217. * Create a new ColorMergerBlock
  146218. * @param name defines the block name
  146219. */
  146220. constructor(name: string);
  146221. /**
  146222. * Gets the current class name
  146223. * @returns the class name
  146224. */
  146225. getClassName(): string;
  146226. /**
  146227. * Gets the rgb component (input)
  146228. */
  146229. get rgbIn(): NodeMaterialConnectionPoint;
  146230. /**
  146231. * Gets the r component (input)
  146232. */
  146233. get r(): NodeMaterialConnectionPoint;
  146234. /**
  146235. * Gets the g component (input)
  146236. */
  146237. get g(): NodeMaterialConnectionPoint;
  146238. /**
  146239. * Gets the b component (input)
  146240. */
  146241. get b(): NodeMaterialConnectionPoint;
  146242. /**
  146243. * Gets the a component (input)
  146244. */
  146245. get a(): NodeMaterialConnectionPoint;
  146246. /**
  146247. * Gets the rgba component (output)
  146248. */
  146249. get rgba(): NodeMaterialConnectionPoint;
  146250. /**
  146251. * Gets the rgb component (output)
  146252. */
  146253. get rgbOut(): NodeMaterialConnectionPoint;
  146254. /**
  146255. * Gets the rgb component (output)
  146256. * @deprecated Please use rgbOut instead.
  146257. */
  146258. get rgb(): NodeMaterialConnectionPoint;
  146259. protected _buildBlock(state: NodeMaterialBuildState): this;
  146260. }
  146261. }
  146262. declare module BABYLON {
  146263. /**
  146264. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  146265. */
  146266. export class VectorSplitterBlock extends NodeMaterialBlock {
  146267. /**
  146268. * Create a new VectorSplitterBlock
  146269. * @param name defines the block name
  146270. */
  146271. constructor(name: string);
  146272. /**
  146273. * Gets the current class name
  146274. * @returns the class name
  146275. */
  146276. getClassName(): string;
  146277. /**
  146278. * Gets the xyzw component (input)
  146279. */
  146280. get xyzw(): NodeMaterialConnectionPoint;
  146281. /**
  146282. * Gets the xyz component (input)
  146283. */
  146284. get xyzIn(): NodeMaterialConnectionPoint;
  146285. /**
  146286. * Gets the xy component (input)
  146287. */
  146288. get xyIn(): NodeMaterialConnectionPoint;
  146289. /**
  146290. * Gets the xyz component (output)
  146291. */
  146292. get xyzOut(): NodeMaterialConnectionPoint;
  146293. /**
  146294. * Gets the xy component (output)
  146295. */
  146296. get xyOut(): NodeMaterialConnectionPoint;
  146297. /**
  146298. * Gets the x component (output)
  146299. */
  146300. get x(): NodeMaterialConnectionPoint;
  146301. /**
  146302. * Gets the y component (output)
  146303. */
  146304. get y(): NodeMaterialConnectionPoint;
  146305. /**
  146306. * Gets the z component (output)
  146307. */
  146308. get z(): NodeMaterialConnectionPoint;
  146309. /**
  146310. * Gets the w component (output)
  146311. */
  146312. get w(): NodeMaterialConnectionPoint;
  146313. protected _inputRename(name: string): string;
  146314. protected _outputRename(name: string): string;
  146315. protected _buildBlock(state: NodeMaterialBuildState): this;
  146316. }
  146317. }
  146318. declare module BABYLON {
  146319. /**
  146320. * Block used to lerp between 2 values
  146321. */
  146322. export class LerpBlock extends NodeMaterialBlock {
  146323. /**
  146324. * Creates a new LerpBlock
  146325. * @param name defines the block name
  146326. */
  146327. constructor(name: string);
  146328. /**
  146329. * Gets the current class name
  146330. * @returns the class name
  146331. */
  146332. getClassName(): string;
  146333. /**
  146334. * Gets the left operand input component
  146335. */
  146336. get left(): NodeMaterialConnectionPoint;
  146337. /**
  146338. * Gets the right operand input component
  146339. */
  146340. get right(): NodeMaterialConnectionPoint;
  146341. /**
  146342. * Gets the gradient operand input component
  146343. */
  146344. get gradient(): NodeMaterialConnectionPoint;
  146345. /**
  146346. * Gets the output component
  146347. */
  146348. get output(): NodeMaterialConnectionPoint;
  146349. protected _buildBlock(state: NodeMaterialBuildState): this;
  146350. }
  146351. }
  146352. declare module BABYLON {
  146353. /**
  146354. * Block used to divide 2 vectors
  146355. */
  146356. export class DivideBlock extends NodeMaterialBlock {
  146357. /**
  146358. * Creates a new DivideBlock
  146359. * @param name defines the block name
  146360. */
  146361. constructor(name: string);
  146362. /**
  146363. * Gets the current class name
  146364. * @returns the class name
  146365. */
  146366. getClassName(): string;
  146367. /**
  146368. * Gets the left operand input component
  146369. */
  146370. get left(): NodeMaterialConnectionPoint;
  146371. /**
  146372. * Gets the right operand input component
  146373. */
  146374. get right(): NodeMaterialConnectionPoint;
  146375. /**
  146376. * Gets the output component
  146377. */
  146378. get output(): NodeMaterialConnectionPoint;
  146379. protected _buildBlock(state: NodeMaterialBuildState): this;
  146380. }
  146381. }
  146382. declare module BABYLON {
  146383. /**
  146384. * Block used to subtract 2 vectors
  146385. */
  146386. export class SubtractBlock extends NodeMaterialBlock {
  146387. /**
  146388. * Creates a new SubtractBlock
  146389. * @param name defines the block name
  146390. */
  146391. constructor(name: string);
  146392. /**
  146393. * Gets the current class name
  146394. * @returns the class name
  146395. */
  146396. getClassName(): string;
  146397. /**
  146398. * Gets the left operand input component
  146399. */
  146400. get left(): NodeMaterialConnectionPoint;
  146401. /**
  146402. * Gets the right operand input component
  146403. */
  146404. get right(): NodeMaterialConnectionPoint;
  146405. /**
  146406. * Gets the output component
  146407. */
  146408. get output(): NodeMaterialConnectionPoint;
  146409. protected _buildBlock(state: NodeMaterialBuildState): this;
  146410. }
  146411. }
  146412. declare module BABYLON {
  146413. /**
  146414. * Block used to step a value
  146415. */
  146416. export class StepBlock extends NodeMaterialBlock {
  146417. /**
  146418. * Creates a new StepBlock
  146419. * @param name defines the block name
  146420. */
  146421. constructor(name: string);
  146422. /**
  146423. * Gets the current class name
  146424. * @returns the class name
  146425. */
  146426. getClassName(): string;
  146427. /**
  146428. * Gets the value operand input component
  146429. */
  146430. get value(): NodeMaterialConnectionPoint;
  146431. /**
  146432. * Gets the edge operand input component
  146433. */
  146434. get edge(): NodeMaterialConnectionPoint;
  146435. /**
  146436. * Gets the output component
  146437. */
  146438. get output(): NodeMaterialConnectionPoint;
  146439. protected _buildBlock(state: NodeMaterialBuildState): this;
  146440. }
  146441. }
  146442. declare module BABYLON {
  146443. /**
  146444. * Block used to get the opposite (1 - x) of a value
  146445. */
  146446. export class OneMinusBlock extends NodeMaterialBlock {
  146447. /**
  146448. * Creates a new OneMinusBlock
  146449. * @param name defines the block name
  146450. */
  146451. constructor(name: string);
  146452. /**
  146453. * Gets the current class name
  146454. * @returns the class name
  146455. */
  146456. getClassName(): string;
  146457. /**
  146458. * Gets the input component
  146459. */
  146460. get input(): NodeMaterialConnectionPoint;
  146461. /**
  146462. * Gets the output component
  146463. */
  146464. get output(): NodeMaterialConnectionPoint;
  146465. protected _buildBlock(state: NodeMaterialBuildState): this;
  146466. }
  146467. }
  146468. declare module BABYLON {
  146469. /**
  146470. * Block used to get the view direction
  146471. */
  146472. export class ViewDirectionBlock extends NodeMaterialBlock {
  146473. /**
  146474. * Creates a new ViewDirectionBlock
  146475. * @param name defines the block name
  146476. */
  146477. constructor(name: string);
  146478. /**
  146479. * Gets the current class name
  146480. * @returns the class name
  146481. */
  146482. getClassName(): string;
  146483. /**
  146484. * Gets the world position component
  146485. */
  146486. get worldPosition(): NodeMaterialConnectionPoint;
  146487. /**
  146488. * Gets the camera position component
  146489. */
  146490. get cameraPosition(): NodeMaterialConnectionPoint;
  146491. /**
  146492. * Gets the output component
  146493. */
  146494. get output(): NodeMaterialConnectionPoint;
  146495. autoConfigure(material: NodeMaterial): void;
  146496. protected _buildBlock(state: NodeMaterialBuildState): this;
  146497. }
  146498. }
  146499. declare module BABYLON {
  146500. /**
  146501. * Block used to compute fresnel value
  146502. */
  146503. export class FresnelBlock extends NodeMaterialBlock {
  146504. /**
  146505. * Create a new FresnelBlock
  146506. * @param name defines the block name
  146507. */
  146508. constructor(name: string);
  146509. /**
  146510. * Gets the current class name
  146511. * @returns the class name
  146512. */
  146513. getClassName(): string;
  146514. /**
  146515. * Gets the world normal input component
  146516. */
  146517. get worldNormal(): NodeMaterialConnectionPoint;
  146518. /**
  146519. * Gets the view direction input component
  146520. */
  146521. get viewDirection(): NodeMaterialConnectionPoint;
  146522. /**
  146523. * Gets the bias input component
  146524. */
  146525. get bias(): NodeMaterialConnectionPoint;
  146526. /**
  146527. * Gets the camera (or eye) position component
  146528. */
  146529. get power(): NodeMaterialConnectionPoint;
  146530. /**
  146531. * Gets the fresnel output component
  146532. */
  146533. get fresnel(): NodeMaterialConnectionPoint;
  146534. autoConfigure(material: NodeMaterial): void;
  146535. protected _buildBlock(state: NodeMaterialBuildState): this;
  146536. }
  146537. }
  146538. declare module BABYLON {
  146539. /**
  146540. * Block used to get the max of 2 values
  146541. */
  146542. export class MaxBlock extends NodeMaterialBlock {
  146543. /**
  146544. * Creates a new MaxBlock
  146545. * @param name defines the block name
  146546. */
  146547. constructor(name: string);
  146548. /**
  146549. * Gets the current class name
  146550. * @returns the class name
  146551. */
  146552. getClassName(): string;
  146553. /**
  146554. * Gets the left operand input component
  146555. */
  146556. get left(): NodeMaterialConnectionPoint;
  146557. /**
  146558. * Gets the right operand input component
  146559. */
  146560. get right(): NodeMaterialConnectionPoint;
  146561. /**
  146562. * Gets the output component
  146563. */
  146564. get output(): NodeMaterialConnectionPoint;
  146565. protected _buildBlock(state: NodeMaterialBuildState): this;
  146566. }
  146567. }
  146568. declare module BABYLON {
  146569. /**
  146570. * Block used to get the min of 2 values
  146571. */
  146572. export class MinBlock extends NodeMaterialBlock {
  146573. /**
  146574. * Creates a new MinBlock
  146575. * @param name defines the block name
  146576. */
  146577. constructor(name: string);
  146578. /**
  146579. * Gets the current class name
  146580. * @returns the class name
  146581. */
  146582. getClassName(): string;
  146583. /**
  146584. * Gets the left operand input component
  146585. */
  146586. get left(): NodeMaterialConnectionPoint;
  146587. /**
  146588. * Gets the right operand input component
  146589. */
  146590. get right(): NodeMaterialConnectionPoint;
  146591. /**
  146592. * Gets the output component
  146593. */
  146594. get output(): NodeMaterialConnectionPoint;
  146595. protected _buildBlock(state: NodeMaterialBuildState): this;
  146596. }
  146597. }
  146598. declare module BABYLON {
  146599. /**
  146600. * Block used to get the distance between 2 values
  146601. */
  146602. export class DistanceBlock extends NodeMaterialBlock {
  146603. /**
  146604. * Creates a new DistanceBlock
  146605. * @param name defines the block name
  146606. */
  146607. constructor(name: string);
  146608. /**
  146609. * Gets the current class name
  146610. * @returns the class name
  146611. */
  146612. getClassName(): string;
  146613. /**
  146614. * Gets the left operand input component
  146615. */
  146616. get left(): NodeMaterialConnectionPoint;
  146617. /**
  146618. * Gets the right operand input component
  146619. */
  146620. get right(): NodeMaterialConnectionPoint;
  146621. /**
  146622. * Gets the output component
  146623. */
  146624. get output(): NodeMaterialConnectionPoint;
  146625. protected _buildBlock(state: NodeMaterialBuildState): this;
  146626. }
  146627. }
  146628. declare module BABYLON {
  146629. /**
  146630. * Block used to get the length of a vector
  146631. */
  146632. export class LengthBlock extends NodeMaterialBlock {
  146633. /**
  146634. * Creates a new LengthBlock
  146635. * @param name defines the block name
  146636. */
  146637. constructor(name: string);
  146638. /**
  146639. * Gets the current class name
  146640. * @returns the class name
  146641. */
  146642. getClassName(): string;
  146643. /**
  146644. * Gets the value input component
  146645. */
  146646. get value(): NodeMaterialConnectionPoint;
  146647. /**
  146648. * Gets the output component
  146649. */
  146650. get output(): NodeMaterialConnectionPoint;
  146651. protected _buildBlock(state: NodeMaterialBuildState): this;
  146652. }
  146653. }
  146654. declare module BABYLON {
  146655. /**
  146656. * Block used to get negative version of a value (i.e. x * -1)
  146657. */
  146658. export class NegateBlock extends NodeMaterialBlock {
  146659. /**
  146660. * Creates a new NegateBlock
  146661. * @param name defines the block name
  146662. */
  146663. constructor(name: string);
  146664. /**
  146665. * Gets the current class name
  146666. * @returns the class name
  146667. */
  146668. getClassName(): string;
  146669. /**
  146670. * Gets the value input component
  146671. */
  146672. get value(): NodeMaterialConnectionPoint;
  146673. /**
  146674. * Gets the output component
  146675. */
  146676. get output(): NodeMaterialConnectionPoint;
  146677. protected _buildBlock(state: NodeMaterialBuildState): this;
  146678. }
  146679. }
  146680. declare module BABYLON {
  146681. /**
  146682. * Block used to get the value of the first parameter raised to the power of the second
  146683. */
  146684. export class PowBlock extends NodeMaterialBlock {
  146685. /**
  146686. * Creates a new PowBlock
  146687. * @param name defines the block name
  146688. */
  146689. constructor(name: string);
  146690. /**
  146691. * Gets the current class name
  146692. * @returns the class name
  146693. */
  146694. getClassName(): string;
  146695. /**
  146696. * Gets the value operand input component
  146697. */
  146698. get value(): NodeMaterialConnectionPoint;
  146699. /**
  146700. * Gets the power operand input component
  146701. */
  146702. get power(): NodeMaterialConnectionPoint;
  146703. /**
  146704. * Gets the output component
  146705. */
  146706. get output(): NodeMaterialConnectionPoint;
  146707. protected _buildBlock(state: NodeMaterialBuildState): this;
  146708. }
  146709. }
  146710. declare module BABYLON {
  146711. /**
  146712. * Block used to get a random number
  146713. */
  146714. export class RandomNumberBlock extends NodeMaterialBlock {
  146715. /**
  146716. * Creates a new RandomNumberBlock
  146717. * @param name defines the block name
  146718. */
  146719. constructor(name: string);
  146720. /**
  146721. * Gets the current class name
  146722. * @returns the class name
  146723. */
  146724. getClassName(): string;
  146725. /**
  146726. * Gets the seed input component
  146727. */
  146728. get seed(): NodeMaterialConnectionPoint;
  146729. /**
  146730. * Gets the output component
  146731. */
  146732. get output(): NodeMaterialConnectionPoint;
  146733. protected _buildBlock(state: NodeMaterialBuildState): this;
  146734. }
  146735. }
  146736. declare module BABYLON {
  146737. /**
  146738. * Block used to compute arc tangent of 2 values
  146739. */
  146740. export class ArcTan2Block extends NodeMaterialBlock {
  146741. /**
  146742. * Creates a new ArcTan2Block
  146743. * @param name defines the block name
  146744. */
  146745. constructor(name: string);
  146746. /**
  146747. * Gets the current class name
  146748. * @returns the class name
  146749. */
  146750. getClassName(): string;
  146751. /**
  146752. * Gets the x operand input component
  146753. */
  146754. get x(): NodeMaterialConnectionPoint;
  146755. /**
  146756. * Gets the y operand input component
  146757. */
  146758. get y(): NodeMaterialConnectionPoint;
  146759. /**
  146760. * Gets the output component
  146761. */
  146762. get output(): NodeMaterialConnectionPoint;
  146763. protected _buildBlock(state: NodeMaterialBuildState): this;
  146764. }
  146765. }
  146766. declare module BABYLON {
  146767. /**
  146768. * Block used to smooth step a value
  146769. */
  146770. export class SmoothStepBlock extends NodeMaterialBlock {
  146771. /**
  146772. * Creates a new SmoothStepBlock
  146773. * @param name defines the block name
  146774. */
  146775. constructor(name: string);
  146776. /**
  146777. * Gets the current class name
  146778. * @returns the class name
  146779. */
  146780. getClassName(): string;
  146781. /**
  146782. * Gets the value operand input component
  146783. */
  146784. get value(): NodeMaterialConnectionPoint;
  146785. /**
  146786. * Gets the first edge operand input component
  146787. */
  146788. get edge0(): NodeMaterialConnectionPoint;
  146789. /**
  146790. * Gets the second edge operand input component
  146791. */
  146792. get edge1(): NodeMaterialConnectionPoint;
  146793. /**
  146794. * Gets the output component
  146795. */
  146796. get output(): NodeMaterialConnectionPoint;
  146797. protected _buildBlock(state: NodeMaterialBuildState): this;
  146798. }
  146799. }
  146800. declare module BABYLON {
  146801. /**
  146802. * Block used to get the reciprocal (1 / x) of a value
  146803. */
  146804. export class ReciprocalBlock extends NodeMaterialBlock {
  146805. /**
  146806. * Creates a new ReciprocalBlock
  146807. * @param name defines the block name
  146808. */
  146809. constructor(name: string);
  146810. /**
  146811. * Gets the current class name
  146812. * @returns the class name
  146813. */
  146814. getClassName(): string;
  146815. /**
  146816. * Gets the input component
  146817. */
  146818. get input(): NodeMaterialConnectionPoint;
  146819. /**
  146820. * Gets the output component
  146821. */
  146822. get output(): NodeMaterialConnectionPoint;
  146823. protected _buildBlock(state: NodeMaterialBuildState): this;
  146824. }
  146825. }
  146826. declare module BABYLON {
  146827. /**
  146828. * Block used to replace a color by another one
  146829. */
  146830. export class ReplaceColorBlock extends NodeMaterialBlock {
  146831. /**
  146832. * Creates a new ReplaceColorBlock
  146833. * @param name defines the block name
  146834. */
  146835. constructor(name: string);
  146836. /**
  146837. * Gets the current class name
  146838. * @returns the class name
  146839. */
  146840. getClassName(): string;
  146841. /**
  146842. * Gets the value input component
  146843. */
  146844. get value(): NodeMaterialConnectionPoint;
  146845. /**
  146846. * Gets the reference input component
  146847. */
  146848. get reference(): NodeMaterialConnectionPoint;
  146849. /**
  146850. * Gets the distance input component
  146851. */
  146852. get distance(): NodeMaterialConnectionPoint;
  146853. /**
  146854. * Gets the replacement input component
  146855. */
  146856. get replacement(): NodeMaterialConnectionPoint;
  146857. /**
  146858. * Gets the output component
  146859. */
  146860. get output(): NodeMaterialConnectionPoint;
  146861. protected _buildBlock(state: NodeMaterialBuildState): this;
  146862. }
  146863. }
  146864. declare module BABYLON {
  146865. /**
  146866. * Block used to posterize a value
  146867. * @see https://en.wikipedia.org/wiki/Posterization
  146868. */
  146869. export class PosterizeBlock extends NodeMaterialBlock {
  146870. /**
  146871. * Creates a new PosterizeBlock
  146872. * @param name defines the block name
  146873. */
  146874. constructor(name: string);
  146875. /**
  146876. * Gets the current class name
  146877. * @returns the class name
  146878. */
  146879. getClassName(): string;
  146880. /**
  146881. * Gets the value input component
  146882. */
  146883. get value(): NodeMaterialConnectionPoint;
  146884. /**
  146885. * Gets the steps input component
  146886. */
  146887. get steps(): NodeMaterialConnectionPoint;
  146888. /**
  146889. * Gets the output component
  146890. */
  146891. get output(): NodeMaterialConnectionPoint;
  146892. protected _buildBlock(state: NodeMaterialBuildState): this;
  146893. }
  146894. }
  146895. declare module BABYLON {
  146896. /**
  146897. * Operations supported by the Wave block
  146898. */
  146899. export enum WaveBlockKind {
  146900. /** SawTooth */
  146901. SawTooth = 0,
  146902. /** Square */
  146903. Square = 1,
  146904. /** Triangle */
  146905. Triangle = 2
  146906. }
  146907. /**
  146908. * Block used to apply wave operation to floats
  146909. */
  146910. export class WaveBlock extends NodeMaterialBlock {
  146911. /**
  146912. * Gets or sets the kibnd of wave to be applied by the block
  146913. */
  146914. kind: WaveBlockKind;
  146915. /**
  146916. * Creates a new WaveBlock
  146917. * @param name defines the block name
  146918. */
  146919. constructor(name: string);
  146920. /**
  146921. * Gets the current class name
  146922. * @returns the class name
  146923. */
  146924. getClassName(): string;
  146925. /**
  146926. * Gets the input component
  146927. */
  146928. get input(): NodeMaterialConnectionPoint;
  146929. /**
  146930. * Gets the output component
  146931. */
  146932. get output(): NodeMaterialConnectionPoint;
  146933. protected _buildBlock(state: NodeMaterialBuildState): this;
  146934. serialize(): any;
  146935. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146936. }
  146937. }
  146938. declare module BABYLON {
  146939. /**
  146940. * Class used to store a color step for the GradientBlock
  146941. */
  146942. export class GradientBlockColorStep {
  146943. private _step;
  146944. /**
  146945. * Gets value indicating which step this color is associated with (between 0 and 1)
  146946. */
  146947. get step(): number;
  146948. /**
  146949. * Sets a value indicating which step this color is associated with (between 0 and 1)
  146950. */
  146951. set step(val: number);
  146952. private _color;
  146953. /**
  146954. * Gets the color associated with this step
  146955. */
  146956. get color(): Color3;
  146957. /**
  146958. * Sets the color associated with this step
  146959. */
  146960. set color(val: Color3);
  146961. /**
  146962. * Creates a new GradientBlockColorStep
  146963. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  146964. * @param color defines the color associated with this step
  146965. */
  146966. constructor(step: number, color: Color3);
  146967. }
  146968. /**
  146969. * Block used to return a color from a gradient based on an input value between 0 and 1
  146970. */
  146971. export class GradientBlock extends NodeMaterialBlock {
  146972. /**
  146973. * Gets or sets the list of color steps
  146974. */
  146975. colorSteps: GradientBlockColorStep[];
  146976. /** Gets an observable raised when the value is changed */
  146977. onValueChangedObservable: Observable<GradientBlock>;
  146978. /** calls observable when the value is changed*/
  146979. colorStepsUpdated(): void;
  146980. /**
  146981. * Creates a new GradientBlock
  146982. * @param name defines the block name
  146983. */
  146984. constructor(name: string);
  146985. /**
  146986. * Gets the current class name
  146987. * @returns the class name
  146988. */
  146989. getClassName(): string;
  146990. /**
  146991. * Gets the gradient input component
  146992. */
  146993. get gradient(): NodeMaterialConnectionPoint;
  146994. /**
  146995. * Gets the output component
  146996. */
  146997. get output(): NodeMaterialConnectionPoint;
  146998. private _writeColorConstant;
  146999. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  147000. serialize(): any;
  147001. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147002. protected _dumpPropertiesCode(): string;
  147003. }
  147004. }
  147005. declare module BABYLON {
  147006. /**
  147007. * Block used to normalize lerp between 2 values
  147008. */
  147009. export class NLerpBlock extends NodeMaterialBlock {
  147010. /**
  147011. * Creates a new NLerpBlock
  147012. * @param name defines the block name
  147013. */
  147014. constructor(name: string);
  147015. /**
  147016. * Gets the current class name
  147017. * @returns the class name
  147018. */
  147019. getClassName(): string;
  147020. /**
  147021. * Gets the left operand input component
  147022. */
  147023. get left(): NodeMaterialConnectionPoint;
  147024. /**
  147025. * Gets the right operand input component
  147026. */
  147027. get right(): NodeMaterialConnectionPoint;
  147028. /**
  147029. * Gets the gradient operand input component
  147030. */
  147031. get gradient(): NodeMaterialConnectionPoint;
  147032. /**
  147033. * Gets the output component
  147034. */
  147035. get output(): NodeMaterialConnectionPoint;
  147036. protected _buildBlock(state: NodeMaterialBuildState): this;
  147037. }
  147038. }
  147039. declare module BABYLON {
  147040. /**
  147041. * block used to Generate a Worley Noise 3D Noise Pattern
  147042. */
  147043. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  147044. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  147045. manhattanDistance: boolean;
  147046. /**
  147047. * Creates a new WorleyNoise3DBlock
  147048. * @param name defines the block name
  147049. */
  147050. constructor(name: string);
  147051. /**
  147052. * Gets the current class name
  147053. * @returns the class name
  147054. */
  147055. getClassName(): string;
  147056. /**
  147057. * Gets the seed input component
  147058. */
  147059. get seed(): NodeMaterialConnectionPoint;
  147060. /**
  147061. * Gets the jitter input component
  147062. */
  147063. get jitter(): NodeMaterialConnectionPoint;
  147064. /**
  147065. * Gets the output component
  147066. */
  147067. get output(): NodeMaterialConnectionPoint;
  147068. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  147069. /**
  147070. * Exposes the properties to the UI?
  147071. */
  147072. protected _dumpPropertiesCode(): string;
  147073. /**
  147074. * Exposes the properties to the Seralize?
  147075. */
  147076. serialize(): any;
  147077. /**
  147078. * Exposes the properties to the deseralize?
  147079. */
  147080. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147081. }
  147082. }
  147083. declare module BABYLON {
  147084. /**
  147085. * block used to Generate a Simplex Perlin 3d Noise Pattern
  147086. */
  147087. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  147088. /**
  147089. * Creates a new SimplexPerlin3DBlock
  147090. * @param name defines the block name
  147091. */
  147092. constructor(name: string);
  147093. /**
  147094. * Gets the current class name
  147095. * @returns the class name
  147096. */
  147097. getClassName(): string;
  147098. /**
  147099. * Gets the seed operand input component
  147100. */
  147101. get seed(): NodeMaterialConnectionPoint;
  147102. /**
  147103. * Gets the output component
  147104. */
  147105. get output(): NodeMaterialConnectionPoint;
  147106. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  147107. }
  147108. }
  147109. declare module BABYLON {
  147110. /**
  147111. * Block used to blend normals
  147112. */
  147113. export class NormalBlendBlock extends NodeMaterialBlock {
  147114. /**
  147115. * Creates a new NormalBlendBlock
  147116. * @param name defines the block name
  147117. */
  147118. constructor(name: string);
  147119. /**
  147120. * Gets the current class name
  147121. * @returns the class name
  147122. */
  147123. getClassName(): string;
  147124. /**
  147125. * Gets the first input component
  147126. */
  147127. get normalMap0(): NodeMaterialConnectionPoint;
  147128. /**
  147129. * Gets the second input component
  147130. */
  147131. get normalMap1(): NodeMaterialConnectionPoint;
  147132. /**
  147133. * Gets the output component
  147134. */
  147135. get output(): NodeMaterialConnectionPoint;
  147136. protected _buildBlock(state: NodeMaterialBuildState): this;
  147137. }
  147138. }
  147139. declare module BABYLON {
  147140. /**
  147141. * Block used to rotate a 2d vector by a given angle
  147142. */
  147143. export class Rotate2dBlock extends NodeMaterialBlock {
  147144. /**
  147145. * Creates a new Rotate2dBlock
  147146. * @param name defines the block name
  147147. */
  147148. constructor(name: string);
  147149. /**
  147150. * Gets the current class name
  147151. * @returns the class name
  147152. */
  147153. getClassName(): string;
  147154. /**
  147155. * Gets the input vector
  147156. */
  147157. get input(): NodeMaterialConnectionPoint;
  147158. /**
  147159. * Gets the input angle
  147160. */
  147161. get angle(): NodeMaterialConnectionPoint;
  147162. /**
  147163. * Gets the output component
  147164. */
  147165. get output(): NodeMaterialConnectionPoint;
  147166. autoConfigure(material: NodeMaterial): void;
  147167. protected _buildBlock(state: NodeMaterialBuildState): this;
  147168. }
  147169. }
  147170. declare module BABYLON {
  147171. /**
  147172. * Block used to get the reflected vector from a direction and a normal
  147173. */
  147174. export class ReflectBlock extends NodeMaterialBlock {
  147175. /**
  147176. * Creates a new ReflectBlock
  147177. * @param name defines the block name
  147178. */
  147179. constructor(name: string);
  147180. /**
  147181. * Gets the current class name
  147182. * @returns the class name
  147183. */
  147184. getClassName(): string;
  147185. /**
  147186. * Gets the incident component
  147187. */
  147188. get incident(): NodeMaterialConnectionPoint;
  147189. /**
  147190. * Gets the normal component
  147191. */
  147192. get normal(): NodeMaterialConnectionPoint;
  147193. /**
  147194. * Gets the output component
  147195. */
  147196. get output(): NodeMaterialConnectionPoint;
  147197. protected _buildBlock(state: NodeMaterialBuildState): this;
  147198. }
  147199. }
  147200. declare module BABYLON {
  147201. /**
  147202. * Block used to get the refracted vector from a direction and a normal
  147203. */
  147204. export class RefractBlock extends NodeMaterialBlock {
  147205. /**
  147206. * Creates a new RefractBlock
  147207. * @param name defines the block name
  147208. */
  147209. constructor(name: string);
  147210. /**
  147211. * Gets the current class name
  147212. * @returns the class name
  147213. */
  147214. getClassName(): string;
  147215. /**
  147216. * Gets the incident component
  147217. */
  147218. get incident(): NodeMaterialConnectionPoint;
  147219. /**
  147220. * Gets the normal component
  147221. */
  147222. get normal(): NodeMaterialConnectionPoint;
  147223. /**
  147224. * Gets the index of refraction component
  147225. */
  147226. get ior(): NodeMaterialConnectionPoint;
  147227. /**
  147228. * Gets the output component
  147229. */
  147230. get output(): NodeMaterialConnectionPoint;
  147231. protected _buildBlock(state: NodeMaterialBuildState): this;
  147232. }
  147233. }
  147234. declare module BABYLON {
  147235. /**
  147236. * Block used to desaturate a color
  147237. */
  147238. export class DesaturateBlock extends NodeMaterialBlock {
  147239. /**
  147240. * Creates a new DesaturateBlock
  147241. * @param name defines the block name
  147242. */
  147243. constructor(name: string);
  147244. /**
  147245. * Gets the current class name
  147246. * @returns the class name
  147247. */
  147248. getClassName(): string;
  147249. /**
  147250. * Gets the color operand input component
  147251. */
  147252. get color(): NodeMaterialConnectionPoint;
  147253. /**
  147254. * Gets the level operand input component
  147255. */
  147256. get level(): NodeMaterialConnectionPoint;
  147257. /**
  147258. * Gets the output component
  147259. */
  147260. get output(): NodeMaterialConnectionPoint;
  147261. protected _buildBlock(state: NodeMaterialBuildState): this;
  147262. }
  147263. }
  147264. declare module BABYLON {
  147265. /**
  147266. * Block used to implement the reflection module of the PBR material
  147267. */
  147268. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  147269. /** @hidden */
  147270. _defineLODReflectionAlpha: string;
  147271. /** @hidden */
  147272. _defineLinearSpecularReflection: string;
  147273. private _vEnvironmentIrradianceName;
  147274. /** @hidden */
  147275. _vReflectionMicrosurfaceInfosName: string;
  147276. /** @hidden */
  147277. _vReflectionInfosName: string;
  147278. /** @hidden */
  147279. _vReflectionFilteringInfoName: string;
  147280. private _scene;
  147281. /**
  147282. * The properties below are set by the main PBR block prior to calling methods of this class.
  147283. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  147284. * It's less burden on the user side in the editor part.
  147285. */
  147286. /** @hidden */
  147287. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  147288. /** @hidden */
  147289. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  147290. /** @hidden */
  147291. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  147292. /** @hidden */
  147293. viewConnectionPoint: NodeMaterialConnectionPoint;
  147294. /**
  147295. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  147296. * diffuse part of the IBL.
  147297. */
  147298. useSphericalHarmonics: boolean;
  147299. /**
  147300. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  147301. */
  147302. forceIrradianceInFragment: boolean;
  147303. /**
  147304. * Create a new ReflectionBlock
  147305. * @param name defines the block name
  147306. */
  147307. constructor(name: string);
  147308. /**
  147309. * Gets the current class name
  147310. * @returns the class name
  147311. */
  147312. getClassName(): string;
  147313. /**
  147314. * Gets the position input component
  147315. */
  147316. get position(): NodeMaterialConnectionPoint;
  147317. /**
  147318. * Gets the world position input component
  147319. */
  147320. get worldPosition(): NodeMaterialConnectionPoint;
  147321. /**
  147322. * Gets the world normal input component
  147323. */
  147324. get worldNormal(): NodeMaterialConnectionPoint;
  147325. /**
  147326. * Gets the world input component
  147327. */
  147328. get world(): NodeMaterialConnectionPoint;
  147329. /**
  147330. * Gets the camera (or eye) position component
  147331. */
  147332. get cameraPosition(): NodeMaterialConnectionPoint;
  147333. /**
  147334. * Gets the view input component
  147335. */
  147336. get view(): NodeMaterialConnectionPoint;
  147337. /**
  147338. * Gets the color input component
  147339. */
  147340. get color(): NodeMaterialConnectionPoint;
  147341. /**
  147342. * Gets the reflection object output component
  147343. */
  147344. get reflection(): NodeMaterialConnectionPoint;
  147345. /**
  147346. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  147347. */
  147348. get hasTexture(): boolean;
  147349. /**
  147350. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  147351. */
  147352. get reflectionColor(): string;
  147353. protected _getTexture(): Nullable<BaseTexture>;
  147354. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147355. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  147356. /**
  147357. * Gets the code to inject in the vertex shader
  147358. * @param state current state of the node material building
  147359. * @returns the shader code
  147360. */
  147361. handleVertexSide(state: NodeMaterialBuildState): string;
  147362. /**
  147363. * Gets the main code of the block (fragment side)
  147364. * @param state current state of the node material building
  147365. * @param normalVarName name of the existing variable corresponding to the normal
  147366. * @returns the shader code
  147367. */
  147368. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  147369. protected _buildBlock(state: NodeMaterialBuildState): this;
  147370. protected _dumpPropertiesCode(): string;
  147371. serialize(): any;
  147372. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147373. }
  147374. }
  147375. declare module BABYLON {
  147376. /**
  147377. * Block used to implement the sheen module of the PBR material
  147378. */
  147379. export class SheenBlock extends NodeMaterialBlock {
  147380. /**
  147381. * Create a new SheenBlock
  147382. * @param name defines the block name
  147383. */
  147384. constructor(name: string);
  147385. /**
  147386. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  147387. * It allows the strength of the sheen effect to not depend on the base color of the material,
  147388. * making it easier to setup and tweak the effect
  147389. */
  147390. albedoScaling: boolean;
  147391. /**
  147392. * Defines if the sheen is linked to the sheen color.
  147393. */
  147394. linkSheenWithAlbedo: boolean;
  147395. /**
  147396. * Initialize the block and prepare the context for build
  147397. * @param state defines the state that will be used for the build
  147398. */
  147399. initialize(state: NodeMaterialBuildState): void;
  147400. /**
  147401. * Gets the current class name
  147402. * @returns the class name
  147403. */
  147404. getClassName(): string;
  147405. /**
  147406. * Gets the intensity input component
  147407. */
  147408. get intensity(): NodeMaterialConnectionPoint;
  147409. /**
  147410. * Gets the color input component
  147411. */
  147412. get color(): NodeMaterialConnectionPoint;
  147413. /**
  147414. * Gets the roughness input component
  147415. */
  147416. get roughness(): NodeMaterialConnectionPoint;
  147417. /**
  147418. * Gets the sheen object output component
  147419. */
  147420. get sheen(): NodeMaterialConnectionPoint;
  147421. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147422. /**
  147423. * Gets the main code of the block (fragment side)
  147424. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147425. * @returns the shader code
  147426. */
  147427. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  147428. protected _buildBlock(state: NodeMaterialBuildState): this;
  147429. protected _dumpPropertiesCode(): string;
  147430. serialize(): any;
  147431. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147432. }
  147433. }
  147434. declare module BABYLON {
  147435. /**
  147436. * Block used to implement the anisotropy module of the PBR material
  147437. */
  147438. export class AnisotropyBlock extends NodeMaterialBlock {
  147439. /**
  147440. * The two properties below are set by the main PBR block prior to calling methods of this class.
  147441. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  147442. * It's less burden on the user side in the editor part.
  147443. */
  147444. /** @hidden */
  147445. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  147446. /** @hidden */
  147447. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  147448. /**
  147449. * Create a new AnisotropyBlock
  147450. * @param name defines the block name
  147451. */
  147452. constructor(name: string);
  147453. /**
  147454. * Initialize the block and prepare the context for build
  147455. * @param state defines the state that will be used for the build
  147456. */
  147457. initialize(state: NodeMaterialBuildState): void;
  147458. /**
  147459. * Gets the current class name
  147460. * @returns the class name
  147461. */
  147462. getClassName(): string;
  147463. /**
  147464. * Gets the intensity input component
  147465. */
  147466. get intensity(): NodeMaterialConnectionPoint;
  147467. /**
  147468. * Gets the direction input component
  147469. */
  147470. get direction(): NodeMaterialConnectionPoint;
  147471. /**
  147472. * Gets the uv input component
  147473. */
  147474. get uv(): NodeMaterialConnectionPoint;
  147475. /**
  147476. * Gets the worldTangent input component
  147477. */
  147478. get worldTangent(): NodeMaterialConnectionPoint;
  147479. /**
  147480. * Gets the anisotropy object output component
  147481. */
  147482. get anisotropy(): NodeMaterialConnectionPoint;
  147483. private _generateTBNSpace;
  147484. /**
  147485. * Gets the main code of the block (fragment side)
  147486. * @param state current state of the node material building
  147487. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  147488. * @returns the shader code
  147489. */
  147490. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  147491. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147492. protected _buildBlock(state: NodeMaterialBuildState): this;
  147493. }
  147494. }
  147495. declare module BABYLON {
  147496. /**
  147497. * Block used to implement the clear coat module of the PBR material
  147498. */
  147499. export class ClearCoatBlock extends NodeMaterialBlock {
  147500. private _scene;
  147501. /**
  147502. * Create a new ClearCoatBlock
  147503. * @param name defines the block name
  147504. */
  147505. constructor(name: string);
  147506. /**
  147507. * Defines if the F0 value should be remapped to account for the interface change in the material.
  147508. */
  147509. remapF0OnInterfaceChange: boolean;
  147510. /**
  147511. * Initialize the block and prepare the context for build
  147512. * @param state defines the state that will be used for the build
  147513. */
  147514. initialize(state: NodeMaterialBuildState): void;
  147515. /**
  147516. * Gets the current class name
  147517. * @returns the class name
  147518. */
  147519. getClassName(): string;
  147520. /**
  147521. * Gets the intensity input component
  147522. */
  147523. get intensity(): NodeMaterialConnectionPoint;
  147524. /**
  147525. * Gets the roughness input component
  147526. */
  147527. get roughness(): NodeMaterialConnectionPoint;
  147528. /**
  147529. * Gets the ior input component
  147530. */
  147531. get indexOfRefraction(): NodeMaterialConnectionPoint;
  147532. /**
  147533. * Gets the bump texture input component
  147534. */
  147535. get normalMapColor(): NodeMaterialConnectionPoint;
  147536. /**
  147537. * Gets the uv input component
  147538. */
  147539. get uv(): NodeMaterialConnectionPoint;
  147540. /**
  147541. * Gets the tint color input component
  147542. */
  147543. get tintColor(): NodeMaterialConnectionPoint;
  147544. /**
  147545. * Gets the tint "at distance" input component
  147546. */
  147547. get tintAtDistance(): NodeMaterialConnectionPoint;
  147548. /**
  147549. * Gets the tint thickness input component
  147550. */
  147551. get tintThickness(): NodeMaterialConnectionPoint;
  147552. /**
  147553. * Gets the world tangent input component
  147554. */
  147555. get worldTangent(): NodeMaterialConnectionPoint;
  147556. /**
  147557. * Gets the clear coat object output component
  147558. */
  147559. get clearcoat(): NodeMaterialConnectionPoint;
  147560. autoConfigure(material: NodeMaterial): void;
  147561. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147562. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  147563. private _generateTBNSpace;
  147564. /**
  147565. * Gets the main code of the block (fragment side)
  147566. * @param state current state of the node material building
  147567. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  147568. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147569. * @param worldPosVarName name of the variable holding the world position
  147570. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  147571. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  147572. * @param worldNormalVarName name of the variable holding the world normal
  147573. * @returns the shader code
  147574. */
  147575. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  147576. protected _buildBlock(state: NodeMaterialBuildState): this;
  147577. protected _dumpPropertiesCode(): string;
  147578. serialize(): any;
  147579. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147580. }
  147581. }
  147582. declare module BABYLON {
  147583. /**
  147584. * Block used to implement the sub surface module of the PBR material
  147585. */
  147586. export class SubSurfaceBlock extends NodeMaterialBlock {
  147587. /**
  147588. * Create a new SubSurfaceBlock
  147589. * @param name defines the block name
  147590. */
  147591. constructor(name: string);
  147592. /**
  147593. * Initialize the block and prepare the context for build
  147594. * @param state defines the state that will be used for the build
  147595. */
  147596. initialize(state: NodeMaterialBuildState): void;
  147597. /**
  147598. * Gets the current class name
  147599. * @returns the class name
  147600. */
  147601. getClassName(): string;
  147602. /**
  147603. * Gets the thickness component
  147604. */
  147605. get thickness(): NodeMaterialConnectionPoint;
  147606. /**
  147607. * Gets the tint color input component
  147608. */
  147609. get tintColor(): NodeMaterialConnectionPoint;
  147610. /**
  147611. * Gets the translucency intensity input component
  147612. */
  147613. get translucencyIntensity(): NodeMaterialConnectionPoint;
  147614. /**
  147615. * Gets the translucency diffusion distance input component
  147616. */
  147617. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  147618. /**
  147619. * Gets the refraction object parameters
  147620. */
  147621. get refraction(): NodeMaterialConnectionPoint;
  147622. /**
  147623. * Gets the sub surface object output component
  147624. */
  147625. get subsurface(): NodeMaterialConnectionPoint;
  147626. autoConfigure(material: NodeMaterial): void;
  147627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147628. /**
  147629. * Gets the main code of the block (fragment side)
  147630. * @param state current state of the node material building
  147631. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  147632. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147633. * @param worldPosVarName name of the variable holding the world position
  147634. * @returns the shader code
  147635. */
  147636. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  147637. protected _buildBlock(state: NodeMaterialBuildState): this;
  147638. }
  147639. }
  147640. declare module BABYLON {
  147641. /**
  147642. * Block used to implement the PBR metallic/roughness model
  147643. */
  147644. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  147645. /**
  147646. * Gets or sets the light associated with this block
  147647. */
  147648. light: Nullable<Light>;
  147649. private _lightId;
  147650. private _scene;
  147651. private _environmentBRDFTexture;
  147652. private _environmentBrdfSamplerName;
  147653. private _vNormalWName;
  147654. private _invertNormalName;
  147655. private _metallicReflectanceColor;
  147656. private _metallicF0Factor;
  147657. private _vMetallicReflectanceFactorsName;
  147658. /**
  147659. * Create a new ReflectionBlock
  147660. * @param name defines the block name
  147661. */
  147662. constructor(name: string);
  147663. /**
  147664. * Intensity of the direct lights e.g. the four lights available in your scene.
  147665. * This impacts both the direct diffuse and specular highlights.
  147666. */
  147667. directIntensity: number;
  147668. /**
  147669. * Intensity of the environment e.g. how much the environment will light the object
  147670. * either through harmonics for rough material or through the refelction for shiny ones.
  147671. */
  147672. environmentIntensity: number;
  147673. /**
  147674. * This is a special control allowing the reduction of the specular highlights coming from the
  147675. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  147676. */
  147677. specularIntensity: number;
  147678. /**
  147679. * Defines the falloff type used in this material.
  147680. * It by default is Physical.
  147681. */
  147682. lightFalloff: number;
  147683. /**
  147684. * Specifies that alpha test should be used
  147685. */
  147686. useAlphaTest: boolean;
  147687. /**
  147688. * Defines the alpha limits in alpha test mode.
  147689. */
  147690. alphaTestCutoff: number;
  147691. /**
  147692. * Specifies that alpha blending should be used
  147693. */
  147694. useAlphaBlending: boolean;
  147695. /**
  147696. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  147697. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  147698. */
  147699. useRadianceOverAlpha: boolean;
  147700. /**
  147701. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  147702. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  147703. */
  147704. useSpecularOverAlpha: boolean;
  147705. /**
  147706. * Enables specular anti aliasing in the PBR shader.
  147707. * It will both interacts on the Geometry for analytical and IBL lighting.
  147708. * It also prefilter the roughness map based on the bump values.
  147709. */
  147710. enableSpecularAntiAliasing: boolean;
  147711. /**
  147712. * Enables realtime filtering on the texture.
  147713. */
  147714. realTimeFiltering: boolean;
  147715. /**
  147716. * Quality switch for realtime filtering
  147717. */
  147718. realTimeFilteringQuality: number;
  147719. /**
  147720. * Defines if the material uses energy conservation.
  147721. */
  147722. useEnergyConservation: boolean;
  147723. /**
  147724. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  147725. * too much the area relying on ambient texture to define their ambient occlusion.
  147726. */
  147727. useRadianceOcclusion: boolean;
  147728. /**
  147729. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  147730. * makes the reflect vector face the model (under horizon).
  147731. */
  147732. useHorizonOcclusion: boolean;
  147733. /**
  147734. * If set to true, no lighting calculations will be applied.
  147735. */
  147736. unlit: boolean;
  147737. /**
  147738. * Force normal to face away from face.
  147739. */
  147740. forceNormalForward: boolean;
  147741. /**
  147742. * Defines the material debug mode.
  147743. * It helps seeing only some components of the material while troubleshooting.
  147744. */
  147745. debugMode: number;
  147746. /**
  147747. * Specify from where on screen the debug mode should start.
  147748. * The value goes from -1 (full screen) to 1 (not visible)
  147749. * It helps with side by side comparison against the final render
  147750. * This defaults to 0
  147751. */
  147752. debugLimit: number;
  147753. /**
  147754. * As the default viewing range might not be enough (if the ambient is really small for instance)
  147755. * You can use the factor to better multiply the final value.
  147756. */
  147757. debugFactor: number;
  147758. /**
  147759. * Initialize the block and prepare the context for build
  147760. * @param state defines the state that will be used for the build
  147761. */
  147762. initialize(state: NodeMaterialBuildState): void;
  147763. /**
  147764. * Gets the current class name
  147765. * @returns the class name
  147766. */
  147767. getClassName(): string;
  147768. /**
  147769. * Gets the world position input component
  147770. */
  147771. get worldPosition(): NodeMaterialConnectionPoint;
  147772. /**
  147773. * Gets the world normal input component
  147774. */
  147775. get worldNormal(): NodeMaterialConnectionPoint;
  147776. /**
  147777. * Gets the view matrix parameter
  147778. */
  147779. get view(): NodeMaterialConnectionPoint;
  147780. /**
  147781. * Gets the camera position input component
  147782. */
  147783. get cameraPosition(): NodeMaterialConnectionPoint;
  147784. /**
  147785. * Gets the perturbed normal input component
  147786. */
  147787. get perturbedNormal(): NodeMaterialConnectionPoint;
  147788. /**
  147789. * Gets the base color input component
  147790. */
  147791. get baseColor(): NodeMaterialConnectionPoint;
  147792. /**
  147793. * Gets the metallic input component
  147794. */
  147795. get metallic(): NodeMaterialConnectionPoint;
  147796. /**
  147797. * Gets the roughness input component
  147798. */
  147799. get roughness(): NodeMaterialConnectionPoint;
  147800. /**
  147801. * Gets the ambient occlusion input component
  147802. */
  147803. get ambientOcc(): NodeMaterialConnectionPoint;
  147804. /**
  147805. * Gets the opacity input component
  147806. */
  147807. get opacity(): NodeMaterialConnectionPoint;
  147808. /**
  147809. * Gets the index of refraction input component
  147810. */
  147811. get indexOfRefraction(): NodeMaterialConnectionPoint;
  147812. /**
  147813. * Gets the ambient color input component
  147814. */
  147815. get ambientColor(): NodeMaterialConnectionPoint;
  147816. /**
  147817. * Gets the reflection object parameters
  147818. */
  147819. get reflection(): NodeMaterialConnectionPoint;
  147820. /**
  147821. * Gets the clear coat object parameters
  147822. */
  147823. get clearcoat(): NodeMaterialConnectionPoint;
  147824. /**
  147825. * Gets the sheen object parameters
  147826. */
  147827. get sheen(): NodeMaterialConnectionPoint;
  147828. /**
  147829. * Gets the sub surface object parameters
  147830. */
  147831. get subsurface(): NodeMaterialConnectionPoint;
  147832. /**
  147833. * Gets the anisotropy object parameters
  147834. */
  147835. get anisotropy(): NodeMaterialConnectionPoint;
  147836. /**
  147837. * Gets the ambient output component
  147838. */
  147839. get ambientClr(): NodeMaterialConnectionPoint;
  147840. /**
  147841. * Gets the diffuse output component
  147842. */
  147843. get diffuseDir(): NodeMaterialConnectionPoint;
  147844. /**
  147845. * Gets the specular output component
  147846. */
  147847. get specularDir(): NodeMaterialConnectionPoint;
  147848. /**
  147849. * Gets the clear coat output component
  147850. */
  147851. get clearcoatDir(): NodeMaterialConnectionPoint;
  147852. /**
  147853. * Gets the sheen output component
  147854. */
  147855. get sheenDir(): NodeMaterialConnectionPoint;
  147856. /**
  147857. * Gets the indirect diffuse output component
  147858. */
  147859. get diffuseIndirect(): NodeMaterialConnectionPoint;
  147860. /**
  147861. * Gets the indirect specular output component
  147862. */
  147863. get specularIndirect(): NodeMaterialConnectionPoint;
  147864. /**
  147865. * Gets the indirect clear coat output component
  147866. */
  147867. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  147868. /**
  147869. * Gets the indirect sheen output component
  147870. */
  147871. get sheenIndirect(): NodeMaterialConnectionPoint;
  147872. /**
  147873. * Gets the refraction output component
  147874. */
  147875. get refraction(): NodeMaterialConnectionPoint;
  147876. /**
  147877. * Gets the global lighting output component
  147878. */
  147879. get lighting(): NodeMaterialConnectionPoint;
  147880. /**
  147881. * Gets the shadow output component
  147882. */
  147883. get shadow(): NodeMaterialConnectionPoint;
  147884. /**
  147885. * Gets the alpha output component
  147886. */
  147887. get alpha(): NodeMaterialConnectionPoint;
  147888. autoConfigure(material: NodeMaterial): void;
  147889. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147890. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  147891. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  147892. private _injectVertexCode;
  147893. private _getAlbedoOpacityCode;
  147894. private _getAmbientOcclusionCode;
  147895. private _getReflectivityCode;
  147896. protected _buildBlock(state: NodeMaterialBuildState): this;
  147897. protected _dumpPropertiesCode(): string;
  147898. serialize(): any;
  147899. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147900. }
  147901. }
  147902. declare module BABYLON {
  147903. /**
  147904. * Block used to compute value of one parameter modulo another
  147905. */
  147906. export class ModBlock extends NodeMaterialBlock {
  147907. /**
  147908. * Creates a new ModBlock
  147909. * @param name defines the block name
  147910. */
  147911. constructor(name: string);
  147912. /**
  147913. * Gets the current class name
  147914. * @returns the class name
  147915. */
  147916. getClassName(): string;
  147917. /**
  147918. * Gets the left operand input component
  147919. */
  147920. get left(): NodeMaterialConnectionPoint;
  147921. /**
  147922. * Gets the right operand input component
  147923. */
  147924. get right(): NodeMaterialConnectionPoint;
  147925. /**
  147926. * Gets the output component
  147927. */
  147928. get output(): NodeMaterialConnectionPoint;
  147929. protected _buildBlock(state: NodeMaterialBuildState): this;
  147930. }
  147931. }
  147932. declare module BABYLON {
  147933. /**
  147934. * Configuration for Draco compression
  147935. */
  147936. export interface IDracoCompressionConfiguration {
  147937. /**
  147938. * Configuration for the decoder.
  147939. */
  147940. decoder: {
  147941. /**
  147942. * The url to the WebAssembly module.
  147943. */
  147944. wasmUrl?: string;
  147945. /**
  147946. * The url to the WebAssembly binary.
  147947. */
  147948. wasmBinaryUrl?: string;
  147949. /**
  147950. * The url to the fallback JavaScript module.
  147951. */
  147952. fallbackUrl?: string;
  147953. };
  147954. }
  147955. /**
  147956. * Draco compression (https://google.github.io/draco/)
  147957. *
  147958. * This class wraps the Draco module.
  147959. *
  147960. * **Encoder**
  147961. *
  147962. * The encoder is not currently implemented.
  147963. *
  147964. * **Decoder**
  147965. *
  147966. * 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.
  147967. *
  147968. * To update the configuration, use the following code:
  147969. * ```javascript
  147970. * DracoCompression.Configuration = {
  147971. * decoder: {
  147972. * wasmUrl: "<url to the WebAssembly library>",
  147973. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  147974. * fallbackUrl: "<url to the fallback JavaScript library>",
  147975. * }
  147976. * };
  147977. * ```
  147978. *
  147979. * 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.
  147980. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  147981. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  147982. *
  147983. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  147984. * ```javascript
  147985. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  147986. * ```
  147987. *
  147988. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  147989. */
  147990. export class DracoCompression implements IDisposable {
  147991. private _workerPoolPromise?;
  147992. private _decoderModulePromise?;
  147993. /**
  147994. * The configuration. Defaults to the following urls:
  147995. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  147996. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  147997. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  147998. */
  147999. static Configuration: IDracoCompressionConfiguration;
  148000. /**
  148001. * Returns true if the decoder configuration is available.
  148002. */
  148003. static get DecoderAvailable(): boolean;
  148004. /**
  148005. * Default number of workers to create when creating the draco compression object.
  148006. */
  148007. static DefaultNumWorkers: number;
  148008. private static GetDefaultNumWorkers;
  148009. private static _Default;
  148010. /**
  148011. * Default instance for the draco compression object.
  148012. */
  148013. static get Default(): DracoCompression;
  148014. /**
  148015. * Constructor
  148016. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  148017. */
  148018. constructor(numWorkers?: number);
  148019. /**
  148020. * Stop all async operations and release resources.
  148021. */
  148022. dispose(): void;
  148023. /**
  148024. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  148025. * @returns a promise that resolves when ready
  148026. */
  148027. whenReadyAsync(): Promise<void>;
  148028. /**
  148029. * Decode Draco compressed mesh data to vertex data.
  148030. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  148031. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  148032. * @returns A promise that resolves with the decoded vertex data
  148033. */
  148034. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  148035. [kind: string]: number;
  148036. }): Promise<VertexData>;
  148037. }
  148038. }
  148039. declare module BABYLON {
  148040. /**
  148041. * Class for building Constructive Solid Geometry
  148042. */
  148043. export class CSG {
  148044. private polygons;
  148045. /**
  148046. * The world matrix
  148047. */
  148048. matrix: Matrix;
  148049. /**
  148050. * Stores the position
  148051. */
  148052. position: Vector3;
  148053. /**
  148054. * Stores the rotation
  148055. */
  148056. rotation: Vector3;
  148057. /**
  148058. * Stores the rotation quaternion
  148059. */
  148060. rotationQuaternion: Nullable<Quaternion>;
  148061. /**
  148062. * Stores the scaling vector
  148063. */
  148064. scaling: Vector3;
  148065. /**
  148066. * Convert the Mesh to CSG
  148067. * @param mesh The Mesh to convert to CSG
  148068. * @returns A new CSG from the Mesh
  148069. */
  148070. static FromMesh(mesh: Mesh): CSG;
  148071. /**
  148072. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  148073. * @param polygons Polygons used to construct a CSG solid
  148074. */
  148075. private static FromPolygons;
  148076. /**
  148077. * Clones, or makes a deep copy, of the CSG
  148078. * @returns A new CSG
  148079. */
  148080. clone(): CSG;
  148081. /**
  148082. * Unions this CSG with another CSG
  148083. * @param csg The CSG to union against this CSG
  148084. * @returns The unioned CSG
  148085. */
  148086. union(csg: CSG): CSG;
  148087. /**
  148088. * Unions this CSG with another CSG in place
  148089. * @param csg The CSG to union against this CSG
  148090. */
  148091. unionInPlace(csg: CSG): void;
  148092. /**
  148093. * Subtracts this CSG with another CSG
  148094. * @param csg The CSG to subtract against this CSG
  148095. * @returns A new CSG
  148096. */
  148097. subtract(csg: CSG): CSG;
  148098. /**
  148099. * Subtracts this CSG with another CSG in place
  148100. * @param csg The CSG to subtact against this CSG
  148101. */
  148102. subtractInPlace(csg: CSG): void;
  148103. /**
  148104. * Intersect this CSG with another CSG
  148105. * @param csg The CSG to intersect against this CSG
  148106. * @returns A new CSG
  148107. */
  148108. intersect(csg: CSG): CSG;
  148109. /**
  148110. * Intersects this CSG with another CSG in place
  148111. * @param csg The CSG to intersect against this CSG
  148112. */
  148113. intersectInPlace(csg: CSG): void;
  148114. /**
  148115. * Return a new CSG solid with solid and empty space switched. This solid is
  148116. * not modified.
  148117. * @returns A new CSG solid with solid and empty space switched
  148118. */
  148119. inverse(): CSG;
  148120. /**
  148121. * Inverses the CSG in place
  148122. */
  148123. inverseInPlace(): void;
  148124. /**
  148125. * This is used to keep meshes transformations so they can be restored
  148126. * when we build back a Babylon Mesh
  148127. * NB : All CSG operations are performed in world coordinates
  148128. * @param csg The CSG to copy the transform attributes from
  148129. * @returns This CSG
  148130. */
  148131. copyTransformAttributes(csg: CSG): CSG;
  148132. /**
  148133. * Build Raw mesh from CSG
  148134. * Coordinates here are in world space
  148135. * @param name The name of the mesh geometry
  148136. * @param scene The Scene
  148137. * @param keepSubMeshes Specifies if the submeshes should be kept
  148138. * @returns A new Mesh
  148139. */
  148140. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  148141. /**
  148142. * Build Mesh from CSG taking material and transforms into account
  148143. * @param name The name of the Mesh
  148144. * @param material The material of the Mesh
  148145. * @param scene The Scene
  148146. * @param keepSubMeshes Specifies if submeshes should be kept
  148147. * @returns The new Mesh
  148148. */
  148149. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  148150. }
  148151. }
  148152. declare module BABYLON {
  148153. /**
  148154. * Class used to create a trail following a mesh
  148155. */
  148156. export class TrailMesh extends Mesh {
  148157. private _generator;
  148158. private _autoStart;
  148159. private _running;
  148160. private _diameter;
  148161. private _length;
  148162. private _sectionPolygonPointsCount;
  148163. private _sectionVectors;
  148164. private _sectionNormalVectors;
  148165. private _beforeRenderObserver;
  148166. /**
  148167. * @constructor
  148168. * @param name The value used by scene.getMeshByName() to do a lookup.
  148169. * @param generator The mesh or transform node to generate a trail.
  148170. * @param scene The scene to add this mesh to.
  148171. * @param diameter Diameter of trailing mesh. Default is 1.
  148172. * @param length Length of trailing mesh. Default is 60.
  148173. * @param autoStart Automatically start trailing mesh. Default true.
  148174. */
  148175. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  148176. /**
  148177. * "TrailMesh"
  148178. * @returns "TrailMesh"
  148179. */
  148180. getClassName(): string;
  148181. private _createMesh;
  148182. /**
  148183. * Start trailing mesh.
  148184. */
  148185. start(): void;
  148186. /**
  148187. * Stop trailing mesh.
  148188. */
  148189. stop(): void;
  148190. /**
  148191. * Update trailing mesh geometry.
  148192. */
  148193. update(): void;
  148194. /**
  148195. * Returns a new TrailMesh object.
  148196. * @param name is a string, the name given to the new mesh
  148197. * @param newGenerator use new generator object for cloned trail mesh
  148198. * @returns a new mesh
  148199. */
  148200. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  148201. /**
  148202. * Serializes this trail mesh
  148203. * @param serializationObject object to write serialization to
  148204. */
  148205. serialize(serializationObject: any): void;
  148206. /**
  148207. * Parses a serialized trail mesh
  148208. * @param parsedMesh the serialized mesh
  148209. * @param scene the scene to create the trail mesh in
  148210. * @returns the created trail mesh
  148211. */
  148212. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  148213. }
  148214. }
  148215. declare module BABYLON {
  148216. /**
  148217. * Class containing static functions to help procedurally build meshes
  148218. */
  148219. export class TiledBoxBuilder {
  148220. /**
  148221. * Creates a box mesh
  148222. * 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)
  148223. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148224. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148225. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148227. * @param name defines the name of the mesh
  148228. * @param options defines the options used to create the mesh
  148229. * @param scene defines the hosting scene
  148230. * @returns the box mesh
  148231. */
  148232. static CreateTiledBox(name: string, options: {
  148233. pattern?: number;
  148234. width?: number;
  148235. height?: number;
  148236. depth?: number;
  148237. tileSize?: number;
  148238. tileWidth?: number;
  148239. tileHeight?: number;
  148240. alignHorizontal?: number;
  148241. alignVertical?: number;
  148242. faceUV?: Vector4[];
  148243. faceColors?: Color4[];
  148244. sideOrientation?: number;
  148245. updatable?: boolean;
  148246. }, scene?: Nullable<Scene>): Mesh;
  148247. }
  148248. }
  148249. declare module BABYLON {
  148250. /**
  148251. * Class containing static functions to help procedurally build meshes
  148252. */
  148253. export class TorusKnotBuilder {
  148254. /**
  148255. * Creates a torus knot mesh
  148256. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  148257. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  148258. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  148259. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  148260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148263. * @param name defines the name of the mesh
  148264. * @param options defines the options used to create the mesh
  148265. * @param scene defines the hosting scene
  148266. * @returns the torus knot mesh
  148267. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  148268. */
  148269. static CreateTorusKnot(name: string, options: {
  148270. radius?: number;
  148271. tube?: number;
  148272. radialSegments?: number;
  148273. tubularSegments?: number;
  148274. p?: number;
  148275. q?: number;
  148276. updatable?: boolean;
  148277. sideOrientation?: number;
  148278. frontUVs?: Vector4;
  148279. backUVs?: Vector4;
  148280. }, scene: any): Mesh;
  148281. }
  148282. }
  148283. declare module BABYLON {
  148284. /**
  148285. * Polygon
  148286. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  148287. */
  148288. export class Polygon {
  148289. /**
  148290. * Creates a rectangle
  148291. * @param xmin bottom X coord
  148292. * @param ymin bottom Y coord
  148293. * @param xmax top X coord
  148294. * @param ymax top Y coord
  148295. * @returns points that make the resulting rectation
  148296. */
  148297. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  148298. /**
  148299. * Creates a circle
  148300. * @param radius radius of circle
  148301. * @param cx scale in x
  148302. * @param cy scale in y
  148303. * @param numberOfSides number of sides that make up the circle
  148304. * @returns points that make the resulting circle
  148305. */
  148306. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  148307. /**
  148308. * Creates a polygon from input string
  148309. * @param input Input polygon data
  148310. * @returns the parsed points
  148311. */
  148312. static Parse(input: string): Vector2[];
  148313. /**
  148314. * Starts building a polygon from x and y coordinates
  148315. * @param x x coordinate
  148316. * @param y y coordinate
  148317. * @returns the started path2
  148318. */
  148319. static StartingAt(x: number, y: number): Path2;
  148320. }
  148321. /**
  148322. * Builds a polygon
  148323. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  148324. */
  148325. export class PolygonMeshBuilder {
  148326. private _points;
  148327. private _outlinepoints;
  148328. private _holes;
  148329. private _name;
  148330. private _scene;
  148331. private _epoints;
  148332. private _eholes;
  148333. private _addToepoint;
  148334. /**
  148335. * Babylon reference to the earcut plugin.
  148336. */
  148337. bjsEarcut: any;
  148338. /**
  148339. * Creates a PolygonMeshBuilder
  148340. * @param name name of the builder
  148341. * @param contours Path of the polygon
  148342. * @param scene scene to add to when creating the mesh
  148343. * @param earcutInjection can be used to inject your own earcut reference
  148344. */
  148345. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  148346. /**
  148347. * Adds a whole within the polygon
  148348. * @param hole Array of points defining the hole
  148349. * @returns this
  148350. */
  148351. addHole(hole: Vector2[]): PolygonMeshBuilder;
  148352. /**
  148353. * Creates the polygon
  148354. * @param updatable If the mesh should be updatable
  148355. * @param depth The depth of the mesh created
  148356. * @returns the created mesh
  148357. */
  148358. build(updatable?: boolean, depth?: number): Mesh;
  148359. /**
  148360. * Creates the polygon
  148361. * @param depth The depth of the mesh created
  148362. * @returns the created VertexData
  148363. */
  148364. buildVertexData(depth?: number): VertexData;
  148365. /**
  148366. * Adds a side to the polygon
  148367. * @param positions points that make the polygon
  148368. * @param normals normals of the polygon
  148369. * @param uvs uvs of the polygon
  148370. * @param indices indices of the polygon
  148371. * @param bounds bounds of the polygon
  148372. * @param points points of the polygon
  148373. * @param depth depth of the polygon
  148374. * @param flip flip of the polygon
  148375. */
  148376. private addSide;
  148377. }
  148378. }
  148379. declare module BABYLON {
  148380. /**
  148381. * Class containing static functions to help procedurally build meshes
  148382. */
  148383. export class PolygonBuilder {
  148384. /**
  148385. * Creates a polygon mesh
  148386. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  148387. * * 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
  148388. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148390. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  148391. * * Remember you can only change the shape positions, not their number when updating a polygon
  148392. * @param name defines the name of the mesh
  148393. * @param options defines the options used to create the mesh
  148394. * @param scene defines the hosting scene
  148395. * @param earcutInjection can be used to inject your own earcut reference
  148396. * @returns the polygon mesh
  148397. */
  148398. static CreatePolygon(name: string, options: {
  148399. shape: Vector3[];
  148400. holes?: Vector3[][];
  148401. depth?: number;
  148402. faceUV?: Vector4[];
  148403. faceColors?: Color4[];
  148404. updatable?: boolean;
  148405. sideOrientation?: number;
  148406. frontUVs?: Vector4;
  148407. backUVs?: Vector4;
  148408. wrap?: boolean;
  148409. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148410. /**
  148411. * Creates an extruded polygon mesh, with depth in the Y direction.
  148412. * * 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)
  148413. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  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. * @param earcutInjection can be used to inject your own earcut reference
  148418. * @returns the polygon mesh
  148419. */
  148420. static ExtrudePolygon(name: string, options: {
  148421. shape: Vector3[];
  148422. holes?: Vector3[][];
  148423. depth?: number;
  148424. faceUV?: Vector4[];
  148425. faceColors?: Color4[];
  148426. updatable?: boolean;
  148427. sideOrientation?: number;
  148428. frontUVs?: Vector4;
  148429. backUVs?: Vector4;
  148430. wrap?: boolean;
  148431. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148432. }
  148433. }
  148434. declare module BABYLON {
  148435. /**
  148436. * Class containing static functions to help procedurally build meshes
  148437. */
  148438. export class LatheBuilder {
  148439. /**
  148440. * Creates lathe mesh.
  148441. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  148442. * * 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
  148443. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  148444. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  148445. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  148446. * * 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
  148447. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  148448. * * 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
  148449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148453. * @param name defines the name of the mesh
  148454. * @param options defines the options used to create the mesh
  148455. * @param scene defines the hosting scene
  148456. * @returns the lathe mesh
  148457. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  148458. */
  148459. static CreateLathe(name: string, options: {
  148460. shape: Vector3[];
  148461. radius?: number;
  148462. tessellation?: number;
  148463. clip?: number;
  148464. arc?: number;
  148465. closed?: boolean;
  148466. updatable?: boolean;
  148467. sideOrientation?: number;
  148468. frontUVs?: Vector4;
  148469. backUVs?: Vector4;
  148470. cap?: number;
  148471. invertUV?: boolean;
  148472. }, scene?: Nullable<Scene>): Mesh;
  148473. }
  148474. }
  148475. declare module BABYLON {
  148476. /**
  148477. * Class containing static functions to help procedurally build meshes
  148478. */
  148479. export class TiledPlaneBuilder {
  148480. /**
  148481. * Creates a tiled plane mesh
  148482. * * The parameter `pattern` will, depending on value, do nothing or
  148483. * * * flip (reflect about central vertical) alternate tiles across and up
  148484. * * * flip every tile on alternate rows
  148485. * * * rotate (180 degs) alternate tiles across and up
  148486. * * * rotate every tile on alternate rows
  148487. * * * flip and rotate alternate tiles across and up
  148488. * * * flip and rotate every tile on alternate rows
  148489. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  148490. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  148491. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148492. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148493. * * 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)
  148494. * * 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)
  148495. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  148496. * @param name defines the name of the mesh
  148497. * @param options defines the options used to create the mesh
  148498. * @param scene defines the hosting scene
  148499. * @returns the box mesh
  148500. */
  148501. static CreateTiledPlane(name: string, options: {
  148502. pattern?: number;
  148503. tileSize?: number;
  148504. tileWidth?: number;
  148505. tileHeight?: number;
  148506. size?: number;
  148507. width?: number;
  148508. height?: number;
  148509. alignHorizontal?: number;
  148510. alignVertical?: number;
  148511. sideOrientation?: number;
  148512. frontUVs?: Vector4;
  148513. backUVs?: Vector4;
  148514. updatable?: boolean;
  148515. }, scene?: Nullable<Scene>): Mesh;
  148516. }
  148517. }
  148518. declare module BABYLON {
  148519. /**
  148520. * Class containing static functions to help procedurally build meshes
  148521. */
  148522. export class TubeBuilder {
  148523. /**
  148524. * Creates a tube mesh.
  148525. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148526. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  148527. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  148528. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  148529. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  148530. * * 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)
  148531. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  148532. * * 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
  148533. * * 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
  148534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148535. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148536. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148538. * @param name defines the name of the mesh
  148539. * @param options defines the options used to create the mesh
  148540. * @param scene defines the hosting scene
  148541. * @returns the tube mesh
  148542. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148543. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  148544. */
  148545. static CreateTube(name: string, options: {
  148546. path: Vector3[];
  148547. radius?: number;
  148548. tessellation?: number;
  148549. radiusFunction?: {
  148550. (i: number, distance: number): number;
  148551. };
  148552. cap?: number;
  148553. arc?: number;
  148554. updatable?: boolean;
  148555. sideOrientation?: number;
  148556. frontUVs?: Vector4;
  148557. backUVs?: Vector4;
  148558. instance?: Mesh;
  148559. invertUV?: boolean;
  148560. }, scene?: Nullable<Scene>): Mesh;
  148561. }
  148562. }
  148563. declare module BABYLON {
  148564. /**
  148565. * Class containing static functions to help procedurally build meshes
  148566. */
  148567. export class IcoSphereBuilder {
  148568. /**
  148569. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148570. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148571. * * 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`)
  148572. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148573. * * 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
  148574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148577. * @param name defines the name of the mesh
  148578. * @param options defines the options used to create the mesh
  148579. * @param scene defines the hosting scene
  148580. * @returns the icosahedron mesh
  148581. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148582. */
  148583. static CreateIcoSphere(name: string, options: {
  148584. radius?: number;
  148585. radiusX?: number;
  148586. radiusY?: number;
  148587. radiusZ?: number;
  148588. flat?: boolean;
  148589. subdivisions?: number;
  148590. sideOrientation?: number;
  148591. frontUVs?: Vector4;
  148592. backUVs?: Vector4;
  148593. updatable?: boolean;
  148594. }, scene?: Nullable<Scene>): Mesh;
  148595. }
  148596. }
  148597. declare module BABYLON {
  148598. /**
  148599. * Class containing static functions to help procedurally build meshes
  148600. */
  148601. export class DecalBuilder {
  148602. /**
  148603. * Creates a decal mesh.
  148604. * 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
  148605. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  148606. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  148607. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  148608. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  148609. * @param name defines the name of the mesh
  148610. * @param sourceMesh defines the mesh where the decal must be applied
  148611. * @param options defines the options used to create the mesh
  148612. * @param scene defines the hosting scene
  148613. * @returns the decal mesh
  148614. * @see https://doc.babylonjs.com/how_to/decals
  148615. */
  148616. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  148617. position?: Vector3;
  148618. normal?: Vector3;
  148619. size?: Vector3;
  148620. angle?: number;
  148621. }): Mesh;
  148622. }
  148623. }
  148624. declare module BABYLON {
  148625. /**
  148626. * Class containing static functions to help procedurally build meshes
  148627. */
  148628. export class MeshBuilder {
  148629. /**
  148630. * Creates a box mesh
  148631. * * The parameter `size` sets the size (float) of each box side (default 1)
  148632. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  148633. * * 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)
  148634. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148636. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148638. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  148639. * @param name defines the name of the mesh
  148640. * @param options defines the options used to create the mesh
  148641. * @param scene defines the hosting scene
  148642. * @returns the box mesh
  148643. */
  148644. static CreateBox(name: string, options: {
  148645. size?: number;
  148646. width?: number;
  148647. height?: number;
  148648. depth?: number;
  148649. faceUV?: Vector4[];
  148650. faceColors?: Color4[];
  148651. sideOrientation?: number;
  148652. frontUVs?: Vector4;
  148653. backUVs?: Vector4;
  148654. wrap?: boolean;
  148655. topBaseAt?: number;
  148656. bottomBaseAt?: number;
  148657. updatable?: boolean;
  148658. }, scene?: Nullable<Scene>): Mesh;
  148659. /**
  148660. * Creates a tiled box mesh
  148661. * * faceTiles sets the pattern, tile size and number of tiles for a face
  148662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148663. * @param name defines the name of the mesh
  148664. * @param options defines the options used to create the mesh
  148665. * @param scene defines the hosting scene
  148666. * @returns the tiled box mesh
  148667. */
  148668. static CreateTiledBox(name: string, options: {
  148669. pattern?: number;
  148670. size?: number;
  148671. width?: number;
  148672. height?: number;
  148673. depth: number;
  148674. tileSize?: number;
  148675. tileWidth?: number;
  148676. tileHeight?: number;
  148677. faceUV?: Vector4[];
  148678. faceColors?: Color4[];
  148679. alignHorizontal?: number;
  148680. alignVertical?: number;
  148681. sideOrientation?: number;
  148682. updatable?: boolean;
  148683. }, scene?: Nullable<Scene>): Mesh;
  148684. /**
  148685. * Creates a sphere mesh
  148686. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  148687. * * 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`)
  148688. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  148689. * * 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
  148690. * * 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)
  148691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148694. * @param name defines the name of the mesh
  148695. * @param options defines the options used to create the mesh
  148696. * @param scene defines the hosting scene
  148697. * @returns the sphere mesh
  148698. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  148699. */
  148700. static CreateSphere(name: string, options: {
  148701. segments?: number;
  148702. diameter?: number;
  148703. diameterX?: number;
  148704. diameterY?: number;
  148705. diameterZ?: number;
  148706. arc?: number;
  148707. slice?: number;
  148708. sideOrientation?: number;
  148709. frontUVs?: Vector4;
  148710. backUVs?: Vector4;
  148711. updatable?: boolean;
  148712. }, scene?: Nullable<Scene>): Mesh;
  148713. /**
  148714. * Creates a plane polygonal mesh. By default, this is a disc
  148715. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  148716. * * 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
  148717. * * 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
  148718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148719. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148721. * @param name defines the name of the mesh
  148722. * @param options defines the options used to create the mesh
  148723. * @param scene defines the hosting scene
  148724. * @returns the plane polygonal mesh
  148725. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  148726. */
  148727. static CreateDisc(name: string, options: {
  148728. radius?: number;
  148729. tessellation?: number;
  148730. arc?: number;
  148731. updatable?: boolean;
  148732. sideOrientation?: number;
  148733. frontUVs?: Vector4;
  148734. backUVs?: Vector4;
  148735. }, scene?: Nullable<Scene>): Mesh;
  148736. /**
  148737. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148738. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148739. * * 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`)
  148740. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148741. * * 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
  148742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148745. * @param name defines the name of the mesh
  148746. * @param options defines the options used to create the mesh
  148747. * @param scene defines the hosting scene
  148748. * @returns the icosahedron mesh
  148749. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148750. */
  148751. static CreateIcoSphere(name: string, options: {
  148752. radius?: number;
  148753. radiusX?: number;
  148754. radiusY?: number;
  148755. radiusZ?: number;
  148756. flat?: boolean;
  148757. subdivisions?: number;
  148758. sideOrientation?: number;
  148759. frontUVs?: Vector4;
  148760. backUVs?: Vector4;
  148761. updatable?: boolean;
  148762. }, scene?: Nullable<Scene>): Mesh;
  148763. /**
  148764. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148765. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  148766. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  148767. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  148768. * * 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
  148769. * * 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
  148770. * * 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
  148771. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148772. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148773. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148774. * * 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
  148775. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  148776. * * 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
  148777. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  148778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148779. * @param name defines the name of the mesh
  148780. * @param options defines the options used to create the mesh
  148781. * @param scene defines the hosting scene
  148782. * @returns the ribbon mesh
  148783. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  148784. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148785. */
  148786. static CreateRibbon(name: string, options: {
  148787. pathArray: Vector3[][];
  148788. closeArray?: boolean;
  148789. closePath?: boolean;
  148790. offset?: number;
  148791. updatable?: boolean;
  148792. sideOrientation?: number;
  148793. frontUVs?: Vector4;
  148794. backUVs?: Vector4;
  148795. instance?: Mesh;
  148796. invertUV?: boolean;
  148797. uvs?: Vector2[];
  148798. colors?: Color4[];
  148799. }, scene?: Nullable<Scene>): Mesh;
  148800. /**
  148801. * Creates a cylinder or a cone mesh
  148802. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  148803. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  148804. * * 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.
  148805. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  148806. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  148807. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  148808. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  148809. * * 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).
  148810. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  148811. * * 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).
  148812. * * 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
  148813. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  148814. * * 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
  148815. * * 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.
  148816. * * If `enclose` is false, a ring surface is one element.
  148817. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  148818. * * 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
  148819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148822. * @param name defines the name of the mesh
  148823. * @param options defines the options used to create the mesh
  148824. * @param scene defines the hosting scene
  148825. * @returns the cylinder mesh
  148826. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  148827. */
  148828. static CreateCylinder(name: string, options: {
  148829. height?: number;
  148830. diameterTop?: number;
  148831. diameterBottom?: number;
  148832. diameter?: number;
  148833. tessellation?: number;
  148834. subdivisions?: number;
  148835. arc?: number;
  148836. faceColors?: Color4[];
  148837. faceUV?: Vector4[];
  148838. updatable?: boolean;
  148839. hasRings?: boolean;
  148840. enclose?: boolean;
  148841. cap?: number;
  148842. sideOrientation?: number;
  148843. frontUVs?: Vector4;
  148844. backUVs?: Vector4;
  148845. }, scene?: Nullable<Scene>): Mesh;
  148846. /**
  148847. * Creates a torus mesh
  148848. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  148849. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  148850. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  148851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148852. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148854. * @param name defines the name of the mesh
  148855. * @param options defines the options used to create the mesh
  148856. * @param scene defines the hosting scene
  148857. * @returns the torus mesh
  148858. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  148859. */
  148860. static CreateTorus(name: string, options: {
  148861. diameter?: number;
  148862. thickness?: number;
  148863. tessellation?: number;
  148864. updatable?: boolean;
  148865. sideOrientation?: number;
  148866. frontUVs?: Vector4;
  148867. backUVs?: Vector4;
  148868. }, scene?: Nullable<Scene>): Mesh;
  148869. /**
  148870. * Creates a torus knot mesh
  148871. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  148872. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  148873. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  148874. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  148875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148878. * @param name defines the name of the mesh
  148879. * @param options defines the options used to create the mesh
  148880. * @param scene defines the hosting scene
  148881. * @returns the torus knot mesh
  148882. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  148883. */
  148884. static CreateTorusKnot(name: string, options: {
  148885. radius?: number;
  148886. tube?: number;
  148887. radialSegments?: number;
  148888. tubularSegments?: number;
  148889. p?: number;
  148890. q?: number;
  148891. updatable?: boolean;
  148892. sideOrientation?: number;
  148893. frontUVs?: Vector4;
  148894. backUVs?: Vector4;
  148895. }, scene?: Nullable<Scene>): Mesh;
  148896. /**
  148897. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  148898. * * 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
  148899. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  148900. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  148901. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  148902. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  148903. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  148904. * * 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
  148905. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  148906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  148908. * @param name defines the name of the new line system
  148909. * @param options defines the options used to create the line system
  148910. * @param scene defines the hosting scene
  148911. * @returns a new line system mesh
  148912. */
  148913. static CreateLineSystem(name: string, options: {
  148914. lines: Vector3[][];
  148915. updatable?: boolean;
  148916. instance?: Nullable<LinesMesh>;
  148917. colors?: Nullable<Color4[][]>;
  148918. useVertexAlpha?: boolean;
  148919. }, scene: Nullable<Scene>): LinesMesh;
  148920. /**
  148921. * Creates a line mesh
  148922. * 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
  148923. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  148924. * * The parameter `points` is an array successive Vector3
  148925. * * 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
  148926. * * The optional parameter `colors` is an array of successive Color4, one per line point
  148927. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  148928. * * When updating an instance, remember that only point positions can change, not the number of points
  148929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148930. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  148931. * @param name defines the name of the new line system
  148932. * @param options defines the options used to create the line system
  148933. * @param scene defines the hosting scene
  148934. * @returns a new line mesh
  148935. */
  148936. static CreateLines(name: string, options: {
  148937. points: Vector3[];
  148938. updatable?: boolean;
  148939. instance?: Nullable<LinesMesh>;
  148940. colors?: Color4[];
  148941. useVertexAlpha?: boolean;
  148942. }, scene?: Nullable<Scene>): LinesMesh;
  148943. /**
  148944. * Creates a dashed line mesh
  148945. * * 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
  148946. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  148947. * * The parameter `points` is an array successive Vector3
  148948. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  148949. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  148950. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  148951. * * 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
  148952. * * When updating an instance, remember that only point positions can change, not the number of points
  148953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148954. * @param name defines the name of the mesh
  148955. * @param options defines the options used to create the mesh
  148956. * @param scene defines the hosting scene
  148957. * @returns the dashed line mesh
  148958. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  148959. */
  148960. static CreateDashedLines(name: string, options: {
  148961. points: Vector3[];
  148962. dashSize?: number;
  148963. gapSize?: number;
  148964. dashNb?: number;
  148965. updatable?: boolean;
  148966. instance?: LinesMesh;
  148967. }, scene?: Nullable<Scene>): LinesMesh;
  148968. /**
  148969. * 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.
  148970. * * 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.
  148971. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  148972. * * 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.
  148973. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  148974. * * 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
  148975. * * 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
  148976. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  148977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148978. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148979. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  148980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148981. * @param name defines the name of the mesh
  148982. * @param options defines the options used to create the mesh
  148983. * @param scene defines the hosting scene
  148984. * @returns the extruded shape mesh
  148985. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148986. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  148987. */
  148988. static ExtrudeShape(name: string, options: {
  148989. shape: Vector3[];
  148990. path: Vector3[];
  148991. scale?: number;
  148992. rotation?: number;
  148993. cap?: number;
  148994. updatable?: boolean;
  148995. sideOrientation?: number;
  148996. frontUVs?: Vector4;
  148997. backUVs?: Vector4;
  148998. instance?: Mesh;
  148999. invertUV?: boolean;
  149000. }, scene?: Nullable<Scene>): Mesh;
  149001. /**
  149002. * Creates an custom extruded shape mesh.
  149003. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  149004. * * 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.
  149005. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  149006. * * 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
  149007. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  149008. * * 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
  149009. * * It must returns a float value that will be the scale value applied to the shape on each path point
  149010. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  149011. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  149012. * * 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
  149013. * * 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
  149014. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  149015. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149016. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149017. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  149018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149019. * @param name defines the name of the mesh
  149020. * @param options defines the options used to create the mesh
  149021. * @param scene defines the hosting scene
  149022. * @returns the custom extruded shape mesh
  149023. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  149024. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  149025. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  149026. */
  149027. static ExtrudeShapeCustom(name: string, options: {
  149028. shape: Vector3[];
  149029. path: Vector3[];
  149030. scaleFunction?: any;
  149031. rotationFunction?: any;
  149032. ribbonCloseArray?: boolean;
  149033. ribbonClosePath?: boolean;
  149034. cap?: number;
  149035. updatable?: boolean;
  149036. sideOrientation?: number;
  149037. frontUVs?: Vector4;
  149038. backUVs?: Vector4;
  149039. instance?: Mesh;
  149040. invertUV?: boolean;
  149041. }, scene?: Nullable<Scene>): Mesh;
  149042. /**
  149043. * Creates lathe mesh.
  149044. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  149045. * * 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
  149046. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  149047. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  149048. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  149049. * * 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
  149050. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  149051. * * 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
  149052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149054. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  149055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149056. * @param name defines the name of the mesh
  149057. * @param options defines the options used to create the mesh
  149058. * @param scene defines the hosting scene
  149059. * @returns the lathe mesh
  149060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  149061. */
  149062. static CreateLathe(name: string, options: {
  149063. shape: Vector3[];
  149064. radius?: number;
  149065. tessellation?: number;
  149066. clip?: number;
  149067. arc?: number;
  149068. closed?: boolean;
  149069. updatable?: boolean;
  149070. sideOrientation?: number;
  149071. frontUVs?: Vector4;
  149072. backUVs?: Vector4;
  149073. cap?: number;
  149074. invertUV?: boolean;
  149075. }, scene?: Nullable<Scene>): Mesh;
  149076. /**
  149077. * Creates a tiled plane mesh
  149078. * * You can set a limited pattern arrangement with the tiles
  149079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149080. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149082. * @param name defines the name of the mesh
  149083. * @param options defines the options used to create the mesh
  149084. * @param scene defines the hosting scene
  149085. * @returns the plane mesh
  149086. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  149087. */
  149088. static CreateTiledPlane(name: string, options: {
  149089. pattern?: number;
  149090. tileSize?: number;
  149091. tileWidth?: number;
  149092. tileHeight?: number;
  149093. size?: number;
  149094. width?: number;
  149095. height?: number;
  149096. alignHorizontal?: number;
  149097. alignVertical?: number;
  149098. sideOrientation?: number;
  149099. frontUVs?: Vector4;
  149100. backUVs?: Vector4;
  149101. updatable?: boolean;
  149102. }, scene?: Nullable<Scene>): Mesh;
  149103. /**
  149104. * Creates a plane mesh
  149105. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  149106. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  149107. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  149108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149111. * @param name defines the name of the mesh
  149112. * @param options defines the options used to create the mesh
  149113. * @param scene defines the hosting scene
  149114. * @returns the plane mesh
  149115. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  149116. */
  149117. static CreatePlane(name: string, options: {
  149118. size?: number;
  149119. width?: number;
  149120. height?: number;
  149121. sideOrientation?: number;
  149122. frontUVs?: Vector4;
  149123. backUVs?: Vector4;
  149124. updatable?: boolean;
  149125. sourcePlane?: Plane;
  149126. }, scene?: Nullable<Scene>): Mesh;
  149127. /**
  149128. * Creates a ground mesh
  149129. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  149130. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  149131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149132. * @param name defines the name of the mesh
  149133. * @param options defines the options used to create the mesh
  149134. * @param scene defines the hosting scene
  149135. * @returns the ground mesh
  149136. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  149137. */
  149138. static CreateGround(name: string, options: {
  149139. width?: number;
  149140. height?: number;
  149141. subdivisions?: number;
  149142. subdivisionsX?: number;
  149143. subdivisionsY?: number;
  149144. updatable?: boolean;
  149145. }, scene?: Nullable<Scene>): Mesh;
  149146. /**
  149147. * Creates a tiled ground mesh
  149148. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  149149. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  149150. * * 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
  149151. * * 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
  149152. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149153. * @param name defines the name of the mesh
  149154. * @param options defines the options used to create the mesh
  149155. * @param scene defines the hosting scene
  149156. * @returns the tiled ground mesh
  149157. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  149158. */
  149159. static CreateTiledGround(name: string, options: {
  149160. xmin: number;
  149161. zmin: number;
  149162. xmax: number;
  149163. zmax: number;
  149164. subdivisions?: {
  149165. w: number;
  149166. h: number;
  149167. };
  149168. precision?: {
  149169. w: number;
  149170. h: number;
  149171. };
  149172. updatable?: boolean;
  149173. }, scene?: Nullable<Scene>): Mesh;
  149174. /**
  149175. * Creates a ground mesh from a height map
  149176. * * The parameter `url` sets the URL of the height map image resource.
  149177. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  149178. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  149179. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  149180. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  149181. * * 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.
  149182. * * 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).
  149183. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  149184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149185. * @param name defines the name of the mesh
  149186. * @param url defines the url to the height map
  149187. * @param options defines the options used to create the mesh
  149188. * @param scene defines the hosting scene
  149189. * @returns the ground mesh
  149190. * @see https://doc.babylonjs.com/babylon101/height_map
  149191. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  149192. */
  149193. static CreateGroundFromHeightMap(name: string, url: string, options: {
  149194. width?: number;
  149195. height?: number;
  149196. subdivisions?: number;
  149197. minHeight?: number;
  149198. maxHeight?: number;
  149199. colorFilter?: Color3;
  149200. alphaFilter?: number;
  149201. updatable?: boolean;
  149202. onReady?: (mesh: GroundMesh) => void;
  149203. }, scene?: Nullable<Scene>): GroundMesh;
  149204. /**
  149205. * Creates a polygon mesh
  149206. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  149207. * * 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
  149208. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  149209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149210. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  149211. * * Remember you can only change the shape positions, not their number when updating a polygon
  149212. * @param name defines the name of the mesh
  149213. * @param options defines the options used to create the mesh
  149214. * @param scene defines the hosting scene
  149215. * @param earcutInjection can be used to inject your own earcut reference
  149216. * @returns the polygon mesh
  149217. */
  149218. static CreatePolygon(name: string, options: {
  149219. shape: Vector3[];
  149220. holes?: Vector3[][];
  149221. depth?: number;
  149222. faceUV?: Vector4[];
  149223. faceColors?: Color4[];
  149224. updatable?: boolean;
  149225. sideOrientation?: number;
  149226. frontUVs?: Vector4;
  149227. backUVs?: Vector4;
  149228. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  149229. /**
  149230. * Creates an extruded polygon mesh, with depth in the Y direction.
  149231. * * 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)
  149232. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  149233. * @param name defines the name of the mesh
  149234. * @param options defines the options used to create the mesh
  149235. * @param scene defines the hosting scene
  149236. * @param earcutInjection can be used to inject your own earcut reference
  149237. * @returns the polygon mesh
  149238. */
  149239. static ExtrudePolygon(name: string, options: {
  149240. shape: Vector3[];
  149241. holes?: Vector3[][];
  149242. depth?: number;
  149243. faceUV?: Vector4[];
  149244. faceColors?: Color4[];
  149245. updatable?: boolean;
  149246. sideOrientation?: number;
  149247. frontUVs?: Vector4;
  149248. backUVs?: Vector4;
  149249. wrap?: boolean;
  149250. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  149251. /**
  149252. * Creates a tube mesh.
  149253. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  149254. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  149255. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  149256. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  149257. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  149258. * * 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)
  149259. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  149260. * * 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
  149261. * * 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
  149262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149264. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  149265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149266. * @param name defines the name of the mesh
  149267. * @param options defines the options used to create the mesh
  149268. * @param scene defines the hosting scene
  149269. * @returns the tube mesh
  149270. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  149271. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  149272. */
  149273. static CreateTube(name: string, options: {
  149274. path: Vector3[];
  149275. radius?: number;
  149276. tessellation?: number;
  149277. radiusFunction?: {
  149278. (i: number, distance: number): number;
  149279. };
  149280. cap?: number;
  149281. arc?: number;
  149282. updatable?: boolean;
  149283. sideOrientation?: number;
  149284. frontUVs?: Vector4;
  149285. backUVs?: Vector4;
  149286. instance?: Mesh;
  149287. invertUV?: boolean;
  149288. }, scene?: Nullable<Scene>): Mesh;
  149289. /**
  149290. * Creates a polyhedron mesh
  149291. * * 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
  149292. * * The parameter `size` (positive float, default 1) sets the polygon size
  149293. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  149294. * * 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`
  149295. * * 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
  149296. * * 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)`)
  149297. * * 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
  149298. * * 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
  149299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149302. * @param name defines the name of the mesh
  149303. * @param options defines the options used to create the mesh
  149304. * @param scene defines the hosting scene
  149305. * @returns the polyhedron mesh
  149306. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  149307. */
  149308. static CreatePolyhedron(name: string, options: {
  149309. type?: number;
  149310. size?: number;
  149311. sizeX?: number;
  149312. sizeY?: number;
  149313. sizeZ?: number;
  149314. custom?: any;
  149315. faceUV?: Vector4[];
  149316. faceColors?: Color4[];
  149317. flat?: boolean;
  149318. updatable?: boolean;
  149319. sideOrientation?: number;
  149320. frontUVs?: Vector4;
  149321. backUVs?: Vector4;
  149322. }, scene?: Nullable<Scene>): Mesh;
  149323. /**
  149324. * Creates a decal mesh.
  149325. * 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
  149326. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  149327. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  149328. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  149329. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  149330. * @param name defines the name of the mesh
  149331. * @param sourceMesh defines the mesh where the decal must be applied
  149332. * @param options defines the options used to create the mesh
  149333. * @param scene defines the hosting scene
  149334. * @returns the decal mesh
  149335. * @see https://doc.babylonjs.com/how_to/decals
  149336. */
  149337. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  149338. position?: Vector3;
  149339. normal?: Vector3;
  149340. size?: Vector3;
  149341. angle?: number;
  149342. }): Mesh;
  149343. /**
  149344. * Creates a Capsule Mesh
  149345. * @param name defines the name of the mesh.
  149346. * @param options the constructors options used to shape the mesh.
  149347. * @param scene defines the scene the mesh is scoped to.
  149348. * @returns the capsule mesh
  149349. * @see https://doc.babylonjs.com/how_to/capsule_shape
  149350. */
  149351. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  149352. }
  149353. }
  149354. declare module BABYLON {
  149355. /**
  149356. * A simplifier interface for future simplification implementations
  149357. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149358. */
  149359. export interface ISimplifier {
  149360. /**
  149361. * Simplification of a given mesh according to the given settings.
  149362. * Since this requires computation, it is assumed that the function runs async.
  149363. * @param settings The settings of the simplification, including quality and distance
  149364. * @param successCallback A callback that will be called after the mesh was simplified.
  149365. * @param errorCallback in case of an error, this callback will be called. optional.
  149366. */
  149367. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  149368. }
  149369. /**
  149370. * Expected simplification settings.
  149371. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  149372. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149373. */
  149374. export interface ISimplificationSettings {
  149375. /**
  149376. * Gets or sets the expected quality
  149377. */
  149378. quality: number;
  149379. /**
  149380. * Gets or sets the distance when this optimized version should be used
  149381. */
  149382. distance: number;
  149383. /**
  149384. * Gets an already optimized mesh
  149385. */
  149386. optimizeMesh?: boolean;
  149387. }
  149388. /**
  149389. * Class used to specify simplification options
  149390. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149391. */
  149392. export class SimplificationSettings implements ISimplificationSettings {
  149393. /** expected quality */
  149394. quality: number;
  149395. /** distance when this optimized version should be used */
  149396. distance: number;
  149397. /** already optimized mesh */
  149398. optimizeMesh?: boolean | undefined;
  149399. /**
  149400. * Creates a SimplificationSettings
  149401. * @param quality expected quality
  149402. * @param distance distance when this optimized version should be used
  149403. * @param optimizeMesh already optimized mesh
  149404. */
  149405. constructor(
  149406. /** expected quality */
  149407. quality: number,
  149408. /** distance when this optimized version should be used */
  149409. distance: number,
  149410. /** already optimized mesh */
  149411. optimizeMesh?: boolean | undefined);
  149412. }
  149413. /**
  149414. * Interface used to define a simplification task
  149415. */
  149416. export interface ISimplificationTask {
  149417. /**
  149418. * Array of settings
  149419. */
  149420. settings: Array<ISimplificationSettings>;
  149421. /**
  149422. * Simplification type
  149423. */
  149424. simplificationType: SimplificationType;
  149425. /**
  149426. * Mesh to simplify
  149427. */
  149428. mesh: Mesh;
  149429. /**
  149430. * Callback called on success
  149431. */
  149432. successCallback?: () => void;
  149433. /**
  149434. * Defines if parallel processing can be used
  149435. */
  149436. parallelProcessing: boolean;
  149437. }
  149438. /**
  149439. * Queue used to order the simplification tasks
  149440. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149441. */
  149442. export class SimplificationQueue {
  149443. private _simplificationArray;
  149444. /**
  149445. * Gets a boolean indicating that the process is still running
  149446. */
  149447. running: boolean;
  149448. /**
  149449. * Creates a new queue
  149450. */
  149451. constructor();
  149452. /**
  149453. * Adds a new simplification task
  149454. * @param task defines a task to add
  149455. */
  149456. addTask(task: ISimplificationTask): void;
  149457. /**
  149458. * Execute next task
  149459. */
  149460. executeNext(): void;
  149461. /**
  149462. * Execute a simplification task
  149463. * @param task defines the task to run
  149464. */
  149465. runSimplification(task: ISimplificationTask): void;
  149466. private getSimplifier;
  149467. }
  149468. /**
  149469. * The implemented types of simplification
  149470. * At the moment only Quadratic Error Decimation is implemented
  149471. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149472. */
  149473. export enum SimplificationType {
  149474. /** Quadratic error decimation */
  149475. QUADRATIC = 0
  149476. }
  149477. /**
  149478. * An implementation of the Quadratic Error simplification algorithm.
  149479. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  149480. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  149481. * @author RaananW
  149482. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149483. */
  149484. export class QuadraticErrorSimplification implements ISimplifier {
  149485. private _mesh;
  149486. private triangles;
  149487. private vertices;
  149488. private references;
  149489. private _reconstructedMesh;
  149490. /** Gets or sets the number pf sync interations */
  149491. syncIterations: number;
  149492. /** Gets or sets the aggressiveness of the simplifier */
  149493. aggressiveness: number;
  149494. /** Gets or sets the number of allowed iterations for decimation */
  149495. decimationIterations: number;
  149496. /** Gets or sets the espilon to use for bounding box computation */
  149497. boundingBoxEpsilon: number;
  149498. /**
  149499. * Creates a new QuadraticErrorSimplification
  149500. * @param _mesh defines the target mesh
  149501. */
  149502. constructor(_mesh: Mesh);
  149503. /**
  149504. * Simplification of a given mesh according to the given settings.
  149505. * Since this requires computation, it is assumed that the function runs async.
  149506. * @param settings The settings of the simplification, including quality and distance
  149507. * @param successCallback A callback that will be called after the mesh was simplified.
  149508. */
  149509. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  149510. private runDecimation;
  149511. private initWithMesh;
  149512. private init;
  149513. private reconstructMesh;
  149514. private initDecimatedMesh;
  149515. private isFlipped;
  149516. private updateTriangles;
  149517. private identifyBorder;
  149518. private updateMesh;
  149519. private vertexError;
  149520. private calculateError;
  149521. }
  149522. }
  149523. declare module BABYLON {
  149524. interface Scene {
  149525. /** @hidden (Backing field) */
  149526. _simplificationQueue: SimplificationQueue;
  149527. /**
  149528. * Gets or sets the simplification queue attached to the scene
  149529. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149530. */
  149531. simplificationQueue: SimplificationQueue;
  149532. }
  149533. interface Mesh {
  149534. /**
  149535. * Simplify the mesh according to the given array of settings.
  149536. * Function will return immediately and will simplify async
  149537. * @param settings a collection of simplification settings
  149538. * @param parallelProcessing should all levels calculate parallel or one after the other
  149539. * @param simplificationType the type of simplification to run
  149540. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  149541. * @returns the current mesh
  149542. */
  149543. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  149544. }
  149545. /**
  149546. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  149547. * created in a scene
  149548. */
  149549. export class SimplicationQueueSceneComponent implements ISceneComponent {
  149550. /**
  149551. * The component name helpfull to identify the component in the list of scene components.
  149552. */
  149553. readonly name: string;
  149554. /**
  149555. * The scene the component belongs to.
  149556. */
  149557. scene: Scene;
  149558. /**
  149559. * Creates a new instance of the component for the given scene
  149560. * @param scene Defines the scene to register the component in
  149561. */
  149562. constructor(scene: Scene);
  149563. /**
  149564. * Registers the component in a given scene
  149565. */
  149566. register(): void;
  149567. /**
  149568. * Rebuilds the elements related to this component in case of
  149569. * context lost for instance.
  149570. */
  149571. rebuild(): void;
  149572. /**
  149573. * Disposes the component and the associated ressources
  149574. */
  149575. dispose(): void;
  149576. private _beforeCameraUpdate;
  149577. }
  149578. }
  149579. declare module BABYLON {
  149580. interface Mesh {
  149581. /**
  149582. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  149583. */
  149584. thinInstanceEnablePicking: boolean;
  149585. /**
  149586. * Creates a new thin instance
  149587. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  149588. * @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
  149589. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  149590. */
  149591. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  149592. /**
  149593. * Adds the transformation (matrix) of the current mesh as a thin instance
  149594. * @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
  149595. * @returns the thin instance index number
  149596. */
  149597. thinInstanceAddSelf(refresh: boolean): number;
  149598. /**
  149599. * Registers a custom attribute to be used with thin instances
  149600. * @param kind name of the attribute
  149601. * @param stride size in floats of the attribute
  149602. */
  149603. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  149604. /**
  149605. * Sets the matrix of a thin instance
  149606. * @param index index of the thin instance
  149607. * @param matrix matrix to set
  149608. * @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
  149609. */
  149610. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  149611. /**
  149612. * Sets the value of a custom attribute for a thin instance
  149613. * @param kind name of the attribute
  149614. * @param index index of the thin instance
  149615. * @param value value to set
  149616. * @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
  149617. */
  149618. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  149619. /**
  149620. * 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.
  149621. */
  149622. thinInstanceCount: number;
  149623. /**
  149624. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  149625. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  149626. * @param buffer buffer to set
  149627. * @param stride size in floats of each value of the buffer
  149628. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  149629. */
  149630. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  149631. /**
  149632. * Gets the list of world matrices
  149633. * @return an array containing all the world matrices from the thin instances
  149634. */
  149635. thinInstanceGetWorldMatrices(): Matrix[];
  149636. /**
  149637. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  149638. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149639. */
  149640. thinInstanceBufferUpdated(kind: string): void;
  149641. /**
  149642. * Applies a partial update to a buffer directly on the GPU
  149643. * 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
  149644. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149645. * @param data the data to set in the GPU buffer
  149646. * @param offset the offset in the GPU buffer where to update the data
  149647. */
  149648. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  149649. /**
  149650. * Refreshes the bounding info, taking into account all the thin instances defined
  149651. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  149652. */
  149653. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  149654. /** @hidden */
  149655. _thinInstanceInitializeUserStorage(): void;
  149656. /** @hidden */
  149657. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  149658. /** @hidden */
  149659. _userThinInstanceBuffersStorage: {
  149660. data: {
  149661. [key: string]: Float32Array;
  149662. };
  149663. sizes: {
  149664. [key: string]: number;
  149665. };
  149666. vertexBuffers: {
  149667. [key: string]: Nullable<VertexBuffer>;
  149668. };
  149669. strides: {
  149670. [key: string]: number;
  149671. };
  149672. };
  149673. }
  149674. }
  149675. declare module BABYLON {
  149676. /**
  149677. * Navigation plugin interface to add navigation constrained by a navigation mesh
  149678. */
  149679. export interface INavigationEnginePlugin {
  149680. /**
  149681. * plugin name
  149682. */
  149683. name: string;
  149684. /**
  149685. * Creates a navigation mesh
  149686. * @param meshes array of all the geometry used to compute the navigatio mesh
  149687. * @param parameters bunch of parameters used to filter geometry
  149688. */
  149689. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  149690. /**
  149691. * Create a navigation mesh debug mesh
  149692. * @param scene is where the mesh will be added
  149693. * @returns debug display mesh
  149694. */
  149695. createDebugNavMesh(scene: Scene): Mesh;
  149696. /**
  149697. * Get a navigation mesh constrained position, closest to the parameter position
  149698. * @param position world position
  149699. * @returns the closest point to position constrained by the navigation mesh
  149700. */
  149701. getClosestPoint(position: Vector3): Vector3;
  149702. /**
  149703. * Get a navigation mesh constrained position, closest to the parameter position
  149704. * @param position world position
  149705. * @param result output the closest point to position constrained by the navigation mesh
  149706. */
  149707. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149708. /**
  149709. * Get a navigation mesh constrained position, within a particular radius
  149710. * @param position world position
  149711. * @param maxRadius the maximum distance to the constrained world position
  149712. * @returns the closest point to position constrained by the navigation mesh
  149713. */
  149714. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149715. /**
  149716. * Get a navigation mesh constrained position, within a particular radius
  149717. * @param position world position
  149718. * @param maxRadius the maximum distance to the constrained world position
  149719. * @param result output the closest point to position constrained by the navigation mesh
  149720. */
  149721. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149722. /**
  149723. * Compute the final position from a segment made of destination-position
  149724. * @param position world position
  149725. * @param destination world position
  149726. * @returns the resulting point along the navmesh
  149727. */
  149728. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149729. /**
  149730. * Compute the final position from a segment made of destination-position
  149731. * @param position world position
  149732. * @param destination world position
  149733. * @param result output the resulting point along the navmesh
  149734. */
  149735. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149736. /**
  149737. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149738. * @param start world position
  149739. * @param end world position
  149740. * @returns array containing world position composing the path
  149741. */
  149742. computePath(start: Vector3, end: Vector3): Vector3[];
  149743. /**
  149744. * If this plugin is supported
  149745. * @returns true if plugin is supported
  149746. */
  149747. isSupported(): boolean;
  149748. /**
  149749. * Create a new Crowd so you can add agents
  149750. * @param maxAgents the maximum agent count in the crowd
  149751. * @param maxAgentRadius the maximum radius an agent can have
  149752. * @param scene to attach the crowd to
  149753. * @returns the crowd you can add agents to
  149754. */
  149755. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149756. /**
  149757. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149758. * The queries will try to find a solution within those bounds
  149759. * default is (1,1,1)
  149760. * @param extent x,y,z value that define the extent around the queries point of reference
  149761. */
  149762. setDefaultQueryExtent(extent: Vector3): void;
  149763. /**
  149764. * Get the Bounding box extent specified by setDefaultQueryExtent
  149765. * @returns the box extent values
  149766. */
  149767. getDefaultQueryExtent(): Vector3;
  149768. /**
  149769. * build the navmesh from a previously saved state using getNavmeshData
  149770. * @param data the Uint8Array returned by getNavmeshData
  149771. */
  149772. buildFromNavmeshData(data: Uint8Array): void;
  149773. /**
  149774. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  149775. * @returns data the Uint8Array that can be saved and reused
  149776. */
  149777. getNavmeshData(): Uint8Array;
  149778. /**
  149779. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149780. * @param result output the box extent values
  149781. */
  149782. getDefaultQueryExtentToRef(result: Vector3): void;
  149783. /**
  149784. * Release all resources
  149785. */
  149786. dispose(): void;
  149787. }
  149788. /**
  149789. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  149790. */
  149791. export interface ICrowd {
  149792. /**
  149793. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  149794. * You can attach anything to that node. The node position is updated in the scene update tick.
  149795. * @param pos world position that will be constrained by the navigation mesh
  149796. * @param parameters agent parameters
  149797. * @param transform hooked to the agent that will be update by the scene
  149798. * @returns agent index
  149799. */
  149800. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  149801. /**
  149802. * Returns the agent position in world space
  149803. * @param index agent index returned by addAgent
  149804. * @returns world space position
  149805. */
  149806. getAgentPosition(index: number): Vector3;
  149807. /**
  149808. * Gets the agent position result in world space
  149809. * @param index agent index returned by addAgent
  149810. * @param result output world space position
  149811. */
  149812. getAgentPositionToRef(index: number, result: Vector3): void;
  149813. /**
  149814. * Gets the agent velocity in world space
  149815. * @param index agent index returned by addAgent
  149816. * @returns world space velocity
  149817. */
  149818. getAgentVelocity(index: number): Vector3;
  149819. /**
  149820. * Gets the agent velocity result in world space
  149821. * @param index agent index returned by addAgent
  149822. * @param result output world space velocity
  149823. */
  149824. getAgentVelocityToRef(index: number, result: Vector3): void;
  149825. /**
  149826. * Gets the agent next target point on the path
  149827. * @param index agent index returned by addAgent
  149828. * @returns world space position
  149829. */
  149830. getAgentNextTargetPath(index: number): Vector3;
  149831. /**
  149832. * Gets the agent state
  149833. * @param index agent index returned by addAgent
  149834. * @returns agent state
  149835. */
  149836. getAgentState(index: number): number;
  149837. /**
  149838. * returns true if the agent in over an off mesh link connection
  149839. * @param index agent index returned by addAgent
  149840. * @returns true if over an off mesh link connection
  149841. */
  149842. overOffmeshConnection(index: number): boolean;
  149843. /**
  149844. * Gets the agent next target point on the path
  149845. * @param index agent index returned by addAgent
  149846. * @param result output world space position
  149847. */
  149848. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  149849. /**
  149850. * remove a particular agent previously created
  149851. * @param index agent index returned by addAgent
  149852. */
  149853. removeAgent(index: number): void;
  149854. /**
  149855. * get the list of all agents attached to this crowd
  149856. * @returns list of agent indices
  149857. */
  149858. getAgents(): number[];
  149859. /**
  149860. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  149861. * @param deltaTime in seconds
  149862. */
  149863. update(deltaTime: number): void;
  149864. /**
  149865. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  149866. * @param index agent index returned by addAgent
  149867. * @param destination targeted world position
  149868. */
  149869. agentGoto(index: number, destination: Vector3): void;
  149870. /**
  149871. * Teleport the agent to a new position
  149872. * @param index agent index returned by addAgent
  149873. * @param destination targeted world position
  149874. */
  149875. agentTeleport(index: number, destination: Vector3): void;
  149876. /**
  149877. * Update agent parameters
  149878. * @param index agent index returned by addAgent
  149879. * @param parameters agent parameters
  149880. */
  149881. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  149882. /**
  149883. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149884. * The queries will try to find a solution within those bounds
  149885. * default is (1,1,1)
  149886. * @param extent x,y,z value that define the extent around the queries point of reference
  149887. */
  149888. setDefaultQueryExtent(extent: Vector3): void;
  149889. /**
  149890. * Get the Bounding box extent specified by setDefaultQueryExtent
  149891. * @returns the box extent values
  149892. */
  149893. getDefaultQueryExtent(): Vector3;
  149894. /**
  149895. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149896. * @param result output the box extent values
  149897. */
  149898. getDefaultQueryExtentToRef(result: Vector3): void;
  149899. /**
  149900. * Release all resources
  149901. */
  149902. dispose(): void;
  149903. }
  149904. /**
  149905. * Configures an agent
  149906. */
  149907. export interface IAgentParameters {
  149908. /**
  149909. * Agent radius. [Limit: >= 0]
  149910. */
  149911. radius: number;
  149912. /**
  149913. * Agent height. [Limit: > 0]
  149914. */
  149915. height: number;
  149916. /**
  149917. * Maximum allowed acceleration. [Limit: >= 0]
  149918. */
  149919. maxAcceleration: number;
  149920. /**
  149921. * Maximum allowed speed. [Limit: >= 0]
  149922. */
  149923. maxSpeed: number;
  149924. /**
  149925. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  149926. */
  149927. collisionQueryRange: number;
  149928. /**
  149929. * The path visibility optimization range. [Limit: > 0]
  149930. */
  149931. pathOptimizationRange: number;
  149932. /**
  149933. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  149934. */
  149935. separationWeight: number;
  149936. }
  149937. /**
  149938. * Configures the navigation mesh creation
  149939. */
  149940. export interface INavMeshParameters {
  149941. /**
  149942. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  149943. */
  149944. cs: number;
  149945. /**
  149946. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  149947. */
  149948. ch: number;
  149949. /**
  149950. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  149951. */
  149952. walkableSlopeAngle: number;
  149953. /**
  149954. * Minimum floor to 'ceiling' height that will still allow the floor area to
  149955. * be considered walkable. [Limit: >= 3] [Units: vx]
  149956. */
  149957. walkableHeight: number;
  149958. /**
  149959. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  149960. */
  149961. walkableClimb: number;
  149962. /**
  149963. * The distance to erode/shrink the walkable area of the heightfield away from
  149964. * obstructions. [Limit: >=0] [Units: vx]
  149965. */
  149966. walkableRadius: number;
  149967. /**
  149968. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  149969. */
  149970. maxEdgeLen: number;
  149971. /**
  149972. * The maximum distance a simplfied contour's border edges should deviate
  149973. * the original raw contour. [Limit: >=0] [Units: vx]
  149974. */
  149975. maxSimplificationError: number;
  149976. /**
  149977. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  149978. */
  149979. minRegionArea: number;
  149980. /**
  149981. * Any regions with a span count smaller than this value will, if possible,
  149982. * be merged with larger regions. [Limit: >=0] [Units: vx]
  149983. */
  149984. mergeRegionArea: number;
  149985. /**
  149986. * The maximum number of vertices allowed for polygons generated during the
  149987. * contour to polygon conversion process. [Limit: >= 3]
  149988. */
  149989. maxVertsPerPoly: number;
  149990. /**
  149991. * Sets the sampling distance to use when generating the detail mesh.
  149992. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  149993. */
  149994. detailSampleDist: number;
  149995. /**
  149996. * The maximum distance the detail mesh surface should deviate from heightfield
  149997. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  149998. */
  149999. detailSampleMaxError: number;
  150000. }
  150001. }
  150002. declare module BABYLON {
  150003. /**
  150004. * RecastJS navigation plugin
  150005. */
  150006. export class RecastJSPlugin implements INavigationEnginePlugin {
  150007. /**
  150008. * Reference to the Recast library
  150009. */
  150010. bjsRECAST: any;
  150011. /**
  150012. * plugin name
  150013. */
  150014. name: string;
  150015. /**
  150016. * the first navmesh created. We might extend this to support multiple navmeshes
  150017. */
  150018. navMesh: any;
  150019. /**
  150020. * Initializes the recastJS plugin
  150021. * @param recastInjection can be used to inject your own recast reference
  150022. */
  150023. constructor(recastInjection?: any);
  150024. /**
  150025. * Creates a navigation mesh
  150026. * @param meshes array of all the geometry used to compute the navigatio mesh
  150027. * @param parameters bunch of parameters used to filter geometry
  150028. */
  150029. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  150030. /**
  150031. * Create a navigation mesh debug mesh
  150032. * @param scene is where the mesh will be added
  150033. * @returns debug display mesh
  150034. */
  150035. createDebugNavMesh(scene: Scene): Mesh;
  150036. /**
  150037. * Get a navigation mesh constrained position, closest to the parameter position
  150038. * @param position world position
  150039. * @returns the closest point to position constrained by the navigation mesh
  150040. */
  150041. getClosestPoint(position: Vector3): Vector3;
  150042. /**
  150043. * Get a navigation mesh constrained position, closest to the parameter position
  150044. * @param position world position
  150045. * @param result output the closest point to position constrained by the navigation mesh
  150046. */
  150047. getClosestPointToRef(position: Vector3, result: Vector3): void;
  150048. /**
  150049. * Get a navigation mesh constrained position, within a particular radius
  150050. * @param position world position
  150051. * @param maxRadius the maximum distance to the constrained world position
  150052. * @returns the closest point to position constrained by the navigation mesh
  150053. */
  150054. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  150055. /**
  150056. * Get a navigation mesh constrained position, within a particular radius
  150057. * @param position world position
  150058. * @param maxRadius the maximum distance to the constrained world position
  150059. * @param result output the closest point to position constrained by the navigation mesh
  150060. */
  150061. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  150062. /**
  150063. * Compute the final position from a segment made of destination-position
  150064. * @param position world position
  150065. * @param destination world position
  150066. * @returns the resulting point along the navmesh
  150067. */
  150068. moveAlong(position: Vector3, destination: Vector3): Vector3;
  150069. /**
  150070. * Compute the final position from a segment made of destination-position
  150071. * @param position world position
  150072. * @param destination world position
  150073. * @param result output the resulting point along the navmesh
  150074. */
  150075. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  150076. /**
  150077. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  150078. * @param start world position
  150079. * @param end world position
  150080. * @returns array containing world position composing the path
  150081. */
  150082. computePath(start: Vector3, end: Vector3): Vector3[];
  150083. /**
  150084. * Create a new Crowd so you can add agents
  150085. * @param maxAgents the maximum agent count in the crowd
  150086. * @param maxAgentRadius the maximum radius an agent can have
  150087. * @param scene to attach the crowd to
  150088. * @returns the crowd you can add agents to
  150089. */
  150090. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  150091. /**
  150092. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  150093. * The queries will try to find a solution within those bounds
  150094. * default is (1,1,1)
  150095. * @param extent x,y,z value that define the extent around the queries point of reference
  150096. */
  150097. setDefaultQueryExtent(extent: Vector3): void;
  150098. /**
  150099. * Get the Bounding box extent specified by setDefaultQueryExtent
  150100. * @returns the box extent values
  150101. */
  150102. getDefaultQueryExtent(): Vector3;
  150103. /**
  150104. * build the navmesh from a previously saved state using getNavmeshData
  150105. * @param data the Uint8Array returned by getNavmeshData
  150106. */
  150107. buildFromNavmeshData(data: Uint8Array): void;
  150108. /**
  150109. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  150110. * @returns data the Uint8Array that can be saved and reused
  150111. */
  150112. getNavmeshData(): Uint8Array;
  150113. /**
  150114. * Get the Bounding box extent result specified by setDefaultQueryExtent
  150115. * @param result output the box extent values
  150116. */
  150117. getDefaultQueryExtentToRef(result: Vector3): void;
  150118. /**
  150119. * Disposes
  150120. */
  150121. dispose(): void;
  150122. /**
  150123. * If this plugin is supported
  150124. * @returns true if plugin is supported
  150125. */
  150126. isSupported(): boolean;
  150127. }
  150128. /**
  150129. * Recast detour crowd implementation
  150130. */
  150131. export class RecastJSCrowd implements ICrowd {
  150132. /**
  150133. * Recast/detour plugin
  150134. */
  150135. bjsRECASTPlugin: RecastJSPlugin;
  150136. /**
  150137. * Link to the detour crowd
  150138. */
  150139. recastCrowd: any;
  150140. /**
  150141. * One transform per agent
  150142. */
  150143. transforms: TransformNode[];
  150144. /**
  150145. * All agents created
  150146. */
  150147. agents: number[];
  150148. /**
  150149. * Link to the scene is kept to unregister the crowd from the scene
  150150. */
  150151. private _scene;
  150152. /**
  150153. * Observer for crowd updates
  150154. */
  150155. private _onBeforeAnimationsObserver;
  150156. /**
  150157. * Constructor
  150158. * @param plugin recastJS plugin
  150159. * @param maxAgents the maximum agent count in the crowd
  150160. * @param maxAgentRadius the maximum radius an agent can have
  150161. * @param scene to attach the crowd to
  150162. * @returns the crowd you can add agents to
  150163. */
  150164. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  150165. /**
  150166. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  150167. * You can attach anything to that node. The node position is updated in the scene update tick.
  150168. * @param pos world position that will be constrained by the navigation mesh
  150169. * @param parameters agent parameters
  150170. * @param transform hooked to the agent that will be update by the scene
  150171. * @returns agent index
  150172. */
  150173. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  150174. /**
  150175. * Returns the agent position in world space
  150176. * @param index agent index returned by addAgent
  150177. * @returns world space position
  150178. */
  150179. getAgentPosition(index: number): Vector3;
  150180. /**
  150181. * Returns the agent position result in world space
  150182. * @param index agent index returned by addAgent
  150183. * @param result output world space position
  150184. */
  150185. getAgentPositionToRef(index: number, result: Vector3): void;
  150186. /**
  150187. * Returns the agent velocity in world space
  150188. * @param index agent index returned by addAgent
  150189. * @returns world space velocity
  150190. */
  150191. getAgentVelocity(index: number): Vector3;
  150192. /**
  150193. * Returns the agent velocity result in world space
  150194. * @param index agent index returned by addAgent
  150195. * @param result output world space velocity
  150196. */
  150197. getAgentVelocityToRef(index: number, result: Vector3): void;
  150198. /**
  150199. * Returns the agent next target point on the path
  150200. * @param index agent index returned by addAgent
  150201. * @returns world space position
  150202. */
  150203. getAgentNextTargetPath(index: number): Vector3;
  150204. /**
  150205. * Returns the agent next target point on the path
  150206. * @param index agent index returned by addAgent
  150207. * @param result output world space position
  150208. */
  150209. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  150210. /**
  150211. * Gets the agent state
  150212. * @param index agent index returned by addAgent
  150213. * @returns agent state
  150214. */
  150215. getAgentState(index: number): number;
  150216. /**
  150217. * returns true if the agent in over an off mesh link connection
  150218. * @param index agent index returned by addAgent
  150219. * @returns true if over an off mesh link connection
  150220. */
  150221. overOffmeshConnection(index: number): boolean;
  150222. /**
  150223. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  150224. * @param index agent index returned by addAgent
  150225. * @param destination targeted world position
  150226. */
  150227. agentGoto(index: number, destination: Vector3): void;
  150228. /**
  150229. * Teleport the agent to a new position
  150230. * @param index agent index returned by addAgent
  150231. * @param destination targeted world position
  150232. */
  150233. agentTeleport(index: number, destination: Vector3): void;
  150234. /**
  150235. * Update agent parameters
  150236. * @param index agent index returned by addAgent
  150237. * @param parameters agent parameters
  150238. */
  150239. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  150240. /**
  150241. * remove a particular agent previously created
  150242. * @param index agent index returned by addAgent
  150243. */
  150244. removeAgent(index: number): void;
  150245. /**
  150246. * get the list of all agents attached to this crowd
  150247. * @returns list of agent indices
  150248. */
  150249. getAgents(): number[];
  150250. /**
  150251. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  150252. * @param deltaTime in seconds
  150253. */
  150254. update(deltaTime: number): void;
  150255. /**
  150256. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  150257. * The queries will try to find a solution within those bounds
  150258. * default is (1,1,1)
  150259. * @param extent x,y,z value that define the extent around the queries point of reference
  150260. */
  150261. setDefaultQueryExtent(extent: Vector3): void;
  150262. /**
  150263. * Get the Bounding box extent specified by setDefaultQueryExtent
  150264. * @returns the box extent values
  150265. */
  150266. getDefaultQueryExtent(): Vector3;
  150267. /**
  150268. * Get the Bounding box extent result specified by setDefaultQueryExtent
  150269. * @param result output the box extent values
  150270. */
  150271. getDefaultQueryExtentToRef(result: Vector3): void;
  150272. /**
  150273. * Release all resources
  150274. */
  150275. dispose(): void;
  150276. }
  150277. }
  150278. declare module BABYLON {
  150279. /**
  150280. * Class used to enable access to IndexedDB
  150281. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  150282. */
  150283. export class Database implements IOfflineProvider {
  150284. private _callbackManifestChecked;
  150285. private _currentSceneUrl;
  150286. private _db;
  150287. private _enableSceneOffline;
  150288. private _enableTexturesOffline;
  150289. private _manifestVersionFound;
  150290. private _mustUpdateRessources;
  150291. private _hasReachedQuota;
  150292. private _isSupported;
  150293. private _idbFactory;
  150294. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  150295. private static IsUASupportingBlobStorage;
  150296. /**
  150297. * Gets a boolean indicating if Database storate is enabled (off by default)
  150298. */
  150299. static IDBStorageEnabled: boolean;
  150300. /**
  150301. * Gets a boolean indicating if scene must be saved in the database
  150302. */
  150303. get enableSceneOffline(): boolean;
  150304. /**
  150305. * Gets a boolean indicating if textures must be saved in the database
  150306. */
  150307. get enableTexturesOffline(): boolean;
  150308. /**
  150309. * Creates a new Database
  150310. * @param urlToScene defines the url to load the scene
  150311. * @param callbackManifestChecked defines the callback to use when manifest is checked
  150312. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  150313. */
  150314. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  150315. private static _ParseURL;
  150316. private static _ReturnFullUrlLocation;
  150317. private _checkManifestFile;
  150318. /**
  150319. * Open the database and make it available
  150320. * @param successCallback defines the callback to call on success
  150321. * @param errorCallback defines the callback to call on error
  150322. */
  150323. open(successCallback: () => void, errorCallback: () => void): void;
  150324. /**
  150325. * Loads an image from the database
  150326. * @param url defines the url to load from
  150327. * @param image defines the target DOM image
  150328. */
  150329. loadImage(url: string, image: HTMLImageElement): void;
  150330. private _loadImageFromDBAsync;
  150331. private _saveImageIntoDBAsync;
  150332. private _checkVersionFromDB;
  150333. private _loadVersionFromDBAsync;
  150334. private _saveVersionIntoDBAsync;
  150335. /**
  150336. * Loads a file from database
  150337. * @param url defines the URL to load from
  150338. * @param sceneLoaded defines a callback to call on success
  150339. * @param progressCallBack defines a callback to call when progress changed
  150340. * @param errorCallback defines a callback to call on error
  150341. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  150342. */
  150343. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  150344. private _loadFileAsync;
  150345. private _saveFileAsync;
  150346. /**
  150347. * Validates if xhr data is correct
  150348. * @param xhr defines the request to validate
  150349. * @param dataType defines the expected data type
  150350. * @returns true if data is correct
  150351. */
  150352. private static _ValidateXHRData;
  150353. }
  150354. }
  150355. declare module BABYLON {
  150356. /** @hidden */
  150357. export var gpuUpdateParticlesPixelShader: {
  150358. name: string;
  150359. shader: string;
  150360. };
  150361. }
  150362. declare module BABYLON {
  150363. /** @hidden */
  150364. export var gpuUpdateParticlesVertexShader: {
  150365. name: string;
  150366. shader: string;
  150367. };
  150368. }
  150369. declare module BABYLON {
  150370. /** @hidden */
  150371. export var clipPlaneFragmentDeclaration2: {
  150372. name: string;
  150373. shader: string;
  150374. };
  150375. }
  150376. declare module BABYLON {
  150377. /** @hidden */
  150378. export var gpuRenderParticlesPixelShader: {
  150379. name: string;
  150380. shader: string;
  150381. };
  150382. }
  150383. declare module BABYLON {
  150384. /** @hidden */
  150385. export var clipPlaneVertexDeclaration2: {
  150386. name: string;
  150387. shader: string;
  150388. };
  150389. }
  150390. declare module BABYLON {
  150391. /** @hidden */
  150392. export var gpuRenderParticlesVertexShader: {
  150393. name: string;
  150394. shader: string;
  150395. };
  150396. }
  150397. declare module BABYLON {
  150398. /**
  150399. * This represents a GPU particle system in Babylon
  150400. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  150401. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  150402. */
  150403. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  150404. /**
  150405. * The layer mask we are rendering the particles through.
  150406. */
  150407. layerMask: number;
  150408. private _capacity;
  150409. private _activeCount;
  150410. private _currentActiveCount;
  150411. private _accumulatedCount;
  150412. private _renderEffect;
  150413. private _updateEffect;
  150414. private _buffer0;
  150415. private _buffer1;
  150416. private _spriteBuffer;
  150417. private _updateVAO;
  150418. private _renderVAO;
  150419. private _targetIndex;
  150420. private _sourceBuffer;
  150421. private _targetBuffer;
  150422. private _currentRenderId;
  150423. private _started;
  150424. private _stopped;
  150425. private _timeDelta;
  150426. private _randomTexture;
  150427. private _randomTexture2;
  150428. private _attributesStrideSize;
  150429. private _updateEffectOptions;
  150430. private _randomTextureSize;
  150431. private _actualFrame;
  150432. private _customEffect;
  150433. private readonly _rawTextureWidth;
  150434. /**
  150435. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  150436. */
  150437. static get IsSupported(): boolean;
  150438. /**
  150439. * An event triggered when the system is disposed.
  150440. */
  150441. onDisposeObservable: Observable<IParticleSystem>;
  150442. /**
  150443. * An event triggered when the system is stopped
  150444. */
  150445. onStoppedObservable: Observable<IParticleSystem>;
  150446. /**
  150447. * Gets the maximum number of particles active at the same time.
  150448. * @returns The max number of active particles.
  150449. */
  150450. getCapacity(): number;
  150451. /**
  150452. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  150453. * to override the particles.
  150454. */
  150455. forceDepthWrite: boolean;
  150456. /**
  150457. * Gets or set the number of active particles
  150458. */
  150459. get activeParticleCount(): number;
  150460. set activeParticleCount(value: number);
  150461. private _preWarmDone;
  150462. /**
  150463. * Specifies if the particles are updated in emitter local space or world space.
  150464. */
  150465. isLocal: boolean;
  150466. /** Gets or sets a matrix to use to compute projection */
  150467. defaultProjectionMatrix: Matrix;
  150468. /**
  150469. * Is this system ready to be used/rendered
  150470. * @return true if the system is ready
  150471. */
  150472. isReady(): boolean;
  150473. /**
  150474. * Gets if the system has been started. (Note: this will still be true after stop is called)
  150475. * @returns True if it has been started, otherwise false.
  150476. */
  150477. isStarted(): boolean;
  150478. /**
  150479. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  150480. * @returns True if it has been stopped, otherwise false.
  150481. */
  150482. isStopped(): boolean;
  150483. /**
  150484. * Gets a boolean indicating that the system is stopping
  150485. * @returns true if the system is currently stopping
  150486. */
  150487. isStopping(): boolean;
  150488. /**
  150489. * Gets the number of particles active at the same time.
  150490. * @returns The number of active particles.
  150491. */
  150492. getActiveCount(): number;
  150493. /**
  150494. * Starts the particle system and begins to emit
  150495. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  150496. */
  150497. start(delay?: number): void;
  150498. /**
  150499. * Stops the particle system.
  150500. */
  150501. stop(): void;
  150502. /**
  150503. * Remove all active particles
  150504. */
  150505. reset(): void;
  150506. /**
  150507. * Returns the string "GPUParticleSystem"
  150508. * @returns a string containing the class name
  150509. */
  150510. getClassName(): string;
  150511. /**
  150512. * Gets the custom effect used to render the particles
  150513. * @param blendMode Blend mode for which the effect should be retrieved
  150514. * @returns The effect
  150515. */
  150516. getCustomEffect(blendMode?: number): Nullable<Effect>;
  150517. /**
  150518. * Sets the custom effect used to render the particles
  150519. * @param effect The effect to set
  150520. * @param blendMode Blend mode for which the effect should be set
  150521. */
  150522. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  150523. /** @hidden */
  150524. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  150525. /**
  150526. * Observable that will be called just before the particles are drawn
  150527. */
  150528. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  150529. /**
  150530. * Gets the name of the particle vertex shader
  150531. */
  150532. get vertexShaderName(): string;
  150533. private _colorGradientsTexture;
  150534. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  150535. /**
  150536. * Adds a new color gradient
  150537. * @param gradient defines the gradient to use (between 0 and 1)
  150538. * @param color1 defines the color to affect to the specified gradient
  150539. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  150540. * @returns the current particle system
  150541. */
  150542. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  150543. private _refreshColorGradient;
  150544. /** Force the system to rebuild all gradients that need to be resync */
  150545. forceRefreshGradients(): void;
  150546. /**
  150547. * Remove a specific color gradient
  150548. * @param gradient defines the gradient to remove
  150549. * @returns the current particle system
  150550. */
  150551. removeColorGradient(gradient: number): GPUParticleSystem;
  150552. private _angularSpeedGradientsTexture;
  150553. private _sizeGradientsTexture;
  150554. private _velocityGradientsTexture;
  150555. private _limitVelocityGradientsTexture;
  150556. private _dragGradientsTexture;
  150557. private _addFactorGradient;
  150558. /**
  150559. * Adds a new size gradient
  150560. * @param gradient defines the gradient to use (between 0 and 1)
  150561. * @param factor defines the size factor to affect to the specified gradient
  150562. * @returns the current particle system
  150563. */
  150564. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  150565. /**
  150566. * Remove a specific size gradient
  150567. * @param gradient defines the gradient to remove
  150568. * @returns the current particle system
  150569. */
  150570. removeSizeGradient(gradient: number): GPUParticleSystem;
  150571. private _refreshFactorGradient;
  150572. /**
  150573. * Adds a new angular speed gradient
  150574. * @param gradient defines the gradient to use (between 0 and 1)
  150575. * @param factor defines the angular speed to affect to the specified gradient
  150576. * @returns the current particle system
  150577. */
  150578. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  150579. /**
  150580. * Remove a specific angular speed gradient
  150581. * @param gradient defines the gradient to remove
  150582. * @returns the current particle system
  150583. */
  150584. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  150585. /**
  150586. * Adds a new velocity gradient
  150587. * @param gradient defines the gradient to use (between 0 and 1)
  150588. * @param factor defines the velocity to affect to the specified gradient
  150589. * @returns the current particle system
  150590. */
  150591. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150592. /**
  150593. * Remove a specific velocity gradient
  150594. * @param gradient defines the gradient to remove
  150595. * @returns the current particle system
  150596. */
  150597. removeVelocityGradient(gradient: number): GPUParticleSystem;
  150598. /**
  150599. * Adds a new limit velocity gradient
  150600. * @param gradient defines the gradient to use (between 0 and 1)
  150601. * @param factor defines the limit velocity value to affect to the specified gradient
  150602. * @returns the current particle system
  150603. */
  150604. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150605. /**
  150606. * Remove a specific limit velocity gradient
  150607. * @param gradient defines the gradient to remove
  150608. * @returns the current particle system
  150609. */
  150610. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  150611. /**
  150612. * Adds a new drag gradient
  150613. * @param gradient defines the gradient to use (between 0 and 1)
  150614. * @param factor defines the drag value to affect to the specified gradient
  150615. * @returns the current particle system
  150616. */
  150617. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  150618. /**
  150619. * Remove a specific drag gradient
  150620. * @param gradient defines the gradient to remove
  150621. * @returns the current particle system
  150622. */
  150623. removeDragGradient(gradient: number): GPUParticleSystem;
  150624. /**
  150625. * Not supported by GPUParticleSystem
  150626. * @param gradient defines the gradient to use (between 0 and 1)
  150627. * @param factor defines the emit rate value to affect to the specified gradient
  150628. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150629. * @returns the current particle system
  150630. */
  150631. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150632. /**
  150633. * Not supported by GPUParticleSystem
  150634. * @param gradient defines the gradient to remove
  150635. * @returns the current particle system
  150636. */
  150637. removeEmitRateGradient(gradient: number): IParticleSystem;
  150638. /**
  150639. * Not supported by GPUParticleSystem
  150640. * @param gradient defines the gradient to use (between 0 and 1)
  150641. * @param factor defines the start size value to affect to the specified gradient
  150642. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150643. * @returns the current particle system
  150644. */
  150645. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150646. /**
  150647. * Not supported by GPUParticleSystem
  150648. * @param gradient defines the gradient to remove
  150649. * @returns the current particle system
  150650. */
  150651. removeStartSizeGradient(gradient: number): IParticleSystem;
  150652. /**
  150653. * Not supported by GPUParticleSystem
  150654. * @param gradient defines the gradient to use (between 0 and 1)
  150655. * @param min defines the color remap minimal range
  150656. * @param max defines the color remap maximal range
  150657. * @returns the current particle system
  150658. */
  150659. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150660. /**
  150661. * Not supported by GPUParticleSystem
  150662. * @param gradient defines the gradient to remove
  150663. * @returns the current particle system
  150664. */
  150665. removeColorRemapGradient(): IParticleSystem;
  150666. /**
  150667. * Not supported by GPUParticleSystem
  150668. * @param gradient defines the gradient to use (between 0 and 1)
  150669. * @param min defines the alpha remap minimal range
  150670. * @param max defines the alpha remap maximal range
  150671. * @returns the current particle system
  150672. */
  150673. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150674. /**
  150675. * Not supported by GPUParticleSystem
  150676. * @param gradient defines the gradient to remove
  150677. * @returns the current particle system
  150678. */
  150679. removeAlphaRemapGradient(): IParticleSystem;
  150680. /**
  150681. * Not supported by GPUParticleSystem
  150682. * @param gradient defines the gradient to use (between 0 and 1)
  150683. * @param color defines the color to affect to the specified gradient
  150684. * @returns the current particle system
  150685. */
  150686. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  150687. /**
  150688. * Not supported by GPUParticleSystem
  150689. * @param gradient defines the gradient to remove
  150690. * @returns the current particle system
  150691. */
  150692. removeRampGradient(): IParticleSystem;
  150693. /**
  150694. * Not supported by GPUParticleSystem
  150695. * @returns the list of ramp gradients
  150696. */
  150697. getRampGradients(): Nullable<Array<Color3Gradient>>;
  150698. /**
  150699. * Not supported by GPUParticleSystem
  150700. * Gets or sets a boolean indicating that ramp gradients must be used
  150701. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  150702. */
  150703. get useRampGradients(): boolean;
  150704. set useRampGradients(value: boolean);
  150705. /**
  150706. * Not supported by GPUParticleSystem
  150707. * @param gradient defines the gradient to use (between 0 and 1)
  150708. * @param factor defines the life time factor to affect to the specified gradient
  150709. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150710. * @returns the current particle system
  150711. */
  150712. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150713. /**
  150714. * Not supported by GPUParticleSystem
  150715. * @param gradient defines the gradient to remove
  150716. * @returns the current particle system
  150717. */
  150718. removeLifeTimeGradient(gradient: number): IParticleSystem;
  150719. /**
  150720. * Instantiates a GPU particle system.
  150721. * 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.
  150722. * @param name The name of the particle system
  150723. * @param options The options used to create the system
  150724. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  150725. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  150726. * @param customEffect a custom effect used to change the way particles are rendered by default
  150727. */
  150728. constructor(name: string, options: Partial<{
  150729. capacity: number;
  150730. randomTextureSize: number;
  150731. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  150732. protected _reset(): void;
  150733. private _createUpdateVAO;
  150734. private _createRenderVAO;
  150735. private _initialize;
  150736. /** @hidden */
  150737. _recreateUpdateEffect(): void;
  150738. private _getEffect;
  150739. /**
  150740. * Fill the defines array according to the current settings of the particle system
  150741. * @param defines Array to be updated
  150742. * @param blendMode blend mode to take into account when updating the array
  150743. */
  150744. fillDefines(defines: Array<string>, blendMode?: number): void;
  150745. /**
  150746. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  150747. * @param uniforms Uniforms array to fill
  150748. * @param attributes Attributes array to fill
  150749. * @param samplers Samplers array to fill
  150750. */
  150751. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  150752. /** @hidden */
  150753. _recreateRenderEffect(): Effect;
  150754. /**
  150755. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  150756. * @param preWarm defines if we are in the pre-warmimg phase
  150757. */
  150758. animate(preWarm?: boolean): void;
  150759. private _createFactorGradientTexture;
  150760. private _createSizeGradientTexture;
  150761. private _createAngularSpeedGradientTexture;
  150762. private _createVelocityGradientTexture;
  150763. private _createLimitVelocityGradientTexture;
  150764. private _createDragGradientTexture;
  150765. private _createColorGradientTexture;
  150766. /**
  150767. * Renders the particle system in its current state
  150768. * @param preWarm defines if the system should only update the particles but not render them
  150769. * @returns the current number of particles
  150770. */
  150771. render(preWarm?: boolean): number;
  150772. /**
  150773. * Rebuilds the particle system
  150774. */
  150775. rebuild(): void;
  150776. private _releaseBuffers;
  150777. private _releaseVAOs;
  150778. /**
  150779. * Disposes the particle system and free the associated resources
  150780. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  150781. */
  150782. dispose(disposeTexture?: boolean): void;
  150783. /**
  150784. * Clones the particle system.
  150785. * @param name The name of the cloned object
  150786. * @param newEmitter The new emitter to use
  150787. * @returns the cloned particle system
  150788. */
  150789. clone(name: string, newEmitter: any): GPUParticleSystem;
  150790. /**
  150791. * Serializes the particle system to a JSON object
  150792. * @param serializeTexture defines if the texture must be serialized as well
  150793. * @returns the JSON object
  150794. */
  150795. serialize(serializeTexture?: boolean): any;
  150796. /**
  150797. * Parses a JSON object to create a GPU particle system.
  150798. * @param parsedParticleSystem The JSON object to parse
  150799. * @param sceneOrEngine The scene or the engine to create the particle system in
  150800. * @param rootUrl The root url to use to load external dependencies like texture
  150801. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  150802. * @returns the parsed GPU particle system
  150803. */
  150804. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  150805. }
  150806. }
  150807. declare module BABYLON {
  150808. /**
  150809. * Represents a set of particle systems working together to create a specific effect
  150810. */
  150811. export class ParticleSystemSet implements IDisposable {
  150812. /**
  150813. * Gets or sets base Assets URL
  150814. */
  150815. static BaseAssetsUrl: string;
  150816. private _emitterCreationOptions;
  150817. private _emitterNode;
  150818. /**
  150819. * Gets the particle system list
  150820. */
  150821. systems: IParticleSystem[];
  150822. /**
  150823. * Gets the emitter node used with this set
  150824. */
  150825. get emitterNode(): Nullable<TransformNode>;
  150826. /**
  150827. * Creates a new emitter mesh as a sphere
  150828. * @param options defines the options used to create the sphere
  150829. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  150830. * @param scene defines the hosting scene
  150831. */
  150832. setEmitterAsSphere(options: {
  150833. diameter: number;
  150834. segments: number;
  150835. color: Color3;
  150836. }, renderingGroupId: number, scene: Scene): void;
  150837. /**
  150838. * Starts all particle systems of the set
  150839. * @param emitter defines an optional mesh to use as emitter for the particle systems
  150840. */
  150841. start(emitter?: AbstractMesh): void;
  150842. /**
  150843. * Release all associated resources
  150844. */
  150845. dispose(): void;
  150846. /**
  150847. * Serialize the set into a JSON compatible object
  150848. * @param serializeTexture defines if the texture must be serialized as well
  150849. * @returns a JSON compatible representation of the set
  150850. */
  150851. serialize(serializeTexture?: boolean): any;
  150852. /**
  150853. * Parse a new ParticleSystemSet from a serialized source
  150854. * @param data defines a JSON compatible representation of the set
  150855. * @param scene defines the hosting scene
  150856. * @param gpu defines if we want GPU particles or CPU particles
  150857. * @returns a new ParticleSystemSet
  150858. */
  150859. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  150860. }
  150861. }
  150862. declare module BABYLON {
  150863. /**
  150864. * This class is made for on one-liner static method to help creating particle system set.
  150865. */
  150866. export class ParticleHelper {
  150867. /**
  150868. * Gets or sets base Assets URL
  150869. */
  150870. static BaseAssetsUrl: string;
  150871. /** Define the Url to load snippets */
  150872. static SnippetUrl: string;
  150873. /**
  150874. * Create a default particle system that you can tweak
  150875. * @param emitter defines the emitter to use
  150876. * @param capacity defines the system capacity (default is 500 particles)
  150877. * @param scene defines the hosting scene
  150878. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  150879. * @returns the new Particle system
  150880. */
  150881. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  150882. /**
  150883. * This is the main static method (one-liner) of this helper to create different particle systems
  150884. * @param type This string represents the type to the particle system to create
  150885. * @param scene The scene where the particle system should live
  150886. * @param gpu If the system will use gpu
  150887. * @returns the ParticleSystemSet created
  150888. */
  150889. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  150890. /**
  150891. * Static function used to export a particle system to a ParticleSystemSet variable.
  150892. * Please note that the emitter shape is not exported
  150893. * @param systems defines the particle systems to export
  150894. * @returns the created particle system set
  150895. */
  150896. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  150897. /**
  150898. * Creates a particle system from a snippet saved in a remote file
  150899. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  150900. * @param url defines the url to load from
  150901. * @param scene defines the hosting scene
  150902. * @param gpu If the system will use gpu
  150903. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  150904. * @returns a promise that will resolve to the new particle system
  150905. */
  150906. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  150907. /**
  150908. * Creates a particle system from a snippet saved by the particle system editor
  150909. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  150910. * @param scene defines the hosting scene
  150911. * @param gpu If the system will use gpu
  150912. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  150913. * @returns a promise that will resolve to the new particle system
  150914. */
  150915. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  150916. }
  150917. }
  150918. declare module BABYLON {
  150919. interface Engine {
  150920. /**
  150921. * Create an effect to use with particle systems.
  150922. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  150923. * the particle system for which you want to create a custom effect in the last parameter
  150924. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  150925. * @param uniformsNames defines a list of attribute names
  150926. * @param samplers defines an array of string used to represent textures
  150927. * @param defines defines the string containing the defines to use to compile the shaders
  150928. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  150929. * @param onCompiled defines a function to call when the effect creation is successful
  150930. * @param onError defines a function to call when the effect creation has failed
  150931. * @param particleSystem the particle system you want to create the effect for
  150932. * @returns the new Effect
  150933. */
  150934. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  150935. }
  150936. interface Mesh {
  150937. /**
  150938. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  150939. * @returns an array of IParticleSystem
  150940. */
  150941. getEmittedParticleSystems(): IParticleSystem[];
  150942. /**
  150943. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  150944. * @returns an array of IParticleSystem
  150945. */
  150946. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  150947. }
  150948. }
  150949. declare module BABYLON {
  150950. /** Defines the 4 color options */
  150951. export enum PointColor {
  150952. /** color value */
  150953. Color = 2,
  150954. /** uv value */
  150955. UV = 1,
  150956. /** random value */
  150957. Random = 0,
  150958. /** stated value */
  150959. Stated = 3
  150960. }
  150961. /**
  150962. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  150963. * 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.
  150964. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  150965. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  150966. *
  150967. * Full documentation here : TO BE ENTERED
  150968. */
  150969. export class PointsCloudSystem implements IDisposable {
  150970. /**
  150971. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  150972. * Example : var p = SPS.particles[i];
  150973. */
  150974. particles: CloudPoint[];
  150975. /**
  150976. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  150977. */
  150978. nbParticles: number;
  150979. /**
  150980. * This a counter for your own usage. It's not set by any SPS functions.
  150981. */
  150982. counter: number;
  150983. /**
  150984. * The PCS name. This name is also given to the underlying mesh.
  150985. */
  150986. name: string;
  150987. /**
  150988. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  150989. */
  150990. mesh: Mesh;
  150991. /**
  150992. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  150993. * Please read :
  150994. */
  150995. vars: any;
  150996. /**
  150997. * @hidden
  150998. */
  150999. _size: number;
  151000. private _scene;
  151001. private _promises;
  151002. private _positions;
  151003. private _indices;
  151004. private _normals;
  151005. private _colors;
  151006. private _uvs;
  151007. private _indices32;
  151008. private _positions32;
  151009. private _colors32;
  151010. private _uvs32;
  151011. private _updatable;
  151012. private _isVisibilityBoxLocked;
  151013. private _alwaysVisible;
  151014. private _groups;
  151015. private _groupCounter;
  151016. private _computeParticleColor;
  151017. private _computeParticleTexture;
  151018. private _computeParticleRotation;
  151019. private _computeBoundingBox;
  151020. private _isReady;
  151021. /**
  151022. * Creates a PCS (Points Cloud System) object
  151023. * @param name (String) is the PCS name, this will be the underlying mesh name
  151024. * @param pointSize (number) is the size for each point
  151025. * @param scene (Scene) is the scene in which the PCS is added
  151026. * @param options defines the options of the PCS e.g.
  151027. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  151028. */
  151029. constructor(name: string, pointSize: number, scene: Scene, options?: {
  151030. updatable?: boolean;
  151031. });
  151032. /**
  151033. * Builds the PCS underlying mesh. Returns a standard Mesh.
  151034. * If no points were added to the PCS, the returned mesh is just a single point.
  151035. * @returns a promise for the created mesh
  151036. */
  151037. buildMeshAsync(): Promise<Mesh>;
  151038. /**
  151039. * @hidden
  151040. */
  151041. private _buildMesh;
  151042. private _addParticle;
  151043. private _randomUnitVector;
  151044. private _getColorIndicesForCoord;
  151045. private _setPointsColorOrUV;
  151046. private _colorFromTexture;
  151047. private _calculateDensity;
  151048. /**
  151049. * Adds points to the PCS in random positions within a unit sphere
  151050. * @param nb (positive integer) the number of particles to be created from this model
  151051. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  151052. * @returns the number of groups in the system
  151053. */
  151054. addPoints(nb: number, pointFunction?: any): number;
  151055. /**
  151056. * Adds points to the PCS from the surface of the model shape
  151057. * @param mesh is any Mesh object that will be used as a surface model for the points
  151058. * @param nb (positive integer) the number of particles to be created from this model
  151059. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  151060. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  151061. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  151062. * @returns the number of groups in the system
  151063. */
  151064. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  151065. /**
  151066. * Adds points to the PCS inside the model shape
  151067. * @param mesh is any Mesh object that will be used as a surface model for the points
  151068. * @param nb (positive integer) the number of particles to be created from this model
  151069. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  151070. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  151071. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  151072. * @returns the number of groups in the system
  151073. */
  151074. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  151075. /**
  151076. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  151077. * This method calls `updateParticle()` for each particle of the SPS.
  151078. * For an animated SPS, it is usually called within the render loop.
  151079. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  151080. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  151081. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  151082. * @returns the PCS.
  151083. */
  151084. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  151085. /**
  151086. * Disposes the PCS.
  151087. */
  151088. dispose(): void;
  151089. /**
  151090. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  151091. * doc :
  151092. * @returns the PCS.
  151093. */
  151094. refreshVisibleSize(): PointsCloudSystem;
  151095. /**
  151096. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  151097. * @param size the size (float) of the visibility box
  151098. * note : this doesn't lock the PCS mesh bounding box.
  151099. * doc :
  151100. */
  151101. setVisibilityBox(size: number): void;
  151102. /**
  151103. * Gets whether the PCS is always visible or not
  151104. * doc :
  151105. */
  151106. get isAlwaysVisible(): boolean;
  151107. /**
  151108. * Sets the PCS as always visible or not
  151109. * doc :
  151110. */
  151111. set isAlwaysVisible(val: boolean);
  151112. /**
  151113. * Tells to `setParticles()` to compute the particle rotations or not
  151114. * Default value : false. The PCS is faster when it's set to false
  151115. * Note : particle rotations are only applied to parent particles
  151116. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  151117. */
  151118. set computeParticleRotation(val: boolean);
  151119. /**
  151120. * Tells to `setParticles()` to compute the particle colors or not.
  151121. * Default value : true. The PCS is faster when it's set to false.
  151122. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  151123. */
  151124. set computeParticleColor(val: boolean);
  151125. set computeParticleTexture(val: boolean);
  151126. /**
  151127. * Gets if `setParticles()` computes the particle colors or not.
  151128. * Default value : false. The PCS is faster when it's set to false.
  151129. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  151130. */
  151131. get computeParticleColor(): boolean;
  151132. /**
  151133. * Gets if `setParticles()` computes the particle textures or not.
  151134. * Default value : false. The PCS is faster when it's set to false.
  151135. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  151136. */
  151137. get computeParticleTexture(): boolean;
  151138. /**
  151139. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  151140. */
  151141. set computeBoundingBox(val: boolean);
  151142. /**
  151143. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  151144. */
  151145. get computeBoundingBox(): boolean;
  151146. /**
  151147. * This function does nothing. It may be overwritten to set all the particle first values.
  151148. * The PCS doesn't call this function, you may have to call it by your own.
  151149. * doc :
  151150. */
  151151. initParticles(): void;
  151152. /**
  151153. * This function does nothing. It may be overwritten to recycle a particle
  151154. * The PCS doesn't call this function, you can to call it
  151155. * doc :
  151156. * @param particle The particle to recycle
  151157. * @returns the recycled particle
  151158. */
  151159. recycleParticle(particle: CloudPoint): CloudPoint;
  151160. /**
  151161. * Updates a particle : this function should be overwritten by the user.
  151162. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  151163. * doc :
  151164. * @example : just set a particle position or velocity and recycle conditions
  151165. * @param particle The particle to update
  151166. * @returns the updated particle
  151167. */
  151168. updateParticle(particle: CloudPoint): CloudPoint;
  151169. /**
  151170. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  151171. * This does nothing and may be overwritten by the user.
  151172. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  151173. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  151174. * @param update the boolean update value actually passed to setParticles()
  151175. */
  151176. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  151177. /**
  151178. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  151179. * This will be passed three parameters.
  151180. * This does nothing and may be overwritten by the user.
  151181. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  151182. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  151183. * @param update the boolean update value actually passed to setParticles()
  151184. */
  151185. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  151186. }
  151187. }
  151188. declare module BABYLON {
  151189. /**
  151190. * Represents one particle of a points cloud system.
  151191. */
  151192. export class CloudPoint {
  151193. /**
  151194. * particle global index
  151195. */
  151196. idx: number;
  151197. /**
  151198. * The color of the particle
  151199. */
  151200. color: Nullable<Color4>;
  151201. /**
  151202. * The world space position of the particle.
  151203. */
  151204. position: Vector3;
  151205. /**
  151206. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  151207. */
  151208. rotation: Vector3;
  151209. /**
  151210. * The world space rotation quaternion of the particle.
  151211. */
  151212. rotationQuaternion: Nullable<Quaternion>;
  151213. /**
  151214. * The uv of the particle.
  151215. */
  151216. uv: Nullable<Vector2>;
  151217. /**
  151218. * The current speed of the particle.
  151219. */
  151220. velocity: Vector3;
  151221. /**
  151222. * The pivot point in the particle local space.
  151223. */
  151224. pivot: Vector3;
  151225. /**
  151226. * Must the particle be translated from its pivot point in its local space ?
  151227. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  151228. * Default : false
  151229. */
  151230. translateFromPivot: boolean;
  151231. /**
  151232. * Index of this particle in the global "positions" array (Internal use)
  151233. * @hidden
  151234. */
  151235. _pos: number;
  151236. /**
  151237. * @hidden Index of this particle in the global "indices" array (Internal use)
  151238. */
  151239. _ind: number;
  151240. /**
  151241. * Group this particle belongs to
  151242. */
  151243. _group: PointsGroup;
  151244. /**
  151245. * Group id of this particle
  151246. */
  151247. groupId: number;
  151248. /**
  151249. * Index of the particle in its group id (Internal use)
  151250. */
  151251. idxInGroup: number;
  151252. /**
  151253. * @hidden Particle BoundingInfo object (Internal use)
  151254. */
  151255. _boundingInfo: BoundingInfo;
  151256. /**
  151257. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  151258. */
  151259. _pcs: PointsCloudSystem;
  151260. /**
  151261. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  151262. */
  151263. _stillInvisible: boolean;
  151264. /**
  151265. * @hidden Last computed particle rotation matrix
  151266. */
  151267. _rotationMatrix: number[];
  151268. /**
  151269. * Parent particle Id, if any.
  151270. * Default null.
  151271. */
  151272. parentId: Nullable<number>;
  151273. /**
  151274. * @hidden Internal global position in the PCS.
  151275. */
  151276. _globalPosition: Vector3;
  151277. /**
  151278. * Creates a Point Cloud object.
  151279. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  151280. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  151281. * @param group (PointsGroup) is the group the particle belongs to
  151282. * @param groupId (integer) is the group identifier in the PCS.
  151283. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  151284. * @param pcs defines the PCS it is associated to
  151285. */
  151286. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  151287. /**
  151288. * get point size
  151289. */
  151290. get size(): Vector3;
  151291. /**
  151292. * Set point size
  151293. */
  151294. set size(scale: Vector3);
  151295. /**
  151296. * Legacy support, changed quaternion to rotationQuaternion
  151297. */
  151298. get quaternion(): Nullable<Quaternion>;
  151299. /**
  151300. * Legacy support, changed quaternion to rotationQuaternion
  151301. */
  151302. set quaternion(q: Nullable<Quaternion>);
  151303. /**
  151304. * Returns a boolean. True if the particle intersects a mesh, else false
  151305. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  151306. * @param target is the object (point or mesh) what the intersection is computed against
  151307. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  151308. * @returns true if it intersects
  151309. */
  151310. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  151311. /**
  151312. * get the rotation matrix of the particle
  151313. * @hidden
  151314. */
  151315. getRotationMatrix(m: Matrix): void;
  151316. }
  151317. /**
  151318. * Represents a group of points in a points cloud system
  151319. * * PCS internal tool, don't use it manually.
  151320. */
  151321. export class PointsGroup {
  151322. /**
  151323. * The group id
  151324. * @hidden
  151325. */
  151326. groupID: number;
  151327. /**
  151328. * image data for group (internal use)
  151329. * @hidden
  151330. */
  151331. _groupImageData: Nullable<ArrayBufferView>;
  151332. /**
  151333. * Image Width (internal use)
  151334. * @hidden
  151335. */
  151336. _groupImgWidth: number;
  151337. /**
  151338. * Image Height (internal use)
  151339. * @hidden
  151340. */
  151341. _groupImgHeight: number;
  151342. /**
  151343. * Custom position function (internal use)
  151344. * @hidden
  151345. */
  151346. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  151347. /**
  151348. * density per facet for surface points
  151349. * @hidden
  151350. */
  151351. _groupDensity: number[];
  151352. /**
  151353. * Only when points are colored by texture carries pointer to texture list array
  151354. * @hidden
  151355. */
  151356. _textureNb: number;
  151357. /**
  151358. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  151359. * PCS internal tool, don't use it manually.
  151360. * @hidden
  151361. */
  151362. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  151363. }
  151364. }
  151365. declare module BABYLON {
  151366. interface Scene {
  151367. /** @hidden (Backing field) */
  151368. _physicsEngine: Nullable<IPhysicsEngine>;
  151369. /** @hidden */
  151370. _physicsTimeAccumulator: number;
  151371. /**
  151372. * Gets the current physics engine
  151373. * @returns a IPhysicsEngine or null if none attached
  151374. */
  151375. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  151376. /**
  151377. * Enables physics to the current scene
  151378. * @param gravity defines the scene's gravity for the physics engine
  151379. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  151380. * @return a boolean indicating if the physics engine was initialized
  151381. */
  151382. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  151383. /**
  151384. * Disables and disposes the physics engine associated with the scene
  151385. */
  151386. disablePhysicsEngine(): void;
  151387. /**
  151388. * Gets a boolean indicating if there is an active physics engine
  151389. * @returns a boolean indicating if there is an active physics engine
  151390. */
  151391. isPhysicsEnabled(): boolean;
  151392. /**
  151393. * Deletes a physics compound impostor
  151394. * @param compound defines the compound to delete
  151395. */
  151396. deleteCompoundImpostor(compound: any): void;
  151397. /**
  151398. * An event triggered when physic simulation is about to be run
  151399. */
  151400. onBeforePhysicsObservable: Observable<Scene>;
  151401. /**
  151402. * An event triggered when physic simulation has been done
  151403. */
  151404. onAfterPhysicsObservable: Observable<Scene>;
  151405. }
  151406. interface AbstractMesh {
  151407. /** @hidden */
  151408. _physicsImpostor: Nullable<PhysicsImpostor>;
  151409. /**
  151410. * Gets or sets impostor used for physic simulation
  151411. * @see https://doc.babylonjs.com/features/physics_engine
  151412. */
  151413. physicsImpostor: Nullable<PhysicsImpostor>;
  151414. /**
  151415. * Gets the current physics impostor
  151416. * @see https://doc.babylonjs.com/features/physics_engine
  151417. * @returns a physics impostor or null
  151418. */
  151419. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  151420. /** Apply a physic impulse to the mesh
  151421. * @param force defines the force to apply
  151422. * @param contactPoint defines where to apply the force
  151423. * @returns the current mesh
  151424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  151425. */
  151426. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  151427. /**
  151428. * Creates a physic joint between two meshes
  151429. * @param otherMesh defines the other mesh to use
  151430. * @param pivot1 defines the pivot to use on this mesh
  151431. * @param pivot2 defines the pivot to use on the other mesh
  151432. * @param options defines additional options (can be plugin dependent)
  151433. * @returns the current mesh
  151434. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  151435. */
  151436. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  151437. /** @hidden */
  151438. _disposePhysicsObserver: Nullable<Observer<Node>>;
  151439. }
  151440. /**
  151441. * Defines the physics engine scene component responsible to manage a physics engine
  151442. */
  151443. export class PhysicsEngineSceneComponent implements ISceneComponent {
  151444. /**
  151445. * The component name helpful to identify the component in the list of scene components.
  151446. */
  151447. readonly name: string;
  151448. /**
  151449. * The scene the component belongs to.
  151450. */
  151451. scene: Scene;
  151452. /**
  151453. * Creates a new instance of the component for the given scene
  151454. * @param scene Defines the scene to register the component in
  151455. */
  151456. constructor(scene: Scene);
  151457. /**
  151458. * Registers the component in a given scene
  151459. */
  151460. register(): void;
  151461. /**
  151462. * Rebuilds the elements related to this component in case of
  151463. * context lost for instance.
  151464. */
  151465. rebuild(): void;
  151466. /**
  151467. * Disposes the component and the associated ressources
  151468. */
  151469. dispose(): void;
  151470. }
  151471. }
  151472. declare module BABYLON {
  151473. /**
  151474. * A helper for physics simulations
  151475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151476. */
  151477. export class PhysicsHelper {
  151478. private _scene;
  151479. private _physicsEngine;
  151480. /**
  151481. * Initializes the Physics helper
  151482. * @param scene Babylon.js scene
  151483. */
  151484. constructor(scene: Scene);
  151485. /**
  151486. * Applies a radial explosion impulse
  151487. * @param origin the origin of the explosion
  151488. * @param radiusOrEventOptions the radius or the options of radial explosion
  151489. * @param strength the explosion strength
  151490. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151491. * @returns A physics radial explosion event, or null
  151492. */
  151493. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  151494. /**
  151495. * Applies a radial explosion force
  151496. * @param origin the origin of the explosion
  151497. * @param radiusOrEventOptions the radius or the options of radial explosion
  151498. * @param strength the explosion strength
  151499. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151500. * @returns A physics radial explosion event, or null
  151501. */
  151502. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  151503. /**
  151504. * Creates a gravitational field
  151505. * @param origin the origin of the explosion
  151506. * @param radiusOrEventOptions the radius or the options of radial explosion
  151507. * @param strength the explosion strength
  151508. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151509. * @returns A physics gravitational field event, or null
  151510. */
  151511. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  151512. /**
  151513. * Creates a physics updraft event
  151514. * @param origin the origin of the updraft
  151515. * @param radiusOrEventOptions the radius or the options of the updraft
  151516. * @param strength the strength of the updraft
  151517. * @param height the height of the updraft
  151518. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  151519. * @returns A physics updraft event, or null
  151520. */
  151521. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  151522. /**
  151523. * Creates a physics vortex event
  151524. * @param origin the of the vortex
  151525. * @param radiusOrEventOptions the radius or the options of the vortex
  151526. * @param strength the strength of the vortex
  151527. * @param height the height of the vortex
  151528. * @returns a Physics vortex event, or null
  151529. * A physics vortex event or null
  151530. */
  151531. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  151532. }
  151533. /**
  151534. * Represents a physics radial explosion event
  151535. */
  151536. class PhysicsRadialExplosionEvent {
  151537. private _scene;
  151538. private _options;
  151539. private _sphere;
  151540. private _dataFetched;
  151541. /**
  151542. * Initializes a radial explosioin event
  151543. * @param _scene BabylonJS scene
  151544. * @param _options The options for the vortex event
  151545. */
  151546. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  151547. /**
  151548. * Returns the data related to the radial explosion event (sphere).
  151549. * @returns The radial explosion event data
  151550. */
  151551. getData(): PhysicsRadialExplosionEventData;
  151552. /**
  151553. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  151554. * @param impostor A physics imposter
  151555. * @param origin the origin of the explosion
  151556. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  151557. */
  151558. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  151559. /**
  151560. * Triggers affecterd impostors callbacks
  151561. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  151562. */
  151563. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  151564. /**
  151565. * Disposes the sphere.
  151566. * @param force Specifies if the sphere should be disposed by force
  151567. */
  151568. dispose(force?: boolean): void;
  151569. /*** Helpers ***/
  151570. private _prepareSphere;
  151571. private _intersectsWithSphere;
  151572. }
  151573. /**
  151574. * Represents a gravitational field event
  151575. */
  151576. class PhysicsGravitationalFieldEvent {
  151577. private _physicsHelper;
  151578. private _scene;
  151579. private _origin;
  151580. private _options;
  151581. private _tickCallback;
  151582. private _sphere;
  151583. private _dataFetched;
  151584. /**
  151585. * Initializes the physics gravitational field event
  151586. * @param _physicsHelper A physics helper
  151587. * @param _scene BabylonJS scene
  151588. * @param _origin The origin position of the gravitational field event
  151589. * @param _options The options for the vortex event
  151590. */
  151591. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  151592. /**
  151593. * Returns the data related to the gravitational field event (sphere).
  151594. * @returns A gravitational field event
  151595. */
  151596. getData(): PhysicsGravitationalFieldEventData;
  151597. /**
  151598. * Enables the gravitational field.
  151599. */
  151600. enable(): void;
  151601. /**
  151602. * Disables the gravitational field.
  151603. */
  151604. disable(): void;
  151605. /**
  151606. * Disposes the sphere.
  151607. * @param force The force to dispose from the gravitational field event
  151608. */
  151609. dispose(force?: boolean): void;
  151610. private _tick;
  151611. }
  151612. /**
  151613. * Represents a physics updraft event
  151614. */
  151615. class PhysicsUpdraftEvent {
  151616. private _scene;
  151617. private _origin;
  151618. private _options;
  151619. private _physicsEngine;
  151620. private _originTop;
  151621. private _originDirection;
  151622. private _tickCallback;
  151623. private _cylinder;
  151624. private _cylinderPosition;
  151625. private _dataFetched;
  151626. /**
  151627. * Initializes the physics updraft event
  151628. * @param _scene BabylonJS scene
  151629. * @param _origin The origin position of the updraft
  151630. * @param _options The options for the updraft event
  151631. */
  151632. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  151633. /**
  151634. * Returns the data related to the updraft event (cylinder).
  151635. * @returns A physics updraft event
  151636. */
  151637. getData(): PhysicsUpdraftEventData;
  151638. /**
  151639. * Enables the updraft.
  151640. */
  151641. enable(): void;
  151642. /**
  151643. * Disables the updraft.
  151644. */
  151645. disable(): void;
  151646. /**
  151647. * Disposes the cylinder.
  151648. * @param force Specifies if the updraft should be disposed by force
  151649. */
  151650. dispose(force?: boolean): void;
  151651. private getImpostorHitData;
  151652. private _tick;
  151653. /*** Helpers ***/
  151654. private _prepareCylinder;
  151655. private _intersectsWithCylinder;
  151656. }
  151657. /**
  151658. * Represents a physics vortex event
  151659. */
  151660. class PhysicsVortexEvent {
  151661. private _scene;
  151662. private _origin;
  151663. private _options;
  151664. private _physicsEngine;
  151665. private _originTop;
  151666. private _tickCallback;
  151667. private _cylinder;
  151668. private _cylinderPosition;
  151669. private _dataFetched;
  151670. /**
  151671. * Initializes the physics vortex event
  151672. * @param _scene The BabylonJS scene
  151673. * @param _origin The origin position of the vortex
  151674. * @param _options The options for the vortex event
  151675. */
  151676. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  151677. /**
  151678. * Returns the data related to the vortex event (cylinder).
  151679. * @returns The physics vortex event data
  151680. */
  151681. getData(): PhysicsVortexEventData;
  151682. /**
  151683. * Enables the vortex.
  151684. */
  151685. enable(): void;
  151686. /**
  151687. * Disables the cortex.
  151688. */
  151689. disable(): void;
  151690. /**
  151691. * Disposes the sphere.
  151692. * @param force
  151693. */
  151694. dispose(force?: boolean): void;
  151695. private getImpostorHitData;
  151696. private _tick;
  151697. /*** Helpers ***/
  151698. private _prepareCylinder;
  151699. private _intersectsWithCylinder;
  151700. }
  151701. /**
  151702. * Options fot the radial explosion event
  151703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151704. */
  151705. export class PhysicsRadialExplosionEventOptions {
  151706. /**
  151707. * The radius of the sphere for the radial explosion.
  151708. */
  151709. radius: number;
  151710. /**
  151711. * The strenth of the explosion.
  151712. */
  151713. strength: number;
  151714. /**
  151715. * The strenght of the force in correspondence to the distance of the affected object
  151716. */
  151717. falloff: PhysicsRadialImpulseFalloff;
  151718. /**
  151719. * Sphere options for the radial explosion.
  151720. */
  151721. sphere: {
  151722. segments: number;
  151723. diameter: number;
  151724. };
  151725. /**
  151726. * Sphere options for the radial explosion.
  151727. */
  151728. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  151729. }
  151730. /**
  151731. * Options fot the updraft event
  151732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151733. */
  151734. export class PhysicsUpdraftEventOptions {
  151735. /**
  151736. * The radius of the cylinder for the vortex
  151737. */
  151738. radius: number;
  151739. /**
  151740. * The strenth of the updraft.
  151741. */
  151742. strength: number;
  151743. /**
  151744. * The height of the cylinder for the updraft.
  151745. */
  151746. height: number;
  151747. /**
  151748. * The mode for the the updraft.
  151749. */
  151750. updraftMode: PhysicsUpdraftMode;
  151751. }
  151752. /**
  151753. * Options fot the vortex event
  151754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151755. */
  151756. export class PhysicsVortexEventOptions {
  151757. /**
  151758. * The radius of the cylinder for the vortex
  151759. */
  151760. radius: number;
  151761. /**
  151762. * The strenth of the vortex.
  151763. */
  151764. strength: number;
  151765. /**
  151766. * The height of the cylinder for the vortex.
  151767. */
  151768. height: number;
  151769. /**
  151770. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  151771. */
  151772. centripetalForceThreshold: number;
  151773. /**
  151774. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  151775. */
  151776. centripetalForceMultiplier: number;
  151777. /**
  151778. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  151779. */
  151780. centrifugalForceMultiplier: number;
  151781. /**
  151782. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  151783. */
  151784. updraftForceMultiplier: number;
  151785. }
  151786. /**
  151787. * The strenght of the force in correspondence to the distance of the affected object
  151788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151789. */
  151790. export enum PhysicsRadialImpulseFalloff {
  151791. /** Defines that impulse is constant in strength across it's whole radius */
  151792. Constant = 0,
  151793. /** Defines that impulse gets weaker if it's further from the origin */
  151794. Linear = 1
  151795. }
  151796. /**
  151797. * The strength of the force in correspondence to the distance of the affected object
  151798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151799. */
  151800. export enum PhysicsUpdraftMode {
  151801. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  151802. Center = 0,
  151803. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  151804. Perpendicular = 1
  151805. }
  151806. /**
  151807. * Interface for a physics hit data
  151808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151809. */
  151810. export interface PhysicsHitData {
  151811. /**
  151812. * The force applied at the contact point
  151813. */
  151814. force: Vector3;
  151815. /**
  151816. * The contact point
  151817. */
  151818. contactPoint: Vector3;
  151819. /**
  151820. * The distance from the origin to the contact point
  151821. */
  151822. distanceFromOrigin: number;
  151823. }
  151824. /**
  151825. * Interface for radial explosion event data
  151826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151827. */
  151828. export interface PhysicsRadialExplosionEventData {
  151829. /**
  151830. * A sphere used for the radial explosion event
  151831. */
  151832. sphere: Mesh;
  151833. }
  151834. /**
  151835. * Interface for gravitational field event data
  151836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151837. */
  151838. export interface PhysicsGravitationalFieldEventData {
  151839. /**
  151840. * A sphere mesh used for the gravitational field event
  151841. */
  151842. sphere: Mesh;
  151843. }
  151844. /**
  151845. * Interface for updraft event data
  151846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151847. */
  151848. export interface PhysicsUpdraftEventData {
  151849. /**
  151850. * A cylinder used for the updraft event
  151851. */
  151852. cylinder: Mesh;
  151853. }
  151854. /**
  151855. * Interface for vortex event data
  151856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151857. */
  151858. export interface PhysicsVortexEventData {
  151859. /**
  151860. * A cylinder used for the vortex event
  151861. */
  151862. cylinder: Mesh;
  151863. }
  151864. /**
  151865. * Interface for an affected physics impostor
  151866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151867. */
  151868. export interface PhysicsAffectedImpostorWithData {
  151869. /**
  151870. * The impostor affected by the effect
  151871. */
  151872. impostor: PhysicsImpostor;
  151873. /**
  151874. * The data about the hit/horce from the explosion
  151875. */
  151876. hitData: PhysicsHitData;
  151877. }
  151878. }
  151879. declare module BABYLON {
  151880. /** @hidden */
  151881. export var blackAndWhitePixelShader: {
  151882. name: string;
  151883. shader: string;
  151884. };
  151885. }
  151886. declare module BABYLON {
  151887. /**
  151888. * Post process used to render in black and white
  151889. */
  151890. export class BlackAndWhitePostProcess extends PostProcess {
  151891. /**
  151892. * Linear about to convert he result to black and white (default: 1)
  151893. */
  151894. degree: number;
  151895. /**
  151896. * Gets a string identifying the name of the class
  151897. * @returns "BlackAndWhitePostProcess" string
  151898. */
  151899. getClassName(): string;
  151900. /**
  151901. * Creates a black and white post process
  151902. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  151903. * @param name The name of the effect.
  151904. * @param options The required width/height ratio to downsize to before computing the render pass.
  151905. * @param camera The camera to apply the render pass to.
  151906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151907. * @param engine The engine which the post process will be applied. (default: current engine)
  151908. * @param reusable If the post process can be reused on the same frame. (default: false)
  151909. */
  151910. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151911. /** @hidden */
  151912. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  151913. }
  151914. }
  151915. declare module BABYLON {
  151916. /**
  151917. * This represents a set of one or more post processes in Babylon.
  151918. * A post process can be used to apply a shader to a texture after it is rendered.
  151919. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151920. */
  151921. export class PostProcessRenderEffect {
  151922. private _postProcesses;
  151923. private _getPostProcesses;
  151924. private _singleInstance;
  151925. private _cameras;
  151926. private _indicesForCamera;
  151927. /**
  151928. * Name of the effect
  151929. * @hidden
  151930. */
  151931. _name: string;
  151932. /**
  151933. * Instantiates a post process render effect.
  151934. * A post process can be used to apply a shader to a texture after it is rendered.
  151935. * @param engine The engine the effect is tied to
  151936. * @param name The name of the effect
  151937. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  151938. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  151939. */
  151940. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  151941. /**
  151942. * Checks if all the post processes in the effect are supported.
  151943. */
  151944. get isSupported(): boolean;
  151945. /**
  151946. * Updates the current state of the effect
  151947. * @hidden
  151948. */
  151949. _update(): void;
  151950. /**
  151951. * Attaches the effect on cameras
  151952. * @param cameras The camera to attach to.
  151953. * @hidden
  151954. */
  151955. _attachCameras(cameras: Camera): void;
  151956. /**
  151957. * Attaches the effect on cameras
  151958. * @param cameras The camera to attach to.
  151959. * @hidden
  151960. */
  151961. _attachCameras(cameras: Camera[]): void;
  151962. /**
  151963. * Detaches the effect on cameras
  151964. * @param cameras The camera to detatch from.
  151965. * @hidden
  151966. */
  151967. _detachCameras(cameras: Camera): void;
  151968. /**
  151969. * Detatches the effect on cameras
  151970. * @param cameras The camera to detatch from.
  151971. * @hidden
  151972. */
  151973. _detachCameras(cameras: Camera[]): void;
  151974. /**
  151975. * Enables the effect on given cameras
  151976. * @param cameras The camera to enable.
  151977. * @hidden
  151978. */
  151979. _enable(cameras: Camera): void;
  151980. /**
  151981. * Enables the effect on given cameras
  151982. * @param cameras The camera to enable.
  151983. * @hidden
  151984. */
  151985. _enable(cameras: Nullable<Camera[]>): void;
  151986. /**
  151987. * Disables the effect on the given cameras
  151988. * @param cameras The camera to disable.
  151989. * @hidden
  151990. */
  151991. _disable(cameras: Camera): void;
  151992. /**
  151993. * Disables the effect on the given cameras
  151994. * @param cameras The camera to disable.
  151995. * @hidden
  151996. */
  151997. _disable(cameras: Nullable<Camera[]>): void;
  151998. /**
  151999. * Gets a list of the post processes contained in the effect.
  152000. * @param camera The camera to get the post processes on.
  152001. * @returns The list of the post processes in the effect.
  152002. */
  152003. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  152004. }
  152005. }
  152006. declare module BABYLON {
  152007. /** @hidden */
  152008. export var extractHighlightsPixelShader: {
  152009. name: string;
  152010. shader: string;
  152011. };
  152012. }
  152013. declare module BABYLON {
  152014. /**
  152015. * 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.
  152016. */
  152017. export class ExtractHighlightsPostProcess extends PostProcess {
  152018. /**
  152019. * The luminance threshold, pixels below this value will be set to black.
  152020. */
  152021. threshold: number;
  152022. /** @hidden */
  152023. _exposure: number;
  152024. /**
  152025. * Post process which has the input texture to be used when performing highlight extraction
  152026. * @hidden
  152027. */
  152028. _inputPostProcess: Nullable<PostProcess>;
  152029. /**
  152030. * Gets a string identifying the name of the class
  152031. * @returns "ExtractHighlightsPostProcess" string
  152032. */
  152033. getClassName(): string;
  152034. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152035. }
  152036. }
  152037. declare module BABYLON {
  152038. /** @hidden */
  152039. export var bloomMergePixelShader: {
  152040. name: string;
  152041. shader: string;
  152042. };
  152043. }
  152044. declare module BABYLON {
  152045. /**
  152046. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  152047. */
  152048. export class BloomMergePostProcess extends PostProcess {
  152049. /** Weight of the bloom to be added to the original input. */
  152050. weight: number;
  152051. /**
  152052. * Gets a string identifying the name of the class
  152053. * @returns "BloomMergePostProcess" string
  152054. */
  152055. getClassName(): string;
  152056. /**
  152057. * Creates a new instance of @see BloomMergePostProcess
  152058. * @param name The name of the effect.
  152059. * @param originalFromInput Post process which's input will be used for the merge.
  152060. * @param blurred Blurred highlights post process which's output will be used.
  152061. * @param weight Weight of the bloom to be added to the original input.
  152062. * @param options The required width/height ratio to downsize to before computing the render pass.
  152063. * @param camera The camera to apply the render pass to.
  152064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152065. * @param engine The engine which the post process will be applied. (default: current engine)
  152066. * @param reusable If the post process can be reused on the same frame. (default: false)
  152067. * @param textureType Type of textures used when performing the post process. (default: 0)
  152068. * @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)
  152069. */
  152070. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  152071. /** Weight of the bloom to be added to the original input. */
  152072. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152073. }
  152074. }
  152075. declare module BABYLON {
  152076. /**
  152077. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  152078. */
  152079. export class BloomEffect extends PostProcessRenderEffect {
  152080. private bloomScale;
  152081. /**
  152082. * @hidden Internal
  152083. */
  152084. _effects: Array<PostProcess>;
  152085. /**
  152086. * @hidden Internal
  152087. */
  152088. _downscale: ExtractHighlightsPostProcess;
  152089. private _blurX;
  152090. private _blurY;
  152091. private _merge;
  152092. /**
  152093. * The luminance threshold to find bright areas of the image to bloom.
  152094. */
  152095. get threshold(): number;
  152096. set threshold(value: number);
  152097. /**
  152098. * The strength of the bloom.
  152099. */
  152100. get weight(): number;
  152101. set weight(value: number);
  152102. /**
  152103. * Specifies the size of the bloom blur kernel, relative to the final output size
  152104. */
  152105. get kernel(): number;
  152106. set kernel(value: number);
  152107. /**
  152108. * Creates a new instance of @see BloomEffect
  152109. * @param scene The scene the effect belongs to.
  152110. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  152111. * @param bloomKernel The size of the kernel to be used when applying the blur.
  152112. * @param bloomWeight The the strength of bloom.
  152113. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  152114. * @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)
  152115. */
  152116. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  152117. /**
  152118. * Disposes each of the internal effects for a given camera.
  152119. * @param camera The camera to dispose the effect on.
  152120. */
  152121. disposeEffects(camera: Camera): void;
  152122. /**
  152123. * @hidden Internal
  152124. */
  152125. _updateEffects(): void;
  152126. /**
  152127. * Internal
  152128. * @returns if all the contained post processes are ready.
  152129. * @hidden
  152130. */
  152131. _isReady(): boolean;
  152132. }
  152133. }
  152134. declare module BABYLON {
  152135. /** @hidden */
  152136. export var chromaticAberrationPixelShader: {
  152137. name: string;
  152138. shader: string;
  152139. };
  152140. }
  152141. declare module BABYLON {
  152142. /**
  152143. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  152144. */
  152145. export class ChromaticAberrationPostProcess extends PostProcess {
  152146. /**
  152147. * The amount of seperation of rgb channels (default: 30)
  152148. */
  152149. aberrationAmount: number;
  152150. /**
  152151. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  152152. */
  152153. radialIntensity: number;
  152154. /**
  152155. * 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))
  152156. */
  152157. direction: Vector2;
  152158. /**
  152159. * 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))
  152160. */
  152161. centerPosition: Vector2;
  152162. /** The width of the screen to apply the effect on */
  152163. screenWidth: number;
  152164. /** The height of the screen to apply the effect on */
  152165. screenHeight: number;
  152166. /**
  152167. * Gets a string identifying the name of the class
  152168. * @returns "ChromaticAberrationPostProcess" string
  152169. */
  152170. getClassName(): string;
  152171. /**
  152172. * Creates a new instance ChromaticAberrationPostProcess
  152173. * @param name The name of the effect.
  152174. * @param screenWidth The width of the screen to apply the effect on.
  152175. * @param screenHeight The height of the screen to apply the effect on.
  152176. * @param options The required width/height ratio to downsize to before computing the render pass.
  152177. * @param camera The camera to apply the render pass to.
  152178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152179. * @param engine The engine which the post process will be applied. (default: current engine)
  152180. * @param reusable If the post process can be reused on the same frame. (default: false)
  152181. * @param textureType Type of textures used when performing the post process. (default: 0)
  152182. * @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)
  152183. */
  152184. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152185. /** @hidden */
  152186. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  152187. }
  152188. }
  152189. declare module BABYLON {
  152190. /** @hidden */
  152191. export var circleOfConfusionPixelShader: {
  152192. name: string;
  152193. shader: string;
  152194. };
  152195. }
  152196. declare module BABYLON {
  152197. /**
  152198. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  152199. */
  152200. export class CircleOfConfusionPostProcess extends PostProcess {
  152201. /**
  152202. * 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.
  152203. */
  152204. lensSize: number;
  152205. /**
  152206. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  152207. */
  152208. fStop: number;
  152209. /**
  152210. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  152211. */
  152212. focusDistance: number;
  152213. /**
  152214. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  152215. */
  152216. focalLength: number;
  152217. /**
  152218. * Gets a string identifying the name of the class
  152219. * @returns "CircleOfConfusionPostProcess" string
  152220. */
  152221. getClassName(): string;
  152222. private _depthTexture;
  152223. /**
  152224. * Creates a new instance CircleOfConfusionPostProcess
  152225. * @param name The name of the effect.
  152226. * @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.
  152227. * @param options The required width/height ratio to downsize to before computing the render pass.
  152228. * @param camera The camera to apply the render pass to.
  152229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152230. * @param engine The engine which the post process will be applied. (default: current engine)
  152231. * @param reusable If the post process can be reused on the same frame. (default: false)
  152232. * @param textureType Type of textures used when performing the post process. (default: 0)
  152233. * @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)
  152234. */
  152235. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152236. /**
  152237. * 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.
  152238. */
  152239. set depthTexture(value: RenderTargetTexture);
  152240. }
  152241. }
  152242. declare module BABYLON {
  152243. /** @hidden */
  152244. export var colorCorrectionPixelShader: {
  152245. name: string;
  152246. shader: string;
  152247. };
  152248. }
  152249. declare module BABYLON {
  152250. /**
  152251. *
  152252. * This post-process allows the modification of rendered colors by using
  152253. * a 'look-up table' (LUT). This effect is also called Color Grading.
  152254. *
  152255. * The object needs to be provided an url to a texture containing the color
  152256. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  152257. * Use an image editing software to tweak the LUT to match your needs.
  152258. *
  152259. * For an example of a color LUT, see here:
  152260. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  152261. * For explanations on color grading, see here:
  152262. * @see http://udn.epicgames.com/Three/ColorGrading.html
  152263. *
  152264. */
  152265. export class ColorCorrectionPostProcess extends PostProcess {
  152266. private _colorTableTexture;
  152267. /**
  152268. * Gets the color table url used to create the LUT texture
  152269. */
  152270. colorTableUrl: string;
  152271. /**
  152272. * Gets a string identifying the name of the class
  152273. * @returns "ColorCorrectionPostProcess" string
  152274. */
  152275. getClassName(): string;
  152276. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152277. /** @hidden */
  152278. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  152279. }
  152280. }
  152281. declare module BABYLON {
  152282. /** @hidden */
  152283. export var convolutionPixelShader: {
  152284. name: string;
  152285. shader: string;
  152286. };
  152287. }
  152288. declare module BABYLON {
  152289. /**
  152290. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  152291. * input texture to perform effects such as edge detection or sharpening
  152292. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  152293. */
  152294. export class ConvolutionPostProcess extends PostProcess {
  152295. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  152296. kernel: number[];
  152297. /**
  152298. * Gets a string identifying the name of the class
  152299. * @returns "ConvolutionPostProcess" string
  152300. */
  152301. getClassName(): string;
  152302. /**
  152303. * Creates a new instance ConvolutionPostProcess
  152304. * @param name The name of the effect.
  152305. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  152306. * @param options The required width/height ratio to downsize to before computing the render pass.
  152307. * @param camera The camera to apply the render pass to.
  152308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152309. * @param engine The engine which the post process will be applied. (default: current engine)
  152310. * @param reusable If the post process can be reused on the same frame. (default: false)
  152311. * @param textureType Type of textures used when performing the post process. (default: 0)
  152312. */
  152313. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152314. /** @hidden */
  152315. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  152316. /**
  152317. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152318. */
  152319. static EdgeDetect0Kernel: number[];
  152320. /**
  152321. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152322. */
  152323. static EdgeDetect1Kernel: number[];
  152324. /**
  152325. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152326. */
  152327. static EdgeDetect2Kernel: number[];
  152328. /**
  152329. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152330. */
  152331. static SharpenKernel: number[];
  152332. /**
  152333. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152334. */
  152335. static EmbossKernel: number[];
  152336. /**
  152337. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152338. */
  152339. static GaussianKernel: number[];
  152340. }
  152341. }
  152342. declare module BABYLON {
  152343. /**
  152344. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  152345. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  152346. * based on samples that have a large difference in distance than the center pixel.
  152347. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  152348. */
  152349. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  152350. /**
  152351. * The direction the blur should be applied
  152352. */
  152353. direction: Vector2;
  152354. /**
  152355. * Gets a string identifying the name of the class
  152356. * @returns "DepthOfFieldBlurPostProcess" string
  152357. */
  152358. getClassName(): string;
  152359. /**
  152360. * Creates a new instance CircleOfConfusionPostProcess
  152361. * @param name The name of the effect.
  152362. * @param scene The scene the effect belongs to.
  152363. * @param direction The direction the blur should be applied.
  152364. * @param kernel The size of the kernel used to blur.
  152365. * @param options The required width/height ratio to downsize to before computing the render pass.
  152366. * @param camera The camera to apply the render pass to.
  152367. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  152368. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  152369. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152370. * @param engine The engine which the post process will be applied. (default: current engine)
  152371. * @param reusable If the post process can be reused on the same frame. (default: false)
  152372. * @param textureType Type of textures used when performing the post process. (default: 0)
  152373. * @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)
  152374. */
  152375. 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);
  152376. }
  152377. }
  152378. declare module BABYLON {
  152379. /** @hidden */
  152380. export var depthOfFieldMergePixelShader: {
  152381. name: string;
  152382. shader: string;
  152383. };
  152384. }
  152385. declare module BABYLON {
  152386. /**
  152387. * Options to be set when merging outputs from the default pipeline.
  152388. */
  152389. export class DepthOfFieldMergePostProcessOptions {
  152390. /**
  152391. * The original image to merge on top of
  152392. */
  152393. originalFromInput: PostProcess;
  152394. /**
  152395. * Parameters to perform the merge of the depth of field effect
  152396. */
  152397. depthOfField?: {
  152398. circleOfConfusion: PostProcess;
  152399. blurSteps: Array<PostProcess>;
  152400. };
  152401. /**
  152402. * Parameters to perform the merge of bloom effect
  152403. */
  152404. bloom?: {
  152405. blurred: PostProcess;
  152406. weight: number;
  152407. };
  152408. }
  152409. /**
  152410. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  152411. */
  152412. export class DepthOfFieldMergePostProcess extends PostProcess {
  152413. private blurSteps;
  152414. /**
  152415. * Gets a string identifying the name of the class
  152416. * @returns "DepthOfFieldMergePostProcess" string
  152417. */
  152418. getClassName(): string;
  152419. /**
  152420. * Creates a new instance of DepthOfFieldMergePostProcess
  152421. * @param name The name of the effect.
  152422. * @param originalFromInput Post process which's input will be used for the merge.
  152423. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  152424. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  152425. * @param options The required width/height ratio to downsize to before computing the render pass.
  152426. * @param camera The camera to apply the render pass to.
  152427. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152428. * @param engine The engine which the post process will be applied. (default: current engine)
  152429. * @param reusable If the post process can be reused on the same frame. (default: false)
  152430. * @param textureType Type of textures used when performing the post process. (default: 0)
  152431. * @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)
  152432. */
  152433. 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);
  152434. /**
  152435. * Updates the effect with the current post process compile time values and recompiles the shader.
  152436. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  152437. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  152438. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  152439. * @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
  152440. * @param onCompiled Called when the shader has been compiled.
  152441. * @param onError Called if there is an error when compiling a shader.
  152442. */
  152443. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  152444. }
  152445. }
  152446. declare module BABYLON {
  152447. /**
  152448. * Specifies the level of max blur that should be applied when using the depth of field effect
  152449. */
  152450. export enum DepthOfFieldEffectBlurLevel {
  152451. /**
  152452. * Subtle blur
  152453. */
  152454. Low = 0,
  152455. /**
  152456. * Medium blur
  152457. */
  152458. Medium = 1,
  152459. /**
  152460. * Large blur
  152461. */
  152462. High = 2
  152463. }
  152464. /**
  152465. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  152466. */
  152467. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  152468. private _circleOfConfusion;
  152469. /**
  152470. * @hidden Internal, blurs from high to low
  152471. */
  152472. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  152473. private _depthOfFieldBlurY;
  152474. private _dofMerge;
  152475. /**
  152476. * @hidden Internal post processes in depth of field effect
  152477. */
  152478. _effects: Array<PostProcess>;
  152479. /**
  152480. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  152481. */
  152482. set focalLength(value: number);
  152483. get focalLength(): number;
  152484. /**
  152485. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  152486. */
  152487. set fStop(value: number);
  152488. get fStop(): number;
  152489. /**
  152490. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  152491. */
  152492. set focusDistance(value: number);
  152493. get focusDistance(): number;
  152494. /**
  152495. * 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.
  152496. */
  152497. set lensSize(value: number);
  152498. get lensSize(): number;
  152499. /**
  152500. * Creates a new instance DepthOfFieldEffect
  152501. * @param scene The scene the effect belongs to.
  152502. * @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.
  152503. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  152504. * @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)
  152505. */
  152506. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  152507. /**
  152508. * Get the current class name of the current effet
  152509. * @returns "DepthOfFieldEffect"
  152510. */
  152511. getClassName(): string;
  152512. /**
  152513. * 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.
  152514. */
  152515. set depthTexture(value: RenderTargetTexture);
  152516. /**
  152517. * Disposes each of the internal effects for a given camera.
  152518. * @param camera The camera to dispose the effect on.
  152519. */
  152520. disposeEffects(camera: Camera): void;
  152521. /**
  152522. * @hidden Internal
  152523. */
  152524. _updateEffects(): void;
  152525. /**
  152526. * Internal
  152527. * @returns if all the contained post processes are ready.
  152528. * @hidden
  152529. */
  152530. _isReady(): boolean;
  152531. }
  152532. }
  152533. declare module BABYLON {
  152534. /** @hidden */
  152535. export var displayPassPixelShader: {
  152536. name: string;
  152537. shader: string;
  152538. };
  152539. }
  152540. declare module BABYLON {
  152541. /**
  152542. * DisplayPassPostProcess which produces an output the same as it's input
  152543. */
  152544. export class DisplayPassPostProcess extends PostProcess {
  152545. /**
  152546. * Gets a string identifying the name of the class
  152547. * @returns "DisplayPassPostProcess" string
  152548. */
  152549. getClassName(): string;
  152550. /**
  152551. * Creates the DisplayPassPostProcess
  152552. * @param name The name of the effect.
  152553. * @param options The required width/height ratio to downsize to before computing the render pass.
  152554. * @param camera The camera to apply the render pass to.
  152555. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152556. * @param engine The engine which the post process will be applied. (default: current engine)
  152557. * @param reusable If the post process can be reused on the same frame. (default: false)
  152558. */
  152559. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152560. /** @hidden */
  152561. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  152562. }
  152563. }
  152564. declare module BABYLON {
  152565. /** @hidden */
  152566. export var filterPixelShader: {
  152567. name: string;
  152568. shader: string;
  152569. };
  152570. }
  152571. declare module BABYLON {
  152572. /**
  152573. * Applies a kernel filter to the image
  152574. */
  152575. export class FilterPostProcess extends PostProcess {
  152576. /** The matrix to be applied to the image */
  152577. kernelMatrix: Matrix;
  152578. /**
  152579. * Gets a string identifying the name of the class
  152580. * @returns "FilterPostProcess" string
  152581. */
  152582. getClassName(): string;
  152583. /**
  152584. *
  152585. * @param name The name of the effect.
  152586. * @param kernelMatrix The matrix to be applied to the image
  152587. * @param options The required width/height ratio to downsize to before computing the render pass.
  152588. * @param camera The camera to apply the render pass to.
  152589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152590. * @param engine The engine which the post process will be applied. (default: current engine)
  152591. * @param reusable If the post process can be reused on the same frame. (default: false)
  152592. */
  152593. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152594. /** @hidden */
  152595. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  152596. }
  152597. }
  152598. declare module BABYLON {
  152599. /** @hidden */
  152600. export var fxaaPixelShader: {
  152601. name: string;
  152602. shader: string;
  152603. };
  152604. }
  152605. declare module BABYLON {
  152606. /** @hidden */
  152607. export var fxaaVertexShader: {
  152608. name: string;
  152609. shader: string;
  152610. };
  152611. }
  152612. declare module BABYLON {
  152613. /**
  152614. * Fxaa post process
  152615. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  152616. */
  152617. export class FxaaPostProcess extends PostProcess {
  152618. /**
  152619. * Gets a string identifying the name of the class
  152620. * @returns "FxaaPostProcess" string
  152621. */
  152622. getClassName(): string;
  152623. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152624. private _getDefines;
  152625. /** @hidden */
  152626. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  152627. }
  152628. }
  152629. declare module BABYLON {
  152630. /** @hidden */
  152631. export var grainPixelShader: {
  152632. name: string;
  152633. shader: string;
  152634. };
  152635. }
  152636. declare module BABYLON {
  152637. /**
  152638. * The GrainPostProcess adds noise to the image at mid luminance levels
  152639. */
  152640. export class GrainPostProcess extends PostProcess {
  152641. /**
  152642. * The intensity of the grain added (default: 30)
  152643. */
  152644. intensity: number;
  152645. /**
  152646. * If the grain should be randomized on every frame
  152647. */
  152648. animated: boolean;
  152649. /**
  152650. * Gets a string identifying the name of the class
  152651. * @returns "GrainPostProcess" string
  152652. */
  152653. getClassName(): string;
  152654. /**
  152655. * Creates a new instance of @see GrainPostProcess
  152656. * @param name The name of the effect.
  152657. * @param options The required width/height ratio to downsize to before computing the render pass.
  152658. * @param camera The camera to apply the render pass to.
  152659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152660. * @param engine The engine which the post process will be applied. (default: current engine)
  152661. * @param reusable If the post process can be reused on the same frame. (default: false)
  152662. * @param textureType Type of textures used when performing the post process. (default: 0)
  152663. * @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)
  152664. */
  152665. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152666. /** @hidden */
  152667. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  152668. }
  152669. }
  152670. declare module BABYLON {
  152671. /** @hidden */
  152672. export var highlightsPixelShader: {
  152673. name: string;
  152674. shader: string;
  152675. };
  152676. }
  152677. declare module BABYLON {
  152678. /**
  152679. * Extracts highlights from the image
  152680. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152681. */
  152682. export class HighlightsPostProcess extends PostProcess {
  152683. /**
  152684. * Gets a string identifying the name of the class
  152685. * @returns "HighlightsPostProcess" string
  152686. */
  152687. getClassName(): string;
  152688. /**
  152689. * Extracts highlights from the image
  152690. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152691. * @param name The name of the effect.
  152692. * @param options The required width/height ratio to downsize to before computing the render pass.
  152693. * @param camera The camera to apply the render pass to.
  152694. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152695. * @param engine The engine which the post process will be applied. (default: current engine)
  152696. * @param reusable If the post process can be reused on the same frame. (default: false)
  152697. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  152698. */
  152699. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152700. }
  152701. }
  152702. declare module BABYLON {
  152703. /**
  152704. * Contains all parameters needed for the prepass to perform
  152705. * motion blur
  152706. */
  152707. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  152708. /**
  152709. * Is motion blur enabled
  152710. */
  152711. enabled: boolean;
  152712. /**
  152713. * Name of the configuration
  152714. */
  152715. name: string;
  152716. /**
  152717. * Textures that should be present in the MRT for this effect to work
  152718. */
  152719. readonly texturesRequired: number[];
  152720. }
  152721. }
  152722. declare module BABYLON {
  152723. interface Scene {
  152724. /** @hidden (Backing field) */
  152725. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152726. /**
  152727. * Gets or Sets the current geometry buffer associated to the scene.
  152728. */
  152729. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152730. /**
  152731. * Enables a GeometryBufferRender and associates it with the scene
  152732. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  152733. * @returns the GeometryBufferRenderer
  152734. */
  152735. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  152736. /**
  152737. * Disables the GeometryBufferRender associated with the scene
  152738. */
  152739. disableGeometryBufferRenderer(): void;
  152740. }
  152741. /**
  152742. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152743. * in several rendering techniques.
  152744. */
  152745. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  152746. /**
  152747. * The component name helpful to identify the component in the list of scene components.
  152748. */
  152749. readonly name: string;
  152750. /**
  152751. * The scene the component belongs to.
  152752. */
  152753. scene: Scene;
  152754. /**
  152755. * Creates a new instance of the component for the given scene
  152756. * @param scene Defines the scene to register the component in
  152757. */
  152758. constructor(scene: Scene);
  152759. /**
  152760. * Registers the component in a given scene
  152761. */
  152762. register(): void;
  152763. /**
  152764. * Rebuilds the elements related to this component in case of
  152765. * context lost for instance.
  152766. */
  152767. rebuild(): void;
  152768. /**
  152769. * Disposes the component and the associated ressources
  152770. */
  152771. dispose(): void;
  152772. private _gatherRenderTargets;
  152773. }
  152774. }
  152775. declare module BABYLON {
  152776. /** @hidden */
  152777. export var motionBlurPixelShader: {
  152778. name: string;
  152779. shader: string;
  152780. };
  152781. }
  152782. declare module BABYLON {
  152783. /**
  152784. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  152785. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  152786. * As an example, all you have to do is to create the post-process:
  152787. * var mb = new BABYLON.MotionBlurPostProcess(
  152788. * 'mb', // The name of the effect.
  152789. * scene, // The scene containing the objects to blur according to their velocity.
  152790. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  152791. * camera // The camera to apply the render pass to.
  152792. * );
  152793. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  152794. */
  152795. export class MotionBlurPostProcess extends PostProcess {
  152796. /**
  152797. * Defines how much the image is blurred by the movement. Default value is equal to 1
  152798. */
  152799. motionStrength: number;
  152800. /**
  152801. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  152802. */
  152803. get motionBlurSamples(): number;
  152804. /**
  152805. * Sets the number of iterations to be used for motion blur quality
  152806. */
  152807. set motionBlurSamples(samples: number);
  152808. private _motionBlurSamples;
  152809. private _forceGeometryBuffer;
  152810. private _geometryBufferRenderer;
  152811. private _prePassRenderer;
  152812. /**
  152813. * Gets a string identifying the name of the class
  152814. * @returns "MotionBlurPostProcess" string
  152815. */
  152816. getClassName(): string;
  152817. /**
  152818. * Creates a new instance MotionBlurPostProcess
  152819. * @param name The name of the effect.
  152820. * @param scene The scene containing the objects to blur according to their velocity.
  152821. * @param options The required width/height ratio to downsize to before computing the render pass.
  152822. * @param camera The camera to apply the render pass to.
  152823. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152824. * @param engine The engine which the post process will be applied. (default: current engine)
  152825. * @param reusable If the post process can be reused on the same frame. (default: false)
  152826. * @param textureType Type of textures used when performing the post process. (default: 0)
  152827. * @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)
  152828. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152829. */
  152830. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152831. /**
  152832. * Excludes the given skinned mesh from computing bones velocities.
  152833. * 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.
  152834. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  152835. */
  152836. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  152837. /**
  152838. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  152839. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  152840. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  152841. */
  152842. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  152843. /**
  152844. * Disposes the post process.
  152845. * @param camera The camera to dispose the post process on.
  152846. */
  152847. dispose(camera?: Camera): void;
  152848. /** @hidden */
  152849. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  152850. }
  152851. }
  152852. declare module BABYLON {
  152853. /** @hidden */
  152854. export var refractionPixelShader: {
  152855. name: string;
  152856. shader: string;
  152857. };
  152858. }
  152859. declare module BABYLON {
  152860. /**
  152861. * Post process which applies a refractin texture
  152862. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  152863. */
  152864. export class RefractionPostProcess extends PostProcess {
  152865. private _refTexture;
  152866. private _ownRefractionTexture;
  152867. /** the base color of the refraction (used to taint the rendering) */
  152868. color: Color3;
  152869. /** simulated refraction depth */
  152870. depth: number;
  152871. /** the coefficient of the base color (0 to remove base color tainting) */
  152872. colorLevel: number;
  152873. /** Gets the url used to load the refraction texture */
  152874. refractionTextureUrl: string;
  152875. /**
  152876. * Gets or sets the refraction texture
  152877. * Please note that you are responsible for disposing the texture if you set it manually
  152878. */
  152879. get refractionTexture(): Texture;
  152880. set refractionTexture(value: Texture);
  152881. /**
  152882. * Gets a string identifying the name of the class
  152883. * @returns "RefractionPostProcess" string
  152884. */
  152885. getClassName(): string;
  152886. /**
  152887. * Initializes the RefractionPostProcess
  152888. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  152889. * @param name The name of the effect.
  152890. * @param refractionTextureUrl Url of the refraction texture to use
  152891. * @param color the base color of the refraction (used to taint the rendering)
  152892. * @param depth simulated refraction depth
  152893. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  152894. * @param camera The camera to apply the render pass to.
  152895. * @param options The required width/height ratio to downsize to before computing the render pass.
  152896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152897. * @param engine The engine which the post process will be applied. (default: current engine)
  152898. * @param reusable If the post process can be reused on the same frame. (default: false)
  152899. */
  152900. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152901. /**
  152902. * Disposes of the post process
  152903. * @param camera Camera to dispose post process on
  152904. */
  152905. dispose(camera: Camera): void;
  152906. /** @hidden */
  152907. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  152908. }
  152909. }
  152910. declare module BABYLON {
  152911. /** @hidden */
  152912. export var sharpenPixelShader: {
  152913. name: string;
  152914. shader: string;
  152915. };
  152916. }
  152917. declare module BABYLON {
  152918. /**
  152919. * The SharpenPostProcess applies a sharpen kernel to every pixel
  152920. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  152921. */
  152922. export class SharpenPostProcess extends PostProcess {
  152923. /**
  152924. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  152925. */
  152926. colorAmount: number;
  152927. /**
  152928. * How much sharpness should be applied (default: 0.3)
  152929. */
  152930. edgeAmount: number;
  152931. /**
  152932. * Gets a string identifying the name of the class
  152933. * @returns "SharpenPostProcess" string
  152934. */
  152935. getClassName(): string;
  152936. /**
  152937. * Creates a new instance ConvolutionPostProcess
  152938. * @param name The name of the effect.
  152939. * @param options The required width/height ratio to downsize to before computing the render pass.
  152940. * @param camera The camera to apply the render pass to.
  152941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152942. * @param engine The engine which the post process will be applied. (default: current engine)
  152943. * @param reusable If the post process can be reused on the same frame. (default: false)
  152944. * @param textureType Type of textures used when performing the post process. (default: 0)
  152945. * @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)
  152946. */
  152947. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152948. /** @hidden */
  152949. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  152950. }
  152951. }
  152952. declare module BABYLON {
  152953. /**
  152954. * PostProcessRenderPipeline
  152955. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152956. */
  152957. export class PostProcessRenderPipeline {
  152958. private engine;
  152959. private _renderEffects;
  152960. private _renderEffectsForIsolatedPass;
  152961. /**
  152962. * List of inspectable custom properties (used by the Inspector)
  152963. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  152964. */
  152965. inspectableCustomProperties: IInspectable[];
  152966. /**
  152967. * @hidden
  152968. */
  152969. protected _cameras: Camera[];
  152970. /** @hidden */
  152971. _name: string;
  152972. /**
  152973. * Gets pipeline name
  152974. */
  152975. get name(): string;
  152976. /** Gets the list of attached cameras */
  152977. get cameras(): Camera[];
  152978. /**
  152979. * Initializes a PostProcessRenderPipeline
  152980. * @param engine engine to add the pipeline to
  152981. * @param name name of the pipeline
  152982. */
  152983. constructor(engine: Engine, name: string);
  152984. /**
  152985. * Gets the class name
  152986. * @returns "PostProcessRenderPipeline"
  152987. */
  152988. getClassName(): string;
  152989. /**
  152990. * If all the render effects in the pipeline are supported
  152991. */
  152992. get isSupported(): boolean;
  152993. /**
  152994. * Adds an effect to the pipeline
  152995. * @param renderEffect the effect to add
  152996. */
  152997. addEffect(renderEffect: PostProcessRenderEffect): void;
  152998. /** @hidden */
  152999. _rebuild(): void;
  153000. /** @hidden */
  153001. _enableEffect(renderEffectName: string, cameras: Camera): void;
  153002. /** @hidden */
  153003. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  153004. /** @hidden */
  153005. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  153006. /** @hidden */
  153007. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  153008. /** @hidden */
  153009. _attachCameras(cameras: Camera, unique: boolean): void;
  153010. /** @hidden */
  153011. _attachCameras(cameras: Camera[], unique: boolean): void;
  153012. /** @hidden */
  153013. _detachCameras(cameras: Camera): void;
  153014. /** @hidden */
  153015. _detachCameras(cameras: Nullable<Camera[]>): void;
  153016. /** @hidden */
  153017. _update(): void;
  153018. /** @hidden */
  153019. _reset(): void;
  153020. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  153021. /**
  153022. * Sets the required values to the prepass renderer.
  153023. * @param prePassRenderer defines the prepass renderer to setup.
  153024. * @returns true if the pre pass is needed.
  153025. */
  153026. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  153027. /**
  153028. * Disposes of the pipeline
  153029. */
  153030. dispose(): void;
  153031. }
  153032. }
  153033. declare module BABYLON {
  153034. /**
  153035. * PostProcessRenderPipelineManager class
  153036. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153037. */
  153038. export class PostProcessRenderPipelineManager {
  153039. private _renderPipelines;
  153040. /**
  153041. * Initializes a PostProcessRenderPipelineManager
  153042. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153043. */
  153044. constructor();
  153045. /**
  153046. * Gets the list of supported render pipelines
  153047. */
  153048. get supportedPipelines(): PostProcessRenderPipeline[];
  153049. /**
  153050. * Adds a pipeline to the manager
  153051. * @param renderPipeline The pipeline to add
  153052. */
  153053. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  153054. /**
  153055. * Attaches a camera to the pipeline
  153056. * @param renderPipelineName The name of the pipeline to attach to
  153057. * @param cameras the camera to attach
  153058. * @param unique if the camera can be attached multiple times to the pipeline
  153059. */
  153060. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  153061. /**
  153062. * Detaches a camera from the pipeline
  153063. * @param renderPipelineName The name of the pipeline to detach from
  153064. * @param cameras the camera to detach
  153065. */
  153066. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  153067. /**
  153068. * Enables an effect by name on a pipeline
  153069. * @param renderPipelineName the name of the pipeline to enable the effect in
  153070. * @param renderEffectName the name of the effect to enable
  153071. * @param cameras the cameras that the effect should be enabled on
  153072. */
  153073. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  153074. /**
  153075. * Disables an effect by name on a pipeline
  153076. * @param renderPipelineName the name of the pipeline to disable the effect in
  153077. * @param renderEffectName the name of the effect to disable
  153078. * @param cameras the cameras that the effect should be disabled on
  153079. */
  153080. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  153081. /**
  153082. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  153083. */
  153084. update(): void;
  153085. /** @hidden */
  153086. _rebuild(): void;
  153087. /**
  153088. * Disposes of the manager and pipelines
  153089. */
  153090. dispose(): void;
  153091. }
  153092. }
  153093. declare module BABYLON {
  153094. interface Scene {
  153095. /** @hidden (Backing field) */
  153096. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  153097. /**
  153098. * Gets the postprocess render pipeline manager
  153099. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153100. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  153101. */
  153102. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  153103. }
  153104. /**
  153105. * Defines the Render Pipeline scene component responsible to rendering pipelines
  153106. */
  153107. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  153108. /**
  153109. * The component name helpfull to identify the component in the list of scene components.
  153110. */
  153111. readonly name: string;
  153112. /**
  153113. * The scene the component belongs to.
  153114. */
  153115. scene: Scene;
  153116. /**
  153117. * Creates a new instance of the component for the given scene
  153118. * @param scene Defines the scene to register the component in
  153119. */
  153120. constructor(scene: Scene);
  153121. /**
  153122. * Registers the component in a given scene
  153123. */
  153124. register(): void;
  153125. /**
  153126. * Rebuilds the elements related to this component in case of
  153127. * context lost for instance.
  153128. */
  153129. rebuild(): void;
  153130. /**
  153131. * Disposes the component and the associated ressources
  153132. */
  153133. dispose(): void;
  153134. private _gatherRenderTargets;
  153135. }
  153136. }
  153137. declare module BABYLON {
  153138. /**
  153139. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  153140. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  153141. */
  153142. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  153143. private _scene;
  153144. private _camerasToBeAttached;
  153145. /**
  153146. * ID of the sharpen post process,
  153147. */
  153148. private readonly SharpenPostProcessId;
  153149. /**
  153150. * @ignore
  153151. * ID of the image processing post process;
  153152. */
  153153. readonly ImageProcessingPostProcessId: string;
  153154. /**
  153155. * @ignore
  153156. * ID of the Fast Approximate Anti-Aliasing post process;
  153157. */
  153158. readonly FxaaPostProcessId: string;
  153159. /**
  153160. * ID of the chromatic aberration post process,
  153161. */
  153162. private readonly ChromaticAberrationPostProcessId;
  153163. /**
  153164. * ID of the grain post process
  153165. */
  153166. private readonly GrainPostProcessId;
  153167. /**
  153168. * Sharpen post process which will apply a sharpen convolution to enhance edges
  153169. */
  153170. sharpen: SharpenPostProcess;
  153171. private _sharpenEffect;
  153172. private bloom;
  153173. /**
  153174. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  153175. */
  153176. depthOfField: DepthOfFieldEffect;
  153177. /**
  153178. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  153179. */
  153180. fxaa: FxaaPostProcess;
  153181. /**
  153182. * Image post processing pass used to perform operations such as tone mapping or color grading.
  153183. */
  153184. imageProcessing: ImageProcessingPostProcess;
  153185. /**
  153186. * Chromatic aberration post process which will shift rgb colors in the image
  153187. */
  153188. chromaticAberration: ChromaticAberrationPostProcess;
  153189. private _chromaticAberrationEffect;
  153190. /**
  153191. * Grain post process which add noise to the image
  153192. */
  153193. grain: GrainPostProcess;
  153194. private _grainEffect;
  153195. /**
  153196. * Glow post process which adds a glow to emissive areas of the image
  153197. */
  153198. private _glowLayer;
  153199. /**
  153200. * Animations which can be used to tweak settings over a period of time
  153201. */
  153202. animations: Animation[];
  153203. private _imageProcessingConfigurationObserver;
  153204. private _sharpenEnabled;
  153205. private _bloomEnabled;
  153206. private _depthOfFieldEnabled;
  153207. private _depthOfFieldBlurLevel;
  153208. private _fxaaEnabled;
  153209. private _imageProcessingEnabled;
  153210. private _defaultPipelineTextureType;
  153211. private _bloomScale;
  153212. private _chromaticAberrationEnabled;
  153213. private _grainEnabled;
  153214. private _buildAllowed;
  153215. /**
  153216. * This is triggered each time the pipeline has been built.
  153217. */
  153218. onBuildObservable: Observable<DefaultRenderingPipeline>;
  153219. /**
  153220. * Gets active scene
  153221. */
  153222. get scene(): Scene;
  153223. /**
  153224. * Enable or disable the sharpen process from the pipeline
  153225. */
  153226. set sharpenEnabled(enabled: boolean);
  153227. get sharpenEnabled(): boolean;
  153228. private _resizeObserver;
  153229. private _hardwareScaleLevel;
  153230. private _bloomKernel;
  153231. /**
  153232. * Specifies the size of the bloom blur kernel, relative to the final output size
  153233. */
  153234. get bloomKernel(): number;
  153235. set bloomKernel(value: number);
  153236. /**
  153237. * Specifies the weight of the bloom in the final rendering
  153238. */
  153239. private _bloomWeight;
  153240. /**
  153241. * Specifies the luma threshold for the area that will be blurred by the bloom
  153242. */
  153243. private _bloomThreshold;
  153244. private _hdr;
  153245. /**
  153246. * The strength of the bloom.
  153247. */
  153248. set bloomWeight(value: number);
  153249. get bloomWeight(): number;
  153250. /**
  153251. * The strength of the bloom.
  153252. */
  153253. set bloomThreshold(value: number);
  153254. get bloomThreshold(): number;
  153255. /**
  153256. * The scale of the bloom, lower value will provide better performance.
  153257. */
  153258. set bloomScale(value: number);
  153259. get bloomScale(): number;
  153260. /**
  153261. * Enable or disable the bloom from the pipeline
  153262. */
  153263. set bloomEnabled(enabled: boolean);
  153264. get bloomEnabled(): boolean;
  153265. private _rebuildBloom;
  153266. /**
  153267. * If the depth of field is enabled.
  153268. */
  153269. get depthOfFieldEnabled(): boolean;
  153270. set depthOfFieldEnabled(enabled: boolean);
  153271. /**
  153272. * Blur level of the depth of field effect. (Higher blur will effect performance)
  153273. */
  153274. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  153275. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  153276. /**
  153277. * If the anti aliasing is enabled.
  153278. */
  153279. set fxaaEnabled(enabled: boolean);
  153280. get fxaaEnabled(): boolean;
  153281. private _samples;
  153282. /**
  153283. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  153284. */
  153285. set samples(sampleCount: number);
  153286. get samples(): number;
  153287. /**
  153288. * If image processing is enabled.
  153289. */
  153290. set imageProcessingEnabled(enabled: boolean);
  153291. get imageProcessingEnabled(): boolean;
  153292. /**
  153293. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  153294. */
  153295. set glowLayerEnabled(enabled: boolean);
  153296. get glowLayerEnabled(): boolean;
  153297. /**
  153298. * Gets the glow layer (or null if not defined)
  153299. */
  153300. get glowLayer(): Nullable<GlowLayer>;
  153301. /**
  153302. * Enable or disable the chromaticAberration process from the pipeline
  153303. */
  153304. set chromaticAberrationEnabled(enabled: boolean);
  153305. get chromaticAberrationEnabled(): boolean;
  153306. /**
  153307. * Enable or disable the grain process from the pipeline
  153308. */
  153309. set grainEnabled(enabled: boolean);
  153310. get grainEnabled(): boolean;
  153311. /**
  153312. * @constructor
  153313. * @param name - The rendering pipeline name (default: "")
  153314. * @param hdr - If high dynamic range textures should be used (default: true)
  153315. * @param scene - The scene linked to this pipeline (default: the last created scene)
  153316. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  153317. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  153318. */
  153319. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  153320. /**
  153321. * Get the class name
  153322. * @returns "DefaultRenderingPipeline"
  153323. */
  153324. getClassName(): string;
  153325. /**
  153326. * Force the compilation of the entire pipeline.
  153327. */
  153328. prepare(): void;
  153329. private _hasCleared;
  153330. private _prevPostProcess;
  153331. private _prevPrevPostProcess;
  153332. private _setAutoClearAndTextureSharing;
  153333. private _depthOfFieldSceneObserver;
  153334. private _buildPipeline;
  153335. private _disposePostProcesses;
  153336. /**
  153337. * Adds a camera to the pipeline
  153338. * @param camera the camera to be added
  153339. */
  153340. addCamera(camera: Camera): void;
  153341. /**
  153342. * Removes a camera from the pipeline
  153343. * @param camera the camera to remove
  153344. */
  153345. removeCamera(camera: Camera): void;
  153346. /**
  153347. * Dispose of the pipeline and stop all post processes
  153348. */
  153349. dispose(): void;
  153350. /**
  153351. * Serialize the rendering pipeline (Used when exporting)
  153352. * @returns the serialized object
  153353. */
  153354. serialize(): any;
  153355. /**
  153356. * Parse the serialized pipeline
  153357. * @param source Source pipeline.
  153358. * @param scene The scene to load the pipeline to.
  153359. * @param rootUrl The URL of the serialized pipeline.
  153360. * @returns An instantiated pipeline from the serialized object.
  153361. */
  153362. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  153363. }
  153364. }
  153365. declare module BABYLON {
  153366. /** @hidden */
  153367. export var lensHighlightsPixelShader: {
  153368. name: string;
  153369. shader: string;
  153370. };
  153371. }
  153372. declare module BABYLON {
  153373. /** @hidden */
  153374. export var depthOfFieldPixelShader: {
  153375. name: string;
  153376. shader: string;
  153377. };
  153378. }
  153379. declare module BABYLON {
  153380. /**
  153381. * BABYLON.JS Chromatic Aberration GLSL Shader
  153382. * Author: Olivier Guyot
  153383. * Separates very slightly R, G and B colors on the edges of the screen
  153384. * Inspired by Francois Tarlier & Martins Upitis
  153385. */
  153386. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  153387. /**
  153388. * @ignore
  153389. * The chromatic aberration PostProcess id in the pipeline
  153390. */
  153391. LensChromaticAberrationEffect: string;
  153392. /**
  153393. * @ignore
  153394. * The highlights enhancing PostProcess id in the pipeline
  153395. */
  153396. HighlightsEnhancingEffect: string;
  153397. /**
  153398. * @ignore
  153399. * The depth-of-field PostProcess id in the pipeline
  153400. */
  153401. LensDepthOfFieldEffect: string;
  153402. private _scene;
  153403. private _depthTexture;
  153404. private _grainTexture;
  153405. private _chromaticAberrationPostProcess;
  153406. private _highlightsPostProcess;
  153407. private _depthOfFieldPostProcess;
  153408. private _edgeBlur;
  153409. private _grainAmount;
  153410. private _chromaticAberration;
  153411. private _distortion;
  153412. private _highlightsGain;
  153413. private _highlightsThreshold;
  153414. private _dofDistance;
  153415. private _dofAperture;
  153416. private _dofDarken;
  153417. private _dofPentagon;
  153418. private _blurNoise;
  153419. /**
  153420. * @constructor
  153421. *
  153422. * Effect parameters are as follow:
  153423. * {
  153424. * chromatic_aberration: number; // from 0 to x (1 for realism)
  153425. * edge_blur: number; // from 0 to x (1 for realism)
  153426. * distortion: number; // from 0 to x (1 for realism)
  153427. * grain_amount: number; // from 0 to 1
  153428. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  153429. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  153430. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  153431. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  153432. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  153433. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  153434. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  153435. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  153436. * }
  153437. * Note: if an effect parameter is unset, effect is disabled
  153438. *
  153439. * @param name The rendering pipeline name
  153440. * @param parameters - An object containing all parameters (see above)
  153441. * @param scene The scene linked to this pipeline
  153442. * @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)
  153443. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153444. */
  153445. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  153446. /**
  153447. * Get the class name
  153448. * @returns "LensRenderingPipeline"
  153449. */
  153450. getClassName(): string;
  153451. /**
  153452. * Gets associated scene
  153453. */
  153454. get scene(): Scene;
  153455. /**
  153456. * Gets or sets the edge blur
  153457. */
  153458. get edgeBlur(): number;
  153459. set edgeBlur(value: number);
  153460. /**
  153461. * Gets or sets the grain amount
  153462. */
  153463. get grainAmount(): number;
  153464. set grainAmount(value: number);
  153465. /**
  153466. * Gets or sets the chromatic aberration amount
  153467. */
  153468. get chromaticAberration(): number;
  153469. set chromaticAberration(value: number);
  153470. /**
  153471. * Gets or sets the depth of field aperture
  153472. */
  153473. get dofAperture(): number;
  153474. set dofAperture(value: number);
  153475. /**
  153476. * Gets or sets the edge distortion
  153477. */
  153478. get edgeDistortion(): number;
  153479. set edgeDistortion(value: number);
  153480. /**
  153481. * Gets or sets the depth of field distortion
  153482. */
  153483. get dofDistortion(): number;
  153484. set dofDistortion(value: number);
  153485. /**
  153486. * Gets or sets the darken out of focus amount
  153487. */
  153488. get darkenOutOfFocus(): number;
  153489. set darkenOutOfFocus(value: number);
  153490. /**
  153491. * Gets or sets a boolean indicating if blur noise is enabled
  153492. */
  153493. get blurNoise(): boolean;
  153494. set blurNoise(value: boolean);
  153495. /**
  153496. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  153497. */
  153498. get pentagonBokeh(): boolean;
  153499. set pentagonBokeh(value: boolean);
  153500. /**
  153501. * Gets or sets the highlight grain amount
  153502. */
  153503. get highlightsGain(): number;
  153504. set highlightsGain(value: number);
  153505. /**
  153506. * Gets or sets the highlight threshold
  153507. */
  153508. get highlightsThreshold(): number;
  153509. set highlightsThreshold(value: number);
  153510. /**
  153511. * Sets the amount of blur at the edges
  153512. * @param amount blur amount
  153513. */
  153514. setEdgeBlur(amount: number): void;
  153515. /**
  153516. * Sets edge blur to 0
  153517. */
  153518. disableEdgeBlur(): void;
  153519. /**
  153520. * Sets the amout of grain
  153521. * @param amount Amount of grain
  153522. */
  153523. setGrainAmount(amount: number): void;
  153524. /**
  153525. * Set grain amount to 0
  153526. */
  153527. disableGrain(): void;
  153528. /**
  153529. * Sets the chromatic aberration amount
  153530. * @param amount amount of chromatic aberration
  153531. */
  153532. setChromaticAberration(amount: number): void;
  153533. /**
  153534. * Sets chromatic aberration amount to 0
  153535. */
  153536. disableChromaticAberration(): void;
  153537. /**
  153538. * Sets the EdgeDistortion amount
  153539. * @param amount amount of EdgeDistortion
  153540. */
  153541. setEdgeDistortion(amount: number): void;
  153542. /**
  153543. * Sets edge distortion to 0
  153544. */
  153545. disableEdgeDistortion(): void;
  153546. /**
  153547. * Sets the FocusDistance amount
  153548. * @param amount amount of FocusDistance
  153549. */
  153550. setFocusDistance(amount: number): void;
  153551. /**
  153552. * Disables depth of field
  153553. */
  153554. disableDepthOfField(): void;
  153555. /**
  153556. * Sets the Aperture amount
  153557. * @param amount amount of Aperture
  153558. */
  153559. setAperture(amount: number): void;
  153560. /**
  153561. * Sets the DarkenOutOfFocus amount
  153562. * @param amount amount of DarkenOutOfFocus
  153563. */
  153564. setDarkenOutOfFocus(amount: number): void;
  153565. private _pentagonBokehIsEnabled;
  153566. /**
  153567. * Creates a pentagon bokeh effect
  153568. */
  153569. enablePentagonBokeh(): void;
  153570. /**
  153571. * Disables the pentagon bokeh effect
  153572. */
  153573. disablePentagonBokeh(): void;
  153574. /**
  153575. * Enables noise blur
  153576. */
  153577. enableNoiseBlur(): void;
  153578. /**
  153579. * Disables noise blur
  153580. */
  153581. disableNoiseBlur(): void;
  153582. /**
  153583. * Sets the HighlightsGain amount
  153584. * @param amount amount of HighlightsGain
  153585. */
  153586. setHighlightsGain(amount: number): void;
  153587. /**
  153588. * Sets the HighlightsThreshold amount
  153589. * @param amount amount of HighlightsThreshold
  153590. */
  153591. setHighlightsThreshold(amount: number): void;
  153592. /**
  153593. * Disables highlights
  153594. */
  153595. disableHighlights(): void;
  153596. /**
  153597. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  153598. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  153599. */
  153600. dispose(disableDepthRender?: boolean): void;
  153601. private _createChromaticAberrationPostProcess;
  153602. private _createHighlightsPostProcess;
  153603. private _createDepthOfFieldPostProcess;
  153604. private _createGrainTexture;
  153605. }
  153606. }
  153607. declare module BABYLON {
  153608. /**
  153609. * Contains all parameters needed for the prepass to perform
  153610. * screen space subsurface scattering
  153611. */
  153612. export class SSAO2Configuration implements PrePassEffectConfiguration {
  153613. /**
  153614. * Is subsurface enabled
  153615. */
  153616. enabled: boolean;
  153617. /**
  153618. * Name of the configuration
  153619. */
  153620. name: string;
  153621. /**
  153622. * Textures that should be present in the MRT for this effect to work
  153623. */
  153624. readonly texturesRequired: number[];
  153625. }
  153626. }
  153627. declare module BABYLON {
  153628. /** @hidden */
  153629. export var ssao2PixelShader: {
  153630. name: string;
  153631. shader: string;
  153632. };
  153633. }
  153634. declare module BABYLON {
  153635. /** @hidden */
  153636. export var ssaoCombinePixelShader: {
  153637. name: string;
  153638. shader: string;
  153639. };
  153640. }
  153641. declare module BABYLON {
  153642. /**
  153643. * Render pipeline to produce ssao effect
  153644. */
  153645. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  153646. /**
  153647. * @ignore
  153648. * The PassPostProcess id in the pipeline that contains the original scene color
  153649. */
  153650. SSAOOriginalSceneColorEffect: string;
  153651. /**
  153652. * @ignore
  153653. * The SSAO PostProcess id in the pipeline
  153654. */
  153655. SSAORenderEffect: string;
  153656. /**
  153657. * @ignore
  153658. * The horizontal blur PostProcess id in the pipeline
  153659. */
  153660. SSAOBlurHRenderEffect: string;
  153661. /**
  153662. * @ignore
  153663. * The vertical blur PostProcess id in the pipeline
  153664. */
  153665. SSAOBlurVRenderEffect: string;
  153666. /**
  153667. * @ignore
  153668. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  153669. */
  153670. SSAOCombineRenderEffect: string;
  153671. /**
  153672. * The output strength of the SSAO post-process. Default value is 1.0.
  153673. */
  153674. totalStrength: number;
  153675. /**
  153676. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  153677. */
  153678. maxZ: number;
  153679. /**
  153680. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  153681. */
  153682. minZAspect: number;
  153683. private _samples;
  153684. /**
  153685. * Number of samples used for the SSAO calculations. Default value is 8
  153686. */
  153687. set samples(n: number);
  153688. get samples(): number;
  153689. private _textureSamples;
  153690. /**
  153691. * Number of samples to use for antialiasing
  153692. */
  153693. set textureSamples(n: number);
  153694. get textureSamples(): number;
  153695. /**
  153696. * Force rendering the geometry through geometry buffer
  153697. */
  153698. private _forceGeometryBuffer;
  153699. /**
  153700. * Ratio object used for SSAO ratio and blur ratio
  153701. */
  153702. private _ratio;
  153703. /**
  153704. * Dynamically generated sphere sampler.
  153705. */
  153706. private _sampleSphere;
  153707. /**
  153708. * Blur filter offsets
  153709. */
  153710. private _samplerOffsets;
  153711. private _expensiveBlur;
  153712. /**
  153713. * If bilateral blur should be used
  153714. */
  153715. set expensiveBlur(b: boolean);
  153716. get expensiveBlur(): boolean;
  153717. /**
  153718. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  153719. */
  153720. radius: number;
  153721. /**
  153722. * The base color of the SSAO post-process
  153723. * The final result is "base + ssao" between [0, 1]
  153724. */
  153725. base: number;
  153726. /**
  153727. * Support test.
  153728. */
  153729. static get IsSupported(): boolean;
  153730. private _scene;
  153731. private _randomTexture;
  153732. private _originalColorPostProcess;
  153733. private _ssaoPostProcess;
  153734. private _blurHPostProcess;
  153735. private _blurVPostProcess;
  153736. private _ssaoCombinePostProcess;
  153737. private _prePassRenderer;
  153738. /**
  153739. * Gets active scene
  153740. */
  153741. get scene(): Scene;
  153742. /**
  153743. * @constructor
  153744. * @param name The rendering pipeline name
  153745. * @param scene The scene linked to this pipeline
  153746. * @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 }
  153747. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153748. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  153749. */
  153750. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  153751. /**
  153752. * Get the class name
  153753. * @returns "SSAO2RenderingPipeline"
  153754. */
  153755. getClassName(): string;
  153756. /**
  153757. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153758. */
  153759. dispose(disableGeometryBufferRenderer?: boolean): void;
  153760. private _createBlurPostProcess;
  153761. /** @hidden */
  153762. _rebuild(): void;
  153763. private _bits;
  153764. private _radicalInverse_VdC;
  153765. private _hammersley;
  153766. private _hemisphereSample_uniform;
  153767. private _generateHemisphere;
  153768. private _getDefinesForSSAO;
  153769. private _createSSAOPostProcess;
  153770. private _createSSAOCombinePostProcess;
  153771. private _createRandomTexture;
  153772. /**
  153773. * Serialize the rendering pipeline (Used when exporting)
  153774. * @returns the serialized object
  153775. */
  153776. serialize(): any;
  153777. /**
  153778. * Parse the serialized pipeline
  153779. * @param source Source pipeline.
  153780. * @param scene The scene to load the pipeline to.
  153781. * @param rootUrl The URL of the serialized pipeline.
  153782. * @returns An instantiated pipeline from the serialized object.
  153783. */
  153784. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  153785. }
  153786. }
  153787. declare module BABYLON {
  153788. /** @hidden */
  153789. export var ssaoPixelShader: {
  153790. name: string;
  153791. shader: string;
  153792. };
  153793. }
  153794. declare module BABYLON {
  153795. /**
  153796. * Render pipeline to produce ssao effect
  153797. */
  153798. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  153799. /**
  153800. * @ignore
  153801. * The PassPostProcess id in the pipeline that contains the original scene color
  153802. */
  153803. SSAOOriginalSceneColorEffect: string;
  153804. /**
  153805. * @ignore
  153806. * The SSAO PostProcess id in the pipeline
  153807. */
  153808. SSAORenderEffect: string;
  153809. /**
  153810. * @ignore
  153811. * The horizontal blur PostProcess id in the pipeline
  153812. */
  153813. SSAOBlurHRenderEffect: string;
  153814. /**
  153815. * @ignore
  153816. * The vertical blur PostProcess id in the pipeline
  153817. */
  153818. SSAOBlurVRenderEffect: string;
  153819. /**
  153820. * @ignore
  153821. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  153822. */
  153823. SSAOCombineRenderEffect: string;
  153824. /**
  153825. * The output strength of the SSAO post-process. Default value is 1.0.
  153826. */
  153827. totalStrength: number;
  153828. /**
  153829. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  153830. */
  153831. radius: number;
  153832. /**
  153833. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  153834. * Must not be equal to fallOff and superior to fallOff.
  153835. * Default value is 0.0075
  153836. */
  153837. area: number;
  153838. /**
  153839. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  153840. * Must not be equal to area and inferior to area.
  153841. * Default value is 0.000001
  153842. */
  153843. fallOff: number;
  153844. /**
  153845. * The base color of the SSAO post-process
  153846. * The final result is "base + ssao" between [0, 1]
  153847. */
  153848. base: number;
  153849. private _scene;
  153850. private _depthTexture;
  153851. private _randomTexture;
  153852. private _originalColorPostProcess;
  153853. private _ssaoPostProcess;
  153854. private _blurHPostProcess;
  153855. private _blurVPostProcess;
  153856. private _ssaoCombinePostProcess;
  153857. private _firstUpdate;
  153858. /**
  153859. * Gets active scene
  153860. */
  153861. get scene(): Scene;
  153862. /**
  153863. * @constructor
  153864. * @param name - The rendering pipeline name
  153865. * @param scene - The scene linked to this pipeline
  153866. * @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 }
  153867. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  153868. */
  153869. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  153870. /**
  153871. * Get the class name
  153872. * @returns "SSAORenderingPipeline"
  153873. */
  153874. getClassName(): string;
  153875. /**
  153876. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153877. */
  153878. dispose(disableDepthRender?: boolean): void;
  153879. private _createBlurPostProcess;
  153880. /** @hidden */
  153881. _rebuild(): void;
  153882. private _createSSAOPostProcess;
  153883. private _createSSAOCombinePostProcess;
  153884. private _createRandomTexture;
  153885. }
  153886. }
  153887. declare module BABYLON {
  153888. /**
  153889. * Contains all parameters needed for the prepass to perform
  153890. * screen space reflections
  153891. */
  153892. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  153893. /**
  153894. * Is ssr enabled
  153895. */
  153896. enabled: boolean;
  153897. /**
  153898. * Name of the configuration
  153899. */
  153900. name: string;
  153901. /**
  153902. * Textures that should be present in the MRT for this effect to work
  153903. */
  153904. readonly texturesRequired: number[];
  153905. }
  153906. }
  153907. declare module BABYLON {
  153908. /** @hidden */
  153909. export var screenSpaceReflectionPixelShader: {
  153910. name: string;
  153911. shader: string;
  153912. };
  153913. }
  153914. declare module BABYLON {
  153915. /**
  153916. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  153917. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  153918. */
  153919. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  153920. /**
  153921. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  153922. */
  153923. threshold: number;
  153924. /**
  153925. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  153926. */
  153927. strength: number;
  153928. /**
  153929. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  153930. */
  153931. reflectionSpecularFalloffExponent: number;
  153932. /**
  153933. * 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]
  153934. */
  153935. step: number;
  153936. /**
  153937. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  153938. */
  153939. roughnessFactor: number;
  153940. private _forceGeometryBuffer;
  153941. private _geometryBufferRenderer;
  153942. private _prePassRenderer;
  153943. private _enableSmoothReflections;
  153944. private _reflectionSamples;
  153945. private _smoothSteps;
  153946. /**
  153947. * Gets a string identifying the name of the class
  153948. * @returns "ScreenSpaceReflectionPostProcess" string
  153949. */
  153950. getClassName(): string;
  153951. /**
  153952. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  153953. * @param name The name of the effect.
  153954. * @param scene The scene containing the objects to calculate reflections.
  153955. * @param options The required width/height ratio to downsize to before computing the render pass.
  153956. * @param camera The camera to apply the render pass to.
  153957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153958. * @param engine The engine which the post process will be applied. (default: current engine)
  153959. * @param reusable If the post process can be reused on the same frame. (default: false)
  153960. * @param textureType Type of textures used when performing the post process. (default: 0)
  153961. * @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)
  153962. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  153963. */
  153964. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  153965. /**
  153966. * Gets wether or not smoothing reflections is enabled.
  153967. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  153968. */
  153969. get enableSmoothReflections(): boolean;
  153970. /**
  153971. * Sets wether or not smoothing reflections is enabled.
  153972. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  153973. */
  153974. set enableSmoothReflections(enabled: boolean);
  153975. /**
  153976. * Gets the number of samples taken while computing reflections. More samples count is high,
  153977. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  153978. */
  153979. get reflectionSamples(): number;
  153980. /**
  153981. * Sets the number of samples taken while computing reflections. More samples count is high,
  153982. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  153983. */
  153984. set reflectionSamples(samples: number);
  153985. /**
  153986. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  153987. * more the post-process will require GPU power and can generate a drop in FPS.
  153988. * Default value (5.0) work pretty well in all cases but can be adjusted.
  153989. */
  153990. get smoothSteps(): number;
  153991. set smoothSteps(steps: number);
  153992. private _updateEffectDefines;
  153993. /** @hidden */
  153994. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  153995. }
  153996. }
  153997. declare module BABYLON {
  153998. /** @hidden */
  153999. export var standardPixelShader: {
  154000. name: string;
  154001. shader: string;
  154002. };
  154003. }
  154004. declare module BABYLON {
  154005. /**
  154006. * Standard rendering pipeline
  154007. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  154008. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  154009. */
  154010. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  154011. /**
  154012. * Public members
  154013. */
  154014. /**
  154015. * Post-process which contains the original scene color before the pipeline applies all the effects
  154016. */
  154017. originalPostProcess: Nullable<PostProcess>;
  154018. /**
  154019. * Post-process used to down scale an image x4
  154020. */
  154021. downSampleX4PostProcess: Nullable<PostProcess>;
  154022. /**
  154023. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  154024. */
  154025. brightPassPostProcess: Nullable<PostProcess>;
  154026. /**
  154027. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  154028. */
  154029. blurHPostProcesses: PostProcess[];
  154030. /**
  154031. * Post-process array storing all the vertical blur post-processes used by the pipeline
  154032. */
  154033. blurVPostProcesses: PostProcess[];
  154034. /**
  154035. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  154036. */
  154037. textureAdderPostProcess: Nullable<PostProcess>;
  154038. /**
  154039. * Post-process used to create volumetric lighting effect
  154040. */
  154041. volumetricLightPostProcess: Nullable<PostProcess>;
  154042. /**
  154043. * Post-process used to smooth the previous volumetric light post-process on the X axis
  154044. */
  154045. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  154046. /**
  154047. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  154048. */
  154049. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  154050. /**
  154051. * Post-process used to merge the volumetric light effect and the real scene color
  154052. */
  154053. volumetricLightMergePostProces: Nullable<PostProcess>;
  154054. /**
  154055. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  154056. */
  154057. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  154058. /**
  154059. * Base post-process used to calculate the average luminance of the final image for HDR
  154060. */
  154061. luminancePostProcess: Nullable<PostProcess>;
  154062. /**
  154063. * Post-processes used to create down sample post-processes in order to get
  154064. * the average luminance of the final image for HDR
  154065. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  154066. */
  154067. luminanceDownSamplePostProcesses: PostProcess[];
  154068. /**
  154069. * Post-process used to create a HDR effect (light adaptation)
  154070. */
  154071. hdrPostProcess: Nullable<PostProcess>;
  154072. /**
  154073. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  154074. */
  154075. textureAdderFinalPostProcess: Nullable<PostProcess>;
  154076. /**
  154077. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  154078. */
  154079. lensFlareFinalPostProcess: Nullable<PostProcess>;
  154080. /**
  154081. * Post-process used to merge the final HDR post-process and the real scene color
  154082. */
  154083. hdrFinalPostProcess: Nullable<PostProcess>;
  154084. /**
  154085. * Post-process used to create a lens flare effect
  154086. */
  154087. lensFlarePostProcess: Nullable<PostProcess>;
  154088. /**
  154089. * Post-process that merges the result of the lens flare post-process and the real scene color
  154090. */
  154091. lensFlareComposePostProcess: Nullable<PostProcess>;
  154092. /**
  154093. * Post-process used to create a motion blur effect
  154094. */
  154095. motionBlurPostProcess: Nullable<PostProcess>;
  154096. /**
  154097. * Post-process used to create a depth of field effect
  154098. */
  154099. depthOfFieldPostProcess: Nullable<PostProcess>;
  154100. /**
  154101. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  154102. */
  154103. fxaaPostProcess: Nullable<FxaaPostProcess>;
  154104. /**
  154105. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  154106. */
  154107. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  154108. /**
  154109. * Represents the brightness threshold in order to configure the illuminated surfaces
  154110. */
  154111. brightThreshold: number;
  154112. /**
  154113. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  154114. */
  154115. blurWidth: number;
  154116. /**
  154117. * Sets if the blur for highlighted surfaces must be only horizontal
  154118. */
  154119. horizontalBlur: boolean;
  154120. /**
  154121. * Gets the overall exposure used by the pipeline
  154122. */
  154123. get exposure(): number;
  154124. /**
  154125. * Sets the overall exposure used by the pipeline
  154126. */
  154127. set exposure(value: number);
  154128. /**
  154129. * Texture used typically to simulate "dirty" on camera lens
  154130. */
  154131. lensTexture: Nullable<Texture>;
  154132. /**
  154133. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  154134. */
  154135. volumetricLightCoefficient: number;
  154136. /**
  154137. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  154138. */
  154139. volumetricLightPower: number;
  154140. /**
  154141. * Used the set the blur intensity to smooth the volumetric lights
  154142. */
  154143. volumetricLightBlurScale: number;
  154144. /**
  154145. * Light (spot or directional) used to generate the volumetric lights rays
  154146. * The source light must have a shadow generate so the pipeline can get its
  154147. * depth map
  154148. */
  154149. sourceLight: Nullable<SpotLight | DirectionalLight>;
  154150. /**
  154151. * For eye adaptation, represents the minimum luminance the eye can see
  154152. */
  154153. hdrMinimumLuminance: number;
  154154. /**
  154155. * For eye adaptation, represents the decrease luminance speed
  154156. */
  154157. hdrDecreaseRate: number;
  154158. /**
  154159. * For eye adaptation, represents the increase luminance speed
  154160. */
  154161. hdrIncreaseRate: number;
  154162. /**
  154163. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  154164. */
  154165. get hdrAutoExposure(): boolean;
  154166. /**
  154167. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  154168. */
  154169. set hdrAutoExposure(value: boolean);
  154170. /**
  154171. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  154172. */
  154173. lensColorTexture: Nullable<Texture>;
  154174. /**
  154175. * The overall strengh for the lens flare effect
  154176. */
  154177. lensFlareStrength: number;
  154178. /**
  154179. * Dispersion coefficient for lens flare ghosts
  154180. */
  154181. lensFlareGhostDispersal: number;
  154182. /**
  154183. * Main lens flare halo width
  154184. */
  154185. lensFlareHaloWidth: number;
  154186. /**
  154187. * Based on the lens distortion effect, defines how much the lens flare result
  154188. * is distorted
  154189. */
  154190. lensFlareDistortionStrength: number;
  154191. /**
  154192. * Configures the blur intensity used for for lens flare (halo)
  154193. */
  154194. lensFlareBlurWidth: number;
  154195. /**
  154196. * Lens star texture must be used to simulate rays on the flares and is available
  154197. * in the documentation
  154198. */
  154199. lensStarTexture: Nullable<Texture>;
  154200. /**
  154201. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  154202. * flare effect by taking account of the dirt texture
  154203. */
  154204. lensFlareDirtTexture: Nullable<Texture>;
  154205. /**
  154206. * Represents the focal length for the depth of field effect
  154207. */
  154208. depthOfFieldDistance: number;
  154209. /**
  154210. * Represents the blur intensity for the blurred part of the depth of field effect
  154211. */
  154212. depthOfFieldBlurWidth: number;
  154213. /**
  154214. * Gets how much the image is blurred by the movement while using the motion blur post-process
  154215. */
  154216. get motionStrength(): number;
  154217. /**
  154218. * Sets how much the image is blurred by the movement while using the motion blur post-process
  154219. */
  154220. set motionStrength(strength: number);
  154221. /**
  154222. * Gets wether or not the motion blur post-process is object based or screen based.
  154223. */
  154224. get objectBasedMotionBlur(): boolean;
  154225. /**
  154226. * Sets wether or not the motion blur post-process should be object based or screen based
  154227. */
  154228. set objectBasedMotionBlur(value: boolean);
  154229. /**
  154230. * List of animations for the pipeline (IAnimatable implementation)
  154231. */
  154232. animations: Animation[];
  154233. /**
  154234. * Private members
  154235. */
  154236. private _scene;
  154237. private _currentDepthOfFieldSource;
  154238. private _basePostProcess;
  154239. private _fixedExposure;
  154240. private _currentExposure;
  154241. private _hdrAutoExposure;
  154242. private _hdrCurrentLuminance;
  154243. private _motionStrength;
  154244. private _isObjectBasedMotionBlur;
  154245. private _floatTextureType;
  154246. private _camerasToBeAttached;
  154247. private _ratio;
  154248. private _bloomEnabled;
  154249. private _depthOfFieldEnabled;
  154250. private _vlsEnabled;
  154251. private _lensFlareEnabled;
  154252. private _hdrEnabled;
  154253. private _motionBlurEnabled;
  154254. private _fxaaEnabled;
  154255. private _screenSpaceReflectionsEnabled;
  154256. private _motionBlurSamples;
  154257. private _volumetricLightStepsCount;
  154258. private _samples;
  154259. /**
  154260. * @ignore
  154261. * Specifies if the bloom pipeline is enabled
  154262. */
  154263. get BloomEnabled(): boolean;
  154264. set BloomEnabled(enabled: boolean);
  154265. /**
  154266. * @ignore
  154267. * Specifies if the depth of field pipeline is enabed
  154268. */
  154269. get DepthOfFieldEnabled(): boolean;
  154270. set DepthOfFieldEnabled(enabled: boolean);
  154271. /**
  154272. * @ignore
  154273. * Specifies if the lens flare pipeline is enabed
  154274. */
  154275. get LensFlareEnabled(): boolean;
  154276. set LensFlareEnabled(enabled: boolean);
  154277. /**
  154278. * @ignore
  154279. * Specifies if the HDR pipeline is enabled
  154280. */
  154281. get HDREnabled(): boolean;
  154282. set HDREnabled(enabled: boolean);
  154283. /**
  154284. * @ignore
  154285. * Specifies if the volumetric lights scattering effect is enabled
  154286. */
  154287. get VLSEnabled(): boolean;
  154288. set VLSEnabled(enabled: boolean);
  154289. /**
  154290. * @ignore
  154291. * Specifies if the motion blur effect is enabled
  154292. */
  154293. get MotionBlurEnabled(): boolean;
  154294. set MotionBlurEnabled(enabled: boolean);
  154295. /**
  154296. * Specifies if anti-aliasing is enabled
  154297. */
  154298. get fxaaEnabled(): boolean;
  154299. set fxaaEnabled(enabled: boolean);
  154300. /**
  154301. * Specifies if screen space reflections are enabled.
  154302. */
  154303. get screenSpaceReflectionsEnabled(): boolean;
  154304. set screenSpaceReflectionsEnabled(enabled: boolean);
  154305. /**
  154306. * Specifies the number of steps used to calculate the volumetric lights
  154307. * Typically in interval [50, 200]
  154308. */
  154309. get volumetricLightStepsCount(): number;
  154310. set volumetricLightStepsCount(count: number);
  154311. /**
  154312. * Specifies the number of samples used for the motion blur effect
  154313. * Typically in interval [16, 64]
  154314. */
  154315. get motionBlurSamples(): number;
  154316. set motionBlurSamples(samples: number);
  154317. /**
  154318. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  154319. */
  154320. get samples(): number;
  154321. set samples(sampleCount: number);
  154322. /**
  154323. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  154324. * @constructor
  154325. * @param name The rendering pipeline name
  154326. * @param scene The scene linked to this pipeline
  154327. * @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)
  154328. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  154329. * @param cameras The array of cameras that the rendering pipeline will be attached to
  154330. */
  154331. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  154332. private _buildPipeline;
  154333. private _createDownSampleX4PostProcess;
  154334. private _createBrightPassPostProcess;
  154335. private _createBlurPostProcesses;
  154336. private _createTextureAdderPostProcess;
  154337. private _createVolumetricLightPostProcess;
  154338. private _createLuminancePostProcesses;
  154339. private _createHdrPostProcess;
  154340. private _createLensFlarePostProcess;
  154341. private _createDepthOfFieldPostProcess;
  154342. private _createMotionBlurPostProcess;
  154343. private _getDepthTexture;
  154344. private _disposePostProcesses;
  154345. /**
  154346. * Dispose of the pipeline and stop all post processes
  154347. */
  154348. dispose(): void;
  154349. /**
  154350. * Serialize the rendering pipeline (Used when exporting)
  154351. * @returns the serialized object
  154352. */
  154353. serialize(): any;
  154354. /**
  154355. * Parse the serialized pipeline
  154356. * @param source Source pipeline.
  154357. * @param scene The scene to load the pipeline to.
  154358. * @param rootUrl The URL of the serialized pipeline.
  154359. * @returns An instantiated pipeline from the serialized object.
  154360. */
  154361. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  154362. /**
  154363. * Luminance steps
  154364. */
  154365. static LuminanceSteps: number;
  154366. }
  154367. }
  154368. declare module BABYLON {
  154369. /** @hidden */
  154370. export var stereoscopicInterlacePixelShader: {
  154371. name: string;
  154372. shader: string;
  154373. };
  154374. }
  154375. declare module BABYLON {
  154376. /**
  154377. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  154378. */
  154379. export class StereoscopicInterlacePostProcessI extends PostProcess {
  154380. private _stepSize;
  154381. private _passedProcess;
  154382. /**
  154383. * Gets a string identifying the name of the class
  154384. * @returns "StereoscopicInterlacePostProcessI" string
  154385. */
  154386. getClassName(): string;
  154387. /**
  154388. * Initializes a StereoscopicInterlacePostProcessI
  154389. * @param name The name of the effect.
  154390. * @param rigCameras The rig cameras to be appled to the post process
  154391. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  154392. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  154393. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154394. * @param engine The engine which the post process will be applied. (default: current engine)
  154395. * @param reusable If the post process can be reused on the same frame. (default: false)
  154396. */
  154397. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  154398. }
  154399. /**
  154400. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  154401. */
  154402. export class StereoscopicInterlacePostProcess extends PostProcess {
  154403. private _stepSize;
  154404. private _passedProcess;
  154405. /**
  154406. * Gets a string identifying the name of the class
  154407. * @returns "StereoscopicInterlacePostProcess" string
  154408. */
  154409. getClassName(): string;
  154410. /**
  154411. * Initializes a StereoscopicInterlacePostProcess
  154412. * @param name The name of the effect.
  154413. * @param rigCameras The rig cameras to be appled to the post process
  154414. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  154415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154416. * @param engine The engine which the post process will be applied. (default: current engine)
  154417. * @param reusable If the post process can be reused on the same frame. (default: false)
  154418. */
  154419. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  154420. }
  154421. }
  154422. declare module BABYLON {
  154423. /** @hidden */
  154424. export var tonemapPixelShader: {
  154425. name: string;
  154426. shader: string;
  154427. };
  154428. }
  154429. declare module BABYLON {
  154430. /** Defines operator used for tonemapping */
  154431. export enum TonemappingOperator {
  154432. /** Hable */
  154433. Hable = 0,
  154434. /** Reinhard */
  154435. Reinhard = 1,
  154436. /** HejiDawson */
  154437. HejiDawson = 2,
  154438. /** Photographic */
  154439. Photographic = 3
  154440. }
  154441. /**
  154442. * Defines a post process to apply tone mapping
  154443. */
  154444. export class TonemapPostProcess extends PostProcess {
  154445. private _operator;
  154446. /** Defines the required exposure adjustement */
  154447. exposureAdjustment: number;
  154448. /**
  154449. * Gets a string identifying the name of the class
  154450. * @returns "TonemapPostProcess" string
  154451. */
  154452. getClassName(): string;
  154453. /**
  154454. * Creates a new TonemapPostProcess
  154455. * @param name defines the name of the postprocess
  154456. * @param _operator defines the operator to use
  154457. * @param exposureAdjustment defines the required exposure adjustement
  154458. * @param camera defines the camera to use (can be null)
  154459. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  154460. * @param engine defines the hosting engine (can be ignore if camera is set)
  154461. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  154462. */
  154463. constructor(name: string, _operator: TonemappingOperator,
  154464. /** Defines the required exposure adjustement */
  154465. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  154466. }
  154467. }
  154468. declare module BABYLON {
  154469. /** @hidden */
  154470. export var volumetricLightScatteringPixelShader: {
  154471. name: string;
  154472. shader: string;
  154473. };
  154474. }
  154475. declare module BABYLON {
  154476. /** @hidden */
  154477. export var volumetricLightScatteringPassVertexShader: {
  154478. name: string;
  154479. shader: string;
  154480. };
  154481. }
  154482. declare module BABYLON {
  154483. /** @hidden */
  154484. export var volumetricLightScatteringPassPixelShader: {
  154485. name: string;
  154486. shader: string;
  154487. };
  154488. }
  154489. declare module BABYLON {
  154490. /**
  154491. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  154492. */
  154493. export class VolumetricLightScatteringPostProcess extends PostProcess {
  154494. private _volumetricLightScatteringPass;
  154495. private _volumetricLightScatteringRTT;
  154496. private _viewPort;
  154497. private _screenCoordinates;
  154498. private _cachedDefines;
  154499. /**
  154500. * If not undefined, the mesh position is computed from the attached node position
  154501. */
  154502. attachedNode: {
  154503. position: Vector3;
  154504. };
  154505. /**
  154506. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  154507. */
  154508. customMeshPosition: Vector3;
  154509. /**
  154510. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  154511. */
  154512. useCustomMeshPosition: boolean;
  154513. /**
  154514. * If the post-process should inverse the light scattering direction
  154515. */
  154516. invert: boolean;
  154517. /**
  154518. * The internal mesh used by the post-process
  154519. */
  154520. mesh: Mesh;
  154521. /**
  154522. * @hidden
  154523. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  154524. */
  154525. get useDiffuseColor(): boolean;
  154526. set useDiffuseColor(useDiffuseColor: boolean);
  154527. /**
  154528. * Array containing the excluded meshes not rendered in the internal pass
  154529. */
  154530. excludedMeshes: AbstractMesh[];
  154531. /**
  154532. * Controls the overall intensity of the post-process
  154533. */
  154534. exposure: number;
  154535. /**
  154536. * Dissipates each sample's contribution in range [0, 1]
  154537. */
  154538. decay: number;
  154539. /**
  154540. * Controls the overall intensity of each sample
  154541. */
  154542. weight: number;
  154543. /**
  154544. * Controls the density of each sample
  154545. */
  154546. density: number;
  154547. /**
  154548. * @constructor
  154549. * @param name The post-process name
  154550. * @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)
  154551. * @param camera The camera that the post-process will be attached to
  154552. * @param mesh The mesh used to create the light scattering
  154553. * @param samples The post-process quality, default 100
  154554. * @param samplingModeThe post-process filtering mode
  154555. * @param engine The babylon engine
  154556. * @param reusable If the post-process is reusable
  154557. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  154558. */
  154559. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  154560. /**
  154561. * Returns the string "VolumetricLightScatteringPostProcess"
  154562. * @returns "VolumetricLightScatteringPostProcess"
  154563. */
  154564. getClassName(): string;
  154565. private _isReady;
  154566. /**
  154567. * Sets the new light position for light scattering effect
  154568. * @param position The new custom light position
  154569. */
  154570. setCustomMeshPosition(position: Vector3): void;
  154571. /**
  154572. * Returns the light position for light scattering effect
  154573. * @return Vector3 The custom light position
  154574. */
  154575. getCustomMeshPosition(): Vector3;
  154576. /**
  154577. * Disposes the internal assets and detaches the post-process from the camera
  154578. */
  154579. dispose(camera: Camera): void;
  154580. /**
  154581. * Returns the render target texture used by the post-process
  154582. * @return the render target texture used by the post-process
  154583. */
  154584. getPass(): RenderTargetTexture;
  154585. private _meshExcluded;
  154586. private _createPass;
  154587. private _updateMeshScreenCoordinates;
  154588. /**
  154589. * Creates a default mesh for the Volumeric Light Scattering post-process
  154590. * @param name The mesh name
  154591. * @param scene The scene where to create the mesh
  154592. * @return the default mesh
  154593. */
  154594. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  154595. }
  154596. }
  154597. declare module BABYLON {
  154598. /** @hidden */
  154599. export var screenSpaceCurvaturePixelShader: {
  154600. name: string;
  154601. shader: string;
  154602. };
  154603. }
  154604. declare module BABYLON {
  154605. /**
  154606. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  154607. */
  154608. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  154609. /**
  154610. * Defines how much ridge the curvature effect displays.
  154611. */
  154612. ridge: number;
  154613. /**
  154614. * Defines how much valley the curvature effect displays.
  154615. */
  154616. valley: number;
  154617. private _geometryBufferRenderer;
  154618. /**
  154619. * Gets a string identifying the name of the class
  154620. * @returns "ScreenSpaceCurvaturePostProcess" string
  154621. */
  154622. getClassName(): string;
  154623. /**
  154624. * Creates a new instance ScreenSpaceCurvaturePostProcess
  154625. * @param name The name of the effect.
  154626. * @param scene The scene containing the objects to blur according to their velocity.
  154627. * @param options The required width/height ratio to downsize to before computing the render pass.
  154628. * @param camera The camera to apply the render pass to.
  154629. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154630. * @param engine The engine which the post process will be applied. (default: current engine)
  154631. * @param reusable If the post process can be reused on the same frame. (default: false)
  154632. * @param textureType Type of textures used when performing the post process. (default: 0)
  154633. * @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)
  154634. */
  154635. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  154636. /**
  154637. * Support test.
  154638. */
  154639. static get IsSupported(): boolean;
  154640. /** @hidden */
  154641. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  154642. }
  154643. }
  154644. declare module BABYLON {
  154645. interface Scene {
  154646. /** @hidden (Backing field) */
  154647. _boundingBoxRenderer: BoundingBoxRenderer;
  154648. /** @hidden (Backing field) */
  154649. _forceShowBoundingBoxes: boolean;
  154650. /**
  154651. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  154652. */
  154653. forceShowBoundingBoxes: boolean;
  154654. /**
  154655. * Gets the bounding box renderer associated with the scene
  154656. * @returns a BoundingBoxRenderer
  154657. */
  154658. getBoundingBoxRenderer(): BoundingBoxRenderer;
  154659. }
  154660. interface AbstractMesh {
  154661. /** @hidden (Backing field) */
  154662. _showBoundingBox: boolean;
  154663. /**
  154664. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  154665. */
  154666. showBoundingBox: boolean;
  154667. }
  154668. /**
  154669. * Component responsible of rendering the bounding box of the meshes in a scene.
  154670. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  154671. */
  154672. export class BoundingBoxRenderer implements ISceneComponent {
  154673. /**
  154674. * The component name helpfull to identify the component in the list of scene components.
  154675. */
  154676. readonly name: string;
  154677. /**
  154678. * The scene the component belongs to.
  154679. */
  154680. scene: Scene;
  154681. /**
  154682. * Color of the bounding box lines placed in front of an object
  154683. */
  154684. frontColor: Color3;
  154685. /**
  154686. * Color of the bounding box lines placed behind an object
  154687. */
  154688. backColor: Color3;
  154689. /**
  154690. * Defines if the renderer should show the back lines or not
  154691. */
  154692. showBackLines: boolean;
  154693. /**
  154694. * Observable raised before rendering a bounding box
  154695. */
  154696. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  154697. /**
  154698. * Observable raised after rendering a bounding box
  154699. */
  154700. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  154701. /**
  154702. * Observable raised after resources are created
  154703. */
  154704. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  154705. /**
  154706. * When false, no bounding boxes will be rendered
  154707. */
  154708. enabled: boolean;
  154709. /**
  154710. * @hidden
  154711. */
  154712. renderList: SmartArray<BoundingBox>;
  154713. private _colorShader;
  154714. private _vertexBuffers;
  154715. private _indexBuffer;
  154716. private _fillIndexBuffer;
  154717. private _fillIndexData;
  154718. /**
  154719. * Instantiates a new bounding box renderer in a scene.
  154720. * @param scene the scene the renderer renders in
  154721. */
  154722. constructor(scene: Scene);
  154723. /**
  154724. * Registers the component in a given scene
  154725. */
  154726. register(): void;
  154727. private _evaluateSubMesh;
  154728. private _preActiveMesh;
  154729. private _prepareResources;
  154730. private _createIndexBuffer;
  154731. /**
  154732. * Rebuilds the elements related to this component in case of
  154733. * context lost for instance.
  154734. */
  154735. rebuild(): void;
  154736. /**
  154737. * @hidden
  154738. */
  154739. reset(): void;
  154740. /**
  154741. * Render the bounding boxes of a specific rendering group
  154742. * @param renderingGroupId defines the rendering group to render
  154743. */
  154744. render(renderingGroupId: number): void;
  154745. /**
  154746. * In case of occlusion queries, we can render the occlusion bounding box through this method
  154747. * @param mesh Define the mesh to render the occlusion bounding box for
  154748. */
  154749. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  154750. /**
  154751. * Dispose and release the resources attached to this renderer.
  154752. */
  154753. dispose(): void;
  154754. }
  154755. }
  154756. declare module BABYLON {
  154757. interface Scene {
  154758. /** @hidden (Backing field) */
  154759. _depthRenderer: {
  154760. [id: string]: DepthRenderer;
  154761. };
  154762. /**
  154763. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  154764. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  154765. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  154766. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  154767. * @returns the created depth renderer
  154768. */
  154769. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  154770. /**
  154771. * Disables a depth renderer for a given camera
  154772. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  154773. */
  154774. disableDepthRenderer(camera?: Nullable<Camera>): void;
  154775. }
  154776. /**
  154777. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  154778. * in several rendering techniques.
  154779. */
  154780. export class DepthRendererSceneComponent implements ISceneComponent {
  154781. /**
  154782. * The component name helpfull to identify the component in the list of scene components.
  154783. */
  154784. readonly name: string;
  154785. /**
  154786. * The scene the component belongs to.
  154787. */
  154788. scene: Scene;
  154789. /**
  154790. * Creates a new instance of the component for the given scene
  154791. * @param scene Defines the scene to register the component in
  154792. */
  154793. constructor(scene: Scene);
  154794. /**
  154795. * Registers the component in a given scene
  154796. */
  154797. register(): void;
  154798. /**
  154799. * Rebuilds the elements related to this component in case of
  154800. * context lost for instance.
  154801. */
  154802. rebuild(): void;
  154803. /**
  154804. * Disposes the component and the associated ressources
  154805. */
  154806. dispose(): void;
  154807. private _gatherRenderTargets;
  154808. private _gatherActiveCameraRenderTargets;
  154809. }
  154810. }
  154811. declare module BABYLON {
  154812. interface AbstractScene {
  154813. /** @hidden (Backing field) */
  154814. _prePassRenderer: Nullable<PrePassRenderer>;
  154815. /**
  154816. * Gets or Sets the current prepass renderer associated to the scene.
  154817. */
  154818. prePassRenderer: Nullable<PrePassRenderer>;
  154819. /**
  154820. * Enables the prepass and associates it with the scene
  154821. * @returns the PrePassRenderer
  154822. */
  154823. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  154824. /**
  154825. * Disables the prepass associated with the scene
  154826. */
  154827. disablePrePassRenderer(): void;
  154828. }
  154829. /**
  154830. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  154831. * in several rendering techniques.
  154832. */
  154833. export class PrePassRendererSceneComponent implements ISceneComponent {
  154834. /**
  154835. * The component name helpful to identify the component in the list of scene components.
  154836. */
  154837. readonly name: string;
  154838. /**
  154839. * The scene the component belongs to.
  154840. */
  154841. scene: Scene;
  154842. /**
  154843. * Creates a new instance of the component for the given scene
  154844. * @param scene Defines the scene to register the component in
  154845. */
  154846. constructor(scene: Scene);
  154847. /**
  154848. * Registers the component in a given scene
  154849. */
  154850. register(): void;
  154851. private _beforeCameraDraw;
  154852. private _afterCameraDraw;
  154853. private _beforeClearStage;
  154854. /**
  154855. * Rebuilds the elements related to this component in case of
  154856. * context lost for instance.
  154857. */
  154858. rebuild(): void;
  154859. /**
  154860. * Disposes the component and the associated ressources
  154861. */
  154862. dispose(): void;
  154863. }
  154864. }
  154865. declare module BABYLON {
  154866. /** @hidden */
  154867. export var fibonacci: {
  154868. name: string;
  154869. shader: string;
  154870. };
  154871. }
  154872. declare module BABYLON {
  154873. /** @hidden */
  154874. export var diffusionProfile: {
  154875. name: string;
  154876. shader: string;
  154877. };
  154878. }
  154879. declare module BABYLON {
  154880. /** @hidden */
  154881. export var subSurfaceScatteringPixelShader: {
  154882. name: string;
  154883. shader: string;
  154884. };
  154885. }
  154886. declare module BABYLON {
  154887. /**
  154888. * Sub surface scattering post process
  154889. */
  154890. export class SubSurfaceScatteringPostProcess extends PostProcess {
  154891. /**
  154892. * Gets a string identifying the name of the class
  154893. * @returns "SubSurfaceScatteringPostProcess" string
  154894. */
  154895. getClassName(): string;
  154896. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  154897. }
  154898. }
  154899. declare module BABYLON {
  154900. /**
  154901. * Contains all parameters needed for the prepass to perform
  154902. * screen space subsurface scattering
  154903. */
  154904. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  154905. /** @hidden */
  154906. static _SceneComponentInitialization: (scene: Scene) => void;
  154907. private _ssDiffusionS;
  154908. private _ssFilterRadii;
  154909. private _ssDiffusionD;
  154910. /**
  154911. * Post process to attach for screen space subsurface scattering
  154912. */
  154913. postProcess: SubSurfaceScatteringPostProcess;
  154914. /**
  154915. * Diffusion profile color for subsurface scattering
  154916. */
  154917. get ssDiffusionS(): number[];
  154918. /**
  154919. * Diffusion profile max color channel value for subsurface scattering
  154920. */
  154921. get ssDiffusionD(): number[];
  154922. /**
  154923. * Diffusion profile filter radius for subsurface scattering
  154924. */
  154925. get ssFilterRadii(): number[];
  154926. /**
  154927. * Is subsurface enabled
  154928. */
  154929. enabled: boolean;
  154930. /**
  154931. * Name of the configuration
  154932. */
  154933. name: string;
  154934. /**
  154935. * Diffusion profile colors for subsurface scattering
  154936. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  154937. * See ...
  154938. * Note that you can only store up to 5 of them
  154939. */
  154940. ssDiffusionProfileColors: Color3[];
  154941. /**
  154942. * Defines the ratio real world => scene units.
  154943. * Used for subsurface scattering
  154944. */
  154945. metersPerUnit: number;
  154946. /**
  154947. * Textures that should be present in the MRT for this effect to work
  154948. */
  154949. readonly texturesRequired: number[];
  154950. private _scene;
  154951. /**
  154952. * Builds a subsurface configuration object
  154953. * @param scene The scene
  154954. */
  154955. constructor(scene: Scene);
  154956. /**
  154957. * Adds a new diffusion profile.
  154958. * Useful for more realistic subsurface scattering on diverse materials.
  154959. * @param color The color of the diffusion profile. Should be the average color of the material.
  154960. * @return The index of the diffusion profile for the material subsurface configuration
  154961. */
  154962. addDiffusionProfile(color: Color3): number;
  154963. /**
  154964. * Creates the sss post process
  154965. * @return The created post process
  154966. */
  154967. createPostProcess(): SubSurfaceScatteringPostProcess;
  154968. /**
  154969. * Deletes all diffusion profiles.
  154970. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  154971. */
  154972. clearAllDiffusionProfiles(): void;
  154973. /**
  154974. * Disposes this object
  154975. */
  154976. dispose(): void;
  154977. /**
  154978. * @hidden
  154979. * https://zero-radiance.github.io/post/sampling-diffusion/
  154980. *
  154981. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  154982. * ------------------------------------------------------------------------------------
  154983. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  154984. * PDF[r, phi, s] = r * R[r, phi, s]
  154985. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  154986. * ------------------------------------------------------------------------------------
  154987. * We importance sample the color channel with the widest scattering distance.
  154988. */
  154989. getDiffusionProfileParameters(color: Color3): number;
  154990. /**
  154991. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  154992. * 'u' is the random number (the value of the CDF): [0, 1).
  154993. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  154994. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  154995. */
  154996. private _sampleBurleyDiffusionProfile;
  154997. }
  154998. }
  154999. declare module BABYLON {
  155000. interface AbstractScene {
  155001. /** @hidden (Backing field) */
  155002. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  155003. /**
  155004. * Gets or Sets the current prepass renderer associated to the scene.
  155005. */
  155006. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  155007. /**
  155008. * Enables the subsurface effect for prepass
  155009. * @returns the SubSurfaceConfiguration
  155010. */
  155011. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  155012. /**
  155013. * Disables the subsurface effect for prepass
  155014. */
  155015. disableSubSurfaceForPrePass(): void;
  155016. }
  155017. /**
  155018. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  155019. * in several rendering techniques.
  155020. */
  155021. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  155022. /**
  155023. * The component name helpful to identify the component in the list of scene components.
  155024. */
  155025. readonly name: string;
  155026. /**
  155027. * The scene the component belongs to.
  155028. */
  155029. scene: Scene;
  155030. /**
  155031. * Creates a new instance of the component for the given scene
  155032. * @param scene Defines the scene to register the component in
  155033. */
  155034. constructor(scene: Scene);
  155035. /**
  155036. * Registers the component in a given scene
  155037. */
  155038. register(): void;
  155039. /**
  155040. * Serializes the component data to the specified json object
  155041. * @param serializationObject The object to serialize to
  155042. */
  155043. serialize(serializationObject: any): void;
  155044. /**
  155045. * Adds all the elements from the container to the scene
  155046. * @param container the container holding the elements
  155047. */
  155048. addFromContainer(container: AbstractScene): void;
  155049. /**
  155050. * Removes all the elements in the container from the scene
  155051. * @param container contains the elements to remove
  155052. * @param dispose if the removed element should be disposed (default: false)
  155053. */
  155054. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  155055. /**
  155056. * Rebuilds the elements related to this component in case of
  155057. * context lost for instance.
  155058. */
  155059. rebuild(): void;
  155060. /**
  155061. * Disposes the component and the associated ressources
  155062. */
  155063. dispose(): void;
  155064. }
  155065. }
  155066. declare module BABYLON {
  155067. /** @hidden */
  155068. export var outlinePixelShader: {
  155069. name: string;
  155070. shader: string;
  155071. };
  155072. }
  155073. declare module BABYLON {
  155074. /** @hidden */
  155075. export var outlineVertexShader: {
  155076. name: string;
  155077. shader: string;
  155078. };
  155079. }
  155080. declare module BABYLON {
  155081. interface Scene {
  155082. /** @hidden */
  155083. _outlineRenderer: OutlineRenderer;
  155084. /**
  155085. * Gets the outline renderer associated with the scene
  155086. * @returns a OutlineRenderer
  155087. */
  155088. getOutlineRenderer(): OutlineRenderer;
  155089. }
  155090. interface AbstractMesh {
  155091. /** @hidden (Backing field) */
  155092. _renderOutline: boolean;
  155093. /**
  155094. * Gets or sets a boolean indicating if the outline must be rendered as well
  155095. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  155096. */
  155097. renderOutline: boolean;
  155098. /** @hidden (Backing field) */
  155099. _renderOverlay: boolean;
  155100. /**
  155101. * Gets or sets a boolean indicating if the overlay must be rendered as well
  155102. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  155103. */
  155104. renderOverlay: boolean;
  155105. }
  155106. /**
  155107. * This class is responsible to draw bothe outline/overlay of meshes.
  155108. * It should not be used directly but through the available method on mesh.
  155109. */
  155110. export class OutlineRenderer implements ISceneComponent {
  155111. /**
  155112. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  155113. */
  155114. private static _StencilReference;
  155115. /**
  155116. * The name of the component. Each component must have a unique name.
  155117. */
  155118. name: string;
  155119. /**
  155120. * The scene the component belongs to.
  155121. */
  155122. scene: Scene;
  155123. /**
  155124. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  155125. */
  155126. zOffset: number;
  155127. private _engine;
  155128. private _effect;
  155129. private _cachedDefines;
  155130. private _savedDepthWrite;
  155131. /**
  155132. * Instantiates a new outline renderer. (There could be only one per scene).
  155133. * @param scene Defines the scene it belongs to
  155134. */
  155135. constructor(scene: Scene);
  155136. /**
  155137. * Register the component to one instance of a scene.
  155138. */
  155139. register(): void;
  155140. /**
  155141. * Rebuilds the elements related to this component in case of
  155142. * context lost for instance.
  155143. */
  155144. rebuild(): void;
  155145. /**
  155146. * Disposes the component and the associated ressources.
  155147. */
  155148. dispose(): void;
  155149. /**
  155150. * Renders the outline in the canvas.
  155151. * @param subMesh Defines the sumesh to render
  155152. * @param batch Defines the batch of meshes in case of instances
  155153. * @param useOverlay Defines if the rendering is for the overlay or the outline
  155154. */
  155155. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  155156. /**
  155157. * Returns whether or not the outline renderer is ready for a given submesh.
  155158. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  155159. * @param subMesh Defines the submesh to check readyness for
  155160. * @param useInstances Defines wheter wee are trying to render instances or not
  155161. * @returns true if ready otherwise false
  155162. */
  155163. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  155164. private _beforeRenderingMesh;
  155165. private _afterRenderingMesh;
  155166. }
  155167. }
  155168. declare module BABYLON {
  155169. /**
  155170. * Defines the basic options interface of a Sprite Frame Source Size.
  155171. */
  155172. export interface ISpriteJSONSpriteSourceSize {
  155173. /**
  155174. * number of the original width of the Frame
  155175. */
  155176. w: number;
  155177. /**
  155178. * number of the original height of the Frame
  155179. */
  155180. h: number;
  155181. }
  155182. /**
  155183. * Defines the basic options interface of a Sprite Frame Data.
  155184. */
  155185. export interface ISpriteJSONSpriteFrameData {
  155186. /**
  155187. * number of the x offset of the Frame
  155188. */
  155189. x: number;
  155190. /**
  155191. * number of the y offset of the Frame
  155192. */
  155193. y: number;
  155194. /**
  155195. * number of the width of the Frame
  155196. */
  155197. w: number;
  155198. /**
  155199. * number of the height of the Frame
  155200. */
  155201. h: number;
  155202. }
  155203. /**
  155204. * Defines the basic options interface of a JSON Sprite.
  155205. */
  155206. export interface ISpriteJSONSprite {
  155207. /**
  155208. * string name of the Frame
  155209. */
  155210. filename: string;
  155211. /**
  155212. * ISpriteJSONSpriteFrame basic object of the frame data
  155213. */
  155214. frame: ISpriteJSONSpriteFrameData;
  155215. /**
  155216. * boolean to flag is the frame was rotated.
  155217. */
  155218. rotated: boolean;
  155219. /**
  155220. * boolean to flag is the frame was trimmed.
  155221. */
  155222. trimmed: boolean;
  155223. /**
  155224. * ISpriteJSONSpriteFrame basic object of the source data
  155225. */
  155226. spriteSourceSize: ISpriteJSONSpriteFrameData;
  155227. /**
  155228. * ISpriteJSONSpriteFrame basic object of the source data
  155229. */
  155230. sourceSize: ISpriteJSONSpriteSourceSize;
  155231. }
  155232. /**
  155233. * Defines the basic options interface of a JSON atlas.
  155234. */
  155235. export interface ISpriteJSONAtlas {
  155236. /**
  155237. * Array of objects that contain the frame data.
  155238. */
  155239. frames: Array<ISpriteJSONSprite>;
  155240. /**
  155241. * object basic object containing the sprite meta data.
  155242. */
  155243. meta?: object;
  155244. }
  155245. }
  155246. declare module BABYLON {
  155247. /** @hidden */
  155248. export var spriteMapPixelShader: {
  155249. name: string;
  155250. shader: string;
  155251. };
  155252. }
  155253. declare module BABYLON {
  155254. /** @hidden */
  155255. export var spriteMapVertexShader: {
  155256. name: string;
  155257. shader: string;
  155258. };
  155259. }
  155260. declare module BABYLON {
  155261. /**
  155262. * Defines the basic options interface of a SpriteMap
  155263. */
  155264. export interface ISpriteMapOptions {
  155265. /**
  155266. * Vector2 of the number of cells in the grid.
  155267. */
  155268. stageSize?: Vector2;
  155269. /**
  155270. * Vector2 of the size of the output plane in World Units.
  155271. */
  155272. outputSize?: Vector2;
  155273. /**
  155274. * Vector3 of the position of the output plane in World Units.
  155275. */
  155276. outputPosition?: Vector3;
  155277. /**
  155278. * Vector3 of the rotation of the output plane.
  155279. */
  155280. outputRotation?: Vector3;
  155281. /**
  155282. * number of layers that the system will reserve in resources.
  155283. */
  155284. layerCount?: number;
  155285. /**
  155286. * number of max animation frames a single cell will reserve in resources.
  155287. */
  155288. maxAnimationFrames?: number;
  155289. /**
  155290. * number cell index of the base tile when the system compiles.
  155291. */
  155292. baseTile?: number;
  155293. /**
  155294. * boolean flip the sprite after its been repositioned by the framing data.
  155295. */
  155296. flipU?: boolean;
  155297. /**
  155298. * Vector3 scalar of the global RGB values of the SpriteMap.
  155299. */
  155300. colorMultiply?: Vector3;
  155301. }
  155302. /**
  155303. * Defines the IDisposable interface in order to be cleanable from resources.
  155304. */
  155305. export interface ISpriteMap extends IDisposable {
  155306. /**
  155307. * String name of the SpriteMap.
  155308. */
  155309. name: string;
  155310. /**
  155311. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  155312. */
  155313. atlasJSON: ISpriteJSONAtlas;
  155314. /**
  155315. * Texture of the SpriteMap.
  155316. */
  155317. spriteSheet: Texture;
  155318. /**
  155319. * The parameters to initialize the SpriteMap with.
  155320. */
  155321. options: ISpriteMapOptions;
  155322. }
  155323. /**
  155324. * Class used to manage a grid restricted sprite deployment on an Output plane.
  155325. */
  155326. export class SpriteMap implements ISpriteMap {
  155327. /** The Name of the spriteMap */
  155328. name: string;
  155329. /** The JSON file with the frame and meta data */
  155330. atlasJSON: ISpriteJSONAtlas;
  155331. /** The systems Sprite Sheet Texture */
  155332. spriteSheet: Texture;
  155333. /** Arguments passed with the Constructor */
  155334. options: ISpriteMapOptions;
  155335. /** Public Sprite Storage array, parsed from atlasJSON */
  155336. sprites: Array<ISpriteJSONSprite>;
  155337. /** Returns the Number of Sprites in the System */
  155338. get spriteCount(): number;
  155339. /** Returns the Position of Output Plane*/
  155340. get position(): Vector3;
  155341. /** Returns the Position of Output Plane*/
  155342. set position(v: Vector3);
  155343. /** Returns the Rotation of Output Plane*/
  155344. get rotation(): Vector3;
  155345. /** Returns the Rotation of Output Plane*/
  155346. set rotation(v: Vector3);
  155347. /** Sets the AnimationMap*/
  155348. get animationMap(): RawTexture;
  155349. /** Sets the AnimationMap*/
  155350. set animationMap(v: RawTexture);
  155351. /** Scene that the SpriteMap was created in */
  155352. private _scene;
  155353. /** Texture Buffer of Float32 that holds tile frame data*/
  155354. private _frameMap;
  155355. /** Texture Buffers of Float32 that holds tileMap data*/
  155356. private _tileMaps;
  155357. /** Texture Buffer of Float32 that holds Animation Data*/
  155358. private _animationMap;
  155359. /** Custom ShaderMaterial Central to the System*/
  155360. private _material;
  155361. /** Custom ShaderMaterial Central to the System*/
  155362. private _output;
  155363. /** Systems Time Ticker*/
  155364. private _time;
  155365. /**
  155366. * Creates a new SpriteMap
  155367. * @param name defines the SpriteMaps Name
  155368. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  155369. * @param spriteSheet is the Texture that the Sprites are on.
  155370. * @param options a basic deployment configuration
  155371. * @param scene The Scene that the map is deployed on
  155372. */
  155373. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  155374. /**
  155375. * Returns tileID location
  155376. * @returns Vector2 the cell position ID
  155377. */
  155378. getTileID(): Vector2;
  155379. /**
  155380. * Gets the UV location of the mouse over the SpriteMap.
  155381. * @returns Vector2 the UV position of the mouse interaction
  155382. */
  155383. getMousePosition(): Vector2;
  155384. /**
  155385. * Creates the "frame" texture Buffer
  155386. * -------------------------------------
  155387. * Structure of frames
  155388. * "filename": "Falling-Water-2.png",
  155389. * "frame": {"x":69,"y":103,"w":24,"h":32},
  155390. * "rotated": true,
  155391. * "trimmed": true,
  155392. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  155393. * "sourceSize": {"w":32,"h":32}
  155394. * @returns RawTexture of the frameMap
  155395. */
  155396. private _createFrameBuffer;
  155397. /**
  155398. * Creates the tileMap texture Buffer
  155399. * @param buffer normally and array of numbers, or a false to generate from scratch
  155400. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  155401. * @returns RawTexture of the tileMap
  155402. */
  155403. private _createTileBuffer;
  155404. /**
  155405. * Modifies the data of the tileMaps
  155406. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  155407. * @param pos is the iVector2 Coordinates of the Tile
  155408. * @param tile The SpriteIndex of the new Tile
  155409. */
  155410. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  155411. /**
  155412. * Creates the animationMap texture Buffer
  155413. * @param buffer normally and array of numbers, or a false to generate from scratch
  155414. * @returns RawTexture of the animationMap
  155415. */
  155416. private _createTileAnimationBuffer;
  155417. /**
  155418. * Modifies the data of the animationMap
  155419. * @param cellID is the Index of the Sprite
  155420. * @param _frame is the target Animation frame
  155421. * @param toCell is the Target Index of the next frame of the animation
  155422. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  155423. * @param speed is a global scalar of the time variable on the map.
  155424. */
  155425. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  155426. /**
  155427. * Exports the .tilemaps file
  155428. */
  155429. saveTileMaps(): void;
  155430. /**
  155431. * Imports the .tilemaps file
  155432. * @param url of the .tilemaps file
  155433. */
  155434. loadTileMaps(url: string): void;
  155435. /**
  155436. * Release associated resources
  155437. */
  155438. dispose(): void;
  155439. }
  155440. }
  155441. declare module BABYLON {
  155442. /**
  155443. * Class used to manage multiple sprites of different sizes on the same spritesheet
  155444. * @see https://doc.babylonjs.com/babylon101/sprites
  155445. */
  155446. export class SpritePackedManager extends SpriteManager {
  155447. /** defines the packed manager's name */
  155448. name: string;
  155449. /**
  155450. * Creates a new sprite manager from a packed sprite sheet
  155451. * @param name defines the manager's name
  155452. * @param imgUrl defines the sprite sheet url
  155453. * @param capacity defines the maximum allowed number of sprites
  155454. * @param scene defines the hosting scene
  155455. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  155456. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  155457. * @param samplingMode defines the smapling mode to use with spritesheet
  155458. * @param fromPacked set to true; do not alter
  155459. */
  155460. constructor(
  155461. /** defines the packed manager's name */
  155462. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  155463. }
  155464. }
  155465. declare module BABYLON {
  155466. /**
  155467. * Defines the list of states available for a task inside a AssetsManager
  155468. */
  155469. export enum AssetTaskState {
  155470. /**
  155471. * Initialization
  155472. */
  155473. INIT = 0,
  155474. /**
  155475. * Running
  155476. */
  155477. RUNNING = 1,
  155478. /**
  155479. * Done
  155480. */
  155481. DONE = 2,
  155482. /**
  155483. * Error
  155484. */
  155485. ERROR = 3
  155486. }
  155487. /**
  155488. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  155489. */
  155490. export abstract class AbstractAssetTask {
  155491. /**
  155492. * Task name
  155493. */ name: string;
  155494. /**
  155495. * Callback called when the task is successful
  155496. */
  155497. onSuccess: (task: any) => void;
  155498. /**
  155499. * Callback called when the task is not successful
  155500. */
  155501. onError: (task: any, message?: string, exception?: any) => void;
  155502. /**
  155503. * Creates a new AssetsManager
  155504. * @param name defines the name of the task
  155505. */
  155506. constructor(
  155507. /**
  155508. * Task name
  155509. */ name: string);
  155510. private _isCompleted;
  155511. private _taskState;
  155512. private _errorObject;
  155513. /**
  155514. * Get if the task is completed
  155515. */
  155516. get isCompleted(): boolean;
  155517. /**
  155518. * Gets the current state of the task
  155519. */
  155520. get taskState(): AssetTaskState;
  155521. /**
  155522. * Gets the current error object (if task is in error)
  155523. */
  155524. get errorObject(): {
  155525. message?: string;
  155526. exception?: any;
  155527. };
  155528. /**
  155529. * Internal only
  155530. * @hidden
  155531. */
  155532. _setErrorObject(message?: string, exception?: any): void;
  155533. /**
  155534. * Execute the current task
  155535. * @param scene defines the scene where you want your assets to be loaded
  155536. * @param onSuccess is a callback called when the task is successfully executed
  155537. * @param onError is a callback called if an error occurs
  155538. */
  155539. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155540. /**
  155541. * Execute the current task
  155542. * @param scene defines the scene where you want your assets to be loaded
  155543. * @param onSuccess is a callback called when the task is successfully executed
  155544. * @param onError is a callback called if an error occurs
  155545. */
  155546. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155547. /**
  155548. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  155549. * This can be used with failed tasks that have the reason for failure fixed.
  155550. */
  155551. reset(): void;
  155552. private onErrorCallback;
  155553. private onDoneCallback;
  155554. }
  155555. /**
  155556. * Define the interface used by progress events raised during assets loading
  155557. */
  155558. export interface IAssetsProgressEvent {
  155559. /**
  155560. * Defines the number of remaining tasks to process
  155561. */
  155562. remainingCount: number;
  155563. /**
  155564. * Defines the total number of tasks
  155565. */
  155566. totalCount: number;
  155567. /**
  155568. * Defines the task that was just processed
  155569. */
  155570. task: AbstractAssetTask;
  155571. }
  155572. /**
  155573. * Class used to share progress information about assets loading
  155574. */
  155575. export class AssetsProgressEvent implements IAssetsProgressEvent {
  155576. /**
  155577. * Defines the number of remaining tasks to process
  155578. */
  155579. remainingCount: number;
  155580. /**
  155581. * Defines the total number of tasks
  155582. */
  155583. totalCount: number;
  155584. /**
  155585. * Defines the task that was just processed
  155586. */
  155587. task: AbstractAssetTask;
  155588. /**
  155589. * Creates a AssetsProgressEvent
  155590. * @param remainingCount defines the number of remaining tasks to process
  155591. * @param totalCount defines the total number of tasks
  155592. * @param task defines the task that was just processed
  155593. */
  155594. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  155595. }
  155596. /**
  155597. * Define a task used by AssetsManager to load assets into a container
  155598. */
  155599. export class ContainerAssetTask extends AbstractAssetTask {
  155600. /**
  155601. * Defines the name of the task
  155602. */
  155603. name: string;
  155604. /**
  155605. * Defines the list of mesh's names you want to load
  155606. */
  155607. meshesNames: any;
  155608. /**
  155609. * Defines the root url to use as a base to load your meshes and associated resources
  155610. */
  155611. rootUrl: string;
  155612. /**
  155613. * Defines the filename or File of the scene to load from
  155614. */
  155615. sceneFilename: string | File;
  155616. /**
  155617. * Get the loaded asset container
  155618. */
  155619. loadedContainer: AssetContainer;
  155620. /**
  155621. * Gets the list of loaded meshes
  155622. */
  155623. loadedMeshes: Array<AbstractMesh>;
  155624. /**
  155625. * Gets the list of loaded particle systems
  155626. */
  155627. loadedParticleSystems: Array<IParticleSystem>;
  155628. /**
  155629. * Gets the list of loaded skeletons
  155630. */
  155631. loadedSkeletons: Array<Skeleton>;
  155632. /**
  155633. * Gets the list of loaded animation groups
  155634. */
  155635. loadedAnimationGroups: Array<AnimationGroup>;
  155636. /**
  155637. * Callback called when the task is successful
  155638. */
  155639. onSuccess: (task: ContainerAssetTask) => void;
  155640. /**
  155641. * Callback called when the task is successful
  155642. */
  155643. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  155644. /**
  155645. * Creates a new ContainerAssetTask
  155646. * @param name defines the name of the task
  155647. * @param meshesNames defines the list of mesh's names you want to load
  155648. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155649. * @param sceneFilename defines the filename or File of the scene to load from
  155650. */
  155651. constructor(
  155652. /**
  155653. * Defines the name of the task
  155654. */
  155655. name: string,
  155656. /**
  155657. * Defines the list of mesh's names you want to load
  155658. */
  155659. meshesNames: any,
  155660. /**
  155661. * Defines the root url to use as a base to load your meshes and associated resources
  155662. */
  155663. rootUrl: string,
  155664. /**
  155665. * Defines the filename or File of the scene to load from
  155666. */
  155667. sceneFilename: string | File);
  155668. /**
  155669. * Execute the current task
  155670. * @param scene defines the scene where you want your assets to be loaded
  155671. * @param onSuccess is a callback called when the task is successfully executed
  155672. * @param onError is a callback called if an error occurs
  155673. */
  155674. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155675. }
  155676. /**
  155677. * Define a task used by AssetsManager to load meshes
  155678. */
  155679. export class MeshAssetTask extends AbstractAssetTask {
  155680. /**
  155681. * Defines the name of the task
  155682. */
  155683. name: string;
  155684. /**
  155685. * Defines the list of mesh's names you want to load
  155686. */
  155687. meshesNames: any;
  155688. /**
  155689. * Defines the root url to use as a base to load your meshes and associated resources
  155690. */
  155691. rootUrl: string;
  155692. /**
  155693. * Defines the filename or File of the scene to load from
  155694. */
  155695. sceneFilename: string | File;
  155696. /**
  155697. * Gets the list of loaded meshes
  155698. */
  155699. loadedMeshes: Array<AbstractMesh>;
  155700. /**
  155701. * Gets the list of loaded particle systems
  155702. */
  155703. loadedParticleSystems: Array<IParticleSystem>;
  155704. /**
  155705. * Gets the list of loaded skeletons
  155706. */
  155707. loadedSkeletons: Array<Skeleton>;
  155708. /**
  155709. * Gets the list of loaded animation groups
  155710. */
  155711. loadedAnimationGroups: Array<AnimationGroup>;
  155712. /**
  155713. * Callback called when the task is successful
  155714. */
  155715. onSuccess: (task: MeshAssetTask) => void;
  155716. /**
  155717. * Callback called when the task is successful
  155718. */
  155719. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  155720. /**
  155721. * Creates a new MeshAssetTask
  155722. * @param name defines the name of the task
  155723. * @param meshesNames defines the list of mesh's names you want to load
  155724. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155725. * @param sceneFilename defines the filename or File of the scene to load from
  155726. */
  155727. constructor(
  155728. /**
  155729. * Defines the name of the task
  155730. */
  155731. name: string,
  155732. /**
  155733. * Defines the list of mesh's names you want to load
  155734. */
  155735. meshesNames: any,
  155736. /**
  155737. * Defines the root url to use as a base to load your meshes and associated resources
  155738. */
  155739. rootUrl: string,
  155740. /**
  155741. * Defines the filename or File of the scene to load from
  155742. */
  155743. sceneFilename: string | File);
  155744. /**
  155745. * Execute the current task
  155746. * @param scene defines the scene where you want your assets to be loaded
  155747. * @param onSuccess is a callback called when the task is successfully executed
  155748. * @param onError is a callback called if an error occurs
  155749. */
  155750. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155751. }
  155752. /**
  155753. * Define a task used by AssetsManager to load text content
  155754. */
  155755. export class TextFileAssetTask extends AbstractAssetTask {
  155756. /**
  155757. * Defines the name of the task
  155758. */
  155759. name: string;
  155760. /**
  155761. * Defines the location of the file to load
  155762. */
  155763. url: string;
  155764. /**
  155765. * Gets the loaded text string
  155766. */
  155767. text: string;
  155768. /**
  155769. * Callback called when the task is successful
  155770. */
  155771. onSuccess: (task: TextFileAssetTask) => void;
  155772. /**
  155773. * Callback called when the task is successful
  155774. */
  155775. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  155776. /**
  155777. * Creates a new TextFileAssetTask object
  155778. * @param name defines the name of the task
  155779. * @param url defines the location of the file to load
  155780. */
  155781. constructor(
  155782. /**
  155783. * Defines the name of the task
  155784. */
  155785. name: string,
  155786. /**
  155787. * Defines the location of the file to load
  155788. */
  155789. url: string);
  155790. /**
  155791. * Execute the current task
  155792. * @param scene defines the scene where you want your assets to be loaded
  155793. * @param onSuccess is a callback called when the task is successfully executed
  155794. * @param onError is a callback called if an error occurs
  155795. */
  155796. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155797. }
  155798. /**
  155799. * Define a task used by AssetsManager to load binary data
  155800. */
  155801. export class BinaryFileAssetTask extends AbstractAssetTask {
  155802. /**
  155803. * Defines the name of the task
  155804. */
  155805. name: string;
  155806. /**
  155807. * Defines the location of the file to load
  155808. */
  155809. url: string;
  155810. /**
  155811. * Gets the lodaded data (as an array buffer)
  155812. */
  155813. data: ArrayBuffer;
  155814. /**
  155815. * Callback called when the task is successful
  155816. */
  155817. onSuccess: (task: BinaryFileAssetTask) => void;
  155818. /**
  155819. * Callback called when the task is successful
  155820. */
  155821. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  155822. /**
  155823. * Creates a new BinaryFileAssetTask object
  155824. * @param name defines the name of the new task
  155825. * @param url defines the location of the file to load
  155826. */
  155827. constructor(
  155828. /**
  155829. * Defines the name of the task
  155830. */
  155831. name: string,
  155832. /**
  155833. * Defines the location of the file to load
  155834. */
  155835. url: string);
  155836. /**
  155837. * Execute the current task
  155838. * @param scene defines the scene where you want your assets to be loaded
  155839. * @param onSuccess is a callback called when the task is successfully executed
  155840. * @param onError is a callback called if an error occurs
  155841. */
  155842. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155843. }
  155844. /**
  155845. * Define a task used by AssetsManager to load images
  155846. */
  155847. export class ImageAssetTask extends AbstractAssetTask {
  155848. /**
  155849. * Defines the name of the task
  155850. */
  155851. name: string;
  155852. /**
  155853. * Defines the location of the image to load
  155854. */
  155855. url: string;
  155856. /**
  155857. * Gets the loaded images
  155858. */
  155859. image: HTMLImageElement;
  155860. /**
  155861. * Callback called when the task is successful
  155862. */
  155863. onSuccess: (task: ImageAssetTask) => void;
  155864. /**
  155865. * Callback called when the task is successful
  155866. */
  155867. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  155868. /**
  155869. * Creates a new ImageAssetTask
  155870. * @param name defines the name of the task
  155871. * @param url defines the location of the image to load
  155872. */
  155873. constructor(
  155874. /**
  155875. * Defines the name of the task
  155876. */
  155877. name: string,
  155878. /**
  155879. * Defines the location of the image to load
  155880. */
  155881. url: string);
  155882. /**
  155883. * Execute the current task
  155884. * @param scene defines the scene where you want your assets to be loaded
  155885. * @param onSuccess is a callback called when the task is successfully executed
  155886. * @param onError is a callback called if an error occurs
  155887. */
  155888. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155889. }
  155890. /**
  155891. * Defines the interface used by texture loading tasks
  155892. */
  155893. export interface ITextureAssetTask<TEX extends BaseTexture> {
  155894. /**
  155895. * Gets the loaded texture
  155896. */
  155897. texture: TEX;
  155898. }
  155899. /**
  155900. * Define a task used by AssetsManager to load 2D textures
  155901. */
  155902. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  155903. /**
  155904. * Defines the name of the task
  155905. */
  155906. name: string;
  155907. /**
  155908. * Defines the location of the file to load
  155909. */
  155910. url: string;
  155911. /**
  155912. * Defines if mipmap should not be generated (default is false)
  155913. */
  155914. noMipmap?: boolean | undefined;
  155915. /**
  155916. * Defines if texture must be inverted on Y axis (default is true)
  155917. */
  155918. invertY: boolean;
  155919. /**
  155920. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155921. */
  155922. samplingMode: number;
  155923. /**
  155924. * Gets the loaded texture
  155925. */
  155926. texture: Texture;
  155927. /**
  155928. * Callback called when the task is successful
  155929. */
  155930. onSuccess: (task: TextureAssetTask) => void;
  155931. /**
  155932. * Callback called when the task is successful
  155933. */
  155934. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  155935. /**
  155936. * Creates a new TextureAssetTask object
  155937. * @param name defines the name of the task
  155938. * @param url defines the location of the file to load
  155939. * @param noMipmap defines if mipmap should not be generated (default is false)
  155940. * @param invertY defines if texture must be inverted on Y axis (default is true)
  155941. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155942. */
  155943. constructor(
  155944. /**
  155945. * Defines the name of the task
  155946. */
  155947. name: string,
  155948. /**
  155949. * Defines the location of the file to load
  155950. */
  155951. url: string,
  155952. /**
  155953. * Defines if mipmap should not be generated (default is false)
  155954. */
  155955. noMipmap?: boolean | undefined,
  155956. /**
  155957. * Defines if texture must be inverted on Y axis (default is true)
  155958. */
  155959. invertY?: boolean,
  155960. /**
  155961. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155962. */
  155963. samplingMode?: number);
  155964. /**
  155965. * Execute the current task
  155966. * @param scene defines the scene where you want your assets to be loaded
  155967. * @param onSuccess is a callback called when the task is successfully executed
  155968. * @param onError is a callback called if an error occurs
  155969. */
  155970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155971. }
  155972. /**
  155973. * Define a task used by AssetsManager to load cube textures
  155974. */
  155975. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  155976. /**
  155977. * Defines the name of the task
  155978. */
  155979. name: string;
  155980. /**
  155981. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155982. */
  155983. url: string;
  155984. /**
  155985. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155986. */
  155987. extensions?: string[] | undefined;
  155988. /**
  155989. * Defines if mipmaps should not be generated (default is false)
  155990. */
  155991. noMipmap?: boolean | undefined;
  155992. /**
  155993. * Defines the explicit list of files (undefined by default)
  155994. */
  155995. files?: string[] | undefined;
  155996. /**
  155997. * Gets the loaded texture
  155998. */
  155999. texture: CubeTexture;
  156000. /**
  156001. * Callback called when the task is successful
  156002. */
  156003. onSuccess: (task: CubeTextureAssetTask) => void;
  156004. /**
  156005. * Callback called when the task is successful
  156006. */
  156007. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  156008. /**
  156009. * Creates a new CubeTextureAssetTask
  156010. * @param name defines the name of the task
  156011. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  156012. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  156013. * @param noMipmap defines if mipmaps should not be generated (default is false)
  156014. * @param files defines the explicit list of files (undefined by default)
  156015. */
  156016. constructor(
  156017. /**
  156018. * Defines the name of the task
  156019. */
  156020. name: string,
  156021. /**
  156022. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  156023. */
  156024. url: string,
  156025. /**
  156026. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  156027. */
  156028. extensions?: string[] | undefined,
  156029. /**
  156030. * Defines if mipmaps should not be generated (default is false)
  156031. */
  156032. noMipmap?: boolean | undefined,
  156033. /**
  156034. * Defines the explicit list of files (undefined by default)
  156035. */
  156036. files?: string[] | undefined);
  156037. /**
  156038. * Execute the current task
  156039. * @param scene defines the scene where you want your assets to be loaded
  156040. * @param onSuccess is a callback called when the task is successfully executed
  156041. * @param onError is a callback called if an error occurs
  156042. */
  156043. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156044. }
  156045. /**
  156046. * Define a task used by AssetsManager to load HDR cube textures
  156047. */
  156048. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  156049. /**
  156050. * Defines the name of the task
  156051. */
  156052. name: string;
  156053. /**
  156054. * Defines the location of the file to load
  156055. */
  156056. url: string;
  156057. /**
  156058. * Defines the desired size (the more it increases the longer the generation will be)
  156059. */
  156060. size: number;
  156061. /**
  156062. * Defines if mipmaps should not be generated (default is false)
  156063. */
  156064. noMipmap: boolean;
  156065. /**
  156066. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  156067. */
  156068. generateHarmonics: boolean;
  156069. /**
  156070. * 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)
  156071. */
  156072. gammaSpace: boolean;
  156073. /**
  156074. * Internal Use Only
  156075. */
  156076. reserved: boolean;
  156077. /**
  156078. * Gets the loaded texture
  156079. */
  156080. texture: HDRCubeTexture;
  156081. /**
  156082. * Callback called when the task is successful
  156083. */
  156084. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  156085. /**
  156086. * Callback called when the task is successful
  156087. */
  156088. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  156089. /**
  156090. * Creates a new HDRCubeTextureAssetTask object
  156091. * @param name defines the name of the task
  156092. * @param url defines the location of the file to load
  156093. * @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.
  156094. * @param noMipmap defines if mipmaps should not be generated (default is false)
  156095. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  156096. * @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)
  156097. * @param reserved Internal use only
  156098. */
  156099. constructor(
  156100. /**
  156101. * Defines the name of the task
  156102. */
  156103. name: string,
  156104. /**
  156105. * Defines the location of the file to load
  156106. */
  156107. url: string,
  156108. /**
  156109. * Defines the desired size (the more it increases the longer the generation will be)
  156110. */
  156111. size: number,
  156112. /**
  156113. * Defines if mipmaps should not be generated (default is false)
  156114. */
  156115. noMipmap?: boolean,
  156116. /**
  156117. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  156118. */
  156119. generateHarmonics?: boolean,
  156120. /**
  156121. * 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)
  156122. */
  156123. gammaSpace?: boolean,
  156124. /**
  156125. * Internal Use Only
  156126. */
  156127. reserved?: boolean);
  156128. /**
  156129. * Execute the current task
  156130. * @param scene defines the scene where you want your assets to be loaded
  156131. * @param onSuccess is a callback called when the task is successfully executed
  156132. * @param onError is a callback called if an error occurs
  156133. */
  156134. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156135. }
  156136. /**
  156137. * Define a task used by AssetsManager to load Equirectangular cube textures
  156138. */
  156139. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  156140. /**
  156141. * Defines the name of the task
  156142. */
  156143. name: string;
  156144. /**
  156145. * Defines the location of the file to load
  156146. */
  156147. url: string;
  156148. /**
  156149. * Defines the desired size (the more it increases the longer the generation will be)
  156150. */
  156151. size: number;
  156152. /**
  156153. * Defines if mipmaps should not be generated (default is false)
  156154. */
  156155. noMipmap: boolean;
  156156. /**
  156157. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  156158. * but the standard material would require them in Gamma space) (default is true)
  156159. */
  156160. gammaSpace: boolean;
  156161. /**
  156162. * Gets the loaded texture
  156163. */
  156164. texture: EquiRectangularCubeTexture;
  156165. /**
  156166. * Callback called when the task is successful
  156167. */
  156168. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  156169. /**
  156170. * Callback called when the task is successful
  156171. */
  156172. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  156173. /**
  156174. * Creates a new EquiRectangularCubeTextureAssetTask object
  156175. * @param name defines the name of the task
  156176. * @param url defines the location of the file to load
  156177. * @param size defines the desired size (the more it increases the longer the generation will be)
  156178. * If the size is omitted this implies you are using a preprocessed cubemap.
  156179. * @param noMipmap defines if mipmaps should not be generated (default is false)
  156180. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  156181. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  156182. * (default is true)
  156183. */
  156184. constructor(
  156185. /**
  156186. * Defines the name of the task
  156187. */
  156188. name: string,
  156189. /**
  156190. * Defines the location of the file to load
  156191. */
  156192. url: string,
  156193. /**
  156194. * Defines the desired size (the more it increases the longer the generation will be)
  156195. */
  156196. size: number,
  156197. /**
  156198. * Defines if mipmaps should not be generated (default is false)
  156199. */
  156200. noMipmap?: boolean,
  156201. /**
  156202. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  156203. * but the standard material would require them in Gamma space) (default is true)
  156204. */
  156205. gammaSpace?: boolean);
  156206. /**
  156207. * Execute the current task
  156208. * @param scene defines the scene where you want your assets to be loaded
  156209. * @param onSuccess is a callback called when the task is successfully executed
  156210. * @param onError is a callback called if an error occurs
  156211. */
  156212. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156213. }
  156214. /**
  156215. * This class can be used to easily import assets into a scene
  156216. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  156217. */
  156218. export class AssetsManager {
  156219. private _scene;
  156220. private _isLoading;
  156221. protected _tasks: AbstractAssetTask[];
  156222. protected _waitingTasksCount: number;
  156223. protected _totalTasksCount: number;
  156224. /**
  156225. * Callback called when all tasks are processed
  156226. */
  156227. onFinish: (tasks: AbstractAssetTask[]) => void;
  156228. /**
  156229. * Callback called when a task is successful
  156230. */
  156231. onTaskSuccess: (task: AbstractAssetTask) => void;
  156232. /**
  156233. * Callback called when a task had an error
  156234. */
  156235. onTaskError: (task: AbstractAssetTask) => void;
  156236. /**
  156237. * Callback called when a task is done (whatever the result is)
  156238. */
  156239. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  156240. /**
  156241. * Observable called when all tasks are processed
  156242. */
  156243. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  156244. /**
  156245. * Observable called when a task had an error
  156246. */
  156247. onTaskErrorObservable: Observable<AbstractAssetTask>;
  156248. /**
  156249. * Observable called when all tasks were executed
  156250. */
  156251. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  156252. /**
  156253. * Observable called when a task is done (whatever the result is)
  156254. */
  156255. onProgressObservable: Observable<IAssetsProgressEvent>;
  156256. /**
  156257. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  156258. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  156259. */
  156260. useDefaultLoadingScreen: boolean;
  156261. /**
  156262. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  156263. * when all assets have been downloaded.
  156264. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  156265. */
  156266. autoHideLoadingUI: boolean;
  156267. /**
  156268. * Creates a new AssetsManager
  156269. * @param scene defines the scene to work on
  156270. */
  156271. constructor(scene: Scene);
  156272. /**
  156273. * Add a ContainerAssetTask to the list of active tasks
  156274. * @param taskName defines the name of the new task
  156275. * @param meshesNames defines the name of meshes to load
  156276. * @param rootUrl defines the root url to use to locate files
  156277. * @param sceneFilename defines the filename of the scene file
  156278. * @returns a new ContainerAssetTask object
  156279. */
  156280. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  156281. /**
  156282. * Add a MeshAssetTask to the list of active tasks
  156283. * @param taskName defines the name of the new task
  156284. * @param meshesNames defines the name of meshes to load
  156285. * @param rootUrl defines the root url to use to locate files
  156286. * @param sceneFilename defines the filename of the scene file
  156287. * @returns a new MeshAssetTask object
  156288. */
  156289. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  156290. /**
  156291. * Add a TextFileAssetTask to the list of active tasks
  156292. * @param taskName defines the name of the new task
  156293. * @param url defines the url of the file to load
  156294. * @returns a new TextFileAssetTask object
  156295. */
  156296. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  156297. /**
  156298. * Add a BinaryFileAssetTask to the list of active tasks
  156299. * @param taskName defines the name of the new task
  156300. * @param url defines the url of the file to load
  156301. * @returns a new BinaryFileAssetTask object
  156302. */
  156303. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  156304. /**
  156305. * Add a ImageAssetTask to the list of active tasks
  156306. * @param taskName defines the name of the new task
  156307. * @param url defines the url of the file to load
  156308. * @returns a new ImageAssetTask object
  156309. */
  156310. addImageTask(taskName: string, url: string): ImageAssetTask;
  156311. /**
  156312. * Add a TextureAssetTask to the list of active tasks
  156313. * @param taskName defines the name of the new task
  156314. * @param url defines the url of the file to load
  156315. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156316. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  156317. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  156318. * @returns a new TextureAssetTask object
  156319. */
  156320. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  156321. /**
  156322. * Add a CubeTextureAssetTask to the list of active tasks
  156323. * @param taskName defines the name of the new task
  156324. * @param url defines the url of the file to load
  156325. * @param extensions defines the extension to use to load the cube map (can be null)
  156326. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156327. * @param files defines the list of files to load (can be null)
  156328. * @returns a new CubeTextureAssetTask object
  156329. */
  156330. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  156331. /**
  156332. *
  156333. * Add a HDRCubeTextureAssetTask to the list of active tasks
  156334. * @param taskName defines the name of the new task
  156335. * @param url defines the url of the file to load
  156336. * @param size defines the size you want for the cubemap (can be null)
  156337. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156338. * @param generateHarmonics defines if you want to automatically generate (true by default)
  156339. * @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)
  156340. * @param reserved Internal use only
  156341. * @returns a new HDRCubeTextureAssetTask object
  156342. */
  156343. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  156344. /**
  156345. *
  156346. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  156347. * @param taskName defines the name of the new task
  156348. * @param url defines the url of the file to load
  156349. * @param size defines the size you want for the cubemap (can be null)
  156350. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156351. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  156352. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  156353. * @returns a new EquiRectangularCubeTextureAssetTask object
  156354. */
  156355. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  156356. /**
  156357. * Remove a task from the assets manager.
  156358. * @param task the task to remove
  156359. */
  156360. removeTask(task: AbstractAssetTask): void;
  156361. private _decreaseWaitingTasksCount;
  156362. private _runTask;
  156363. /**
  156364. * Reset the AssetsManager and remove all tasks
  156365. * @return the current instance of the AssetsManager
  156366. */
  156367. reset(): AssetsManager;
  156368. /**
  156369. * Start the loading process
  156370. * @return the current instance of the AssetsManager
  156371. */
  156372. load(): AssetsManager;
  156373. /**
  156374. * Start the loading process as an async operation
  156375. * @return a promise returning the list of failed tasks
  156376. */
  156377. loadAsync(): Promise<void>;
  156378. }
  156379. }
  156380. declare module BABYLON {
  156381. /**
  156382. * Wrapper class for promise with external resolve and reject.
  156383. */
  156384. export class Deferred<T> {
  156385. /**
  156386. * The promise associated with this deferred object.
  156387. */
  156388. readonly promise: Promise<T>;
  156389. private _resolve;
  156390. private _reject;
  156391. /**
  156392. * The resolve method of the promise associated with this deferred object.
  156393. */
  156394. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  156395. /**
  156396. * The reject method of the promise associated with this deferred object.
  156397. */
  156398. get reject(): (reason?: any) => void;
  156399. /**
  156400. * Constructor for this deferred object.
  156401. */
  156402. constructor();
  156403. }
  156404. }
  156405. declare module BABYLON {
  156406. /**
  156407. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  156408. */
  156409. export class MeshExploder {
  156410. private _centerMesh;
  156411. private _meshes;
  156412. private _meshesOrigins;
  156413. private _toCenterVectors;
  156414. private _scaledDirection;
  156415. private _newPosition;
  156416. private _centerPosition;
  156417. /**
  156418. * Explodes meshes from a center mesh.
  156419. * @param meshes The meshes to explode.
  156420. * @param centerMesh The mesh to be center of explosion.
  156421. */
  156422. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  156423. private _setCenterMesh;
  156424. /**
  156425. * Get class name
  156426. * @returns "MeshExploder"
  156427. */
  156428. getClassName(): string;
  156429. /**
  156430. * "Exploded meshes"
  156431. * @returns Array of meshes with the centerMesh at index 0.
  156432. */
  156433. getMeshes(): Array<Mesh>;
  156434. /**
  156435. * Explodes meshes giving a specific direction
  156436. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  156437. */
  156438. explode(direction?: number): void;
  156439. }
  156440. }
  156441. declare module BABYLON {
  156442. /**
  156443. * Class used to help managing file picking and drag'n'drop
  156444. */
  156445. export class FilesInput {
  156446. /**
  156447. * List of files ready to be loaded
  156448. */
  156449. static get FilesToLoad(): {
  156450. [key: string]: File;
  156451. };
  156452. /**
  156453. * Callback called when a file is processed
  156454. */
  156455. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  156456. private _engine;
  156457. private _currentScene;
  156458. private _sceneLoadedCallback;
  156459. private _progressCallback;
  156460. private _additionalRenderLoopLogicCallback;
  156461. private _textureLoadingCallback;
  156462. private _startingProcessingFilesCallback;
  156463. private _onReloadCallback;
  156464. private _errorCallback;
  156465. private _elementToMonitor;
  156466. private _sceneFileToLoad;
  156467. private _filesToLoad;
  156468. /**
  156469. * Creates a new FilesInput
  156470. * @param engine defines the rendering engine
  156471. * @param scene defines the hosting scene
  156472. * @param sceneLoadedCallback callback called when scene is loaded
  156473. * @param progressCallback callback called to track progress
  156474. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  156475. * @param textureLoadingCallback callback called when a texture is loading
  156476. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  156477. * @param onReloadCallback callback called when a reload is requested
  156478. * @param errorCallback callback call if an error occurs
  156479. */
  156480. 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>);
  156481. private _dragEnterHandler;
  156482. private _dragOverHandler;
  156483. private _dropHandler;
  156484. /**
  156485. * Calls this function to listen to drag'n'drop events on a specific DOM element
  156486. * @param elementToMonitor defines the DOM element to track
  156487. */
  156488. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  156489. /** Gets the current list of files to load */
  156490. get filesToLoad(): File[];
  156491. /**
  156492. * Release all associated resources
  156493. */
  156494. dispose(): void;
  156495. private renderFunction;
  156496. private drag;
  156497. private drop;
  156498. private _traverseFolder;
  156499. private _processFiles;
  156500. /**
  156501. * Load files from a drop event
  156502. * @param event defines the drop event to use as source
  156503. */
  156504. loadFiles(event: any): void;
  156505. private _processReload;
  156506. /**
  156507. * Reload the current scene from the loaded files
  156508. */
  156509. reload(): void;
  156510. }
  156511. }
  156512. declare module BABYLON {
  156513. /**
  156514. * Defines the root class used to create scene optimization to use with SceneOptimizer
  156515. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156516. */
  156517. export class SceneOptimization {
  156518. /**
  156519. * Defines the priority of this optimization (0 by default which means first in the list)
  156520. */
  156521. priority: number;
  156522. /**
  156523. * Gets a string describing the action executed by the current optimization
  156524. * @returns description string
  156525. */
  156526. getDescription(): string;
  156527. /**
  156528. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156529. * @param scene defines the current scene where to apply this optimization
  156530. * @param optimizer defines the current optimizer
  156531. * @returns true if everything that can be done was applied
  156532. */
  156533. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156534. /**
  156535. * Creates the SceneOptimization object
  156536. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156537. * @param desc defines the description associated with the optimization
  156538. */
  156539. constructor(
  156540. /**
  156541. * Defines the priority of this optimization (0 by default which means first in the list)
  156542. */
  156543. priority?: number);
  156544. }
  156545. /**
  156546. * Defines an optimization used to reduce the size of render target textures
  156547. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156548. */
  156549. export class TextureOptimization extends SceneOptimization {
  156550. /**
  156551. * Defines the priority of this optimization (0 by default which means first in the list)
  156552. */
  156553. priority: number;
  156554. /**
  156555. * 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
  156556. */
  156557. maximumSize: number;
  156558. /**
  156559. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156560. */
  156561. step: number;
  156562. /**
  156563. * Gets a string describing the action executed by the current optimization
  156564. * @returns description string
  156565. */
  156566. getDescription(): string;
  156567. /**
  156568. * Creates the TextureOptimization object
  156569. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156570. * @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
  156571. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156572. */
  156573. constructor(
  156574. /**
  156575. * Defines the priority of this optimization (0 by default which means first in the list)
  156576. */
  156577. priority?: number,
  156578. /**
  156579. * 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
  156580. */
  156581. maximumSize?: number,
  156582. /**
  156583. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156584. */
  156585. step?: number);
  156586. /**
  156587. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156588. * @param scene defines the current scene where to apply this optimization
  156589. * @param optimizer defines the current optimizer
  156590. * @returns true if everything that can be done was applied
  156591. */
  156592. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156593. }
  156594. /**
  156595. * Defines an optimization used to increase or decrease the rendering resolution
  156596. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156597. */
  156598. export class HardwareScalingOptimization extends SceneOptimization {
  156599. /**
  156600. * Defines the priority of this optimization (0 by default which means first in the list)
  156601. */
  156602. priority: number;
  156603. /**
  156604. * Defines the maximum scale to use (2 by default)
  156605. */
  156606. maximumScale: number;
  156607. /**
  156608. * Defines the step to use between two passes (0.5 by default)
  156609. */
  156610. step: number;
  156611. private _currentScale;
  156612. private _directionOffset;
  156613. /**
  156614. * Gets a string describing the action executed by the current optimization
  156615. * @return description string
  156616. */
  156617. getDescription(): string;
  156618. /**
  156619. * Creates the HardwareScalingOptimization object
  156620. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156621. * @param maximumScale defines the maximum scale to use (2 by default)
  156622. * @param step defines the step to use between two passes (0.5 by default)
  156623. */
  156624. constructor(
  156625. /**
  156626. * Defines the priority of this optimization (0 by default which means first in the list)
  156627. */
  156628. priority?: number,
  156629. /**
  156630. * Defines the maximum scale to use (2 by default)
  156631. */
  156632. maximumScale?: number,
  156633. /**
  156634. * Defines the step to use between two passes (0.5 by default)
  156635. */
  156636. step?: number);
  156637. /**
  156638. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156639. * @param scene defines the current scene where to apply this optimization
  156640. * @param optimizer defines the current optimizer
  156641. * @returns true if everything that can be done was applied
  156642. */
  156643. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156644. }
  156645. /**
  156646. * Defines an optimization used to remove shadows
  156647. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156648. */
  156649. export class ShadowsOptimization extends SceneOptimization {
  156650. /**
  156651. * Gets a string describing the action executed by the current optimization
  156652. * @return description string
  156653. */
  156654. getDescription(): string;
  156655. /**
  156656. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156657. * @param scene defines the current scene where to apply this optimization
  156658. * @param optimizer defines the current optimizer
  156659. * @returns true if everything that can be done was applied
  156660. */
  156661. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156662. }
  156663. /**
  156664. * Defines an optimization used to turn post-processes off
  156665. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156666. */
  156667. export class PostProcessesOptimization extends SceneOptimization {
  156668. /**
  156669. * Gets a string describing the action executed by the current optimization
  156670. * @return description string
  156671. */
  156672. getDescription(): string;
  156673. /**
  156674. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156675. * @param scene defines the current scene where to apply this optimization
  156676. * @param optimizer defines the current optimizer
  156677. * @returns true if everything that can be done was applied
  156678. */
  156679. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156680. }
  156681. /**
  156682. * Defines an optimization used to turn lens flares off
  156683. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156684. */
  156685. export class LensFlaresOptimization extends SceneOptimization {
  156686. /**
  156687. * Gets a string describing the action executed by the current optimization
  156688. * @return description string
  156689. */
  156690. getDescription(): string;
  156691. /**
  156692. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156693. * @param scene defines the current scene where to apply this optimization
  156694. * @param optimizer defines the current optimizer
  156695. * @returns true if everything that can be done was applied
  156696. */
  156697. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156698. }
  156699. /**
  156700. * Defines an optimization based on user defined callback.
  156701. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156702. */
  156703. export class CustomOptimization extends SceneOptimization {
  156704. /**
  156705. * Callback called to apply the custom optimization.
  156706. */
  156707. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  156708. /**
  156709. * Callback called to get custom description
  156710. */
  156711. onGetDescription: () => string;
  156712. /**
  156713. * Gets a string describing the action executed by the current optimization
  156714. * @returns description string
  156715. */
  156716. getDescription(): string;
  156717. /**
  156718. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156719. * @param scene defines the current scene where to apply this optimization
  156720. * @param optimizer defines the current optimizer
  156721. * @returns true if everything that can be done was applied
  156722. */
  156723. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156724. }
  156725. /**
  156726. * Defines an optimization used to turn particles off
  156727. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156728. */
  156729. export class ParticlesOptimization extends SceneOptimization {
  156730. /**
  156731. * Gets a string describing the action executed by the current optimization
  156732. * @return description string
  156733. */
  156734. getDescription(): string;
  156735. /**
  156736. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156737. * @param scene defines the current scene where to apply this optimization
  156738. * @param optimizer defines the current optimizer
  156739. * @returns true if everything that can be done was applied
  156740. */
  156741. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156742. }
  156743. /**
  156744. * Defines an optimization used to turn render targets off
  156745. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156746. */
  156747. export class RenderTargetsOptimization extends SceneOptimization {
  156748. /**
  156749. * Gets a string describing the action executed by the current optimization
  156750. * @return description string
  156751. */
  156752. getDescription(): string;
  156753. /**
  156754. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156755. * @param scene defines the current scene where to apply this optimization
  156756. * @param optimizer defines the current optimizer
  156757. * @returns true if everything that can be done was applied
  156758. */
  156759. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156760. }
  156761. /**
  156762. * Defines an optimization used to merge meshes with compatible materials
  156763. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156764. */
  156765. export class MergeMeshesOptimization extends SceneOptimization {
  156766. private static _UpdateSelectionTree;
  156767. /**
  156768. * Gets or sets a boolean which defines if optimization octree has to be updated
  156769. */
  156770. static get UpdateSelectionTree(): boolean;
  156771. /**
  156772. * Gets or sets a boolean which defines if optimization octree has to be updated
  156773. */
  156774. static set UpdateSelectionTree(value: boolean);
  156775. /**
  156776. * Gets a string describing the action executed by the current optimization
  156777. * @return description string
  156778. */
  156779. getDescription(): string;
  156780. private _canBeMerged;
  156781. /**
  156782. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156783. * @param scene defines the current scene where to apply this optimization
  156784. * @param optimizer defines the current optimizer
  156785. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  156786. * @returns true if everything that can be done was applied
  156787. */
  156788. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  156789. }
  156790. /**
  156791. * Defines a list of options used by SceneOptimizer
  156792. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156793. */
  156794. export class SceneOptimizerOptions {
  156795. /**
  156796. * Defines the target frame rate to reach (60 by default)
  156797. */
  156798. targetFrameRate: number;
  156799. /**
  156800. * Defines the interval between two checkes (2000ms by default)
  156801. */
  156802. trackerDuration: number;
  156803. /**
  156804. * Gets the list of optimizations to apply
  156805. */
  156806. optimizations: SceneOptimization[];
  156807. /**
  156808. * Creates a new list of options used by SceneOptimizer
  156809. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  156810. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  156811. */
  156812. constructor(
  156813. /**
  156814. * Defines the target frame rate to reach (60 by default)
  156815. */
  156816. targetFrameRate?: number,
  156817. /**
  156818. * Defines the interval between two checkes (2000ms by default)
  156819. */
  156820. trackerDuration?: number);
  156821. /**
  156822. * Add a new optimization
  156823. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  156824. * @returns the current SceneOptimizerOptions
  156825. */
  156826. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  156827. /**
  156828. * Add a new custom optimization
  156829. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  156830. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  156831. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156832. * @returns the current SceneOptimizerOptions
  156833. */
  156834. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  156835. /**
  156836. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  156837. * @param targetFrameRate defines the target frame rate (60 by default)
  156838. * @returns a SceneOptimizerOptions object
  156839. */
  156840. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156841. /**
  156842. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  156843. * @param targetFrameRate defines the target frame rate (60 by default)
  156844. * @returns a SceneOptimizerOptions object
  156845. */
  156846. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156847. /**
  156848. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  156849. * @param targetFrameRate defines the target frame rate (60 by default)
  156850. * @returns a SceneOptimizerOptions object
  156851. */
  156852. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156853. }
  156854. /**
  156855. * Class used to run optimizations in order to reach a target frame rate
  156856. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156857. */
  156858. export class SceneOptimizer implements IDisposable {
  156859. private _isRunning;
  156860. private _options;
  156861. private _scene;
  156862. private _currentPriorityLevel;
  156863. private _targetFrameRate;
  156864. private _trackerDuration;
  156865. private _currentFrameRate;
  156866. private _sceneDisposeObserver;
  156867. private _improvementMode;
  156868. /**
  156869. * Defines an observable called when the optimizer reaches the target frame rate
  156870. */
  156871. onSuccessObservable: Observable<SceneOptimizer>;
  156872. /**
  156873. * Defines an observable called when the optimizer enables an optimization
  156874. */
  156875. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  156876. /**
  156877. * Defines an observable called when the optimizer is not able to reach the target frame rate
  156878. */
  156879. onFailureObservable: Observable<SceneOptimizer>;
  156880. /**
  156881. * Gets a boolean indicating if the optimizer is in improvement mode
  156882. */
  156883. get isInImprovementMode(): boolean;
  156884. /**
  156885. * Gets the current priority level (0 at start)
  156886. */
  156887. get currentPriorityLevel(): number;
  156888. /**
  156889. * Gets the current frame rate checked by the SceneOptimizer
  156890. */
  156891. get currentFrameRate(): number;
  156892. /**
  156893. * Gets or sets the current target frame rate (60 by default)
  156894. */
  156895. get targetFrameRate(): number;
  156896. /**
  156897. * Gets or sets the current target frame rate (60 by default)
  156898. */
  156899. set targetFrameRate(value: number);
  156900. /**
  156901. * Gets or sets the current interval between two checks (every 2000ms by default)
  156902. */
  156903. get trackerDuration(): number;
  156904. /**
  156905. * Gets or sets the current interval between two checks (every 2000ms by default)
  156906. */
  156907. set trackerDuration(value: number);
  156908. /**
  156909. * Gets the list of active optimizations
  156910. */
  156911. get optimizations(): SceneOptimization[];
  156912. /**
  156913. * Creates a new SceneOptimizer
  156914. * @param scene defines the scene to work on
  156915. * @param options defines the options to use with the SceneOptimizer
  156916. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  156917. * @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)
  156918. */
  156919. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  156920. /**
  156921. * Stops the current optimizer
  156922. */
  156923. stop(): void;
  156924. /**
  156925. * Reset the optimizer to initial step (current priority level = 0)
  156926. */
  156927. reset(): void;
  156928. /**
  156929. * Start the optimizer. By default it will try to reach a specific framerate
  156930. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  156931. */
  156932. start(): void;
  156933. private _checkCurrentState;
  156934. /**
  156935. * Release all resources
  156936. */
  156937. dispose(): void;
  156938. /**
  156939. * Helper function to create a SceneOptimizer with one single line of code
  156940. * @param scene defines the scene to work on
  156941. * @param options defines the options to use with the SceneOptimizer
  156942. * @param onSuccess defines a callback to call on success
  156943. * @param onFailure defines a callback to call on failure
  156944. * @returns the new SceneOptimizer object
  156945. */
  156946. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  156947. }
  156948. }
  156949. declare module BABYLON {
  156950. /**
  156951. * Class used to serialize a scene into a string
  156952. */
  156953. export class SceneSerializer {
  156954. /**
  156955. * Clear cache used by a previous serialization
  156956. */
  156957. static ClearCache(): void;
  156958. /**
  156959. * Serialize a scene into a JSON compatible object
  156960. * @param scene defines the scene to serialize
  156961. * @returns a JSON compatible object
  156962. */
  156963. static Serialize(scene: Scene): any;
  156964. /**
  156965. * Serialize a mesh into a JSON compatible object
  156966. * @param toSerialize defines the mesh to serialize
  156967. * @param withParents defines if parents must be serialized as well
  156968. * @param withChildren defines if children must be serialized as well
  156969. * @returns a JSON compatible object
  156970. */
  156971. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  156972. }
  156973. }
  156974. declare module BABYLON {
  156975. /**
  156976. * Class used to host texture specific utilities
  156977. */
  156978. export class TextureTools {
  156979. /**
  156980. * Uses the GPU to create a copy texture rescaled at a given size
  156981. * @param texture Texture to copy from
  156982. * @param width defines the desired width
  156983. * @param height defines the desired height
  156984. * @param useBilinearMode defines if bilinear mode has to be used
  156985. * @return the generated texture
  156986. */
  156987. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  156988. }
  156989. }
  156990. declare module BABYLON {
  156991. /**
  156992. * This represents the different options available for the video capture.
  156993. */
  156994. export interface VideoRecorderOptions {
  156995. /** Defines the mime type of the video. */
  156996. mimeType: string;
  156997. /** Defines the FPS the video should be recorded at. */
  156998. fps: number;
  156999. /** Defines the chunk size for the recording data. */
  157000. recordChunckSize: number;
  157001. /** The audio tracks to attach to the recording. */
  157002. audioTracks?: MediaStreamTrack[];
  157003. }
  157004. /**
  157005. * This can help with recording videos from BabylonJS.
  157006. * This is based on the available WebRTC functionalities of the browser.
  157007. *
  157008. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  157009. */
  157010. export class VideoRecorder {
  157011. private static readonly _defaultOptions;
  157012. /**
  157013. * Returns whether or not the VideoRecorder is available in your browser.
  157014. * @param engine Defines the Babylon Engine.
  157015. * @returns true if supported otherwise false.
  157016. */
  157017. static IsSupported(engine: Engine): boolean;
  157018. private readonly _options;
  157019. private _canvas;
  157020. private _mediaRecorder;
  157021. private _recordedChunks;
  157022. private _fileName;
  157023. private _resolve;
  157024. private _reject;
  157025. /**
  157026. * True when a recording is already in progress.
  157027. */
  157028. get isRecording(): boolean;
  157029. /**
  157030. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  157031. * @param engine Defines the BabylonJS Engine you wish to record.
  157032. * @param options Defines options that can be used to customize the capture.
  157033. */
  157034. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  157035. /**
  157036. * Stops the current recording before the default capture timeout passed in the startRecording function.
  157037. */
  157038. stopRecording(): void;
  157039. /**
  157040. * Starts recording the canvas for a max duration specified in parameters.
  157041. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  157042. * If null no automatic download will start and you can rely on the promise to get the data back.
  157043. * @param maxDuration Defines the maximum recording time in seconds.
  157044. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  157045. * @return A promise callback at the end of the recording with the video data in Blob.
  157046. */
  157047. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  157048. /**
  157049. * Releases internal resources used during the recording.
  157050. */
  157051. dispose(): void;
  157052. private _handleDataAvailable;
  157053. private _handleError;
  157054. private _handleStop;
  157055. }
  157056. }
  157057. declare module BABYLON {
  157058. /**
  157059. * Class containing a set of static utilities functions for screenshots
  157060. */
  157061. export class ScreenshotTools {
  157062. /**
  157063. * Captures a screenshot of the current rendering
  157064. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157065. * @param engine defines the rendering engine
  157066. * @param camera defines the source camera
  157067. * @param size This parameter can be set to a single number or to an object with the
  157068. * following (optional) properties: precision, width, height. If a single number is passed,
  157069. * it will be used for both width and height. If an object is passed, the screenshot size
  157070. * will be derived from the parameters. The precision property is a multiplier allowing
  157071. * rendering at a higher or lower resolution
  157072. * @param successCallback defines the callback receives a single parameter which contains the
  157073. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  157074. * src parameter of an <img> to display it
  157075. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  157076. * Check your browser for supported MIME types
  157077. */
  157078. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  157079. /**
  157080. * Captures a screenshot of the current rendering
  157081. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157082. * @param engine defines the rendering engine
  157083. * @param camera defines the source camera
  157084. * @param size This parameter can be set to a single number or to an object with the
  157085. * following (optional) properties: precision, width, height. If a single number is passed,
  157086. * it will be used for both width and height. If an object is passed, the screenshot size
  157087. * will be derived from the parameters. The precision property is a multiplier allowing
  157088. * rendering at a higher or lower resolution
  157089. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  157090. * Check your browser for supported MIME types
  157091. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  157092. * to the src parameter of an <img> to display it
  157093. */
  157094. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  157095. /**
  157096. * Generates an image screenshot from the specified camera.
  157097. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157098. * @param engine The engine to use for rendering
  157099. * @param camera The camera to use for rendering
  157100. * @param size This parameter can be set to a single number or to an object with the
  157101. * following (optional) properties: precision, width, height. If a single number is passed,
  157102. * it will be used for both width and height. If an object is passed, the screenshot size
  157103. * will be derived from the parameters. The precision property is a multiplier allowing
  157104. * rendering at a higher or lower resolution
  157105. * @param successCallback The callback receives a single parameter which contains the
  157106. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  157107. * src parameter of an <img> to display it
  157108. * @param mimeType The MIME type of the screenshot image (default: image/png).
  157109. * Check your browser for supported MIME types
  157110. * @param samples Texture samples (default: 1)
  157111. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  157112. * @param fileName A name for for the downloaded file.
  157113. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  157114. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  157115. */
  157116. 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;
  157117. /**
  157118. * Generates an image screenshot from the specified camera.
  157119. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157120. * @param engine The engine to use for rendering
  157121. * @param camera The camera to use for rendering
  157122. * @param size This parameter can be set to a single number or to an object with the
  157123. * following (optional) properties: precision, width, height. If a single number is passed,
  157124. * it will be used for both width and height. If an object is passed, the screenshot size
  157125. * will be derived from the parameters. The precision property is a multiplier allowing
  157126. * rendering at a higher or lower resolution
  157127. * @param mimeType The MIME type of the screenshot image (default: image/png).
  157128. * Check your browser for supported MIME types
  157129. * @param samples Texture samples (default: 1)
  157130. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  157131. * @param fileName A name for for the downloaded file.
  157132. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  157133. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  157134. * to the src parameter of an <img> to display it
  157135. */
  157136. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  157137. /**
  157138. * Gets height and width for screenshot size
  157139. * @private
  157140. */
  157141. private static _getScreenshotSize;
  157142. }
  157143. }
  157144. declare module BABYLON {
  157145. /**
  157146. * Interface for a data buffer
  157147. */
  157148. export interface IDataBuffer {
  157149. /**
  157150. * Reads bytes from the data buffer.
  157151. * @param byteOffset The byte offset to read
  157152. * @param byteLength The byte length to read
  157153. * @returns A promise that resolves when the bytes are read
  157154. */
  157155. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  157156. /**
  157157. * The byte length of the buffer.
  157158. */
  157159. readonly byteLength: number;
  157160. }
  157161. /**
  157162. * Utility class for reading from a data buffer
  157163. */
  157164. export class DataReader {
  157165. /**
  157166. * The data buffer associated with this data reader.
  157167. */
  157168. readonly buffer: IDataBuffer;
  157169. /**
  157170. * The current byte offset from the beginning of the data buffer.
  157171. */
  157172. byteOffset: number;
  157173. private _dataView;
  157174. private _dataByteOffset;
  157175. /**
  157176. * Constructor
  157177. * @param buffer The buffer to read
  157178. */
  157179. constructor(buffer: IDataBuffer);
  157180. /**
  157181. * Loads the given byte length.
  157182. * @param byteLength The byte length to load
  157183. * @returns A promise that resolves when the load is complete
  157184. */
  157185. loadAsync(byteLength: number): Promise<void>;
  157186. /**
  157187. * Read a unsigned 32-bit integer from the currently loaded data range.
  157188. * @returns The 32-bit integer read
  157189. */
  157190. readUint32(): number;
  157191. /**
  157192. * Read a byte array from the currently loaded data range.
  157193. * @param byteLength The byte length to read
  157194. * @returns The byte array read
  157195. */
  157196. readUint8Array(byteLength: number): Uint8Array;
  157197. /**
  157198. * Read a string from the currently loaded data range.
  157199. * @param byteLength The byte length to read
  157200. * @returns The string read
  157201. */
  157202. readString(byteLength: number): string;
  157203. /**
  157204. * Skips the given byte length the currently loaded data range.
  157205. * @param byteLength The byte length to skip
  157206. */
  157207. skipBytes(byteLength: number): void;
  157208. }
  157209. }
  157210. declare module BABYLON {
  157211. /**
  157212. * Class for storing data to local storage if available or in-memory storage otherwise
  157213. */
  157214. export class DataStorage {
  157215. private static _Storage;
  157216. private static _GetStorage;
  157217. /**
  157218. * Reads a string from the data storage
  157219. * @param key The key to read
  157220. * @param defaultValue The value if the key doesn't exist
  157221. * @returns The string value
  157222. */
  157223. static ReadString(key: string, defaultValue: string): string;
  157224. /**
  157225. * Writes a string to the data storage
  157226. * @param key The key to write
  157227. * @param value The value to write
  157228. */
  157229. static WriteString(key: string, value: string): void;
  157230. /**
  157231. * Reads a boolean from the data storage
  157232. * @param key The key to read
  157233. * @param defaultValue The value if the key doesn't exist
  157234. * @returns The boolean value
  157235. */
  157236. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  157237. /**
  157238. * Writes a boolean to the data storage
  157239. * @param key The key to write
  157240. * @param value The value to write
  157241. */
  157242. static WriteBoolean(key: string, value: boolean): void;
  157243. /**
  157244. * Reads a number from the data storage
  157245. * @param key The key to read
  157246. * @param defaultValue The value if the key doesn't exist
  157247. * @returns The number value
  157248. */
  157249. static ReadNumber(key: string, defaultValue: number): number;
  157250. /**
  157251. * Writes a number to the data storage
  157252. * @param key The key to write
  157253. * @param value The value to write
  157254. */
  157255. static WriteNumber(key: string, value: number): void;
  157256. }
  157257. }
  157258. declare module BABYLON {
  157259. /**
  157260. * Class used to record delta files between 2 scene states
  157261. */
  157262. export class SceneRecorder {
  157263. private _trackedScene;
  157264. private _savedJSON;
  157265. /**
  157266. * Track a given scene. This means the current scene state will be considered the original state
  157267. * @param scene defines the scene to track
  157268. */
  157269. track(scene: Scene): void;
  157270. /**
  157271. * Get the delta between current state and original state
  157272. * @returns a string containing the delta
  157273. */
  157274. getDelta(): any;
  157275. private _compareArray;
  157276. private _compareObjects;
  157277. private _compareCollections;
  157278. private static GetShadowGeneratorById;
  157279. /**
  157280. * Apply a given delta to a given scene
  157281. * @param deltaJSON defines the JSON containing the delta
  157282. * @param scene defines the scene to apply the delta to
  157283. */
  157284. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  157285. private static _ApplyPropertiesToEntity;
  157286. private static _ApplyDeltaForEntity;
  157287. }
  157288. }
  157289. declare module BABYLON {
  157290. /**
  157291. * A 3D trajectory consisting of an order list of vectors describing a
  157292. * path of motion through 3D space.
  157293. */
  157294. export class Trajectory {
  157295. private _points;
  157296. private readonly _segmentLength;
  157297. /**
  157298. * Serialize to JSON.
  157299. * @returns serialized JSON string
  157300. */
  157301. serialize(): string;
  157302. /**
  157303. * Deserialize from JSON.
  157304. * @param json serialized JSON string
  157305. * @returns deserialized Trajectory
  157306. */
  157307. static Deserialize(json: string): Trajectory;
  157308. /**
  157309. * Create a new empty Trajectory.
  157310. * @param segmentLength radius of discretization for Trajectory points
  157311. */
  157312. constructor(segmentLength?: number);
  157313. /**
  157314. * Get the length of the Trajectory.
  157315. * @returns length of the Trajectory
  157316. */
  157317. getLength(): number;
  157318. /**
  157319. * Append a new point to the Trajectory.
  157320. * NOTE: This implementation has many allocations.
  157321. * @param point point to append to the Trajectory
  157322. */
  157323. add(point: DeepImmutable<Vector3>): void;
  157324. /**
  157325. * Create a new Trajectory with a segment length chosen to make it
  157326. * probable that the new Trajectory will have a specified number of
  157327. * segments. This operation is imprecise.
  157328. * @param targetResolution number of segments desired
  157329. * @returns new Trajectory with approximately the requested number of segments
  157330. */
  157331. resampleAtTargetResolution(targetResolution: number): Trajectory;
  157332. /**
  157333. * Convert Trajectory segments into tokenized representation. This
  157334. * representation is an array of numbers where each nth number is the
  157335. * index of the token which is most similar to the nth segment of the
  157336. * Trajectory.
  157337. * @param tokens list of vectors which serve as discrete tokens
  157338. * @returns list of indices of most similar token per segment
  157339. */
  157340. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  157341. private static _forwardDir;
  157342. private static _inverseFromVec;
  157343. private static _upDir;
  157344. private static _fromToVec;
  157345. private static _lookMatrix;
  157346. /**
  157347. * Transform the rotation (i.e., direction) of a segment to isolate
  157348. * the relative transformation represented by the segment. This operation
  157349. * may or may not succeed due to singularities in the equations that define
  157350. * motion relativity in this context.
  157351. * @param priorVec the origin of the prior segment
  157352. * @param fromVec the origin of the current segment
  157353. * @param toVec the destination of the current segment
  157354. * @param result reference to output variable
  157355. * @returns whether or not transformation was successful
  157356. */
  157357. private static _transformSegmentDirToRef;
  157358. private static _bestMatch;
  157359. private static _score;
  157360. private static _bestScore;
  157361. /**
  157362. * Determine which token vector is most similar to the
  157363. * segment vector.
  157364. * @param segment segment vector
  157365. * @param tokens token vector list
  157366. * @returns index of the most similar token to the segment
  157367. */
  157368. private static _tokenizeSegment;
  157369. }
  157370. /**
  157371. * Class representing a set of known, named trajectories to which Trajectories can be
  157372. * added and using which Trajectories can be recognized.
  157373. */
  157374. export class TrajectoryClassifier {
  157375. private _maximumAllowableMatchCost;
  157376. private _vector3Alphabet;
  157377. private _levenshteinAlphabet;
  157378. private _nameToDescribedTrajectory;
  157379. /**
  157380. * Serialize to JSON.
  157381. * @returns JSON serialization
  157382. */
  157383. serialize(): string;
  157384. /**
  157385. * Deserialize from JSON.
  157386. * @param json JSON serialization
  157387. * @returns deserialized TrajectorySet
  157388. */
  157389. static Deserialize(json: string): TrajectoryClassifier;
  157390. /**
  157391. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  157392. * VERY naive, need to be generating these things from known
  157393. * sets. Better version later, probably eliminating this one.
  157394. * @returns auto-generated TrajectorySet
  157395. */
  157396. static Generate(): TrajectoryClassifier;
  157397. private constructor();
  157398. /**
  157399. * Add a new Trajectory to the set with a given name.
  157400. * @param trajectory new Trajectory to be added
  157401. * @param classification name to which to add the Trajectory
  157402. */
  157403. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  157404. /**
  157405. * Remove a known named trajectory and all Trajectories associated with it.
  157406. * @param classification name to remove
  157407. * @returns whether anything was removed
  157408. */
  157409. deleteClassification(classification: string): boolean;
  157410. /**
  157411. * Attempt to recognize a Trajectory from among all the classifications
  157412. * already known to the classifier.
  157413. * @param trajectory Trajectory to be recognized
  157414. * @returns classification of Trajectory if recognized, null otherwise
  157415. */
  157416. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  157417. }
  157418. }
  157419. declare module BABYLON {
  157420. /**
  157421. * An interface for all Hit test features
  157422. */
  157423. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  157424. /**
  157425. * Triggered when new babylon (transformed) hit test results are available
  157426. */
  157427. onHitTestResultObservable: Observable<T[]>;
  157428. }
  157429. /**
  157430. * Options used for hit testing
  157431. */
  157432. export interface IWebXRLegacyHitTestOptions {
  157433. /**
  157434. * Only test when user interacted with the scene. Default - hit test every frame
  157435. */
  157436. testOnPointerDownOnly?: boolean;
  157437. /**
  157438. * The node to use to transform the local results to world coordinates
  157439. */
  157440. worldParentNode?: TransformNode;
  157441. }
  157442. /**
  157443. * Interface defining the babylon result of raycasting/hit-test
  157444. */
  157445. export interface IWebXRLegacyHitResult {
  157446. /**
  157447. * Transformation matrix that can be applied to a node that will put it in the hit point location
  157448. */
  157449. transformationMatrix: Matrix;
  157450. /**
  157451. * The native hit test result
  157452. */
  157453. xrHitResult: XRHitResult | XRHitTestResult;
  157454. }
  157455. /**
  157456. * The currently-working hit-test module.
  157457. * Hit test (or Ray-casting) is used to interact with the real world.
  157458. * For further information read here - https://github.com/immersive-web/hit-test
  157459. */
  157460. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  157461. /**
  157462. * options to use when constructing this feature
  157463. */
  157464. readonly options: IWebXRLegacyHitTestOptions;
  157465. private _direction;
  157466. private _mat;
  157467. private _onSelectEnabled;
  157468. private _origin;
  157469. /**
  157470. * The module's name
  157471. */
  157472. static readonly Name: string;
  157473. /**
  157474. * The (Babylon) version of this module.
  157475. * This is an integer representing the implementation version.
  157476. * This number does not correspond to the WebXR specs version
  157477. */
  157478. static readonly Version: number;
  157479. /**
  157480. * Populated with the last native XR Hit Results
  157481. */
  157482. lastNativeXRHitResults: XRHitResult[];
  157483. /**
  157484. * Triggered when new babylon (transformed) hit test results are available
  157485. */
  157486. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  157487. /**
  157488. * Creates a new instance of the (legacy version) hit test feature
  157489. * @param _xrSessionManager an instance of WebXRSessionManager
  157490. * @param options options to use when constructing this feature
  157491. */
  157492. constructor(_xrSessionManager: WebXRSessionManager,
  157493. /**
  157494. * options to use when constructing this feature
  157495. */
  157496. options?: IWebXRLegacyHitTestOptions);
  157497. /**
  157498. * execute a hit test with an XR Ray
  157499. *
  157500. * @param xrSession a native xrSession that will execute this hit test
  157501. * @param xrRay the ray (position and direction) to use for ray-casting
  157502. * @param referenceSpace native XR reference space to use for the hit-test
  157503. * @param filter filter function that will filter the results
  157504. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  157505. */
  157506. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  157507. /**
  157508. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  157509. * @param event the (select) event to use to select with
  157510. * @param referenceSpace the reference space to use for this hit test
  157511. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  157512. */
  157513. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157514. /**
  157515. * attach this feature
  157516. * Will usually be called by the features manager
  157517. *
  157518. * @returns true if successful.
  157519. */
  157520. attach(): boolean;
  157521. /**
  157522. * detach this feature.
  157523. * Will usually be called by the features manager
  157524. *
  157525. * @returns true if successful.
  157526. */
  157527. detach(): boolean;
  157528. /**
  157529. * Dispose this feature and all of the resources attached
  157530. */
  157531. dispose(): void;
  157532. protected _onXRFrame(frame: XRFrame): void;
  157533. private _onHitTestResults;
  157534. private _onSelect;
  157535. }
  157536. }
  157537. declare module BABYLON {
  157538. /**
  157539. * Options used for hit testing (version 2)
  157540. */
  157541. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  157542. /**
  157543. * Do not create a permanent hit test. Will usually be used when only
  157544. * transient inputs are needed.
  157545. */
  157546. disablePermanentHitTest?: boolean;
  157547. /**
  157548. * Enable transient (for example touch-based) hit test inspections
  157549. */
  157550. enableTransientHitTest?: boolean;
  157551. /**
  157552. * Offset ray for the permanent hit test
  157553. */
  157554. offsetRay?: Vector3;
  157555. /**
  157556. * Offset ray for the transient hit test
  157557. */
  157558. transientOffsetRay?: Vector3;
  157559. /**
  157560. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  157561. */
  157562. useReferenceSpace?: boolean;
  157563. /**
  157564. * Override the default entity type(s) of the hit-test result
  157565. */
  157566. entityTypes?: XRHitTestTrackableType[];
  157567. }
  157568. /**
  157569. * Interface defining the babylon result of hit-test
  157570. */
  157571. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  157572. /**
  157573. * The input source that generated this hit test (if transient)
  157574. */
  157575. inputSource?: XRInputSource;
  157576. /**
  157577. * Is this a transient hit test
  157578. */
  157579. isTransient?: boolean;
  157580. /**
  157581. * Position of the hit test result
  157582. */
  157583. position: Vector3;
  157584. /**
  157585. * Rotation of the hit test result
  157586. */
  157587. rotationQuaternion: Quaternion;
  157588. /**
  157589. * The native hit test result
  157590. */
  157591. xrHitResult: XRHitTestResult;
  157592. }
  157593. /**
  157594. * The currently-working hit-test module.
  157595. * Hit test (or Ray-casting) is used to interact with the real world.
  157596. * For further information read here - https://github.com/immersive-web/hit-test
  157597. *
  157598. * Tested on chrome (mobile) 80.
  157599. */
  157600. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  157601. /**
  157602. * options to use when constructing this feature
  157603. */
  157604. readonly options: IWebXRHitTestOptions;
  157605. private _tmpMat;
  157606. private _tmpPos;
  157607. private _tmpQuat;
  157608. private _transientXrHitTestSource;
  157609. private _xrHitTestSource;
  157610. private initHitTestSource;
  157611. /**
  157612. * The module's name
  157613. */
  157614. static readonly Name: string;
  157615. /**
  157616. * The (Babylon) version of this module.
  157617. * This is an integer representing the implementation version.
  157618. * This number does not correspond to the WebXR specs version
  157619. */
  157620. static readonly Version: number;
  157621. /**
  157622. * When set to true, each hit test will have its own position/rotation objects
  157623. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  157624. * the developers will clone them or copy them as they see fit.
  157625. */
  157626. autoCloneTransformation: boolean;
  157627. /**
  157628. * Triggered when new babylon (transformed) hit test results are available
  157629. * Note - this will be called when results come back from the device. It can be an empty array!!
  157630. */
  157631. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  157632. /**
  157633. * Use this to temporarily pause hit test checks.
  157634. */
  157635. paused: boolean;
  157636. /**
  157637. * Creates a new instance of the hit test feature
  157638. * @param _xrSessionManager an instance of WebXRSessionManager
  157639. * @param options options to use when constructing this feature
  157640. */
  157641. constructor(_xrSessionManager: WebXRSessionManager,
  157642. /**
  157643. * options to use when constructing this feature
  157644. */
  157645. options?: IWebXRHitTestOptions);
  157646. /**
  157647. * attach this feature
  157648. * Will usually be called by the features manager
  157649. *
  157650. * @returns true if successful.
  157651. */
  157652. attach(): boolean;
  157653. /**
  157654. * detach this feature.
  157655. * Will usually be called by the features manager
  157656. *
  157657. * @returns true if successful.
  157658. */
  157659. detach(): boolean;
  157660. /**
  157661. * Dispose this feature and all of the resources attached
  157662. */
  157663. dispose(): void;
  157664. protected _onXRFrame(frame: XRFrame): void;
  157665. private _processWebXRHitTestResult;
  157666. }
  157667. }
  157668. declare module BABYLON {
  157669. /**
  157670. * Configuration options of the anchor system
  157671. */
  157672. export interface IWebXRAnchorSystemOptions {
  157673. /**
  157674. * a node that will be used to convert local to world coordinates
  157675. */
  157676. worldParentNode?: TransformNode;
  157677. /**
  157678. * If set to true a reference of the created anchors will be kept until the next session starts
  157679. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  157680. */
  157681. doNotRemoveAnchorsOnSessionEnded?: boolean;
  157682. }
  157683. /**
  157684. * A babylon container for an XR Anchor
  157685. */
  157686. export interface IWebXRAnchor {
  157687. /**
  157688. * A babylon-assigned ID for this anchor
  157689. */
  157690. id: number;
  157691. /**
  157692. * Transformation matrix to apply to an object attached to this anchor
  157693. */
  157694. transformationMatrix: Matrix;
  157695. /**
  157696. * The native anchor object
  157697. */
  157698. xrAnchor: XRAnchor;
  157699. /**
  157700. * if defined, this object will be constantly updated by the anchor's position and rotation
  157701. */
  157702. attachedNode?: TransformNode;
  157703. /**
  157704. * Remove this anchor from the scene
  157705. */
  157706. remove(): void;
  157707. }
  157708. /**
  157709. * An implementation of the anchor system for WebXR.
  157710. * For further information see https://github.com/immersive-web/anchors/
  157711. */
  157712. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  157713. private _options;
  157714. private _lastFrameDetected;
  157715. private _trackedAnchors;
  157716. private _referenceSpaceForFrameAnchors;
  157717. private _futureAnchors;
  157718. /**
  157719. * The module's name
  157720. */
  157721. static readonly Name: string;
  157722. /**
  157723. * The (Babylon) version of this module.
  157724. * This is an integer representing the implementation version.
  157725. * This number does not correspond to the WebXR specs version
  157726. */
  157727. static readonly Version: number;
  157728. /**
  157729. * Observers registered here will be executed when a new anchor was added to the session
  157730. */
  157731. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  157732. /**
  157733. * Observers registered here will be executed when an anchor was removed from the session
  157734. */
  157735. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  157736. /**
  157737. * Observers registered here will be executed when an existing anchor updates
  157738. * This can execute N times every frame
  157739. */
  157740. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  157741. /**
  157742. * Set the reference space to use for anchor creation, when not using a hit test.
  157743. * Will default to the session's reference space if not defined
  157744. */
  157745. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  157746. /**
  157747. * constructs a new anchor system
  157748. * @param _xrSessionManager an instance of WebXRSessionManager
  157749. * @param _options configuration object for this feature
  157750. */
  157751. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  157752. private _tmpVector;
  157753. private _tmpQuaternion;
  157754. private _populateTmpTransformation;
  157755. /**
  157756. * Create a new anchor point using a hit test result at a specific point in the scene
  157757. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157758. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157759. *
  157760. * @param hitTestResult The hit test result to use for this anchor creation
  157761. * @param position an optional position offset for this anchor
  157762. * @param rotationQuaternion an optional rotation offset for this anchor
  157763. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  157764. */
  157765. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  157766. /**
  157767. * Add a new anchor at a specific position and rotation
  157768. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  157769. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  157770. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157771. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157772. *
  157773. * @param position the position in which to add an anchor
  157774. * @param rotationQuaternion an optional rotation for the anchor transformation
  157775. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  157776. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  157777. */
  157778. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  157779. /**
  157780. * Get the list of anchors currently being tracked by the system
  157781. */
  157782. get anchors(): IWebXRAnchor[];
  157783. /**
  157784. * detach this feature.
  157785. * Will usually be called by the features manager
  157786. *
  157787. * @returns true if successful.
  157788. */
  157789. detach(): boolean;
  157790. /**
  157791. * Dispose this feature and all of the resources attached
  157792. */
  157793. dispose(): void;
  157794. protected _onXRFrame(frame: XRFrame): void;
  157795. /**
  157796. * avoiding using Array.find for global support.
  157797. * @param xrAnchor the plane to find in the array
  157798. */
  157799. private _findIndexInAnchorArray;
  157800. private _updateAnchorWithXRFrame;
  157801. private _createAnchorAtTransformation;
  157802. }
  157803. }
  157804. declare module BABYLON {
  157805. /**
  157806. * Options used in the plane detector module
  157807. */
  157808. export interface IWebXRPlaneDetectorOptions {
  157809. /**
  157810. * The node to use to transform the local results to world coordinates
  157811. */
  157812. worldParentNode?: TransformNode;
  157813. /**
  157814. * If set to true a reference of the created planes will be kept until the next session starts
  157815. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  157816. */
  157817. doNotRemovePlanesOnSessionEnded?: boolean;
  157818. }
  157819. /**
  157820. * A babylon interface for a WebXR plane.
  157821. * A Plane is actually a polygon, built from N points in space
  157822. *
  157823. * Supported in chrome 79, not supported in canary 81 ATM
  157824. */
  157825. export interface IWebXRPlane {
  157826. /**
  157827. * a babylon-assigned ID for this polygon
  157828. */
  157829. id: number;
  157830. /**
  157831. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  157832. */
  157833. polygonDefinition: Array<Vector3>;
  157834. /**
  157835. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  157836. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  157837. */
  157838. transformationMatrix: Matrix;
  157839. /**
  157840. * the native xr-plane object
  157841. */
  157842. xrPlane: XRPlane;
  157843. }
  157844. /**
  157845. * The plane detector is used to detect planes in the real world when in AR
  157846. * For more information see https://github.com/immersive-web/real-world-geometry/
  157847. */
  157848. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  157849. private _options;
  157850. private _detectedPlanes;
  157851. private _enabled;
  157852. private _lastFrameDetected;
  157853. /**
  157854. * The module's name
  157855. */
  157856. static readonly Name: string;
  157857. /**
  157858. * The (Babylon) version of this module.
  157859. * This is an integer representing the implementation version.
  157860. * This number does not correspond to the WebXR specs version
  157861. */
  157862. static readonly Version: number;
  157863. /**
  157864. * Observers registered here will be executed when a new plane was added to the session
  157865. */
  157866. onPlaneAddedObservable: Observable<IWebXRPlane>;
  157867. /**
  157868. * Observers registered here will be executed when a plane is no longer detected in the session
  157869. */
  157870. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  157871. /**
  157872. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  157873. * This can execute N times every frame
  157874. */
  157875. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  157876. /**
  157877. * construct a new Plane Detector
  157878. * @param _xrSessionManager an instance of xr Session manager
  157879. * @param _options configuration to use when constructing this feature
  157880. */
  157881. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  157882. /**
  157883. * detach this feature.
  157884. * Will usually be called by the features manager
  157885. *
  157886. * @returns true if successful.
  157887. */
  157888. detach(): boolean;
  157889. /**
  157890. * Dispose this feature and all of the resources attached
  157891. */
  157892. dispose(): void;
  157893. /**
  157894. * Check if the needed objects are defined.
  157895. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  157896. */
  157897. isCompatible(): boolean;
  157898. protected _onXRFrame(frame: XRFrame): void;
  157899. private _init;
  157900. private _updatePlaneWithXRPlane;
  157901. /**
  157902. * avoiding using Array.find for global support.
  157903. * @param xrPlane the plane to find in the array
  157904. */
  157905. private findIndexInPlaneArray;
  157906. }
  157907. }
  157908. declare module BABYLON {
  157909. /**
  157910. * Options interface for the background remover plugin
  157911. */
  157912. export interface IWebXRBackgroundRemoverOptions {
  157913. /**
  157914. * Further background meshes to disable when entering AR
  157915. */
  157916. backgroundMeshes?: AbstractMesh[];
  157917. /**
  157918. * flags to configure the removal of the environment helper.
  157919. * If not set, the entire background will be removed. If set, flags should be set as well.
  157920. */
  157921. environmentHelperRemovalFlags?: {
  157922. /**
  157923. * Should the skybox be removed (default false)
  157924. */
  157925. skyBox?: boolean;
  157926. /**
  157927. * Should the ground be removed (default false)
  157928. */
  157929. ground?: boolean;
  157930. };
  157931. /**
  157932. * don't disable the environment helper
  157933. */
  157934. ignoreEnvironmentHelper?: boolean;
  157935. }
  157936. /**
  157937. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  157938. */
  157939. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  157940. /**
  157941. * read-only options to be used in this module
  157942. */
  157943. readonly options: IWebXRBackgroundRemoverOptions;
  157944. /**
  157945. * The module's name
  157946. */
  157947. static readonly Name: string;
  157948. /**
  157949. * The (Babylon) version of this module.
  157950. * This is an integer representing the implementation version.
  157951. * This number does not correspond to the WebXR specs version
  157952. */
  157953. static readonly Version: number;
  157954. /**
  157955. * registered observers will be triggered when the background state changes
  157956. */
  157957. onBackgroundStateChangedObservable: Observable<boolean>;
  157958. /**
  157959. * constructs a new background remover module
  157960. * @param _xrSessionManager the session manager for this module
  157961. * @param options read-only options to be used in this module
  157962. */
  157963. constructor(_xrSessionManager: WebXRSessionManager,
  157964. /**
  157965. * read-only options to be used in this module
  157966. */
  157967. options?: IWebXRBackgroundRemoverOptions);
  157968. /**
  157969. * attach this feature
  157970. * Will usually be called by the features manager
  157971. *
  157972. * @returns true if successful.
  157973. */
  157974. attach(): boolean;
  157975. /**
  157976. * detach this feature.
  157977. * Will usually be called by the features manager
  157978. *
  157979. * @returns true if successful.
  157980. */
  157981. detach(): boolean;
  157982. /**
  157983. * Dispose this feature and all of the resources attached
  157984. */
  157985. dispose(): void;
  157986. protected _onXRFrame(_xrFrame: XRFrame): void;
  157987. private _setBackgroundState;
  157988. }
  157989. }
  157990. declare module BABYLON {
  157991. /**
  157992. * Options for the controller physics feature
  157993. */
  157994. export class IWebXRControllerPhysicsOptions {
  157995. /**
  157996. * Should the headset get its own impostor
  157997. */
  157998. enableHeadsetImpostor?: boolean;
  157999. /**
  158000. * Optional parameters for the headset impostor
  158001. */
  158002. headsetImpostorParams?: {
  158003. /**
  158004. * The type of impostor to create. Default is sphere
  158005. */
  158006. impostorType: number;
  158007. /**
  158008. * the size of the impostor. Defaults to 10cm
  158009. */
  158010. impostorSize?: number | {
  158011. width: number;
  158012. height: number;
  158013. depth: number;
  158014. };
  158015. /**
  158016. * Friction definitions
  158017. */
  158018. friction?: number;
  158019. /**
  158020. * Restitution
  158021. */
  158022. restitution?: number;
  158023. };
  158024. /**
  158025. * The physics properties of the future impostors
  158026. */
  158027. physicsProperties?: {
  158028. /**
  158029. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  158030. * Note that this requires a physics engine that supports mesh impostors!
  158031. */
  158032. useControllerMesh?: boolean;
  158033. /**
  158034. * The type of impostor to create. Default is sphere
  158035. */
  158036. impostorType?: number;
  158037. /**
  158038. * the size of the impostor. Defaults to 10cm
  158039. */
  158040. impostorSize?: number | {
  158041. width: number;
  158042. height: number;
  158043. depth: number;
  158044. };
  158045. /**
  158046. * Friction definitions
  158047. */
  158048. friction?: number;
  158049. /**
  158050. * Restitution
  158051. */
  158052. restitution?: number;
  158053. };
  158054. /**
  158055. * the xr input to use with this pointer selection
  158056. */
  158057. xrInput: WebXRInput;
  158058. }
  158059. /**
  158060. * Add physics impostor to your webxr controllers,
  158061. * including naive calculation of their linear and angular velocity
  158062. */
  158063. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  158064. private readonly _options;
  158065. private _attachController;
  158066. private _controllers;
  158067. private _debugMode;
  158068. private _delta;
  158069. private _headsetImpostor?;
  158070. private _headsetMesh?;
  158071. private _lastTimestamp;
  158072. private _tmpQuaternion;
  158073. private _tmpVector;
  158074. /**
  158075. * The module's name
  158076. */
  158077. static readonly Name: string;
  158078. /**
  158079. * The (Babylon) version of this module.
  158080. * This is an integer representing the implementation version.
  158081. * This number does not correspond to the webxr specs version
  158082. */
  158083. static readonly Version: number;
  158084. /**
  158085. * Construct a new Controller Physics Feature
  158086. * @param _xrSessionManager the corresponding xr session manager
  158087. * @param _options options to create this feature with
  158088. */
  158089. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  158090. /**
  158091. * @hidden
  158092. * enable debugging - will show console outputs and the impostor mesh
  158093. */
  158094. _enablePhysicsDebug(): void;
  158095. /**
  158096. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  158097. * @param xrController the controller to add
  158098. */
  158099. addController(xrController: WebXRInputSource): void;
  158100. /**
  158101. * attach this feature
  158102. * Will usually be called by the features manager
  158103. *
  158104. * @returns true if successful.
  158105. */
  158106. attach(): boolean;
  158107. /**
  158108. * detach this feature.
  158109. * Will usually be called by the features manager
  158110. *
  158111. * @returns true if successful.
  158112. */
  158113. detach(): boolean;
  158114. /**
  158115. * Get the headset impostor, if enabled
  158116. * @returns the impostor
  158117. */
  158118. getHeadsetImpostor(): PhysicsImpostor | undefined;
  158119. /**
  158120. * Get the physics impostor of a specific controller.
  158121. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  158122. * @param controller the controller or the controller id of which to get the impostor
  158123. * @returns the impostor or null
  158124. */
  158125. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  158126. /**
  158127. * Update the physics properties provided in the constructor
  158128. * @param newProperties the new properties object
  158129. */
  158130. setPhysicsProperties(newProperties: {
  158131. impostorType?: number;
  158132. impostorSize?: number | {
  158133. width: number;
  158134. height: number;
  158135. depth: number;
  158136. };
  158137. friction?: number;
  158138. restitution?: number;
  158139. }): void;
  158140. protected _onXRFrame(_xrFrame: any): void;
  158141. private _detachController;
  158142. }
  158143. }
  158144. declare module BABYLON {
  158145. /**
  158146. * A babylon interface for a "WebXR" feature point.
  158147. * Represents the position and confidence value of a given feature point.
  158148. */
  158149. export interface IWebXRFeaturePoint {
  158150. /**
  158151. * Represents the position of the feature point in world space.
  158152. */
  158153. position: Vector3;
  158154. /**
  158155. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  158156. */
  158157. confidenceValue: number;
  158158. }
  158159. /**
  158160. * The feature point system is used to detect feature points from real world geometry.
  158161. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  158162. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  158163. */
  158164. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  158165. private _enabled;
  158166. private _featurePointCloud;
  158167. /**
  158168. * The module's name
  158169. */
  158170. static readonly Name: string;
  158171. /**
  158172. * The (Babylon) version of this module.
  158173. * This is an integer representing the implementation version.
  158174. * This number does not correspond to the WebXR specs version
  158175. */
  158176. static readonly Version: number;
  158177. /**
  158178. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  158179. * Will notify the observers about which feature points have been added.
  158180. */
  158181. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  158182. /**
  158183. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  158184. * Will notify the observers about which feature points have been updated.
  158185. */
  158186. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  158187. /**
  158188. * The current feature point cloud maintained across frames.
  158189. */
  158190. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  158191. /**
  158192. * construct the feature point system
  158193. * @param _xrSessionManager an instance of xr Session manager
  158194. */
  158195. constructor(_xrSessionManager: WebXRSessionManager);
  158196. /**
  158197. * Detach this feature.
  158198. * Will usually be called by the features manager
  158199. *
  158200. * @returns true if successful.
  158201. */
  158202. detach(): boolean;
  158203. /**
  158204. * Dispose this feature and all of the resources attached
  158205. */
  158206. dispose(): void;
  158207. /**
  158208. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  158209. */
  158210. protected _onXRFrame(frame: XRFrame): void;
  158211. /**
  158212. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  158213. */
  158214. private _init;
  158215. }
  158216. }
  158217. declare module BABYLON {
  158218. /**
  158219. * Configuration interface for the hand tracking feature
  158220. */
  158221. export interface IWebXRHandTrackingOptions {
  158222. /**
  158223. * The xrInput that will be used as source for new hands
  158224. */
  158225. xrInput: WebXRInput;
  158226. /**
  158227. * Configuration object for the joint meshes
  158228. */
  158229. jointMeshes?: {
  158230. /**
  158231. * Should the meshes created be invisible (defaults to false)
  158232. */
  158233. invisible?: boolean;
  158234. /**
  158235. * A source mesh to be used to create instances. Defaults to a sphere.
  158236. * This mesh will be the source for all other (25) meshes.
  158237. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  158238. */
  158239. sourceMesh?: Mesh;
  158240. /**
  158241. * This function will be called after a mesh was created for a specific joint.
  158242. * Using this function you can either manipulate the instance or return a new mesh.
  158243. * When returning a new mesh the instance created before will be disposed
  158244. */
  158245. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  158246. /**
  158247. * Should the source mesh stay visible. Defaults to false
  158248. */
  158249. keepOriginalVisible?: boolean;
  158250. /**
  158251. * Scale factor for all instances (defaults to 2)
  158252. */
  158253. scaleFactor?: number;
  158254. /**
  158255. * Should each instance have its own physics impostor
  158256. */
  158257. enablePhysics?: boolean;
  158258. /**
  158259. * If enabled, override default physics properties
  158260. */
  158261. physicsProps?: {
  158262. friction?: number;
  158263. restitution?: number;
  158264. impostorType?: number;
  158265. };
  158266. /**
  158267. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  158268. */
  158269. handMesh?: AbstractMesh;
  158270. };
  158271. }
  158272. /**
  158273. * Parts of the hands divided to writs and finger names
  158274. */
  158275. export const enum HandPart {
  158276. /**
  158277. * HandPart - Wrist
  158278. */
  158279. WRIST = "wrist",
  158280. /**
  158281. * HandPart - The THumb
  158282. */
  158283. THUMB = "thumb",
  158284. /**
  158285. * HandPart - Index finger
  158286. */
  158287. INDEX = "index",
  158288. /**
  158289. * HandPart - Middle finger
  158290. */
  158291. MIDDLE = "middle",
  158292. /**
  158293. * HandPart - Ring finger
  158294. */
  158295. RING = "ring",
  158296. /**
  158297. * HandPart - Little finger
  158298. */
  158299. LITTLE = "little"
  158300. }
  158301. /**
  158302. * Representing a single hand (with its corresponding native XRHand object)
  158303. */
  158304. export class WebXRHand implements IDisposable {
  158305. /** the controller to which the hand correlates */
  158306. readonly xrController: WebXRInputSource;
  158307. /** the meshes to be used to track the hand joints */
  158308. readonly trackedMeshes: AbstractMesh[];
  158309. /**
  158310. * Hand-parts definition (key is HandPart)
  158311. */
  158312. handPartsDefinition: {
  158313. [key: string]: number[];
  158314. };
  158315. /**
  158316. * Populate the HandPartsDefinition object.
  158317. * This is called as a side effect since certain browsers don't have XRHand defined.
  158318. */
  158319. private generateHandPartsDefinition;
  158320. /**
  158321. * Construct a new hand object
  158322. * @param xrController the controller to which the hand correlates
  158323. * @param trackedMeshes the meshes to be used to track the hand joints
  158324. */
  158325. constructor(
  158326. /** the controller to which the hand correlates */
  158327. xrController: WebXRInputSource,
  158328. /** the meshes to be used to track the hand joints */
  158329. trackedMeshes: AbstractMesh[]);
  158330. /**
  158331. * Update this hand from the latest xr frame
  158332. * @param xrFrame xrFrame to update from
  158333. * @param referenceSpace The current viewer reference space
  158334. * @param scaleFactor optional scale factor for the meshes
  158335. */
  158336. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  158337. /**
  158338. * Get meshes of part of the hand
  158339. * @param part the part of hand to get
  158340. * @returns An array of meshes that correlate to the hand part requested
  158341. */
  158342. getHandPartMeshes(part: HandPart): AbstractMesh[];
  158343. /**
  158344. * Dispose this Hand object
  158345. */
  158346. dispose(): void;
  158347. }
  158348. /**
  158349. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  158350. */
  158351. export class WebXRHandTracking extends WebXRAbstractFeature {
  158352. /**
  158353. * options to use when constructing this feature
  158354. */
  158355. readonly options: IWebXRHandTrackingOptions;
  158356. private static _idCounter;
  158357. /**
  158358. * The module's name
  158359. */
  158360. static readonly Name: string;
  158361. /**
  158362. * The (Babylon) version of this module.
  158363. * This is an integer representing the implementation version.
  158364. * This number does not correspond to the WebXR specs version
  158365. */
  158366. static readonly Version: number;
  158367. /**
  158368. * This observable will notify registered observers when a new hand object was added and initialized
  158369. */
  158370. onHandAddedObservable: Observable<WebXRHand>;
  158371. /**
  158372. * This observable will notify its observers right before the hand object is disposed
  158373. */
  158374. onHandRemovedObservable: Observable<WebXRHand>;
  158375. private _hands;
  158376. /**
  158377. * Creates a new instance of the hit test feature
  158378. * @param _xrSessionManager an instance of WebXRSessionManager
  158379. * @param options options to use when constructing this feature
  158380. */
  158381. constructor(_xrSessionManager: WebXRSessionManager,
  158382. /**
  158383. * options to use when constructing this feature
  158384. */
  158385. options: IWebXRHandTrackingOptions);
  158386. /**
  158387. * Check if the needed objects are defined.
  158388. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  158389. */
  158390. isCompatible(): boolean;
  158391. /**
  158392. * attach this feature
  158393. * Will usually be called by the features manager
  158394. *
  158395. * @returns true if successful.
  158396. */
  158397. attach(): boolean;
  158398. /**
  158399. * detach this feature.
  158400. * Will usually be called by the features manager
  158401. *
  158402. * @returns true if successful.
  158403. */
  158404. detach(): boolean;
  158405. /**
  158406. * Dispose this feature and all of the resources attached
  158407. */
  158408. dispose(): void;
  158409. /**
  158410. * Get the hand object according to the controller id
  158411. * @param controllerId the controller id to which we want to get the hand
  158412. * @returns null if not found or the WebXRHand object if found
  158413. */
  158414. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  158415. /**
  158416. * Get a hand object according to the requested handedness
  158417. * @param handedness the handedness to request
  158418. * @returns null if not found or the WebXRHand object if found
  158419. */
  158420. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  158421. protected _onXRFrame(_xrFrame: XRFrame): void;
  158422. private _attachHand;
  158423. private _detachHand;
  158424. }
  158425. }
  158426. declare module BABYLON {
  158427. /**
  158428. * The motion controller class for all microsoft mixed reality controllers
  158429. */
  158430. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  158431. protected readonly _mapping: {
  158432. defaultButton: {
  158433. valueNodeName: string;
  158434. unpressedNodeName: string;
  158435. pressedNodeName: string;
  158436. };
  158437. defaultAxis: {
  158438. valueNodeName: string;
  158439. minNodeName: string;
  158440. maxNodeName: string;
  158441. };
  158442. buttons: {
  158443. "xr-standard-trigger": {
  158444. rootNodeName: string;
  158445. componentProperty: string;
  158446. states: string[];
  158447. };
  158448. "xr-standard-squeeze": {
  158449. rootNodeName: string;
  158450. componentProperty: string;
  158451. states: string[];
  158452. };
  158453. "xr-standard-touchpad": {
  158454. rootNodeName: string;
  158455. labelAnchorNodeName: string;
  158456. touchPointNodeName: string;
  158457. };
  158458. "xr-standard-thumbstick": {
  158459. rootNodeName: string;
  158460. componentProperty: string;
  158461. states: string[];
  158462. };
  158463. };
  158464. axes: {
  158465. "xr-standard-touchpad": {
  158466. "x-axis": {
  158467. rootNodeName: string;
  158468. };
  158469. "y-axis": {
  158470. rootNodeName: string;
  158471. };
  158472. };
  158473. "xr-standard-thumbstick": {
  158474. "x-axis": {
  158475. rootNodeName: string;
  158476. };
  158477. "y-axis": {
  158478. rootNodeName: string;
  158479. };
  158480. };
  158481. };
  158482. };
  158483. /**
  158484. * The base url used to load the left and right controller models
  158485. */
  158486. static MODEL_BASE_URL: string;
  158487. /**
  158488. * The name of the left controller model file
  158489. */
  158490. static MODEL_LEFT_FILENAME: string;
  158491. /**
  158492. * The name of the right controller model file
  158493. */
  158494. static MODEL_RIGHT_FILENAME: string;
  158495. profileId: string;
  158496. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  158497. protected _getFilenameAndPath(): {
  158498. filename: string;
  158499. path: string;
  158500. };
  158501. protected _getModelLoadingConstraints(): boolean;
  158502. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158503. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158504. protected _updateModel(): void;
  158505. }
  158506. }
  158507. declare module BABYLON {
  158508. /**
  158509. * The motion controller class for oculus touch (quest, rift).
  158510. * This class supports legacy mapping as well the standard xr mapping
  158511. */
  158512. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  158513. private _forceLegacyControllers;
  158514. private _modelRootNode;
  158515. /**
  158516. * The base url used to load the left and right controller models
  158517. */
  158518. static MODEL_BASE_URL: string;
  158519. /**
  158520. * The name of the left controller model file
  158521. */
  158522. static MODEL_LEFT_FILENAME: string;
  158523. /**
  158524. * The name of the right controller model file
  158525. */
  158526. static MODEL_RIGHT_FILENAME: string;
  158527. /**
  158528. * Base Url for the Quest controller model.
  158529. */
  158530. static QUEST_MODEL_BASE_URL: string;
  158531. profileId: string;
  158532. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  158533. protected _getFilenameAndPath(): {
  158534. filename: string;
  158535. path: string;
  158536. };
  158537. protected _getModelLoadingConstraints(): boolean;
  158538. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158539. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158540. protected _updateModel(): void;
  158541. /**
  158542. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  158543. * between the touch and touch 2.
  158544. */
  158545. private _isQuest;
  158546. }
  158547. }
  158548. declare module BABYLON {
  158549. /**
  158550. * The motion controller class for the standard HTC-Vive controllers
  158551. */
  158552. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  158553. private _modelRootNode;
  158554. /**
  158555. * The base url used to load the left and right controller models
  158556. */
  158557. static MODEL_BASE_URL: string;
  158558. /**
  158559. * File name for the controller model.
  158560. */
  158561. static MODEL_FILENAME: string;
  158562. profileId: string;
  158563. /**
  158564. * Create a new Vive motion controller object
  158565. * @param scene the scene to use to create this controller
  158566. * @param gamepadObject the corresponding gamepad object
  158567. * @param handedness the handedness of the controller
  158568. */
  158569. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  158570. protected _getFilenameAndPath(): {
  158571. filename: string;
  158572. path: string;
  158573. };
  158574. protected _getModelLoadingConstraints(): boolean;
  158575. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158576. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158577. protected _updateModel(): void;
  158578. }
  158579. }
  158580. declare module BABYLON {
  158581. /**
  158582. * A cursor which tracks a point on a path
  158583. */
  158584. export class PathCursor {
  158585. private path;
  158586. /**
  158587. * Stores path cursor callbacks for when an onchange event is triggered
  158588. */
  158589. private _onchange;
  158590. /**
  158591. * The value of the path cursor
  158592. */
  158593. value: number;
  158594. /**
  158595. * The animation array of the path cursor
  158596. */
  158597. animations: Animation[];
  158598. /**
  158599. * Initializes the path cursor
  158600. * @param path The path to track
  158601. */
  158602. constructor(path: Path2);
  158603. /**
  158604. * Gets the cursor point on the path
  158605. * @returns A point on the path cursor at the cursor location
  158606. */
  158607. getPoint(): Vector3;
  158608. /**
  158609. * Moves the cursor ahead by the step amount
  158610. * @param step The amount to move the cursor forward
  158611. * @returns This path cursor
  158612. */
  158613. moveAhead(step?: number): PathCursor;
  158614. /**
  158615. * Moves the cursor behind by the step amount
  158616. * @param step The amount to move the cursor back
  158617. * @returns This path cursor
  158618. */
  158619. moveBack(step?: number): PathCursor;
  158620. /**
  158621. * Moves the cursor by the step amount
  158622. * If the step amount is greater than one, an exception is thrown
  158623. * @param step The amount to move the cursor
  158624. * @returns This path cursor
  158625. */
  158626. move(step: number): PathCursor;
  158627. /**
  158628. * Ensures that the value is limited between zero and one
  158629. * @returns This path cursor
  158630. */
  158631. private ensureLimits;
  158632. /**
  158633. * Runs onchange callbacks on change (used by the animation engine)
  158634. * @returns This path cursor
  158635. */
  158636. private raiseOnChange;
  158637. /**
  158638. * Executes a function on change
  158639. * @param f A path cursor onchange callback
  158640. * @returns This path cursor
  158641. */
  158642. onchange(f: (cursor: PathCursor) => void): PathCursor;
  158643. }
  158644. }
  158645. declare module BABYLON {
  158646. /** @hidden */
  158647. export var blurPixelShader: {
  158648. name: string;
  158649. shader: string;
  158650. };
  158651. }
  158652. declare module BABYLON {
  158653. /** @hidden */
  158654. export var pointCloudVertexDeclaration: {
  158655. name: string;
  158656. shader: string;
  158657. };
  158658. }
  158659. // Mixins
  158660. interface Window {
  158661. mozIndexedDB: IDBFactory;
  158662. webkitIndexedDB: IDBFactory;
  158663. msIndexedDB: IDBFactory;
  158664. webkitURL: typeof URL;
  158665. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  158666. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  158667. WebGLRenderingContext: WebGLRenderingContext;
  158668. MSGesture: MSGesture;
  158669. CANNON: any;
  158670. AudioContext: AudioContext;
  158671. webkitAudioContext: AudioContext;
  158672. PointerEvent: any;
  158673. Math: Math;
  158674. Uint8Array: Uint8ArrayConstructor;
  158675. Float32Array: Float32ArrayConstructor;
  158676. mozURL: typeof URL;
  158677. msURL: typeof URL;
  158678. VRFrameData: any; // WebVR, from specs 1.1
  158679. DracoDecoderModule: any;
  158680. setImmediate(handler: (...args: any[]) => void): number;
  158681. }
  158682. interface HTMLCanvasElement {
  158683. requestPointerLock(): void;
  158684. msRequestPointerLock?(): void;
  158685. mozRequestPointerLock?(): void;
  158686. webkitRequestPointerLock?(): void;
  158687. /** Track wether a record is in progress */
  158688. isRecording: boolean;
  158689. /** Capture Stream method defined by some browsers */
  158690. captureStream(fps?: number): MediaStream;
  158691. }
  158692. interface CanvasRenderingContext2D {
  158693. msImageSmoothingEnabled: boolean;
  158694. }
  158695. interface MouseEvent {
  158696. mozMovementX: number;
  158697. mozMovementY: number;
  158698. webkitMovementX: number;
  158699. webkitMovementY: number;
  158700. msMovementX: number;
  158701. msMovementY: number;
  158702. }
  158703. interface Navigator {
  158704. mozGetVRDevices: (any: any) => any;
  158705. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158706. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158707. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158708. webkitGetGamepads(): Gamepad[];
  158709. msGetGamepads(): Gamepad[];
  158710. webkitGamepads(): Gamepad[];
  158711. }
  158712. interface HTMLVideoElement {
  158713. mozSrcObject: any;
  158714. }
  158715. interface Math {
  158716. fround(x: number): number;
  158717. imul(a: number, b: number): number;
  158718. }
  158719. interface WebGLRenderingContext {
  158720. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  158721. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  158722. vertexAttribDivisor(index: number, divisor: number): void;
  158723. createVertexArray(): any;
  158724. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  158725. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  158726. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  158727. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  158728. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  158729. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  158730. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  158731. // Queries
  158732. createQuery(): WebGLQuery;
  158733. deleteQuery(query: WebGLQuery): void;
  158734. beginQuery(target: number, query: WebGLQuery): void;
  158735. endQuery(target: number): void;
  158736. getQueryParameter(query: WebGLQuery, pname: number): any;
  158737. getQuery(target: number, pname: number): any;
  158738. MAX_SAMPLES: number;
  158739. RGBA8: number;
  158740. READ_FRAMEBUFFER: number;
  158741. DRAW_FRAMEBUFFER: number;
  158742. UNIFORM_BUFFER: number;
  158743. HALF_FLOAT_OES: number;
  158744. RGBA16F: number;
  158745. RGBA32F: number;
  158746. R32F: number;
  158747. RG32F: number;
  158748. RGB32F: number;
  158749. R16F: number;
  158750. RG16F: number;
  158751. RGB16F: number;
  158752. RED: number;
  158753. RG: number;
  158754. R8: number;
  158755. RG8: number;
  158756. UNSIGNED_INT_24_8: number;
  158757. DEPTH24_STENCIL8: number;
  158758. MIN: number;
  158759. MAX: number;
  158760. /* Multiple Render Targets */
  158761. drawBuffers(buffers: number[]): void;
  158762. readBuffer(src: number): void;
  158763. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  158764. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  158765. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  158766. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  158767. // Occlusion Query
  158768. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  158769. ANY_SAMPLES_PASSED: number;
  158770. QUERY_RESULT_AVAILABLE: number;
  158771. QUERY_RESULT: number;
  158772. }
  158773. interface WebGLProgram {
  158774. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  158775. }
  158776. interface EXT_disjoint_timer_query {
  158777. QUERY_COUNTER_BITS_EXT: number;
  158778. TIME_ELAPSED_EXT: number;
  158779. TIMESTAMP_EXT: number;
  158780. GPU_DISJOINT_EXT: number;
  158781. QUERY_RESULT_EXT: number;
  158782. QUERY_RESULT_AVAILABLE_EXT: number;
  158783. queryCounterEXT(query: WebGLQuery, target: number): void;
  158784. createQueryEXT(): WebGLQuery;
  158785. beginQueryEXT(target: number, query: WebGLQuery): void;
  158786. endQueryEXT(target: number): void;
  158787. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  158788. deleteQueryEXT(query: WebGLQuery): void;
  158789. }
  158790. interface WebGLUniformLocation {
  158791. _currentState: any;
  158792. }
  158793. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  158794. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  158795. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  158796. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  158797. interface WebGLRenderingContext {
  158798. readonly RASTERIZER_DISCARD: number;
  158799. readonly DEPTH_COMPONENT24: number;
  158800. readonly TEXTURE_3D: number;
  158801. readonly TEXTURE_2D_ARRAY: number;
  158802. readonly TEXTURE_COMPARE_FUNC: number;
  158803. readonly TEXTURE_COMPARE_MODE: number;
  158804. readonly COMPARE_REF_TO_TEXTURE: number;
  158805. readonly TEXTURE_WRAP_R: number;
  158806. readonly HALF_FLOAT: number;
  158807. readonly RGB8: number;
  158808. readonly RED_INTEGER: number;
  158809. readonly RG_INTEGER: number;
  158810. readonly RGB_INTEGER: number;
  158811. readonly RGBA_INTEGER: number;
  158812. readonly R8_SNORM: number;
  158813. readonly RG8_SNORM: number;
  158814. readonly RGB8_SNORM: number;
  158815. readonly RGBA8_SNORM: number;
  158816. readonly R8I: number;
  158817. readonly RG8I: number;
  158818. readonly RGB8I: number;
  158819. readonly RGBA8I: number;
  158820. readonly R8UI: number;
  158821. readonly RG8UI: number;
  158822. readonly RGB8UI: number;
  158823. readonly RGBA8UI: number;
  158824. readonly R16I: number;
  158825. readonly RG16I: number;
  158826. readonly RGB16I: number;
  158827. readonly RGBA16I: number;
  158828. readonly R16UI: number;
  158829. readonly RG16UI: number;
  158830. readonly RGB16UI: number;
  158831. readonly RGBA16UI: number;
  158832. readonly R32I: number;
  158833. readonly RG32I: number;
  158834. readonly RGB32I: number;
  158835. readonly RGBA32I: number;
  158836. readonly R32UI: number;
  158837. readonly RG32UI: number;
  158838. readonly RGB32UI: number;
  158839. readonly RGBA32UI: number;
  158840. readonly RGB10_A2UI: number;
  158841. readonly R11F_G11F_B10F: number;
  158842. readonly RGB9_E5: number;
  158843. readonly RGB10_A2: number;
  158844. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  158845. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  158846. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  158847. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  158848. readonly DEPTH_COMPONENT32F: number;
  158849. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  158850. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  158851. 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;
  158852. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  158853. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  158854. readonly TRANSFORM_FEEDBACK: number;
  158855. readonly INTERLEAVED_ATTRIBS: number;
  158856. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  158857. createTransformFeedback(): WebGLTransformFeedback;
  158858. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  158859. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  158860. beginTransformFeedback(primitiveMode: number): void;
  158861. endTransformFeedback(): void;
  158862. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  158863. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158864. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158865. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158866. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  158867. }
  158868. interface ImageBitmap {
  158869. readonly width: number;
  158870. readonly height: number;
  158871. close(): void;
  158872. }
  158873. interface WebGLQuery extends WebGLObject {
  158874. }
  158875. declare var WebGLQuery: {
  158876. prototype: WebGLQuery;
  158877. new(): WebGLQuery;
  158878. };
  158879. interface WebGLSampler extends WebGLObject {
  158880. }
  158881. declare var WebGLSampler: {
  158882. prototype: WebGLSampler;
  158883. new(): WebGLSampler;
  158884. };
  158885. interface WebGLSync extends WebGLObject {
  158886. }
  158887. declare var WebGLSync: {
  158888. prototype: WebGLSync;
  158889. new(): WebGLSync;
  158890. };
  158891. interface WebGLTransformFeedback extends WebGLObject {
  158892. }
  158893. declare var WebGLTransformFeedback: {
  158894. prototype: WebGLTransformFeedback;
  158895. new(): WebGLTransformFeedback;
  158896. };
  158897. interface WebGLVertexArrayObject extends WebGLObject {
  158898. }
  158899. declare var WebGLVertexArrayObject: {
  158900. prototype: WebGLVertexArrayObject;
  158901. new(): WebGLVertexArrayObject;
  158902. };
  158903. // Type definitions for WebVR API
  158904. // Project: https://w3c.github.io/webvr/
  158905. // Definitions by: six a <https://github.com/lostfictions>
  158906. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  158907. interface VRDisplay extends EventTarget {
  158908. /**
  158909. * Dictionary of capabilities describing the VRDisplay.
  158910. */
  158911. readonly capabilities: VRDisplayCapabilities;
  158912. /**
  158913. * z-depth defining the far plane of the eye view frustum
  158914. * enables mapping of values in the render target depth
  158915. * attachment to scene coordinates. Initially set to 10000.0.
  158916. */
  158917. depthFar: number;
  158918. /**
  158919. * z-depth defining the near plane of the eye view frustum
  158920. * enables mapping of values in the render target depth
  158921. * attachment to scene coordinates. Initially set to 0.01.
  158922. */
  158923. depthNear: number;
  158924. /**
  158925. * An identifier for this distinct VRDisplay. Used as an
  158926. * association point in the Gamepad API.
  158927. */
  158928. readonly displayId: number;
  158929. /**
  158930. * A display name, a user-readable name identifying it.
  158931. */
  158932. readonly displayName: string;
  158933. readonly isConnected: boolean;
  158934. readonly isPresenting: boolean;
  158935. /**
  158936. * If this VRDisplay supports room-scale experiences, the optional
  158937. * stage attribute contains details on the room-scale parameters.
  158938. */
  158939. readonly stageParameters: VRStageParameters | null;
  158940. /**
  158941. * Passing the value returned by `requestAnimationFrame` to
  158942. * `cancelAnimationFrame` will unregister the callback.
  158943. * @param handle Define the hanle of the request to cancel
  158944. */
  158945. cancelAnimationFrame(handle: number): void;
  158946. /**
  158947. * Stops presenting to the VRDisplay.
  158948. * @returns a promise to know when it stopped
  158949. */
  158950. exitPresent(): Promise<void>;
  158951. /**
  158952. * Return the current VREyeParameters for the given eye.
  158953. * @param whichEye Define the eye we want the parameter for
  158954. * @returns the eye parameters
  158955. */
  158956. getEyeParameters(whichEye: string): VREyeParameters;
  158957. /**
  158958. * Populates the passed VRFrameData with the information required to render
  158959. * the current frame.
  158960. * @param frameData Define the data structure to populate
  158961. * @returns true if ok otherwise false
  158962. */
  158963. getFrameData(frameData: VRFrameData): boolean;
  158964. /**
  158965. * Get the layers currently being presented.
  158966. * @returns the list of VR layers
  158967. */
  158968. getLayers(): VRLayer[];
  158969. /**
  158970. * Return a VRPose containing the future predicted pose of the VRDisplay
  158971. * when the current frame will be presented. The value returned will not
  158972. * change until JavaScript has returned control to the browser.
  158973. *
  158974. * The VRPose will contain the position, orientation, velocity,
  158975. * and acceleration of each of these properties.
  158976. * @returns the pose object
  158977. */
  158978. getPose(): VRPose;
  158979. /**
  158980. * Return the current instantaneous pose of the VRDisplay, with no
  158981. * prediction applied.
  158982. * @returns the current instantaneous pose
  158983. */
  158984. getImmediatePose(): VRPose;
  158985. /**
  158986. * The callback passed to `requestAnimationFrame` will be called
  158987. * any time a new frame should be rendered. When the VRDisplay is
  158988. * presenting the callback will be called at the native refresh
  158989. * rate of the HMD. When not presenting this function acts
  158990. * identically to how window.requestAnimationFrame acts. Content should
  158991. * make no assumptions of frame rate or vsync behavior as the HMD runs
  158992. * asynchronously from other displays and at differing refresh rates.
  158993. * @param callback Define the eaction to run next frame
  158994. * @returns the request handle it
  158995. */
  158996. requestAnimationFrame(callback: FrameRequestCallback): number;
  158997. /**
  158998. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  158999. * Repeat calls while already presenting will update the VRLayers being displayed.
  159000. * @param layers Define the list of layer to present
  159001. * @returns a promise to know when the request has been fulfilled
  159002. */
  159003. requestPresent(layers: VRLayer[]): Promise<void>;
  159004. /**
  159005. * Reset the pose for this display, treating its current position and
  159006. * orientation as the "origin/zero" values. VRPose.position,
  159007. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  159008. * updated when calling resetPose(). This should be called in only
  159009. * sitting-space experiences.
  159010. */
  159011. resetPose(): void;
  159012. /**
  159013. * The VRLayer provided to the VRDisplay will be captured and presented
  159014. * in the HMD. Calling this function has the same effect on the source
  159015. * canvas as any other operation that uses its source image, and canvases
  159016. * created without preserveDrawingBuffer set to true will be cleared.
  159017. * @param pose Define the pose to submit
  159018. */
  159019. submitFrame(pose?: VRPose): void;
  159020. }
  159021. declare var VRDisplay: {
  159022. prototype: VRDisplay;
  159023. new(): VRDisplay;
  159024. };
  159025. interface VRLayer {
  159026. leftBounds?: number[] | Float32Array | null;
  159027. rightBounds?: number[] | Float32Array | null;
  159028. source?: HTMLCanvasElement | null;
  159029. }
  159030. interface VRDisplayCapabilities {
  159031. readonly canPresent: boolean;
  159032. readonly hasExternalDisplay: boolean;
  159033. readonly hasOrientation: boolean;
  159034. readonly hasPosition: boolean;
  159035. readonly maxLayers: number;
  159036. }
  159037. interface VREyeParameters {
  159038. /** @deprecated */
  159039. readonly fieldOfView: VRFieldOfView;
  159040. readonly offset: Float32Array;
  159041. readonly renderHeight: number;
  159042. readonly renderWidth: number;
  159043. }
  159044. interface VRFieldOfView {
  159045. readonly downDegrees: number;
  159046. readonly leftDegrees: number;
  159047. readonly rightDegrees: number;
  159048. readonly upDegrees: number;
  159049. }
  159050. interface VRFrameData {
  159051. readonly leftProjectionMatrix: Float32Array;
  159052. readonly leftViewMatrix: Float32Array;
  159053. readonly pose: VRPose;
  159054. readonly rightProjectionMatrix: Float32Array;
  159055. readonly rightViewMatrix: Float32Array;
  159056. readonly timestamp: number;
  159057. }
  159058. interface VRPose {
  159059. readonly angularAcceleration: Float32Array | null;
  159060. readonly angularVelocity: Float32Array | null;
  159061. readonly linearAcceleration: Float32Array | null;
  159062. readonly linearVelocity: Float32Array | null;
  159063. readonly orientation: Float32Array | null;
  159064. readonly position: Float32Array | null;
  159065. readonly timestamp: number;
  159066. }
  159067. interface VRStageParameters {
  159068. sittingToStandingTransform?: Float32Array;
  159069. sizeX?: number;
  159070. sizeY?: number;
  159071. }
  159072. interface Navigator {
  159073. getVRDisplays(): Promise<VRDisplay[]>;
  159074. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  159075. }
  159076. interface Window {
  159077. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  159078. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  159079. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  159080. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  159081. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  159082. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  159083. }
  159084. interface Gamepad {
  159085. readonly displayId: number;
  159086. }
  159087. /**
  159088. * Available session modes
  159089. */
  159090. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  159091. /**
  159092. * Reference space types
  159093. */
  159094. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  159095. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  159096. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  159097. /**
  159098. * Handedness types
  159099. */
  159100. type XRHandedness = "none" | "left" | "right";
  159101. /**
  159102. * InputSource target ray modes
  159103. */
  159104. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  159105. /**
  159106. * Eye types
  159107. */
  159108. type XREye = "none" | "left" | "right";
  159109. /**
  159110. * Type of XR events available
  159111. */
  159112. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  159113. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  159114. type XRPlaneSet = Set<XRPlane>;
  159115. type XRAnchorSet = Set<XRAnchor>;
  159116. type XREventHandler = (callback: any) => void;
  159117. interface XRLayer extends EventTarget {}
  159118. interface XRSessionInit {
  159119. optionalFeatures?: string[];
  159120. requiredFeatures?: string[];
  159121. }
  159122. interface XRSessionEvent extends Event {
  159123. readonly session: XRSession;
  159124. }
  159125. interface XRSystem {
  159126. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  159127. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  159128. }
  159129. interface XRViewport {
  159130. readonly x: number;
  159131. readonly y: number;
  159132. readonly width: number;
  159133. readonly height: number;
  159134. }
  159135. interface XRWebGLLayerInit {
  159136. antialias?: boolean;
  159137. depth?: boolean;
  159138. stencil?: boolean;
  159139. alpha?: boolean;
  159140. multiview?: boolean;
  159141. framebufferScaleFactor?: number;
  159142. }
  159143. declare class XRWebGLLayer {
  159144. static getNativeFramebufferScaleFactor(session: XRSession): number;
  159145. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  159146. readonly antialias: boolean;
  159147. readonly framebuffer: WebGLFramebuffer;
  159148. readonly framebufferWidth: number;
  159149. readonly framebufferHeight: number;
  159150. readonly ignoreDepthValues: boolean;
  159151. getViewport: (view: XRView) => XRViewport;
  159152. }
  159153. // tslint:disable-next-line no-empty-interface
  159154. interface XRSpace extends EventTarget {}
  159155. interface XRRenderState {
  159156. readonly baseLayer?: XRWebGLLayer;
  159157. readonly depthFar: number;
  159158. readonly depthNear: number;
  159159. readonly inlineVerticalFieldOfView?: number;
  159160. }
  159161. interface XRRenderStateInit extends XRRenderState {
  159162. baseLayer: XRWebGLLayer;
  159163. depthFar: number;
  159164. depthNear: number;
  159165. inlineVerticalFieldOfView?: number;
  159166. layers?: XRLayer[];
  159167. }
  159168. interface XRReferenceSpace extends XRSpace {
  159169. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  159170. onreset: XREventHandler;
  159171. }
  159172. interface XRBoundedReferenceSpace extends XRSpace {
  159173. readonly boundsGeometry: DOMPointReadOnly[];
  159174. }
  159175. interface XRInputSource {
  159176. readonly handedness: XRHandedness;
  159177. readonly targetRayMode: XRTargetRayMode;
  159178. readonly targetRaySpace: XRSpace;
  159179. readonly gripSpace?: XRSpace;
  159180. readonly gamepad?: Gamepad;
  159181. readonly profiles: Array<string>;
  159182. readonly hand?: XRHand;
  159183. }
  159184. interface XRPose {
  159185. readonly transform: XRRigidTransform;
  159186. readonly emulatedPosition: boolean;
  159187. }
  159188. interface XRFrame {
  159189. readonly session: XRSession;
  159190. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  159191. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  159192. // AR
  159193. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  159194. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  159195. // Anchors
  159196. trackedAnchors?: XRAnchorSet;
  159197. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  159198. // Planes
  159199. worldInformation?: {
  159200. detectedPlanes?: XRPlaneSet;
  159201. };
  159202. // Hand tracking
  159203. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  159204. }
  159205. interface XRInputSourceEvent extends Event {
  159206. readonly frame: XRFrame;
  159207. readonly inputSource: XRInputSource;
  159208. }
  159209. type XRInputSourceArray = XRInputSource[];
  159210. interface XRSession {
  159211. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  159212. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  159213. /**
  159214. * Returns a list of this session's XRInputSources, each representing an input device
  159215. * used to control the camera and/or scene.
  159216. */
  159217. readonly inputSources: Array<XRInputSource>;
  159218. /**
  159219. * object which contains options affecting how the imagery is rendered.
  159220. * This includes things such as the near and far clipping planes
  159221. */
  159222. readonly renderState: XRRenderState;
  159223. readonly visibilityState: XRVisibilityState;
  159224. /**
  159225. * Removes a callback from the animation frame painting callback from
  159226. * XRSession's set of animation frame rendering callbacks, given the
  159227. * identifying handle returned by a previous call to requestAnimationFrame().
  159228. */
  159229. cancelAnimationFrame: (handle: number) => void;
  159230. /**
  159231. * Ends the WebXR session. Returns a promise which resolves when the
  159232. * session has been shut down.
  159233. */
  159234. end(): Promise<void>;
  159235. /**
  159236. * Schedules the specified method to be called the next time the user agent
  159237. * is working on rendering an animation frame for the WebXR device. Returns an
  159238. * integer value which can be used to identify the request for the purposes of
  159239. * canceling the callback using cancelAnimationFrame(). This method is comparable
  159240. * to the Window.requestAnimationFrame() method.
  159241. */
  159242. requestAnimationFrame: XRFrameRequestCallback;
  159243. /**
  159244. * Requests that a new XRReferenceSpace of the specified type be created.
  159245. * Returns a promise which resolves with the XRReferenceSpace or
  159246. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  159247. * the requested space type isn't supported by the device.
  159248. */
  159249. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  159250. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  159251. onend: XREventHandler;
  159252. oninputsourceschange: XREventHandler;
  159253. onselect: XREventHandler;
  159254. onselectstart: XREventHandler;
  159255. onselectend: XREventHandler;
  159256. onsqueeze: XREventHandler;
  159257. onsqueezestart: XREventHandler;
  159258. onsqueezeend: XREventHandler;
  159259. onvisibilitychange: XREventHandler;
  159260. // hit test
  159261. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  159262. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  159263. // legacy AR hit test
  159264. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  159265. // legacy plane detection
  159266. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  159267. }
  159268. interface XRViewerPose extends XRPose {
  159269. readonly views: Array<XRView>;
  159270. }
  159271. declare class XRRigidTransform {
  159272. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  159273. position: DOMPointReadOnly;
  159274. orientation: DOMPointReadOnly;
  159275. matrix: Float32Array;
  159276. inverse: XRRigidTransform;
  159277. }
  159278. interface XRView {
  159279. readonly eye: XREye;
  159280. readonly projectionMatrix: Float32Array;
  159281. readonly transform: XRRigidTransform;
  159282. readonly recommendedViewportScale?: number;
  159283. requestViewportScale(scale: number): void;
  159284. }
  159285. interface XRInputSourceChangeEvent extends Event {
  159286. session: XRSession;
  159287. removed: Array<XRInputSource>;
  159288. added: Array<XRInputSource>;
  159289. }
  159290. // Experimental/Draft features
  159291. declare class XRRay {
  159292. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  159293. origin: DOMPointReadOnly;
  159294. direction: DOMPointReadOnly;
  159295. matrix: Float32Array;
  159296. }
  159297. declare enum XRHitTestTrackableType {
  159298. "point",
  159299. "plane",
  159300. "mesh",
  159301. }
  159302. interface XRHitResult {
  159303. hitMatrix: Float32Array;
  159304. }
  159305. interface XRTransientInputHitTestResult {
  159306. readonly inputSource: XRInputSource;
  159307. readonly results: Array<XRHitTestResult>;
  159308. }
  159309. interface XRHitTestResult {
  159310. getPose(baseSpace: XRSpace): XRPose | undefined;
  159311. // When anchor system is enabled
  159312. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  159313. }
  159314. interface XRHitTestSource {
  159315. cancel(): void;
  159316. }
  159317. interface XRTransientInputHitTestSource {
  159318. cancel(): void;
  159319. }
  159320. interface XRHitTestOptionsInit {
  159321. space: XRSpace;
  159322. entityTypes?: Array<XRHitTestTrackableType>;
  159323. offsetRay?: XRRay;
  159324. }
  159325. interface XRTransientInputHitTestOptionsInit {
  159326. profile: string;
  159327. entityTypes?: Array<XRHitTestTrackableType>;
  159328. offsetRay?: XRRay;
  159329. }
  159330. interface XRAnchor {
  159331. anchorSpace: XRSpace;
  159332. delete(): void;
  159333. }
  159334. interface XRPlane {
  159335. orientation: "Horizontal" | "Vertical";
  159336. planeSpace: XRSpace;
  159337. polygon: Array<DOMPointReadOnly>;
  159338. lastChangedTime: number;
  159339. }
  159340. interface XRJointSpace extends XRSpace {}
  159341. interface XRJointPose extends XRPose {
  159342. radius: number | undefined;
  159343. }
  159344. interface XRHand extends Iterable<XRJointSpace> {
  159345. readonly length: number;
  159346. [index: number]: XRJointSpace;
  159347. readonly WRIST: number;
  159348. readonly THUMB_METACARPAL: number;
  159349. readonly THUMB_PHALANX_PROXIMAL: number;
  159350. readonly THUMB_PHALANX_DISTAL: number;
  159351. readonly THUMB_PHALANX_TIP: number;
  159352. readonly INDEX_METACARPAL: number;
  159353. readonly INDEX_PHALANX_PROXIMAL: number;
  159354. readonly INDEX_PHALANX_INTERMEDIATE: number;
  159355. readonly INDEX_PHALANX_DISTAL: number;
  159356. readonly INDEX_PHALANX_TIP: number;
  159357. readonly MIDDLE_METACARPAL: number;
  159358. readonly MIDDLE_PHALANX_PROXIMAL: number;
  159359. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  159360. readonly MIDDLE_PHALANX_DISTAL: number;
  159361. readonly MIDDLE_PHALANX_TIP: number;
  159362. readonly RING_METACARPAL: number;
  159363. readonly RING_PHALANX_PROXIMAL: number;
  159364. readonly RING_PHALANX_INTERMEDIATE: number;
  159365. readonly RING_PHALANX_DISTAL: number;
  159366. readonly RING_PHALANX_TIP: number;
  159367. readonly LITTLE_METACARPAL: number;
  159368. readonly LITTLE_PHALANX_PROXIMAL: number;
  159369. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  159370. readonly LITTLE_PHALANX_DISTAL: number;
  159371. readonly LITTLE_PHALANX_TIP: number;
  159372. }
  159373. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  159374. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  159375. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  159376. interface XRSession {
  159377. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  159378. }
  159379. interface XRFrame {
  159380. featurePointCloud? : Array<number>;
  159381. }